mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 05:07:00 -04:00
New symbol part list control that shows previews and has a built in editor
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@529 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
#include <gui/symbol/basic_shape_editor.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <util/window_id.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <data/action/symbol.hpp>
|
||||
#include <data/action/symbol_part.hpp>
|
||||
#include <wx/spinctrl.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolBasicShapeEditor
|
||||
@@ -108,7 +110,7 @@ void SymbolBasicShapeEditor::onMouseDrag (const Vector2D& from, const Vector2D&
|
||||
// Resize the object
|
||||
if (drawing) {
|
||||
end = to;
|
||||
makeShape(start, end, ev.ControlDown(), ev.ShiftDown());
|
||||
makeShape(start, end, ev.ControlDown(), settings.symbol_grid_snap, ev.ShiftDown());
|
||||
control.Refresh(false);
|
||||
}
|
||||
}
|
||||
@@ -119,7 +121,7 @@ void SymbolBasicShapeEditor::onKeyChange(wxKeyEvent& ev) {
|
||||
if (drawing) {
|
||||
if (ev.GetKeyCode() == WXK_CONTROL || ev.GetKeyCode() == WXK_SHIFT) {
|
||||
// changed constrains
|
||||
makeShape(start, end, ev.ControlDown(), ev.ShiftDown());
|
||||
makeShape(start, end, ev.ControlDown(), settings.symbol_grid_snap, ev.ShiftDown());
|
||||
control.Refresh(false);
|
||||
} else if (ev.GetKeyCode() == WXK_ESCAPE) {
|
||||
// cancel drawing
|
||||
@@ -156,7 +158,12 @@ inline double sgn(double d) {
|
||||
return d < 0 ? - 1 : 1;
|
||||
}
|
||||
|
||||
void SymbolBasicShapeEditor::makeShape(const Vector2D& a, const Vector2D& b, bool constrained, bool centered) {
|
||||
void SymbolBasicShapeEditor::makeShape(Vector2D a, Vector2D b, bool constrained, bool snap, bool centered) {
|
||||
// snap
|
||||
if (snap) {
|
||||
a = snap_vector(a, settings.symbol_grid_size);
|
||||
b = snap_vector(b, settings.symbol_grid_size);
|
||||
}
|
||||
// constrain
|
||||
Vector2D size = b - a;
|
||||
if (constrained) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class SymbolBasicShapeEditor : public SymbolEditorBase {
|
||||
/** when centered: a = center, b-a = radius
|
||||
* otherwise: a = top left, b = bottom right
|
||||
*/
|
||||
void makeShape(const Vector2D& a, const Vector2D& b, bool constrained, bool centered);
|
||||
void makeShape(Vector2D a, Vector2D b, bool constrained, bool snap, bool centered);
|
||||
|
||||
/// Make the shape, centered in c, with radius r
|
||||
void makeCenteredShape(const Vector2D& c, Vector2D r, bool constrained);
|
||||
|
||||
@@ -162,20 +162,20 @@ void SymbolControl::draw(DC& dc) {
|
||||
SymbolViewer::draw(dc);
|
||||
// draw grid
|
||||
if (settings.symbol_grid) {
|
||||
wxSize s = dc.GetSize();
|
||||
double lines = settings.symbol_grid_size;
|
||||
double end = rotation.trS(1);
|
||||
for (int i = 0 ; i <= lines ; ++i) {
|
||||
int x = (int) floor(rotation.trS(i/lines-0.0001));
|
||||
//dc.SetPen(Color(0, i%5 == 0 ? 64 : 31, 0));
|
||||
//dc.SetPen(Color(i%5 == 0 ? 64 : 31, 0, 0));
|
||||
dc.SetLogicalFunction(wxAND);
|
||||
dc.SetPen(i%5 == 0 ? Color(191,255,191) : Color(191, 255, 191));
|
||||
dc.DrawLine(x, 0, x, s.y);
|
||||
dc.DrawLine(0, x, s.x, x);
|
||||
dc.DrawLine(x, 0, x, end);
|
||||
dc.DrawLine(0, x, end, x);
|
||||
dc.SetLogicalFunction(wxOR);
|
||||
dc.SetPen(i%5 == 0 ? Color(0,63,0) : Color(0, 31, 0));
|
||||
dc.DrawLine(x, 0, x, s.y);
|
||||
dc.DrawLine(0, x, s.x, x);
|
||||
dc.DrawLine(x, 0, x, end);
|
||||
dc.DrawLine(0, x, end, x);
|
||||
}
|
||||
dc.SetLogicalFunction(wxCOPY);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ void SymbolControl::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
ev.Check(editor->modeToolId() == ev.GetId());
|
||||
if (ev.GetId() == ID_MODE_POINTS) {
|
||||
// can only edit points when a single part is selected <TODO?>
|
||||
ev.Enable(selected_parts.size() == 1);
|
||||
ev.Enable(selected_parts.size() == 1 && (*selected_parts.begin())->isSymbolShape());
|
||||
}
|
||||
break;
|
||||
case ID_MODE_PAINT:
|
||||
|
||||
@@ -72,7 +72,8 @@ class SymbolControl : public wxControl, public SymbolViewer {
|
||||
public:
|
||||
/// What parts are selected?
|
||||
set<SymbolPartP> selected_parts;
|
||||
SymbolShapeP selected_shape; // if there is a single selection
|
||||
SymbolPartP highlight_part; ///< part the mouse cursor is over
|
||||
SymbolShapeP selected_shape; ///< if there is a single selection
|
||||
|
||||
/// Parent window
|
||||
SymbolWindow* parent;
|
||||
|
||||
+419
-111
@@ -9,147 +9,455 @@
|
||||
#include <gui/symbol/part_list.hpp>
|
||||
#include <gui/util.hpp>
|
||||
#include <data/action/symbol.hpp>
|
||||
#include <wx/imaglist.h>
|
||||
#include <gfx/gfx.hpp>
|
||||
#include <render/symbol/filter.hpp>
|
||||
#include <wx/dcbuffer.h>
|
||||
#include <wx/caret.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Constructor
|
||||
DECLARE_TYPEOF_COLLECTION(SymbolPartP);
|
||||
|
||||
SymbolPartList::SymbolPartList(Window* parent, int id, SymbolP symbol)
|
||||
: wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize,
|
||||
wxLC_REPORT | wxLC_NO_HEADER | wxLC_VIRTUAL | wxLC_EDIT_LABELS)
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
DEFINE_EVENT_TYPE(EVENT_PART_SELECT);
|
||||
DEFINE_EVENT_TYPE(EVENT_PART_ACTIVATE);
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolPartList
|
||||
|
||||
|
||||
SymbolPartList::SymbolPartList(Window* parent, int id, set<SymbolPartP>& selection, SymbolP symbol)
|
||||
: wxScrolledWindow(parent, id, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER | wxVSCROLL)
|
||||
, selection(selection)
|
||||
, state_icons(9,8)
|
||||
{
|
||||
// Create image list
|
||||
wxImageList* images = new wxImageList(16,16);
|
||||
// NOTE: this is based on the order of the SymbolShapeCombine and SymbolSymmetryType enums!
|
||||
images->Add(load_resource_image(_("combine_or")));
|
||||
images->Add(load_resource_image(_("combine_sub")));
|
||||
images->Add(load_resource_image(_("combine_and")));
|
||||
images->Add(load_resource_image(_("combine_xor")));
|
||||
images->Add(load_resource_image(_("combine_over")));
|
||||
images->Add(load_resource_image(_("combine_border")));
|
||||
images->Add(load_resource_image(_("symmetry_rotation")));
|
||||
images->Add(load_resource_image(_("symmetry_reflection")));
|
||||
AssignImageList(images, wxIMAGE_LIST_SMALL);
|
||||
// create columns
|
||||
InsertColumn(0, _("Name"));
|
||||
state_icons.Add(load_resource_image(_("icon_combine_merge")));
|
||||
state_icons.Add(load_resource_image(_("icon_combine_subtract")));
|
||||
state_icons.Add(load_resource_image(_("icon_combine_intersection")));
|
||||
state_icons.Add(load_resource_image(_("icon_combine_difference")));
|
||||
state_icons.Add(load_resource_image(_("icon_combine_overlap")));
|
||||
state_icons.Add(load_resource_image(_("icon_combine_border")));
|
||||
state_icons.Add(load_resource_image(_("icon_symmetry_rotation")));
|
||||
state_icons.Add(load_resource_image(_("icon_symmetry_reflection")));
|
||||
state_icons.Add(load_resource_image(_("icon_symbol_group")));
|
||||
// view symbol
|
||||
setSymbol(symbol);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : View events
|
||||
|
||||
void SymbolPartList::onChangeSymbol() {
|
||||
typing_in = SymbolPartP();
|
||||
cursor = 0;
|
||||
update();
|
||||
}
|
||||
|
||||
void SymbolPartList::onAction(const Action& action, bool undone) {
|
||||
TYPE_CASE(action, ReorderSymbolPartsAction) {
|
||||
if (selected == (long) action.part_id1) {
|
||||
selectItem((long) action.part_id2);
|
||||
} else if (selected == (long) action.part_id2) {
|
||||
selectItem((long) action.part_id1);
|
||||
TYPE_CASE(action, SymbolPartNameAction) {
|
||||
if (typing_in == action.part) {
|
||||
cursor = action.new_cursor;
|
||||
}
|
||||
Refresh(false);
|
||||
if (true) return;
|
||||
}
|
||||
TYPE_CASE_(action, SymbolPartListAction) {
|
||||
update();
|
||||
return;
|
||||
}
|
||||
TYPE_CASE(action, SymbolPartsAction) {
|
||||
symbol_preview.up_to_date = false;
|
||||
updateParts(action.parts);
|
||||
if (true) return;
|
||||
}
|
||||
TYPE_CASE_(action, SymbolPartAction) {
|
||||
symbol_preview.up_to_date = false;
|
||||
// some part changed, but we don't know which one, assume it is the selection
|
||||
updateParts(selection);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Other
|
||||
|
||||
String SymbolPartList::OnGetItemText(long item, long col) const {
|
||||
assert(col == 0);
|
||||
return getPart(item)->name;
|
||||
}
|
||||
int SymbolPartList::OnGetItemImage(long item) const {
|
||||
return getPart(item)->icon();
|
||||
}
|
||||
|
||||
SymbolPartP SymbolPartList::getPart(long item) const {
|
||||
return symbol->parts.at(item);
|
||||
}
|
||||
void SymbolPartList::selectItem(long item) {
|
||||
selected = (long)item;
|
||||
long count = GetItemCount();
|
||||
for (long i = 0 ; i < count ; ++i) {
|
||||
SetItemState(i, i == selected ? wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED : 0,
|
||||
wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPartList::getSelectedParts(set<SymbolPartP>& sel) {
|
||||
sel.clear();
|
||||
long count = GetItemCount();
|
||||
for (long i = 0 ; i < count ; ++ i) {
|
||||
bool selected = GetItemState(i, wxLIST_STATE_SELECTED);
|
||||
if (selected) sel.insert(symbol->parts.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPartList::selectParts(const set<SymbolPartP>& sel) {
|
||||
long count = GetItemCount();
|
||||
for (long i = 0 ; i < count ; ++ i) {
|
||||
// is that part selected?
|
||||
bool selected = sel.find(symbol->parts.at(i)) != sel.end();
|
||||
SetItemState(i, selected ? wxLIST_STATE_SELECTED : 0,
|
||||
wxLIST_STATE_SELECTED);
|
||||
}
|
||||
wxSize SymbolPartList::DoGetBestSize() const {
|
||||
wxSize ws = GetSize(), cs = GetClientSize();
|
||||
const int w = 110;
|
||||
const int h = ITEM_HEIGHT;
|
||||
return wxSize(w, h) + ws - cs;
|
||||
}
|
||||
|
||||
void SymbolPartList::update() {
|
||||
if (symbol->parts.empty()) {
|
||||
// deleting all items requires a full refresh on win32
|
||||
SetItemCount(0);
|
||||
Refresh(true);
|
||||
} else {
|
||||
SetItemCount((long) symbol->parts.size() );
|
||||
Refresh(false);
|
||||
// count items
|
||||
number_of_items = childCount(symbol);
|
||||
SetVirtualSize(110, number_of_items * (ITEM_HEIGHT+1));
|
||||
// invalidate previews
|
||||
symbol_preview.up_to_date = false;
|
||||
for (size_t i = 0 ; i < part_previews.size() ; ++i) {
|
||||
part_previews[i].up_to_date = false;
|
||||
}
|
||||
// refresh
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Event handling
|
||||
|
||||
void SymbolPartList::onSelect(wxListEvent& ev) {
|
||||
selected = ev.GetIndex();
|
||||
ev.Skip();
|
||||
void SymbolPartList::updateParts(const set<SymbolPartP>& parts) {
|
||||
symbol_preview.up_to_date = false;
|
||||
int i = 0;
|
||||
FOR_EACH(p, symbol->parts) {
|
||||
updatePart(parts, i, false, p);
|
||||
}
|
||||
// refresh
|
||||
Refresh(false);
|
||||
}
|
||||
void SymbolPartList::onDeselect(wxListEvent& ev) {
|
||||
selected = -1;
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void SymbolPartList::onLabelEdit(wxListEvent& ev){
|
||||
symbol->actions.add(
|
||||
new SymbolPartNameAction(getPart(ev.GetIndex()), ev.GetLabel())
|
||||
);
|
||||
}
|
||||
|
||||
void SymbolPartList::onSize(wxSizeEvent& ev) {
|
||||
wxSize s = GetClientSize();
|
||||
SetColumnWidth(0, s.GetWidth() - 2);
|
||||
}
|
||||
|
||||
void SymbolPartList::onDrag(wxMouseEvent& ev) {
|
||||
if (!ev.Dragging() || selected == -1) return;
|
||||
// reorder the list of parts
|
||||
int flags;
|
||||
long item = HitTest(ev.GetPosition(), flags);
|
||||
if (flags & wxLIST_HITTEST_ONITEM) {
|
||||
if (item > 0) EnsureVisible(item - 1);
|
||||
if (item < GetItemCount() - 1) EnsureVisible(item + 1);
|
||||
if (item != selected) {
|
||||
// swap the two items
|
||||
symbol->actions.add(new ReorderSymbolPartsAction(*symbol, item, selected));
|
||||
selectItem(item); // deselect all other items, to prevent 'lassoing' them
|
||||
void SymbolPartList::updatePart(const set<SymbolPartP>& parts, int& i, bool parent_updated, const SymbolPartP& part) {
|
||||
bool update = parent_updated || parts.find(part) != parts.end();
|
||||
if (update) {
|
||||
part_previews[i].up_to_date = false;
|
||||
}
|
||||
++i;
|
||||
if (SymbolGroup* g = part->isSymbolGroup()) {
|
||||
FOR_EACH(p, g->parts) {
|
||||
updatePart(parts, i, update, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
void SymbolPartList::onLeftDown(wxMouseEvent& ev) {
|
||||
// find item under cursor
|
||||
if (ev.GetX() < 0 || ev.GetX() >= GetClientSize().x) return;
|
||||
SymbolPartP part = findItem(ev.GetY() / (ITEM_HEIGHT + 1));
|
||||
if (part) {
|
||||
// toggle/select
|
||||
if (!ev.ShiftDown()) {
|
||||
selection.clear();
|
||||
}
|
||||
if (selection.find(part) != selection.end()) {
|
||||
selection.erase(part);
|
||||
} else {
|
||||
selection.insert(part);
|
||||
}
|
||||
if (!ev.ShiftDown()) {
|
||||
// drag item
|
||||
mouse_down_on = part;
|
||||
drop_position = -1;
|
||||
CaptureMouse();
|
||||
}
|
||||
sendEvent(EVENT_PART_SELECT);
|
||||
Refresh(false);
|
||||
}
|
||||
ev.Skip(); // for focus
|
||||
}
|
||||
void SymbolPartList::onLeftUp(wxMouseEvent& ev) {
|
||||
if (HasCapture()) ReleaseMouse();
|
||||
if (mouse_down_on && drop_position != -1) {
|
||||
// move part
|
||||
// find old position
|
||||
vector<SymbolPartP>::const_iterator it = find(symbol->parts.begin(), symbol->parts.end(), mouse_down_on);
|
||||
mouse_down_on = SymbolPartP();
|
||||
if (it == symbol->parts.end()) {
|
||||
Refresh(false);
|
||||
return;
|
||||
}
|
||||
size_t old_position = it - symbol->parts.begin();
|
||||
// find new position
|
||||
size_t new_position;
|
||||
SymbolPartP drop_before = findItem(drop_position);
|
||||
it = find(symbol->parts.begin(), symbol->parts.end(), drop_before);
|
||||
if (it == symbol->parts.end()) {
|
||||
new_position = number_of_items - 1;
|
||||
} else {
|
||||
new_position = it - symbol->parts.begin();
|
||||
if (old_position < new_position) new_position -= 1;
|
||||
}
|
||||
// move part
|
||||
if (old_position != new_position) {
|
||||
symbol->actions.add(new ReorderSymbolPartsAction(*symbol, old_position, new_position));
|
||||
} else {
|
||||
Refresh(false);
|
||||
}
|
||||
} else {
|
||||
mouse_down_on = SymbolPartP();
|
||||
}
|
||||
}
|
||||
void SymbolPartList::onMotion(wxMouseEvent& ev) {
|
||||
if (mouse_down_on) {
|
||||
int new_drop_position = (ev.GetY() + ITEM_HEIGHT/2) / (ITEM_HEIGHT + 1);
|
||||
if (new_drop_position < 0 || new_drop_position > number_of_items) new_drop_position = -1;
|
||||
// TODO: make sure it is not in a group
|
||||
if (drop_position != new_drop_position) {
|
||||
drop_position = new_drop_position;
|
||||
Refresh(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPartList::onLeftDClick(wxMouseEvent& ev) {
|
||||
// double click = activate
|
||||
sendEvent(EVENT_PART_ACTIVATE);
|
||||
}
|
||||
|
||||
void SymbolPartList::onChar(wxKeyEvent& ev) {
|
||||
if (typing_in) {
|
||||
// Typing in name
|
||||
String new_name = typing_in->name;
|
||||
switch (ev.GetKeyCode()) {
|
||||
case WXK_HOME:
|
||||
if (cursor != 0) {
|
||||
cursor = 0; Refresh(false); // TODO: without refresh
|
||||
}
|
||||
break;
|
||||
case WXK_END:
|
||||
if (cursor != typing_in->name.size()) {
|
||||
cursor = typing_in->name.size(); Refresh(false);
|
||||
}
|
||||
break;
|
||||
case WXK_LEFT:
|
||||
if (cursor > 0) {
|
||||
--cursor; Refresh(false);
|
||||
}
|
||||
break;
|
||||
case WXK_RIGHT:
|
||||
if (cursor < typing_in->name.size()) {
|
||||
++cursor; Refresh(false);
|
||||
}
|
||||
break;
|
||||
case WXK_BACK:
|
||||
if (cursor > 0 && cursor <= typing_in->name.size()) {
|
||||
String new_name = typing_in->name;
|
||||
new_name.erase(cursor - 1, 1);
|
||||
symbol->actions.add(new SymbolPartNameAction(typing_in, new_name, cursor, cursor - 1));
|
||||
}
|
||||
break;
|
||||
case WXK_DELETE:
|
||||
if (cursor < typing_in->name.size()) {
|
||||
String new_name = typing_in->name;
|
||||
new_name.erase(cursor, 1);
|
||||
symbol->actions.add(new SymbolPartNameAction(typing_in, new_name, cursor, cursor));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// See gui/value/text.cpp
|
||||
#ifdef __WXMSW__
|
||||
if (ev.GetKeyCode() >= _(' ') && ev.GetKeyCode() == (int)ev.GetRawKeyCode()) {
|
||||
#else
|
||||
if (ev.GetKeyCode() >= _(' ') /*&& ev.GetKeyCode() == (int)ev.GetRawKeyCode()*/) {
|
||||
#endif
|
||||
#ifdef UNICODE
|
||||
Char key = ev.GetUnicodeKey();
|
||||
#else
|
||||
Char key = (Char)ev.GetKeyCode();
|
||||
#endif
|
||||
String new_name = typing_in->name;
|
||||
new_name.insert(cursor, 1, key);
|
||||
symbol->actions.add(new SymbolPartNameAction(typing_in, new_name, cursor, cursor + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Move up/down?
|
||||
}
|
||||
|
||||
void SymbolPartList::onSize(wxSizeEvent&) {
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
void SymbolPartList::sendEvent(int type) {
|
||||
wxCommandEvent ev(type, GetId());
|
||||
ProcessEvent(ev);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Items
|
||||
|
||||
SymbolPartP SymbolPartList::findItem(int i) const {
|
||||
FOR_EACH(p, symbol->parts) {
|
||||
SymbolPartP f = findItem(i, p);
|
||||
if (f) return f;
|
||||
}
|
||||
return SymbolPartP();
|
||||
}
|
||||
SymbolPartP SymbolPartList::findItem(int& i, const SymbolPartP& part) {
|
||||
if (i < 0 ) return SymbolPartP();
|
||||
if (i == 0) return part;
|
||||
i -= 1;
|
||||
// sub item?
|
||||
if (SymbolGroup* g = part->isSymbolGroup()) {
|
||||
FOR_EACH(p, g->parts) {
|
||||
if (findItem(i, p)) return part;
|
||||
}
|
||||
}
|
||||
return SymbolPartP();
|
||||
}
|
||||
|
||||
int SymbolPartList::childCount(const SymbolPartP& part) {
|
||||
if (SymbolGroup* g = part->isSymbolGroup()) {
|
||||
int count = 0;
|
||||
FOR_EACH(p, g->parts) count += 1 + childCount(p);
|
||||
return count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Text editor
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------- : Drawing
|
||||
|
||||
|
||||
void SymbolPartList::onPaint(wxPaintEvent&) {
|
||||
wxBufferedPaintDC dc(this);
|
||||
DoPrepareDC(dc);
|
||||
OnDraw(dc);
|
||||
}
|
||||
void SymbolPartList::OnDraw(DC& dc) {
|
||||
// init
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
// clear background
|
||||
wxSize size = GetClientSize();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.DrawRectangle(0,0,size.x,size.y);
|
||||
// items
|
||||
int i = 0;
|
||||
FOR_EACH(p, symbol->parts) {
|
||||
drawItem(dc, 0, i, false, p);
|
||||
}
|
||||
// drag/drop indicator
|
||||
if (mouse_down_on && drop_position != -1) {
|
||||
dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), 3));
|
||||
int y = drop_position * (ITEM_HEIGHT + 1) - 1;
|
||||
dc.DrawLine(0,y,size.x,y);
|
||||
dc.DrawLine(0,y-3,0,y+3);
|
||||
dc.DrawLine(size.x-1,y-3,size.x-1,y+3);
|
||||
}
|
||||
// hide caret
|
||||
if (selection.size() != 1) {
|
||||
typing_in = SymbolPartP();
|
||||
wxCaret* caret = GetCaret();
|
||||
if (caret) caret->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPartList::drawItem(DC& dc, int x, int& i, bool parent_active, const SymbolPartP& part) {
|
||||
wxSize size = GetClientSize();
|
||||
int w = size.x - x;
|
||||
int y = i * (ITEM_HEIGHT + 1);
|
||||
// draw item : highlight
|
||||
Color background;
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
bool active = selection.find(part) != selection.end();
|
||||
if (active) {
|
||||
background = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
|
||||
dc.SetBrush(background);
|
||||
dc.DrawRectangle(x,y,w,ITEM_HEIGHT);
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
||||
} else if (parent_active) {
|
||||
background = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
} else {
|
||||
background = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
}
|
||||
// draw item : name
|
||||
int h = dc.GetCharHeight();
|
||||
dc.DrawText(part->name, ITEM_HEIGHT + x + 3, y + (ITEM_HEIGHT - h) / 2);
|
||||
// draw item : icon
|
||||
dc.SetBrush(lerp(background,wxColour(0,128,0),0.7));
|
||||
dc.DrawRectangle(x,y,ITEM_HEIGHT,ITEM_HEIGHT);
|
||||
dc.DrawBitmap(symbolPreview(), x, y);
|
||||
dc.DrawBitmap(itemPreview(i,part), x, y);
|
||||
// draw item : border
|
||||
wxPen line_pen = lerp(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW),
|
||||
wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT),0.5);
|
||||
dc.SetPen(line_pen);
|
||||
dc.DrawLine(x+ITEM_HEIGHT, y, x+ITEM_HEIGHT, y + ITEM_HEIGHT + 1); // line after image
|
||||
dc.DrawLine(x, y + ITEM_HEIGHT, size.x, y + ITEM_HEIGHT); // line below
|
||||
// update caret
|
||||
if (selection.size() == 1 && active) {
|
||||
updateCaret(dc, x + ITEM_HEIGHT + 3, y + (ITEM_HEIGHT - h) / 2, h, part);
|
||||
}
|
||||
// move down
|
||||
i += 1;
|
||||
// draw more?
|
||||
if (SymbolShape* s = part->isSymbolShape()) {
|
||||
// combine state
|
||||
state_icons.Draw(s->combine, dc, size.x - 10, y + 1);
|
||||
} else if (SymbolSymmetry* s = part->isSymbolSymmetry()) {
|
||||
// kind of symmetry
|
||||
state_icons.Draw(s->kind, dc, size.x - 10, y + 1);
|
||||
// TODO: show clip mode?
|
||||
} else if (SymbolGroup* g = part->isSymbolGroup()) {
|
||||
state_icons.Draw(SYMMETRY_REFLECTION + 1, dc, size.x - 10, y + 1);
|
||||
FOR_EACH(p, g->parts) drawItem(dc, x + 5, i, active || parent_active, p);
|
||||
// draw bar on the left
|
||||
int new_y = i * (ITEM_HEIGHT + 1);
|
||||
y += ITEM_HEIGHT+1;
|
||||
if (y != new_y) {
|
||||
dc.SetPen(line_pen);
|
||||
dc.SetBrush(background);
|
||||
dc.DrawRectangle(x-1,y-1,5+1,new_y-y+1);
|
||||
}
|
||||
} else {
|
||||
throw "Unknown symbol part type";
|
||||
}
|
||||
}
|
||||
|
||||
const Image& SymbolPartList::itemPreview(int i, const SymbolPartP& part) {
|
||||
if ((size_t)i >= part_previews.size()) part_previews.resize(i + 1);
|
||||
Preview& p = part_previews[i];
|
||||
if (!p.up_to_date) {
|
||||
SolidFillSymbolFilter filter(*wxBLACK, Color(255,128,128));
|
||||
// temporary symbol
|
||||
SymbolP sym(new Symbol); sym->parts.push_back(part);
|
||||
Image img;
|
||||
if (SymbolShape* s = part->isSymbolShape()) {
|
||||
if (s->combine == SYMBOL_COMBINE_SUBTRACT) {
|
||||
// temporarily render using subtract instead, otherwise we don't see anything
|
||||
s->combine = SYMBOL_COMBINE_BORDER;
|
||||
img = render_symbol(sym, filter, 0.08, ITEM_HEIGHT * 4);
|
||||
s->combine = SYMBOL_COMBINE_SUBTRACT;
|
||||
} else {
|
||||
img = render_symbol(sym, filter, 0.08, ITEM_HEIGHT * 4);
|
||||
}
|
||||
} else {
|
||||
img = render_symbol(sym, filter, 0.08, ITEM_HEIGHT * 4);
|
||||
}
|
||||
resample(img, p.image);
|
||||
p.up_to_date = true;
|
||||
}
|
||||
return p.image;
|
||||
}
|
||||
const Image& SymbolPartList::symbolPreview() {
|
||||
if (!symbol_preview.up_to_date) {
|
||||
SolidFillSymbolFilter filter(AColor(0,0,0,40), AColor(255,255,255,40));
|
||||
Image img = render_symbol(symbol, filter, 0.06, ITEM_HEIGHT * 4);
|
||||
resample(img, symbol_preview.image);
|
||||
symbol_preview.up_to_date = true;
|
||||
}
|
||||
return symbol_preview.image;
|
||||
}
|
||||
|
||||
void SymbolPartList::updateCaret(DC& dc, int x, int y, int h, const SymbolPartP& part) {
|
||||
// make caret
|
||||
wxCaret* caret = GetCaret();
|
||||
if (!caret) {
|
||||
caret = new wxCaret(this, 1, h);
|
||||
SetCaret(caret);
|
||||
}
|
||||
// move caret
|
||||
if (typing_in != part) {
|
||||
typing_in = part;
|
||||
cursor = typing_in->name.size();
|
||||
}
|
||||
cursor = min(cursor, typing_in->name.size());
|
||||
int w;
|
||||
dc.GetTextExtent(typing_in->name.substr(0,cursor), &w, nullptr);
|
||||
caret->Move(x+w,y);
|
||||
if (!caret->IsVisible()) caret->Show();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Event table
|
||||
|
||||
BEGIN_EVENT_TABLE(SymbolPartList, wxListCtrl)
|
||||
EVT_LIST_ITEM_SELECTED (wxID_ANY, SymbolPartList::onSelect)
|
||||
EVT_LIST_ITEM_DESELECTED (wxID_ANY, SymbolPartList::onDeselect)
|
||||
EVT_LIST_END_LABEL_EDIT (wxID_ANY, SymbolPartList::onLabelEdit)
|
||||
EVT_SIZE ( SymbolPartList::onSize)
|
||||
EVT_MOTION ( SymbolPartList::onDrag)
|
||||
BEGIN_EVENT_TABLE(SymbolPartList, wxScrolledWindow)
|
||||
EVT_LEFT_DOWN (SymbolPartList::onLeftDown)
|
||||
EVT_LEFT_DCLICK (SymbolPartList::onLeftDClick)
|
||||
EVT_LEFT_UP (SymbolPartList::onLeftUp)
|
||||
EVT_MOTION (SymbolPartList::onMotion)
|
||||
EVT_CHAR (SymbolPartList::onChar)
|
||||
EVT_PAINT (SymbolPartList::onPaint)
|
||||
EVT_SIZE (SymbolPartList::onSize)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
@@ -11,61 +11,80 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <data/symbol.hpp>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Events
|
||||
|
||||
DECLARE_EVENT_TYPE(EVENT_PART_SELECT, <not used>)
|
||||
DECLARE_EVENT_TYPE(EVENT_PART_ACTIVATE, <not used>)
|
||||
|
||||
/// Handle EVENT_PART_SELECT events
|
||||
#define EVT_PART_SELECT( id, handler) EVT_COMMAND(id, EVENT_PART_SELECT, handler)
|
||||
/// Handle EVENT_PART_ACTIVATE events
|
||||
#define EVT_PART_ACTIVATE(id, handler) EVT_COMMAND(id, EVENT_PART_ACTIVATE, handler)
|
||||
|
||||
// ----------------------------------------------------------------------------- : SymbolPartList
|
||||
|
||||
// A list view of parts of a symbol
|
||||
class SymbolPartList : public wxListCtrl, public SymbolView {
|
||||
class SymbolPartList : public wxScrolledWindow, public SymbolView {
|
||||
public:
|
||||
SymbolPartList(Window* parent, int id, SymbolP symbol = SymbolP());
|
||||
|
||||
/// Update the list
|
||||
void update();
|
||||
|
||||
/// Is there a selection?
|
||||
inline bool hasSelection() const { return selected != -1; }
|
||||
/// Return the last part that was selected
|
||||
/** @pre hasSelection()
|
||||
*/
|
||||
inline SymbolPartP getSelection() const { return getPart(selected); }
|
||||
|
||||
/// Get a set of selected parts
|
||||
void getSelectedParts(set<SymbolPartP>& sel);
|
||||
/// Select the specified parts, and nothing else
|
||||
void selectParts(const set<SymbolPartP>& sel);
|
||||
SymbolPartList(Window* parent, int id, set<SymbolPartP>& selection, SymbolP symbol = SymbolP());
|
||||
|
||||
/// Another symbol is being viewed
|
||||
void onChangeSymbol();
|
||||
|
||||
virtual void onChangeSymbol();
|
||||
/// Event handler for changes to the symbol
|
||||
virtual void onAction(const Action& a, bool undone);
|
||||
virtual void onAction(const Action&, bool);
|
||||
|
||||
/// Update the control
|
||||
void update();
|
||||
/// Update only a subset of the parts
|
||||
void updateParts(const set<SymbolPartP>& parts);
|
||||
|
||||
protected:
|
||||
/// Get the text of an item
|
||||
virtual String OnGetItemText(long item, long col) const;
|
||||
/// Get the icon of an item
|
||||
virtual int OnGetItemImage(long item) const;
|
||||
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
private:
|
||||
/// The selected item, or -1 if there is no selection
|
||||
long selected;
|
||||
set<SymbolPartP>& selection; ///< Store selection here
|
||||
|
||||
/// Get a part from the symbol
|
||||
SymbolPartP getPart(long item) const;
|
||||
SymbolPartP mouse_down_on;
|
||||
int drop_position;
|
||||
int number_of_items;
|
||||
|
||||
/// Select an item, also in the list control
|
||||
/// Deselects all other items
|
||||
void selectItem(long item);
|
||||
SymbolPartP typing_in;
|
||||
size_t cursor;
|
||||
|
||||
wxImageList state_icons;
|
||||
struct Preview {
|
||||
Preview() : up_to_date(false), image(25,25) {}
|
||||
bool up_to_date;
|
||||
Image image;
|
||||
};
|
||||
Preview symbol_preview; ///< Preview of the whole symbol
|
||||
vector<Preview> part_previews;
|
||||
|
||||
static const int ITEM_HEIGHT = 25;
|
||||
// --------------------------------------------------- : Event handling
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
void onSelect (wxListEvent& ev);
|
||||
void onDeselect (wxListEvent& ev);
|
||||
void onLabelEdit(wxListEvent& ev);
|
||||
void onSize (wxSizeEvent& ev);
|
||||
void onDrag (wxMouseEvent& ev);
|
||||
void onLeftDown (wxMouseEvent& ev);
|
||||
void onLeftDClick(wxMouseEvent& ev);
|
||||
void onLeftUp (wxMouseEvent& ev);
|
||||
void onMotion (wxMouseEvent& ev);
|
||||
void onChar(wxKeyEvent& ev);
|
||||
void onPaint(wxPaintEvent&);
|
||||
void onSize(wxSizeEvent&);
|
||||
void OnDraw(DC& dc);
|
||||
|
||||
void sendEvent(int type);
|
||||
|
||||
void drawItem(DC& dc, int x, int& i, bool parent_active, const SymbolPartP& part);
|
||||
const Image& itemPreview(int i, const SymbolPartP& part);
|
||||
const Image& symbolPreview();
|
||||
void updatePart(const set<SymbolPartP>& parts, int& i, bool parent_updated, const SymbolPartP& part);
|
||||
|
||||
SymbolPartP findItem(int i) const;
|
||||
static SymbolPartP findItem(int& i, const SymbolPartP& part);
|
||||
|
||||
static int childCount(const SymbolPartP& part);
|
||||
|
||||
void updateCaret(DC& dc, int x, int y, int h, const SymbolPartP& part);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
|
||||
@@ -37,11 +37,7 @@ SymbolSelectEditor::SymbolSelectEditor(SymbolControl* control, bool rotate)
|
||||
handleShearY = wxBitmap(rotate_image(shear,90));
|
||||
handleCenter = wxBitmap(load_resource_image(_("handle_center")));
|
||||
// Make sure all parts have updated bounds
|
||||
FOR_EACH(p, getSymbol()->parts) {
|
||||
if (SymbolShape* s = p->isSymbolShape()) {
|
||||
s->calculateBounds();
|
||||
}
|
||||
}
|
||||
getSymbol()->calculateBounds();
|
||||
resetActions();
|
||||
}
|
||||
|
||||
@@ -132,24 +128,32 @@ void SymbolSelectEditor::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
|
||||
void SymbolSelectEditor::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
if (ev.GetId() >= ID_SYMBOL_COMBINE && ev.GetId() < ID_SYMBOL_COMBINE_MAX) {
|
||||
if (control.selected_parts.empty()) {
|
||||
ev.Check(false);
|
||||
ev.Enable(false);
|
||||
} else {
|
||||
ev.Enable(true);
|
||||
bool check = true;
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
if (SymbolShape* s = p->isSymbolShape()) {
|
||||
if (s->combine != ev.GetId() - ID_SYMBOL_COMBINE) {
|
||||
check = false;
|
||||
break;
|
||||
}
|
||||
} // disable when symmetries are selected?
|
||||
}
|
||||
ev.Check(check);
|
||||
bool enable = false;
|
||||
bool check = true;
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
if (SymbolShape* s = p->isSymbolShape()) {
|
||||
enable = true;
|
||||
if (s->combine != ev.GetId() - ID_SYMBOL_COMBINE) {
|
||||
check = false;
|
||||
break;
|
||||
}
|
||||
} // disable when symmetries are selected?
|
||||
}
|
||||
ev.Enable(enable);
|
||||
ev.Check(enable && check);
|
||||
} else if (ev.GetId() == ID_EDIT_DUPLICATE) {
|
||||
ev.Enable(!control.selected_parts.empty());
|
||||
} else if (ev.GetId() == ID_EDIT_GROUP) {
|
||||
ev.Enable(control.selected_parts.size() >= 2);
|
||||
} else if (ev.GetId() == ID_EDIT_UNGROUP) {
|
||||
// is a group selected
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
if (p->isSymbolGroup()) {
|
||||
ev.Enable(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ev.Enable(false);
|
||||
} else {
|
||||
ev.Enable(false); // we don't know about this item
|
||||
}
|
||||
@@ -165,10 +169,15 @@ void SymbolSelectEditor::onCommand(int id) {
|
||||
control.Refresh(false);
|
||||
} else if (id == ID_EDIT_DUPLICATE && !isEditing()) {
|
||||
// duplicate selection, not when dragging
|
||||
DuplicateSymbolPartsAction* action = new DuplicateSymbolPartsAction(
|
||||
*getSymbol(), control.selected_parts
|
||||
);
|
||||
getSymbol()->actions.add(action);
|
||||
getSymbol()->actions.add(new DuplicateSymbolPartsAction(*getSymbol(), control.selected_parts));
|
||||
control.Refresh(false);
|
||||
} else if (id == ID_EDIT_GROUP && !isEditing()) {
|
||||
// group selection, not when dragging
|
||||
getSymbol()->actions.add(new GroupSymbolPartsAction(*getSymbol(), control.selected_parts));
|
||||
control.Refresh(false);
|
||||
} else if (id == ID_EDIT_UNGROUP && !isEditing()) {
|
||||
// ungroup selection, not when dragging
|
||||
getSymbol()->actions.add(new UngroupSymbolPartsAction(*getSymbol(), control.selected_parts));
|
||||
control.Refresh(false);
|
||||
}
|
||||
}
|
||||
@@ -383,6 +392,7 @@ void SymbolSelectEditor::onChar(wxKeyEvent& ev) {
|
||||
if (ev.GetKeyCode() == WXK_DELETE) {
|
||||
// delete selected parts
|
||||
getSymbol()->actions.add(new RemoveSymbolPartsAction(*getSymbol(), control.selected_parts));
|
||||
if (control.selected_parts.find(highlightPart) != control.selected_parts.end()) highlightPart = SymbolPartP(); // deleted it
|
||||
control.selected_parts.clear();
|
||||
resetActions();
|
||||
control.Refresh(false);
|
||||
@@ -441,15 +451,25 @@ double SymbolSelectEditor::angleTo(const Vector2D& pos) {
|
||||
}
|
||||
|
||||
|
||||
SymbolPartP find_part(const SymbolPartP& part, const Vector2D& pos) {
|
||||
if (SymbolShape* s = part->isSymbolShape()) {
|
||||
if (point_in_shape(pos, *s)) return part;
|
||||
} else if (SymbolSymmetry* s = part->isSymbolSymmetry()) {
|
||||
// TODO
|
||||
} else if (SymbolGroup* g = part->isSymbolGroup()) {
|
||||
FOR_EACH(p, g->parts) {
|
||||
if (find_part(p,pos)) return part;
|
||||
}
|
||||
} else {
|
||||
throw InternalError(_("Invalid symbol part type"));
|
||||
}
|
||||
return SymbolPartP();
|
||||
}
|
||||
|
||||
SymbolPartP SymbolSelectEditor::findPart(const Vector2D& pos) {
|
||||
FOR_EACH(p, getSymbol()->parts) {
|
||||
if (SymbolShape* s = p->isSymbolShape()) {
|
||||
if (point_in_shape(pos, *s)) return p;
|
||||
} else if (SymbolSymmetry* s = p->isSymbolSymmetry()) {
|
||||
// TODO
|
||||
} else {
|
||||
throw InternalError(_("Invalid symbol part type"));
|
||||
}
|
||||
SymbolPartP found = find_part(p, pos);
|
||||
if (found) return found;
|
||||
}
|
||||
return SymbolPartP();
|
||||
}
|
||||
@@ -459,10 +479,8 @@ void SymbolSelectEditor::updateBoundingBox() {
|
||||
minV = Vector2D::infinity();
|
||||
maxV = -Vector2D::infinity();
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
if (SymbolShape* s = p->isSymbolShape()) {
|
||||
minV = piecewise_min(minV, s->min_pos);
|
||||
maxV = piecewise_max(maxV, s->max_pos);
|
||||
}
|
||||
minV = piecewise_min(minV, p->min_pos);
|
||||
maxV = piecewise_max(maxV, p->max_pos);
|
||||
}
|
||||
/* // Find rotation center
|
||||
center = Vector2D(0,0);
|
||||
|
||||
+13
-10
@@ -74,6 +74,9 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
menuEdit->Append(ID_EDIT_UNDO, _("undo"), _MENU_1_("undo",wxEmptyString), _HELP_("undo"));
|
||||
menuEdit->Append(ID_EDIT_REDO, _("redo"), _MENU_1_("redo",wxEmptyString), _HELP_("redo"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_GROUP, _("group"), _MENU_("group"), _HELP_("group"));
|
||||
menuEdit->Append(ID_EDIT_UNGROUP, _("ungroup"), _MENU_("ungroup"), _HELP_("ungroup"));
|
||||
menuEdit->AppendSeparator();
|
||||
menuEdit->Append(ID_EDIT_DUPLICATE, _("duplicate"), _MENU_("duplicate"), _HELP_("duplicate"));
|
||||
menuBar->Append(menuEdit, _MENU_("edit"));
|
||||
|
||||
@@ -82,6 +85,7 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
menuTool->Append(ID_MODE_ROTATE, _("mode_rotate"), _MENU_("rotate"), _HELP_("rotate"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_POINTS, _("mode_curve"), _MENU_("points"), _HELP_("points"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_SHAPES, _("circle"), _MENU_("basic shapes"), _HELP_("basic shapes"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_SYMMETRY, _("mode_symmetry"), _MENU_("symmetry"), _HELP_("symmetry"), wxITEM_CHECK);
|
||||
menuTool->Append(ID_MODE_PAINT, _("mode_paint"), _MENU_("paint"), _HELP_("paint"), wxITEM_CHECK);
|
||||
menuBar->Append(menuTool, _MENU_("tool"));
|
||||
|
||||
@@ -118,11 +122,11 @@ void SymbolWindow::init(Window* parent, SymbolP symbol) {
|
||||
|
||||
// Controls
|
||||
control = new SymbolControl (this, ID_CONTROL, symbol);
|
||||
parts = new SymbolPartList(this, ID_PART_LIST, symbol);
|
||||
parts = new SymbolPartList(this, ID_PART_LIST, control->selected_parts, symbol);
|
||||
|
||||
// Lay out
|
||||
wxSizer* es = new wxBoxSizer(wxHORIZONTAL);
|
||||
es->Add(em, 0, wxEXPAND | wxTOP | wxBOTTOM | wxALIGN_CENTER, 1);
|
||||
es->Add(em, 1, wxEXPAND | wxTOP | wxBOTTOM | wxALIGN_CENTER, 1);
|
||||
emp->SetSizer(es);
|
||||
|
||||
wxSizer* s = new wxBoxSizer(wxHORIZONTAL);
|
||||
@@ -246,21 +250,21 @@ void SymbolWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
}
|
||||
|
||||
|
||||
void SymbolWindow::onSelectFromList(wxListEvent& ev) {
|
||||
void SymbolWindow::onSelectFromList(wxCommandEvent& ev) {
|
||||
if (inSelectionEvent) return ;
|
||||
inSelectionEvent = true;
|
||||
parts->getSelectedParts(control->selected_parts);
|
||||
control->onUpdateSelection();
|
||||
inSelectionEvent = false;
|
||||
}
|
||||
void SymbolWindow::onActivateFromList(wxListEvent& ev) {
|
||||
control->activatePart(control->getSymbol()->parts.at(ev.GetIndex()));
|
||||
void SymbolWindow::onActivateFromList(wxCommandEvent& ev) {
|
||||
//% control->activatePart(control->getSymbol()->parts.at(ev.GetIndex()));
|
||||
// TODO
|
||||
}
|
||||
|
||||
void SymbolWindow::onSelectFromControl() {
|
||||
if (inSelectionEvent) return ;
|
||||
inSelectionEvent = true;
|
||||
parts->selectParts(control->selected_parts);
|
||||
parts->Refresh(false);
|
||||
inSelectionEvent = false;
|
||||
}
|
||||
|
||||
@@ -280,7 +284,6 @@ BEGIN_EVENT_TABLE(SymbolWindow, wxFrame)
|
||||
EVT_TOOL_RANGE (ID_CHILD_MIN, ID_CHILD_MAX, SymbolWindow::onExtraTool)
|
||||
EVT_UPDATE_UI (wxID_ANY, SymbolWindow::onUpdateUI)
|
||||
|
||||
EVT_LIST_ITEM_SELECTED (ID_PART_LIST, SymbolWindow::onSelectFromList)
|
||||
EVT_LIST_ITEM_DESELECTED (ID_PART_LIST, SymbolWindow::onSelectFromList)
|
||||
EVT_LIST_ITEM_ACTIVATED (ID_PART_LIST, SymbolWindow::onActivateFromList)
|
||||
EVT_PART_SELECT (ID_PART_LIST, SymbolWindow::onSelectFromList)
|
||||
EVT_PART_ACTIVATE (ID_PART_LIST, SymbolWindow::onActivateFromList)
|
||||
END_EVENT_TABLE ()
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
class SymbolControl;
|
||||
//%%class SymbolPartList;
|
||||
class SymbolPartList;
|
||||
DECLARE_POINTER_TYPE(SymbolValue);
|
||||
DECLARE_POINTER_TYPE(Set);
|
||||
@@ -62,9 +63,9 @@ class SymbolWindow : public Frame {
|
||||
void onUpdateUI(wxUpdateUIEvent&);
|
||||
|
||||
/// Changing selected parts in the list
|
||||
void onSelectFromList(wxListEvent& ev);
|
||||
void onSelectFromList(wxCommandEvent& ev);
|
||||
/// Activating a part: open the point editor
|
||||
void onActivateFromList(wxListEvent& ev);
|
||||
void onActivateFromList(wxCommandEvent& ev);
|
||||
|
||||
bool inSelectionEvent; ///< Prevent recursion in onSelect...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user