Commit b1ffd63f authored by twanvl's avatar twanvl

Added value actions for common value types; drop down list is now correctly aligned

parent 60760f6f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/action/value.hpp>
#include <data/field.hpp>
#include <data/field/text.hpp>
#include <data/field/choice.hpp>
#include <data/field/multiple_choice.hpp>
#include <data/field/color.hpp>
#include <data/field/image.hpp>
#include <data/field/symbol.hpp>
// ----------------------------------------------------------------------------- : ValueAction
String ValueAction::getName(bool to_undo) const {
return _("Change ") + valueP->fieldP->name;
}
// ----------------------------------------------------------------------------- : Simple
/// A ValueAction that swaps between old and new values
template <typename T, typename T::ValueType T::*member, bool ALLOW_MERGE>
class SimpleValueAction : public ValueAction {
public:
inline SimpleValueAction(const shared_ptr<T>& value, const typename T::ValueType& new_value)
: ValueAction(value), new_value(new_value)
{}
virtual void perform(bool to_undo) {
swap(static_cast<T&>(*valueP).*member, new_value);
}
virtual bool merge(const Action* action) {
if (!ALLOW_MERGE) return false;
if (const SimpleValueAction* sva = dynamic_cast<const SimpleValueAction*>(action)) {
if (sva->valueP == valueP) {
// adjacent actions on the same value, discard the other one,
// because it only keeps an intermediate value
return true;
}
} else {
return false;
}
return false;
}
private:
typename T::ValueType new_value;
};
ValueAction* value_action(const ChoiceValueP& value, const Defaultable<String>& new_value) { return new SimpleValueAction<ChoiceValue, &ChoiceValue::value, true> (value, new_value); }
ValueAction* value_action(const ColorValueP& value, const Defaultable<Color>& new_value) { return new SimpleValueAction<ColorValue, &ColorValue::value, true> (value, new_value); }
ValueAction* value_action(const ImageValueP& value, const FileName& new_value) { return new SimpleValueAction<ImageValue, &ImageValue::filename, false>(value, new_value); }
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value) { return new SimpleValueAction<SymbolValue, &SymbolValue::filename, false>(value, new_value); }
// ----------------------------------------------------------------------------- : Text
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_ACTION_VALUE
#define HEADER_DATA_ACTION_VALUE
/** @file data/action/set.hpp
*
* Actions operating on Values (and derived classes, "*Value")
*/
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <util/action_stack.hpp>
#include <util/defaultable.hpp>
DECLARE_POINTER_TYPE(Value);
DECLARE_POINTER_TYPE(TextValue);
DECLARE_POINTER_TYPE(ChoiceValue);
DECLARE_POINTER_TYPE(ColorValue);
DECLARE_POINTER_TYPE(ImageValue);
DECLARE_POINTER_TYPE(SymbolValue);
// ----------------------------------------------------------------------------- : ValueAction (based class)
/// An Action the changes a Value
class ValueAction : public Action {
public:
inline ValueAction(const ValueP& value) : valueP(value) {}
virtual String getName(bool to_undo) const;
const ValueP valueP; ///< The modified value
};
/// Utility macro for declaring classes derived from ValueAction
#define DECLARE_VALUE_ACTION(Type) \
protected: \
inline Type##Value& value() const { \
return static_cast<Type##Value&>(*valueP); \
} \
public: \
virtual void perform(bool to_undo)
// ----------------------------------------------------------------------------- : Simple
ValueAction* value_action(const ChoiceValueP& value, const Defaultable<String>& new_value);
ValueAction* value_action(const ColorValueP& value, const Defaultable<Color>& new_value);
ValueAction* value_action(const ImageValueP& value, const FileName& new_value);
ValueAction* value_action(const SymbolValueP& value, const FileName& new_value);
// ----------------------------------------------------------------------------- : Text
/*
class ColorValueAction : public ValueAction {
public:
ColorValueAction(const ColorValueP& value, const Defaultable<Color>& color);
DECLARE_VALUE_ACTION(Color);
private:
Defaultable<Color> color; ///< The new/old color
};
*/
// ----------------------------------------------------------------------------- : EOF
#endif
...@@ -143,7 +143,8 @@ class ChoiceValue : public Value { ...@@ -143,7 +143,8 @@ class ChoiceValue : public Value {
{} {}
DECLARE_HAS_FIELD(Choice) DECLARE_HAS_FIELD(Choice)
Defaultable<String> value; /// The name of the selected choice typedef Defaultable<String> ValueType;
ValueType value; /// The name of the selected choice
virtual String toString() const; virtual String toString() const;
virtual bool update(Context&); virtual bool update(Context&);
......
...@@ -76,7 +76,8 @@ class ColorValue : public Value { ...@@ -76,7 +76,8 @@ class ColorValue : public Value {
inline ColorValue(const ColorFieldP& field) : Value(field) {} inline ColorValue(const ColorFieldP& field) : Value(field) {}
DECLARE_HAS_FIELD(Color) DECLARE_HAS_FIELD(Color)
Defaultable<Color> value; ///< The value typedef Defaultable<Color> ValueType;
ValueType value; ///< The value
virtual String toString() const; virtual String toString() const;
virtual bool update(Context&); virtual bool update(Context&);
......
...@@ -50,7 +50,8 @@ class ImageValue : public Value { ...@@ -50,7 +50,8 @@ class ImageValue : public Value {
public: public:
inline ImageValue(const ImageFieldP& field) : Value(field) {} inline ImageValue(const ImageFieldP& field) : Value(field) {}
FileName filename; ///< Filename of the image (in the current package), or "" typedef FileName ValueType;
ValueType filename; ///< Filename of the image (in the current package), or ""
virtual String toString() const; virtual String toString() const;
......
...@@ -65,7 +65,8 @@ class SymbolValue : public Value { ...@@ -65,7 +65,8 @@ class SymbolValue : public Value {
inline SymbolValue(const SymbolFieldP& field) : Value(field) {} inline SymbolValue(const SymbolFieldP& field) : Value(field) {}
DECLARE_HAS_FIELD(Symbol) DECLARE_HAS_FIELD(Symbol)
FileName filename; ///< Filename of the symbol (in the current package) typedef FileName ValueType;
ValueType filename; ///< Filename of the symbol (in the current package)
virtual String toString() const; virtual String toString() const;
......
...@@ -80,7 +80,8 @@ class TextValue : public Value { ...@@ -80,7 +80,8 @@ class TextValue : public Value {
inline TextValue(const TextFieldP& field) : Value(field) {} inline TextValue(const TextFieldP& field) : Value(field) {}
DECLARE_HAS_FIELD(Text) DECLARE_HAS_FIELD(Text)
Defaultable<String> value; ///< The text of this value typedef Defaultable<String> ValueType;
ValueType value; ///< The text of this value
virtual String toString() const; virtual String toString() const;
virtual bool update(Context&); virtual bool update(Context&);
......
...@@ -46,3 +46,13 @@ Color darken(const Color& c) { ...@@ -46,3 +46,13 @@ Color darken(const Color& c) {
c.Blue() * 8 / 10 c.Blue() * 8 / 10
); );
} }
Color saturate(const Color& c, double amount) {
int r = c.Red(), g = c.Green(), b = c.Blue();
double l = (r + g + b) / 3;
return Color(
col((r - amount * l) / (1 - amount)),
col((g - amount * l) / (1 - amount)),
col((b - amount * l) / (1 - amount))
);
}
...@@ -169,5 +169,8 @@ Color hsl2rgb(double h, double s, double l); ...@@ -169,5 +169,8 @@ Color hsl2rgb(double h, double s, double l);
/// A darker version of a color /// A darker version of a color
Color darken(const Color& c); Color darken(const Color& c);
/// A saturated version of a color
Color saturate(const Color& c, double amount);
// ----------------------------------------------------------------------------- : EOF // ----------------------------------------------------------------------------- : EOF
#endif #endif
...@@ -32,7 +32,11 @@ void CardViewer::onChange() { ...@@ -32,7 +32,11 @@ void CardViewer::onChange() {
} }
void CardViewer::onPaint(wxPaintEvent&) { void CardViewer::onPaint(wxPaintEvent&) {
wxBufferedPaintDC dc(this); wxSize cs = GetClientSize();
if (!buffer.Ok() || buffer.GetWidth() != cs.GetWidth() || buffer.GetHeight() != cs.GetHeight()) {
buffer = Bitmap(cs.GetWidth(), cs.GetHeight());
}
wxBufferedPaintDC dc(this, buffer);
dc.BeginDrawing(); dc.BeginDrawing();
draw(dc); draw(dc);
dc.EndDrawing(); dc.EndDrawing();
......
...@@ -29,7 +29,6 @@ class CardViewer : public wxControl, public DataViewer { ...@@ -29,7 +29,6 @@ class CardViewer : public wxControl, public DataViewer {
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
void onPaint(wxPaintEvent&); void onPaint(wxPaintEvent&);
void onSize(wxSizeEvent&);
Bitmap buffer; /// < Off-screen buffer we draw to Bitmap buffer; /// < Off-screen buffer we draw to
}; };
......
...@@ -159,7 +159,7 @@ void GalleryList::OnDraw(DC& dc) { ...@@ -159,7 +159,7 @@ void GalleryList::OnDraw(DC& dc) {
bool selected = i == selection; bool selected = i == selection;
Color c = selected ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT) : unselected; Color c = selected ? wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT) : unselected;
dc.SetPen(c); dc.SetPen(c);
dc.SetBrush(lerp(background, c, 0.3)); dc.SetBrush(saturate(lerp(background, c, 0.3), selected ? 0.5 : 0));
RealPoint pos = itemPos(i); RealPoint pos = itemPos(i);
dc.DrawRectangle(pos.x - BORDER, pos.y - BORDER, item_size.width + 2*BORDER, item_size.height + 2*BORDER); dc.DrawRectangle(pos.x - BORDER, pos.y - BORDER, item_size.width + 2*BORDER, item_size.height + 2*BORDER);
// draw item // draw item
......
...@@ -21,8 +21,12 @@ NativeLookEditor::NativeLookEditor(Window* parent, int id, long style) ...@@ -21,8 +21,12 @@ NativeLookEditor::NativeLookEditor(Window* parent, int id, long style)
: DataEditor(parent, id, style) : DataEditor(parent, id, style)
{} {}
Rotation NativeLookEditor::getRotation() const {
return Rotation(0, RealRect(RealPoint(0,0),GetClientSize()));
}
void NativeLookEditor::draw(DC& dc) { void NativeLookEditor::draw(DC& dc) {
RotatedDC rdc(dc, 0, RealRect(RealPoint(0,0),GetClientSize()), 1, 0); RotatedDC rdc(dc, getRotation(), false);
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
} }
void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) { void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
......
...@@ -22,6 +22,7 @@ class NativeLookEditor : public DataEditor { ...@@ -22,6 +22,7 @@ class NativeLookEditor : public DataEditor {
/// Uses a native look /// Uses a native look
virtual bool nativeLook() const { return true; } virtual bool nativeLook() const { return true; }
virtual bool drawBorders() const { return false; } virtual bool drawBorders() const { return false; }
virtual Rotation getRotation() const;
virtual void draw(DC& dc); virtual void draw(DC& dc);
virtual void drawViewer(RotatedDC& dc, ValueViewer& v); virtual void drawViewer(RotatedDC& dc, ValueViewer& v);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <gui/drop_down_list.hpp> #include <gui/drop_down_list.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
#include <render/value/viewer.hpp> #include <render/value/viewer.hpp>
#include <render/card/viewer.hpp>
#include <util/rotation.hpp>
#include <gfx/gfx.hpp> #include <gfx/gfx.hpp>
#include <wx/dcbuffer.h> #include <wx/dcbuffer.h>
...@@ -23,38 +25,31 @@ class DropDownHider : public wxEvtHandler { ...@@ -23,38 +25,31 @@ class DropDownHider : public wxEvtHandler {
DropDownList& list; DropDownList& list;
virtual bool ProcessEvent(wxEvent& ev) { virtual bool ProcessEvent(wxEvent& ev) {
// close the list, and pass on the event int t = ev.GetEventType();
// don't just use ev.Skip(), because this event handler will be removed by hiding, if ( t == wxEVT_LEFT_DOWN || t == wxEVT_RIGHT_DOWN
// so there will be no next handler to skip to || t == wxEVT_MOVE || t == wxEVT_SIZE
wxEvtHandler* nh = GetNextHandler(); || t == wxEVT_MENU_HIGHLIGHT || t == wxEVT_MENU_OPEN || t == wxEVT_MENU_OPEN
list.hide(false); || t == wxEVT_ACTIVATE || t == wxEVT_CLOSE_WINDOW || t == wxEVT_KILL_FOCUS
if (nh) nh->ProcessEvent(ev); || t == wxEVT_COMMAND_TOOL_CLICKED)
{
// close the list, and pass on the event
// don't just use ev.Skip(), because this event handler will be removed by hiding,
// so there will be no next handler to skip to
wxEvtHandler* nh = GetNextHandler();
list.hide(false);
if (nh) nh->ProcessEvent(ev);
return false;
} else {
// if (t !=10093 && t !=10098 && t !=10097 && t !=10099 && t !=10004 && t !=10062
// && t !=10025 && t !=10035 && t !=10034 && t !=10036 && t !=10042 && t !=10119)
// {
// t=t;//DEBUG
// }
return wxEvtHandler::ProcessEvent(ev);
}
} }
}; };
/*BEGIN_EVENT_TABLE(DropDownHider, wxEvtHandler)
EVT_CUSTOM(wxEVT_LEFT_DOWN, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_RIGHT_DOWN, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_MOVE, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_SIZE, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_MENU_HIGHLIGHT, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_MENU, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_MENU_OPEN, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_ACTIVATE, wxID_ANY, DropDownHider::onEvent)
// EVT_CUSTOM(wxEVT_CLOSE, wxID_ANY, DropDownHider::onEvent)
EVT_CUSTOM(wxEVT_KILL_FOCUS, wxID_ANY, DropDownHider::onEvent)
/* EVT_LEFT_DOWN ( (wxMouseEventFunction)&DropDownHider::onEvent)
EVT_RIGHT_DOWN ( DropDownHider::onMouseEvent)
EVT_MOVE ( DropDownHider::onMoveEvent)
EVT_SIZE ( DropDownHider::onSizeEvent)
EVT_MENU_HIGHLIGHT (wxID_ANY, DropDownHider::onMenuEvent)
EVT_MENU (wxID_ANY, DropDownHider::onCommandEvent)
EVT_MENU_OPEN ( DropDownHider::onMenuEvent)
EVT_ACTIVATE ( DropDownHider::onActivateEvent)
EVT_CLOSE ( DropDownHider::onCloseEvent)
EVT_KILL_FOCUS ( DropDownHider::onFocusEvent)
END_EVENT_TABLE ()
*/
// ----------------------------------------------------------------------------- : DropDownList : Show/Hide // ----------------------------------------------------------------------------- : DropDownList : Show/Hide
...@@ -64,6 +59,7 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer) ...@@ -64,6 +59,7 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
, selected_item(NO_SELECTION) , selected_item(NO_SELECTION)
, open_sub_menu(nullptr) , open_sub_menu(nullptr)
, parent_menu(is_submenu ? static_cast<DropDownList*>(GetParent()) : nullptr) , parent_menu(is_submenu ? static_cast<DropDownList*>(GetParent()) : nullptr)
, hider(is_submenu ? nullptr : new DropDownHider(*this))
, viewer(viewer) , viewer(viewer)
, item_size(100,1) , item_size(100,1)
{ {
...@@ -75,6 +71,10 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer) ...@@ -75,6 +71,10 @@ DropDownList::DropDownList(Window* parent, bool is_submenu, ValueViewer* viewer)
item_size.height = h; item_size.height = h;
} }
DropDownList::~DropDownList() {
delete hider;
}
void DropDownList::show(bool in_place, wxPoint pos) { void DropDownList::show(bool in_place, wxPoint pos) {
if (IsShown()) return; if (IsShown()) return;
// find selection // find selection
...@@ -83,40 +83,38 @@ void DropDownList::show(bool in_place, wxPoint pos) { ...@@ -83,40 +83,38 @@ void DropDownList::show(bool in_place, wxPoint pos) {
int line_count = 0; int line_count = 0;
size_t count = itemCount(); size_t count = itemCount();
for (size_t i = 0 ; i < count ; ++i) if (lineBelow(i)) line_count += 1; for (size_t i = 0 ; i < count ; ++i) if (lineBelow(i)) line_count += 1;
wxSize size( RealSize size(
item_size.width + marginW * 2, item_size.width + marginW * 2,
item_size.height * count + marginH * 2 + line_count item_size.height * count + marginH * 2 + line_count
); );
int parent_height = 0; int parent_height = 0;
/*if (!in_place) { if (!in_place && viewer) {
// Position the drop down list below the editor control (based on the style) // Position the drop down list below the editor control (based on the style)
RotatedObject rot(editor.rotation); RealRect r = viewer->viewer.getRotation().trNoNeg(viewer->getStyle()->getRect());
Rect r = rot.trNoNeg(style->rect); if (viewer->viewer.nativeLook()) {
if (editor.nativeLook()) { pos = wxPoint(r.x - 3, r.y - 3);
pos = Point(r.left - 3, r.top - 3); size.width = max(size.width, r.width + 6);
size.width = max(size.width, r.width + 6); parent_height = r.height + 6;
editorHeight = r.height + 6;
} else { } else {
pos = Point(r.left - 1, r.top - 1); pos = wxPoint(r.x - 1, r.y - 1);
size.width = max(size.width, r.width + 2); size.width = max(size.width, r.width + 2);
editorHeight = r.height; parent_height = r.height;
} }
} else if (parent_menu) { } else if (parent_menu) {
parent_height = -item_height - 1; parent_height = -item_size.height - 1;
} }
*/ pos = GetParent()->ClientToScreen(pos);
// move & resize // move & resize
item_size.width = size.GetWidth() - marginW * 2; item_size.width = size.width - marginW * 2;
SetSize(size); SetSize(size);
Position(pos, wxSize(0, parent_height)); Position(pos, wxSize(0, parent_height));
// set event handler // set event handler
if (!parent_menu) { if (hider) {
// Window* parent = wxGetTopLevelParent(this); Window* parent = wxGetTopLevelParent(GetParent());
// parent->PushEventHandler(&hider); parent->PushEventHandler(hider);
} }
// show // show
// oldSelectedItem = selectedItem; // oldSelectedItem = selectedItem;
if (selected_item == NO_SELECTION && itemCount() > 0) selected_item = 0; // select first item by default if (selected_item == NO_SELECTION && itemCount() > 0) selected_item = 0; // select first item by default
mouse_down = false; mouse_down = false;
Window::Show(); Window::Show();
...@@ -143,10 +141,10 @@ void DropDownList::realHide() { ...@@ -143,10 +141,10 @@ void DropDownList::realHide() {
if (parent_menu) { if (parent_menu) {
parent_menu->open_sub_menu = 0; parent_menu->open_sub_menu = 0;
} else { } else {
// redrawDropDownArrowOnParent(); redrawArrowOnParent();
// disconnect event handler // disconnect event handler
// Window* parent = getTopLevelParent(&editor); Window* parent = wxGetTopLevelParent(GetParent());
// parent->RemoveEventHandler(&hider); parent->RemoveEventHandler(hider);
} }
} }
...@@ -306,7 +304,7 @@ void DropDownList::onCharInParent(wxKeyEvent& ev) { ...@@ -306,7 +304,7 @@ void DropDownList::onCharInParent(wxKeyEvent& ev) {
} else { } else {
switch (k) { switch (k) {
case WXK_UP: case WXK_UP:
if (selected_item - 1 >= 0) { if (selected_item > 0) {
selected_item -= 1; selected_item -= 1;
Refresh(false); Refresh(false);
} }
...@@ -332,11 +330,12 @@ void DropDownList::onCharInParent(wxKeyEvent& ev) { ...@@ -332,11 +330,12 @@ void DropDownList::onCharInParent(wxKeyEvent& ev) {
// match first character of an item, start searching just after the current selection // match first character of an item, start searching just after the current selection
size_t si = selected_item != NO_SELECTION ? selected_item + 1 : 0; size_t si = selected_item != NO_SELECTION ? selected_item + 1 : 0;
size_t count = itemCount(); size_t count = itemCount();
for (size_t i = si ; i < count + si ; ++i) { for (size_t i = 0 ; i < count ; ++i) {
String c = itemText(i); size_t index = (si + i) % count;
String c = itemText(index);
if (!c.empty() && toUpper(c.GetChar(0)) == toUpper(ev.GetUnicodeKey())) { if (!c.empty() && toUpper(c.GetChar(0)) == toUpper(ev.GetUnicodeKey())) {
// first character matches // first character matches
selected_item = i; selected_item = index;
showSubMenu(); showSubMenu();
Refresh(false); Refresh(false);
return; return;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <wx/popupwin.h> // undocumented: wxPopupWindow #include <wx/popupwin.h> // undocumented: wxPopupWindow
class ValueViewer; class ValueViewer;
class DropDownHider;
// ----------------------------------------------------------------------------- : DropDownList // ----------------------------------------------------------------------------- : DropDownList
...@@ -21,6 +22,7 @@ class ValueViewer; ...@@ -21,6 +22,7 @@ class ValueViewer;
/** This class is an abstract base for various drop down lists */ /** This class is an abstract base for various drop down lists */
class DropDownList : public wxPopupWindow { class DropDownList : public wxPopupWindow {
public: public:
~DropDownList();
/// Create a drop down list, possibly a sub menu /// Create a drop down list, possibly a sub menu
/** the viewer will be notified to redraw its drop down icon */ /** the viewer will be notified to redraw its drop down icon */
DropDownList(Window* parent, bool is_submenu = false, ValueViewer* viewer = nullptr); DropDownList(Window* parent, bool is_submenu = false, ValueViewer* viewer = nullptr);
...@@ -78,6 +80,7 @@ class DropDownList : public wxPopupWindow { ...@@ -78,6 +80,7 @@ class DropDownList : public wxPopupWindow {
DropDownList* open_sub_menu; ///< The sub menu that is currently shown, if any DropDownList* open_sub_menu; ///< The sub menu that is currently shown, if any
DropDownList* parent_menu; ///< The parent menu, only applies to sub menus DropDownList* parent_menu; ///< The parent menu, only applies to sub menus
ValueViewer* viewer; ///< The parent viewer object (optional) ValueViewer* viewer; ///< The parent viewer object (optional)
DropDownHider* hider; ///< Class to hide this window when we lose focus
// --------------------------------------------------- : Events // --------------------------------------------------- : Events
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
......
...@@ -96,6 +96,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set) ...@@ -96,6 +96,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
// tool bar // tool bar
wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL); wxToolBar* tb = CreateToolBar(wxTB_FLAT | wxNO_BORDER | wxTB_HORIZONTAL);
tb->SetToolBitmapSize(wxSize(18,18));
tb->AddTool(ID_FILE_NEW, _(""), Bitmap(_("TOOL_NEW")), wxNullBitmap, wxITEM_NORMAL, _("New set"), _("Creates a new set")); tb->AddTool(ID_FILE_NEW, _(""), Bitmap(_("TOOL_NEW")), wxNullBitmap, wxITEM_NORMAL, _("New set"), _("Creates a new set"));
tb->AddTool(ID_FILE_OPEN, _(""), Bitmap(_("TOOL_OPEN")), wxNullBitmap, wxITEM_NORMAL, _("Open set"), _("Opens an existing set")); tb->AddTool(ID_FILE_OPEN, _(""), Bitmap(_("TOOL_OPEN")), wxNullBitmap, wxITEM_NORMAL, _("Open set"), _("Opens an existing set"));
tb->AddTool(ID_FILE_SAVE, _(""), Bitmap(_("TOOL_SAVE")), wxNullBitmap, wxITEM_NORMAL, _("Save set"), _("Saves the current set")); tb->AddTool(ID_FILE_SAVE, _(""), Bitmap(_("TOOL_SAVE")), wxNullBitmap, wxITEM_NORMAL, _("Save set"), _("Saves the current set"));
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <gui/value/color.hpp> #include <gui/value/color.hpp>
#include <gui/drop_down_list.hpp> #include <gui/drop_down_list.hpp>
#include <gui/util.hpp> #include <gui/util.hpp>
#include <data/action/value.hpp>
#include <wx/colordlg.h> #include <wx/colordlg.h>
DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP); DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP);
...@@ -141,7 +142,7 @@ void ColorValueEditor::determineSize() { ...@@ -141,7 +142,7 @@ void ColorValueEditor::determineSize() {
} }
void ColorValueEditor::change(const Defaultable<Color>& c) { void ColorValueEditor::change(const Defaultable<Color>& c) {
// getSet().actions.add(new ColorChangeAction(value(), c)); getSet().actions.add(value_action(static_pointer_cast<ColorValue>(valueP), c));
} }
void ColorValueEditor::changeCustom() { void ColorValueEditor::changeCustom() {
Color c = wxGetColourFromUser(0, value().value()); Color c = wxGetColourFromUser(0, value().value());
......
...@@ -47,7 +47,7 @@ class ValueEditor { ...@@ -47,7 +47,7 @@ class ValueEditor {
virtual void onMouseWheel (const RealPoint& pos, wxMouseEvent& ev) {} virtual void onMouseWheel (const RealPoint& pos, wxMouseEvent& ev) {}
/// Key events /// Key events
virtual void onChar(wxKeyEvent ev) {} virtual void onChar(wxKeyEvent& ev) {}
/// a context menu is requested, add extra items to the menu m /// a context menu is requested, add extra items to the menu m
/** return false to suppress menu */ /** return false to suppress menu */
......
...@@ -984,6 +984,36 @@ ...@@ -984,6 +984,36 @@
<File <File
RelativePath=".\data\action\symbol_part.hpp"> RelativePath=".\data\action\symbol_part.hpp">
</File> </File>
<File
RelativePath=".\data\action\value.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Debug Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release Unicode|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File
RelativePath=".\data\action\value.hpp">
</File>
</Filter> </Filter>
<Filter <Filter
Name="format" Name="format"
......
...@@ -57,6 +57,12 @@ wxPen DataViewer::borderPen(bool) const { return wxPen(); } ...@@ -57,6 +57,12 @@ wxPen DataViewer::borderPen(bool) const { return wxPen(); }
ValueViewer* DataViewer::focusedViewer() const { return nullptr; } ValueViewer* DataViewer::focusedViewer() const { return nullptr; }
Context& DataViewer::getContext() const { return set->getContext(); } Context& DataViewer::getContext() const { return set->getContext(); }
Rotation DataViewer::getRotation() const {
StyleSheetP stylesheet = set->stylesheetFor(card);
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
return Rotation(ss.card_angle(), stylesheet->getCardRect(), ss.card_zoom());
}
// ----------------------------------------------------------------------------- : Setting data // ----------------------------------------------------------------------------- : Setting data
void DataViewer::setCard(const CardP& card) { void DataViewer::setCard(const CardP& card) {
......
...@@ -52,6 +52,8 @@ class DataViewer : public SetView { ...@@ -52,6 +52,8 @@ class DataViewer : public SetView {
virtual ValueViewer* focusedViewer() const; virtual ValueViewer* focusedViewer() const;
/// Get a script context to use for scripts in the viewers /// Get a script context to use for scripts in the viewers
Context& getContext() const; Context& getContext() const;
/// The rotation to use
virtual Rotation getRotation() const;
// --------------------------------------------------- : Setting data // --------------------------------------------------- : Setting data
......
...@@ -58,8 +58,8 @@ class ValueViewer { ...@@ -58,8 +58,8 @@ class ValueViewer {
/// Convert this viewer to an editor, if possible /// Convert this viewer to an editor, if possible
virtual ValueEditor* getEditor() { return 0; } virtual ValueEditor* getEditor() { return 0; }
protected:
DataViewer& viewer; ///< Our parent object DataViewer& viewer; ///< Our parent object
protected:
StyleP styleP; ///< The style of this viewer StyleP styleP; ///< The style of this viewer
ValueP valueP; ///< The value we are currently viewing ValueP valueP; ///< The value we are currently viewing
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment