mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Switched to a new coding style, which plays nicely with the Reader/Writer. This new style allows REFLECT to be used instead of REFLECT_N in most places.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@15 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+40
-40
@@ -26,8 +26,8 @@ DECLARE_TYPEOF_COLLECTION(SetWindowPanel*);
|
||||
|
||||
SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
: wxFrame(parent, wxID_ANY, _("Magic Set Editor"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
||||
, currentPanel(nullptr)
|
||||
, findDialog(nullptr)
|
||||
, current_panel(nullptr)
|
||||
, find_dialog(nullptr)
|
||||
{
|
||||
SetIcon(wxIcon(_("ICON_APP")));
|
||||
|
||||
@@ -43,7 +43,7 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
menuExport->Append(ID_FILE_EXPORT_IMAGE, _("Card &Image..."), _("Export the selected card to an image file"));
|
||||
menuExport->Append(ID_FILE_EXPORT_IMAGES, _("All Card I&mages..."), _("Export images for all cards"));
|
||||
menuExport->Append(ID_FILE_EXPORT_APPR, _("&Apprentice..."), _("Export the set so it can be played with in Apprentice"));
|
||||
menuExport->Append(ID_FILE_EXPORT_MWS, _("Magic &Workstation..."), _("Export the set so it can be played with in Magic Workstation"));
|
||||
menuExport->Append(ID_FILE_EXPORT_MWS, _("Magic &Workstation..."), _("Export the set so it can be played with in Magic Workstation"));
|
||||
menuFile->Append(ID_FILE_EXPORT, _("&Export"), _("Export the set..."), menuExport);
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(ID_FILE_INSPECT, _("Inspect Internal Data..."), _("Shows a the data in the set using a tree structure"));
|
||||
@@ -126,8 +126,8 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
|
||||
// loose ends
|
||||
tabBar->Realize();
|
||||
SetSize(settings.setWindowWidth, settings.setWindowHeight);
|
||||
if (settings.setWindowMaximized) {
|
||||
SetSize(settings.set_window_width, settings.set_window_height);
|
||||
if (settings.set_window_maximized) {
|
||||
Maximize();
|
||||
}
|
||||
// SetWindows.push_back(&this); // register this window
|
||||
@@ -144,15 +144,15 @@ SetWindow::SetWindow(Window* parent, const SetP& set)
|
||||
SetWindow::~SetWindow() {
|
||||
// store window size in settings
|
||||
wxSize s = GetSize();
|
||||
settings.setWindowMaximized = IsMaximized();
|
||||
settings.set_window_maximized = IsMaximized();
|
||||
if (!IsMaximized()) {
|
||||
settings.setWindowWidth = s.GetWidth();
|
||||
settings.setWindowHeight = s.GetHeight();
|
||||
settings.set_window_width = s.GetWidth();
|
||||
settings.set_window_height = s.GetHeight();
|
||||
}
|
||||
// destroy ui of selected panel
|
||||
currentPanel->destroyUI(GetToolBar(), GetMenuBar());
|
||||
current_panel->destroyUI(GetToolBar(), GetMenuBar());
|
||||
// cleanup (see find stuff)
|
||||
delete findDialog;
|
||||
delete find_dialog;
|
||||
// remove from list of main windows
|
||||
// SetWindows.erase(remove(SetWindows.begin(), SetWindows.end(), &this));
|
||||
// stop updating
|
||||
@@ -177,11 +177,11 @@ void SetWindow::addPanel(wxMenu* windowMenu, wxToolBar* tabBar, SetWindowPanel*
|
||||
|
||||
void SetWindow::selectPanel(int id) {
|
||||
SetWindowPanel* toSelect = panels.at(id - ID_WINDOW_MIN);
|
||||
if (currentPanel != toSelect) {
|
||||
if (current_panel != toSelect) {
|
||||
// destroy & create menus
|
||||
if (currentPanel) currentPanel->destroyUI(GetToolBar(), GetMenuBar());
|
||||
currentPanel = toSelect;
|
||||
currentPanel->initUI(GetToolBar(), GetMenuBar());
|
||||
if (current_panel) current_panel->destroyUI(GetToolBar(), GetMenuBar());
|
||||
current_panel = toSelect;
|
||||
current_panel->initUI(GetToolBar(), GetMenuBar());
|
||||
}
|
||||
// show/hide panels and select tabs
|
||||
wxSizer* sizer = GetSizer();
|
||||
@@ -189,9 +189,9 @@ void SetWindow::selectPanel(int id) {
|
||||
wxMenuBar* menuBar = GetMenuBar();
|
||||
int wid = ID_WINDOW_MIN;
|
||||
FOR_EACH(p, panels) {
|
||||
sizer->Show (p, p == currentPanel);
|
||||
tabBar->ToggleTool(wid, p == currentPanel);
|
||||
menuBar->Check (wid, p == currentPanel);
|
||||
sizer->Show (p, p == current_panel);
|
||||
tabBar->ToggleTool(wid, p == current_panel);
|
||||
menuBar->Check (wid, p == current_panel);
|
||||
++wid;
|
||||
}
|
||||
// fix sizer stuff
|
||||
@@ -322,7 +322,7 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
switch (ev.GetId()) {
|
||||
// file menu
|
||||
case ID_FILE_SAVE_AS: ev.Enable(!set->actions.atSavePoint() || set->needSaveAs()); break;
|
||||
case ID_FILE_EXPORT_IMAGE: ev.Enable(!!currentPanel->selectedCard()); break;
|
||||
case ID_FILE_EXPORT_IMAGE: ev.Enable(!!current_panel->selectedCard()); break;
|
||||
case ID_FILE_EXPORT_APPR: ev.Enable(set->game->isMagic()); break;
|
||||
case ID_FILE_EXPORT_MWS: ev.Enable(set->game->isMagic()); break;
|
||||
/*case ID_FILE_INSPECT: {
|
||||
@@ -346,15 +346,15 @@ void SetWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
break;
|
||||
}
|
||||
// copy & paste & find
|
||||
case ID_EDIT_CUT : ev.Enable(currentPanel->canCut()); break;
|
||||
case ID_EDIT_COPY : ev.Enable(currentPanel->canCopy()); break;
|
||||
case ID_EDIT_PASTE : ev.Enable(currentPanel->canPaste()); break;
|
||||
case ID_EDIT_FIND : ev.Enable(currentPanel->canFind()); break;
|
||||
case ID_EDIT_FIND_NEXT : ev.Enable(currentPanel->canFind()); break;
|
||||
case ID_EDIT_REPLACE : ev.Enable(currentPanel->canReplace()); break;
|
||||
case ID_EDIT_CUT : ev.Enable(current_panel->canCut()); break;
|
||||
case ID_EDIT_COPY : ev.Enable(current_panel->canCopy()); break;
|
||||
case ID_EDIT_PASTE : ev.Enable(current_panel->canPaste()); break;
|
||||
case ID_EDIT_FIND : ev.Enable(current_panel->canFind()); break;
|
||||
case ID_EDIT_FIND_NEXT : ev.Enable(current_panel->canFind()); break;
|
||||
case ID_EDIT_REPLACE : ev.Enable(current_panel->canReplace()); break;
|
||||
default:
|
||||
// items created by the panel, and cut/copy/paste and find/replace
|
||||
currentPanel->onUpdateUI(ev);
|
||||
current_panel->onUpdateUI(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ void SetWindow::onFileInspect(wxCommandEvent&) {
|
||||
}*/
|
||||
|
||||
void SetWindow::onFileExportImage(wxCommandEvent&) {
|
||||
CardP card = currentPanel->selectedCard();
|
||||
CardP card = current_panel->selectedCard();
|
||||
if (!card) return; // no card selected
|
||||
String name = wxFileSelector(_("Save image"), _(""), card->identification(), _(""),
|
||||
_("JPEG images (*.jpg)|*.jpg|Windows bitmaps (*.bmp)|*.bmp|PNG images (*.png)|*.png|GIF images (*.gif)|*.gif|TIFF images (*.tif)|*.tif"),
|
||||
@@ -465,38 +465,38 @@ void SetWindow::onEditRedo(wxCommandEvent&) {
|
||||
}
|
||||
|
||||
void SetWindow::onEditCut (wxCommandEvent&) {
|
||||
currentPanel->doCut();
|
||||
current_panel->doCut();
|
||||
}
|
||||
void SetWindow::onEditCopy (wxCommandEvent&) {
|
||||
currentPanel->doCopy();
|
||||
current_panel->doCopy();
|
||||
}
|
||||
void SetWindow::onEditPaste(wxCommandEvent&) {
|
||||
currentPanel->doPaste();
|
||||
current_panel->doPaste();
|
||||
}
|
||||
|
||||
void SetWindow::onEditFind(wxCommandEvent&) {
|
||||
delete findDialog;
|
||||
findDialog = new wxFindReplaceDialog(this, &findData, _("Find"));
|
||||
findDialog->Show();
|
||||
delete find_dialog;
|
||||
find_dialog = new wxFindReplaceDialog(this, &find_data, _("Find"));
|
||||
find_dialog->Show();
|
||||
}
|
||||
void SetWindow::onEditFindNext(wxCommandEvent&) {
|
||||
currentPanel->doFind(findData);
|
||||
current_panel->doFind(find_data);
|
||||
}
|
||||
void SetWindow::onEditReplace(wxCommandEvent&) {
|
||||
delete findDialog;
|
||||
findDialog = new wxFindReplaceDialog(this, &findData, _("Replace"), wxFR_REPLACEDIALOG);
|
||||
findDialog->Show();
|
||||
delete find_dialog;
|
||||
find_dialog = new wxFindReplaceDialog(this, &find_data, _("Replace"), wxFR_REPLACEDIALOG);
|
||||
find_dialog->Show();
|
||||
}
|
||||
|
||||
// find events
|
||||
void SetWindow::onFind (wxFindDialogEvent&) {
|
||||
currentPanel->doFind(findData);
|
||||
current_panel->doFind(find_data);
|
||||
}
|
||||
void SetWindow::onFindNext (wxFindDialogEvent&) {
|
||||
currentPanel->doFind(findData);
|
||||
current_panel->doFind(find_data);
|
||||
}
|
||||
void SetWindow::onReplace (wxFindDialogEvent&) {
|
||||
currentPanel->doReplace(findData);
|
||||
current_panel->doReplace(find_data);
|
||||
}
|
||||
void SetWindow::onReplaceAll(wxFindDialogEvent&) {
|
||||
// todo
|
||||
@@ -541,7 +541,7 @@ void SetWindow::onHelpAbout(wxCommandEvent&) {
|
||||
// ----------------------------------------------------------------------------- : Window events - menu - for child panel
|
||||
|
||||
void SetWindow::onChildMenu(wxCommandEvent& ev) {
|
||||
currentPanel->onCommand(ev.GetId());
|
||||
current_panel->onCommand(ev.GetId());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Event table
|
||||
|
||||
@@ -41,14 +41,14 @@ class SetWindow : public wxFrame, public SetView {
|
||||
|
||||
// gui items
|
||||
vector<SetWindowPanel*> panels; ///< All panels on this window
|
||||
SetWindowPanel* currentPanel;
|
||||
SetWindowPanel* current_panel;
|
||||
|
||||
/// Number of items in the recent sets list
|
||||
size_t numberOfRecentSets;
|
||||
size_t number_of_recentSets;
|
||||
|
||||
// data for find/replace
|
||||
wxDialog* findDialog;
|
||||
wxFindReplaceData findData;
|
||||
wxDialog* find_dialog;
|
||||
wxFindReplaceData find_data;
|
||||
|
||||
// --------------------------------------------------- : Panel managment
|
||||
|
||||
|
||||
+29
-29
@@ -35,7 +35,7 @@ void SymbolControl::switchEditor(const SymbolEditorBaseP& e) {
|
||||
}
|
||||
|
||||
void SymbolControl::onChangeSymbol() {
|
||||
selectedParts.clear();
|
||||
selected_parts.clear();
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, false));
|
||||
Refresh(false);
|
||||
}
|
||||
@@ -49,14 +49,14 @@ void SymbolControl::onModeChange(wxCommandEvent& ev) {
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, true));
|
||||
break;
|
||||
case ID_MODE_POINTS:
|
||||
if (selectedParts.size() == 1) {
|
||||
singleSelection = *selectedParts.begin();
|
||||
switchEditor(new_shared2<SymbolPointEditor>(this, singleSelection));
|
||||
if (selected_parts.size() == 1) {
|
||||
single_selection = *selected_parts.begin();
|
||||
switchEditor(new_shared2<SymbolPointEditor>(this, single_selection));
|
||||
}
|
||||
break;
|
||||
case ID_MODE_SHAPES:
|
||||
if (!selectedParts.empty()) {
|
||||
selectedParts.clear();
|
||||
if (!selected_parts.empty()) {
|
||||
selected_parts.clear();
|
||||
signalSelectionChange();
|
||||
}
|
||||
switchEditor(new_shared1<SymbolBasicShapeEditor>(this));
|
||||
@@ -78,26 +78,26 @@ void SymbolControl::onUpdateSelection() {
|
||||
switch(editor->modeToolId()) {
|
||||
case ID_MODE_POINTS:
|
||||
// can only select a single part!
|
||||
if (selectedParts.size() > 1) {
|
||||
SymbolPartP part = *selectedParts.begin();
|
||||
selectedParts.clear();
|
||||
selectedParts.insert(part);
|
||||
if (selected_parts.size() > 1) {
|
||||
SymbolPartP part = *selected_parts.begin();
|
||||
selected_parts.clear();
|
||||
selected_parts.insert(part);
|
||||
signalSelectionChange();
|
||||
} else if (selectedParts.empty()) {
|
||||
selectedParts.insert(singleSelection);
|
||||
} else if (selected_parts.empty()) {
|
||||
selected_parts.insert(single_selection);
|
||||
signalSelectionChange();
|
||||
}
|
||||
if (singleSelection != *selectedParts.begin()) {
|
||||
if (single_selection != *selected_parts.begin()) {
|
||||
// begin editing another part
|
||||
singleSelection = *selectedParts.begin();
|
||||
editor = new_shared2<SymbolPointEditor>(this, singleSelection);
|
||||
single_selection = *selected_parts.begin();
|
||||
editor = new_shared2<SymbolPointEditor>(this, single_selection);
|
||||
Refresh(false);
|
||||
}
|
||||
break;
|
||||
case ID_MODE_SHAPES:
|
||||
if (!selectedParts.empty()) {
|
||||
if (!selected_parts.empty()) {
|
||||
// there can't be a selection
|
||||
selectedParts.clear();
|
||||
selected_parts.clear();
|
||||
signalSelectionChange();
|
||||
}
|
||||
break;
|
||||
@@ -108,15 +108,15 @@ void SymbolControl::onUpdateSelection() {
|
||||
}
|
||||
|
||||
void SymbolControl::selectPart(const SymbolPartP& part) {
|
||||
selectedParts.clear();
|
||||
selectedParts.insert(part);
|
||||
selected_parts.clear();
|
||||
selected_parts.insert(part);
|
||||
switchEditor(new_shared2<SymbolSelectEditor>(this, false));
|
||||
signalSelectionChange();
|
||||
}
|
||||
|
||||
void SymbolControl::activatePart(const SymbolPartP& part) {
|
||||
selectedParts.clear();
|
||||
selectedParts.insert(part);
|
||||
selected_parts.clear();
|
||||
selected_parts.insert(part);
|
||||
switchEditor(new_shared2<SymbolPointEditor>(this, part));
|
||||
}
|
||||
|
||||
@@ -154,34 +154,34 @@ void SymbolControl::onPaint(wxPaintEvent& e) {
|
||||
void SymbolControl::onLeftDown(wxMouseEvent& ev) {
|
||||
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
if (editor) editor->onLeftDown(pos, ev);
|
||||
lastPos = pos;
|
||||
last_pos = pos;
|
||||
ev.Skip(); // for focus
|
||||
}
|
||||
void SymbolControl::onLeftUp(wxMouseEvent& ev) {
|
||||
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
if (editor) editor->onLeftUp(pos, ev);
|
||||
lastPos = pos;
|
||||
last_pos = pos;
|
||||
}
|
||||
void SymbolControl::onLeftDClick(wxMouseEvent& ev) {
|
||||
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
if (editor) editor->onLeftDClick(pos, ev);
|
||||
lastPos = pos;
|
||||
last_pos = pos;
|
||||
}
|
||||
void SymbolControl::onRightDown(wxMouseEvent& ev) {
|
||||
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
if (editor) editor->onRightDown(pos, ev);
|
||||
lastPos = pos;
|
||||
last_pos = pos;
|
||||
}
|
||||
|
||||
void SymbolControl::onMotion(wxMouseEvent& ev) {
|
||||
Vector2D pos = rotation.trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
// Dragging something?
|
||||
if (ev.LeftIsDown()) {
|
||||
if (editor) editor->onMouseDrag(lastPos, pos, ev);
|
||||
if (editor) editor->onMouseDrag(last_pos, pos, ev);
|
||||
} else {
|
||||
if (editor) editor->onMouseMove(lastPos, pos, ev);
|
||||
if (editor) editor->onMouseMove(last_pos, pos, ev);
|
||||
}
|
||||
lastPos = pos;
|
||||
last_pos = pos;
|
||||
}
|
||||
|
||||
// Key events, just forward
|
||||
@@ -207,7 +207,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(selectedParts.size() == 1);
|
||||
ev.Enable(selected_parts.size() == 1);
|
||||
}
|
||||
break;
|
||||
case ID_MODE_PAINT:
|
||||
|
||||
@@ -71,8 +71,8 @@ class SymbolControl : public wxControl, public SymbolViewer {
|
||||
|
||||
public:
|
||||
/// What parts are selected
|
||||
set<SymbolPartP> selectedParts;
|
||||
SymbolPartP singleSelection;
|
||||
set<SymbolPartP> selected_parts;
|
||||
SymbolPartP single_selection;
|
||||
|
||||
/// Parent window
|
||||
SymbolWindow* parent;
|
||||
@@ -82,7 +82,7 @@ class SymbolControl : public wxControl, public SymbolViewer {
|
||||
SymbolEditorBaseP editor;
|
||||
|
||||
/// Last mouse position
|
||||
Vector2D lastPos;
|
||||
Vector2D last_pos;
|
||||
|
||||
// --------------------------------------------------- : Events
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ SymbolPartList::SymbolPartList(Window* parent, int id, SymbolP symbol)
|
||||
// Create image list
|
||||
wxImageList* images = new wxImageList(16,16);
|
||||
// NOTE: this is based on the order of the SymbolPartCombine enum!
|
||||
images->Add(loadResourceImage(_("COMBINE_OR")));
|
||||
images->Add(loadResourceImage(_("COMBINE_SUB")));
|
||||
images->Add(loadResourceImage(_("COMBINE_AND")));
|
||||
images->Add(loadResourceImage(_("COMBINE_XOR")));
|
||||
images->Add(loadResourceImage(_("COMBINE_OVER")));
|
||||
images->Add(loadResourceImage(_("COMBINE_BORDER")));
|
||||
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")));
|
||||
AssignImageList(images, wxIMAGE_LIST_SMALL);
|
||||
// create columns
|
||||
InsertColumn(0, _("Name"));
|
||||
@@ -74,7 +74,7 @@ void SymbolPartList::selectItem(long item) {
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPartList::getSelectedParts(set<SymbolPartP>& sel) {
|
||||
void SymbolPartList::getselected_parts(set<SymbolPartP>& sel) {
|
||||
sel.clear();
|
||||
long count = GetItemCount();
|
||||
for (long i = 0 ; i < count ; ++ i) {
|
||||
|
||||
@@ -31,7 +31,7 @@ class SymbolPartList : public wxListCtrl, public SymbolView {
|
||||
inline SymbolPartP getSelection() const { return getPart(selected); }
|
||||
|
||||
/// Get a set of selected parts
|
||||
void getSelectedParts(set<SymbolPartP>& sel);
|
||||
void getselected_parts(set<SymbolPartP>& sel);
|
||||
/// Select the specified parts, and nothing else
|
||||
void selectParts(const set<SymbolPartP>& sel);
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ void SymbolPointEditor::draw(DC& dc) {
|
||||
}
|
||||
|
||||
void SymbolPointEditor::drawHoveredLine(DC& dc) {
|
||||
BezierCurve c(*hoverLine1, *hoverLine2);
|
||||
wxPoint prevPoint = control.rotation.tr(hoverLine1->pos);
|
||||
BezierCurve c(*hover_line_1, *hover_line_2);
|
||||
wxPoint prevPoint = control.rotation.tr(hover_line_1->pos);
|
||||
for(int i = 1 ; i <= 100 ; ++i) {
|
||||
// Draw 100 segments of the curve
|
||||
double t = double(i)/100.0f;
|
||||
wxPoint curPoint = control.rotation.tr(c.pointAt(t));
|
||||
double selectPercent = 1.0 - 1.2 * sqrt(fabs(hoverLineT-t)); // amount to color
|
||||
double selectPercent = 1.0 - 1.2 * sqrt(fabs(hover_line_t-t)); // amount to color
|
||||
if (selectPercent > 0) {
|
||||
// gradient color
|
||||
Color color(
|
||||
@@ -87,7 +87,7 @@ void SymbolPointEditor::drawHandles(DC& dc) {
|
||||
void SymbolPointEditor::drawNewPoint(DC& dc) {
|
||||
dc.SetPen(*wxGREEN_PEN);
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
wxPoint p = control.rotation.tr(newPoint);
|
||||
wxPoint p = control.rotation.tr(new_point);
|
||||
drawHandleBox(dc, p.x, p.y, true);
|
||||
}
|
||||
|
||||
@@ -98,16 +98,16 @@ void SymbolPointEditor::drawControlPoint(DC& dc, const ControlPoint& p, bool dra
|
||||
if (drawHandleBefore || drawHandleAfter) {
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
// Before handle
|
||||
if (drawHandleBefore && p.segmentBefore == SEGMENT_CURVE) {
|
||||
wxPoint p1 = control.rotation.tr(p.pos + p.deltaBefore);
|
||||
if (drawHandleBefore && p.segment_before == SEGMENT_CURVE) {
|
||||
wxPoint p1 = control.rotation.tr(p.pos + p.delta_before);
|
||||
dc.SetPen(handlePen(PEN_LINE, p.lock));
|
||||
dc.DrawLine(p0.x, p0.y, p1.x, p1.y);
|
||||
dc.SetPen(handlePen(handleHovered(p, HANDLE_BEFORE) ? PEN_HOVER : PEN_NORMAL, p.lock));
|
||||
drawHandleCircle(dc, p1.x, p1.y);
|
||||
}
|
||||
// After handle
|
||||
if (drawHandleAfter && p.segmentAfter == SEGMENT_CURVE) {
|
||||
wxPoint p1 = control.rotation.tr(p.pos + p.deltaAfter);
|
||||
if (drawHandleAfter && p.segment_after == SEGMENT_CURVE) {
|
||||
wxPoint p1 = control.rotation.tr(p.pos + p.delta_after);
|
||||
dc.SetPen(handlePen(PEN_LINE, p.lock));
|
||||
dc.DrawLine(p0.x, p0.y, p1.x, p1.y);
|
||||
dc.SetPen(handlePen(handleHovered(p, HANDLE_AFTER) ? PEN_HOVER : PEN_NORMAL, p.lock));
|
||||
@@ -186,9 +186,9 @@ void SymbolPointEditor::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
break;
|
||||
case ID_LOCK_FREE: case ID_LOCK_DIR: case ID_LOCK_SIZE:
|
||||
enabled = selection == SELECTED_POINTS &&
|
||||
selectedPoints.size() == 1 &&
|
||||
(*selectedPoints.begin())->segmentBefore == SEGMENT_CURVE &&
|
||||
(*selectedPoints.begin())->segmentAfter == SEGMENT_CURVE;
|
||||
selected_points.size() == 1 &&
|
||||
(*selected_points.begin())->segment_before == SEGMENT_CURVE &&
|
||||
(*selected_points.begin())->segment_after == SEGMENT_CURVE;
|
||||
break;
|
||||
default:
|
||||
ev.Enable(false); // we don't know this item
|
||||
@@ -198,10 +198,10 @@ void SymbolPointEditor::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
if (enabled) {
|
||||
switch (ev.GetId()) {
|
||||
case ID_SEGMENT_LINE: case ID_SEGMENT_CURVE:
|
||||
checked = selectedLine1->segmentAfter == ev.GetId() - ID_SEGMENT;
|
||||
checked = selected_line1->segment_after == ev.GetId() - ID_SEGMENT;
|
||||
break;
|
||||
case ID_LOCK_FREE: case ID_LOCK_DIR: case ID_LOCK_SIZE:
|
||||
checked = (*selectedPoints.begin())->lock == ev.GetId() - ID_LOCK;
|
||||
checked = (*selected_points.begin())->lock == ev.GetId() - ID_LOCK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -248,17 +248,17 @@ void SymbolPointEditor::onLeftDClick(const Vector2D& pos, wxMouseEvent& ev) {
|
||||
findHoveredItem(pos, false);
|
||||
if (hovering == SELECTED_NEW_POINT) {
|
||||
// Add point
|
||||
ControlPointAddAction* act = new ControlPointAddAction(part, hoverLine1Idx, hoverLineT);
|
||||
ControlPointAddAction* act = new ControlPointAddAction(part, hover_line_1_idx, hover_line_t);
|
||||
getSymbol()->actions.add(act);
|
||||
// select the new point
|
||||
selectPoint(act->getNewPoint(), false);
|
||||
selection = SELECTED_POINTS;
|
||||
} else if (hovering == SELECTED_HANDLE && hoverHandle.handle == HANDLE_MAIN) { //%%%%%%% ||/&&
|
||||
} else if (hovering == SELECTED_HANDLE && hover_handle.handle == HANDLE_MAIN) { //%%%%%%% ||/&&
|
||||
// Delete point
|
||||
selectedPoints.clear();
|
||||
selectPoint(hoverHandle.point, false);
|
||||
getSymbol()->actions.add(controlPointRemoveAction(part, selectedPoints));
|
||||
selectedPoints.clear();
|
||||
selected_points.clear();
|
||||
selectPoint(hover_handle.point, false);
|
||||
getSymbol()->actions.add(controlPointRemoveAction(part, selected_points));
|
||||
selected_points.clear();
|
||||
selection = SELECTED_NONE;
|
||||
}
|
||||
// refresh
|
||||
@@ -278,27 +278,27 @@ void SymbolPointEditor::onMouseDrag(const Vector2D& from, const Vector2D& to, wx
|
||||
// Drag the curve
|
||||
if (controlPointMoveAction) controlPointMoveAction = 0;
|
||||
if (!curveDragAction) {
|
||||
curveDragAction = new CurveDragAction(selectedLine1, selectedLine2);
|
||||
curveDragAction = new CurveDragAction(selected_line1, selected_line2);
|
||||
getSymbol()->actions.add(curveDragAction);
|
||||
}
|
||||
curveDragAction->move(delta, selectedLineT);
|
||||
curveDragAction->move(delta, selected_line_t);
|
||||
control.Refresh(false);
|
||||
} else if (selection == SELECTED_POINTS || selection == SELECTED_LINE) {
|
||||
// Move all selected points
|
||||
if (curveDragAction) curveDragAction = 0;
|
||||
if (!controlPointMoveAction) {
|
||||
// create action we can add this movement to
|
||||
controlPointMoveAction = new ControlPointMoveAction(selectedPoints);
|
||||
controlPointMoveAction = new ControlPointMoveAction(selected_points);
|
||||
getSymbol()->actions.add(controlPointMoveAction);
|
||||
}
|
||||
controlPointMoveAction->constrain = ev.ControlDown(); // ctrl constrains
|
||||
controlPointMoveAction->move(delta);
|
||||
newPoint += delta;
|
||||
new_point += delta;
|
||||
control.Refresh(false);
|
||||
} else if (selection == SELECTED_HANDLE) {
|
||||
// Move the selected handle
|
||||
if (!handleMoveAction) {
|
||||
handleMoveAction = new HandleMoveAction(selectedHandle);
|
||||
handleMoveAction = new HandleMoveAction(selected_handle);
|
||||
getSymbol()->actions.add(handleMoveAction);
|
||||
}
|
||||
handleMoveAction->constrain = ev.ControlDown(); // ctrl constrains
|
||||
@@ -352,21 +352,21 @@ bool SymbolPointEditor::isEditing() {
|
||||
|
||||
void SymbolPointEditor::selectNothing() {
|
||||
selection = SELECTED_NONE;
|
||||
selectedPoints.clear();
|
||||
selected_points.clear();
|
||||
}
|
||||
|
||||
void SymbolPointEditor::selectPoint(const ControlPointP& point, bool toggle) {
|
||||
set<ControlPointP>::iterator inSet = selectedPoints.find(point);
|
||||
set<ControlPointP>::iterator inSet = selected_points.find(point);
|
||||
if (toggle) {
|
||||
if (inSet == selectedPoints.end()) {
|
||||
selectedPoints.insert(point);
|
||||
if (inSet == selected_points.end()) {
|
||||
selected_points.insert(point);
|
||||
} else {
|
||||
selectedPoints.erase(inSet);
|
||||
selected_points.erase(inSet);
|
||||
}
|
||||
} else {
|
||||
if (inSet == selectedPoints.end()) {
|
||||
selectedPoints.clear();
|
||||
selectedPoints.insert(point);
|
||||
if (inSet == selected_points.end()) {
|
||||
selected_points.clear();
|
||||
selected_points.insert(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -377,26 +377,26 @@ void SymbolPointEditor::selectHandle(const SelectedHandle& h, const wxMouseEvent
|
||||
selectPoint(h.point, keystate.ShiftDown());
|
||||
} else {
|
||||
selection = SELECTED_HANDLE;
|
||||
selectedHandle = h;
|
||||
selected_handle = h;
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPointEditor::selectLine(const wxMouseEvent& keystate) {
|
||||
selection = SELECTED_LINE;
|
||||
selectedLine1 = hoverLine1;
|
||||
selectedLine2 = hoverLine2;
|
||||
selectedLineT = hoverLineT;
|
||||
if (!keystate.ShiftDown()) selectedPoints.clear();
|
||||
selectPoint(selectedLine1, true);
|
||||
selectPoint(selectedLine2, true);
|
||||
selected_line1 = hover_line_1;
|
||||
selected_line2 = hover_line_2;
|
||||
selected_line_t = hover_line_t;
|
||||
if (!keystate.ShiftDown()) selected_points.clear();
|
||||
selectPoint(selected_line1, true);
|
||||
selectPoint(selected_line2, true);
|
||||
}
|
||||
|
||||
|
||||
bool SymbolPointEditor::pointSelected(const ControlPointP& pnt) {
|
||||
return selectedPoints.find(pnt) != selectedPoints.end();
|
||||
return selected_points.find(pnt) != selected_points.end();
|
||||
}
|
||||
bool SymbolPointEditor::pointSelected(const ControlPoint& pnt) {
|
||||
FOR_EACH(s, selectedPoints) {
|
||||
FOR_EACH(s, selected_points) {
|
||||
if (s.get() == &pnt) return true;
|
||||
}
|
||||
return false;
|
||||
@@ -410,10 +410,10 @@ bool SymbolPointEditor::pointHovered(const ControlPoint& pnt) {
|
||||
}
|
||||
|
||||
bool SymbolPointEditor::handleHovered(const ControlPointP& pnt, WhichHandle wh) {
|
||||
return hovering == SELECTED_HANDLE && hoverHandle.point == pnt && hoverHandle.handle == wh;
|
||||
return hovering == SELECTED_HANDLE && hover_handle.point == pnt && hover_handle.handle == wh;
|
||||
}
|
||||
bool SymbolPointEditor::handleHovered(const ControlPoint& pnt, WhichHandle wh) {
|
||||
return hovering == SELECTED_HANDLE && hoverHandle.point && hoverHandle.point.get() == &pnt && hoverHandle.handle == wh;
|
||||
return hovering == SELECTED_HANDLE && hover_handle.point && hover_handle.point.get() == &pnt && hover_handle.handle == wh;
|
||||
}
|
||||
|
||||
|
||||
@@ -426,24 +426,24 @@ void SymbolPointEditor::resetActions() {
|
||||
}
|
||||
|
||||
void SymbolPointEditor::deleteSelection() {
|
||||
if (!selectedPoints.empty()) {
|
||||
getSymbol()->actions.add(controlPointRemoveAction(part, selectedPoints));
|
||||
selectedPoints.clear();
|
||||
if (!selected_points.empty()) {
|
||||
getSymbol()->actions.add(controlPointRemoveAction(part, selected_points));
|
||||
selected_points.clear();
|
||||
resetActions();
|
||||
control.Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SymbolPointEditor::onChangeSegment(SegmentMode mode) {
|
||||
assert(selectedLine1);
|
||||
assert(selectedLine2);
|
||||
if (selectedLine1->segmentAfter == mode) return;
|
||||
getSymbol()->actions.add(new SegmentModeAction(selectedLine1, selectedLine2, mode));
|
||||
assert(selected_line1);
|
||||
assert(selected_line2);
|
||||
if (selected_line1->segment_after == mode) return;
|
||||
getSymbol()->actions.add(new SegmentModeAction(selected_line1, selected_line2, mode));
|
||||
control.Refresh(false);
|
||||
}
|
||||
|
||||
void SymbolPointEditor::onChangeLock(LockMode mode) {
|
||||
getSymbol()->actions.add(new LockModeAction(*selectedPoints.begin(), mode));
|
||||
getSymbol()->actions.add(new LockModeAction(*selected_points.begin(), mode));
|
||||
control.Refresh(false);
|
||||
}
|
||||
|
||||
@@ -452,9 +452,9 @@ void SymbolPointEditor::onChangeLock(LockMode mode) {
|
||||
|
||||
void SymbolPointEditor::findHoveredItem(const Vector2D& pos, bool altDown) {
|
||||
// is there a point currently under the cursor?
|
||||
hoverHandle = findHandle(pos);
|
||||
hover_handle = findHandle(pos);
|
||||
// change cursor and statusbar if point is under it
|
||||
if (hoverHandle.handle) {
|
||||
if (hover_handle.handle) {
|
||||
hovering = SELECTED_HANDLE;
|
||||
control.SetCursor(pointMove);
|
||||
SetStatusText(_("Click and drag to move control point"));
|
||||
@@ -483,11 +483,11 @@ bool SymbolPointEditor::checkPosOnCurve(const Vector2D& pos) {
|
||||
size_t size = part->points.size();
|
||||
for(int i = 0 ; (size_t)i < size ; ++i) {
|
||||
// Curve between these lines
|
||||
hoverLine1 = part->getPoint(i);
|
||||
hoverLine2 = part->getPoint(i + 1);
|
||||
if (posOnSegment(pos, range, *hoverLine1, *hoverLine2, newPoint, hoverLineT)) {
|
||||
hover_line_1 = part->getPoint(i);
|
||||
hover_line_2 = part->getPoint(i + 1);
|
||||
if (pos_on_segment(pos, range, *hover_line_1, *hover_line_2, new_point, hover_line_t)) {
|
||||
// mouse is on this line
|
||||
hoverLine1Idx = i;
|
||||
hover_line_1_idx = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -510,13 +510,13 @@ SelectedHandle SymbolPointEditor::findHandle(const Vector2D& pos) {
|
||||
bool sel = pointSelected(p);
|
||||
bool before = sel || pointSelected(part->getPoint(i-1)); // are the handles visible?
|
||||
bool after = sel || pointSelected(part->getPoint(i+1));
|
||||
if (before && p->segmentBefore == SEGMENT_CURVE) {
|
||||
if (inRange(p->pos + p->deltaBefore, pos, range)) {
|
||||
if (before && p->segment_before == SEGMENT_CURVE) {
|
||||
if (inRange(p->pos + p->delta_before, pos, range)) {
|
||||
return SelectedHandle(p, HANDLE_BEFORE);
|
||||
}
|
||||
}
|
||||
if (after && p->segmentAfter == SEGMENT_CURVE) {
|
||||
if (inRange(p->pos + p->deltaAfter, pos, range)) {
|
||||
if (after && p->segment_after == SEGMENT_CURVE) {
|
||||
if (inRange(p->pos + p->delta_after, pos, range)) {
|
||||
return SelectedHandle(p, HANDLE_AFTER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,23 +99,23 @@ class SymbolPointEditor : public SymbolEditorBase {
|
||||
};
|
||||
Selection selection;
|
||||
// points
|
||||
set<ControlPointP> selectedPoints;
|
||||
set<ControlPointP> selected_points;
|
||||
// handle
|
||||
SelectedHandle selectedHandle;
|
||||
SelectedHandle selected_handle;
|
||||
// line
|
||||
ControlPointP selectedLine1, selectedLine2; // selected the line between these points
|
||||
double selectedLineT; // time on the line of the selection
|
||||
ControlPointP selected_line1, selected_line2; // selected the line between these points
|
||||
double selected_line_t; // time on the line of the selection
|
||||
|
||||
// Mouse feedback
|
||||
Selection hovering;
|
||||
// handle
|
||||
SelectedHandle hoverHandle; // the handle currently under the cursor
|
||||
SelectedHandle hover_handle; // the handle currently under the cursor
|
||||
// new point
|
||||
Vector2D newPoint;
|
||||
Vector2D new_point;
|
||||
// line
|
||||
ControlPointP hoverLine1, hoverLine2; // hovering on the line between these points
|
||||
double hoverLineT;
|
||||
int hoverLine1Idx; // index of hoverLine1 in the list of points
|
||||
ControlPointP hover_line_1, hover_line_2; // hovering on the line between these points
|
||||
double hover_line_t;
|
||||
int hover_line_1_idx; // index of hover_line_1 in the list of points
|
||||
|
||||
// Gui stock
|
||||
wxBitmap background;
|
||||
|
||||
@@ -25,15 +25,15 @@ SymbolSelectEditor::SymbolSelectEditor(SymbolControl* control, bool rotate)
|
||||
, cursorShearY(_("CUR_SHEAR_Y"), wxBITMAP_TYPE_CUR_RESOURCE)
|
||||
{
|
||||
// Load resource images
|
||||
Image rot = loadResourceImage(_("HANDLE_ROTATE"));
|
||||
Image rot = load_resource_image(_("HANDLE_ROTATE"));
|
||||
handleRotateTL = wxBitmap(rot);
|
||||
handleRotateTR = wxBitmap(rotateImageBy(rot,90));
|
||||
handleRotateBR = wxBitmap(rotateImageBy(rot,180));
|
||||
handleRotateBL = wxBitmap(rotateImageBy(rot,270));
|
||||
Image shear = loadResourceImage(_("HANDLE_SHEAR_X"));
|
||||
handleRotateTR = wxBitmap(rotate_image(rot,90));
|
||||
handleRotateBR = wxBitmap(rotate_image(rot,180));
|
||||
handleRotateBL = wxBitmap(rotate_image(rot,270));
|
||||
Image shear = load_resource_image(_("HANDLE_SHEAR_X"));
|
||||
handleShearX = wxBitmap(shear);
|
||||
handleShearY = wxBitmap(rotateImageBy(shear,90));
|
||||
handleCenter = wxBitmap(loadResourceImage(_("HANDLE_CENTER")));
|
||||
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) {
|
||||
p->calculateBounds();
|
||||
@@ -45,7 +45,7 @@ SymbolSelectEditor::SymbolSelectEditor(SymbolControl* control, bool rotate)
|
||||
|
||||
void SymbolSelectEditor::draw(DC& dc) {
|
||||
// highlight selected parts
|
||||
FOR_EACH(p, control.selectedParts) {
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
control.highlightPart(dc, *p, HIGHLIGHT_INTERIOR);
|
||||
}
|
||||
// highlight the part under the cursor
|
||||
@@ -57,7 +57,7 @@ void SymbolSelectEditor::draw(DC& dc) {
|
||||
}
|
||||
|
||||
void SymbolSelectEditor::drawHandles(DC& dc) {
|
||||
if (control.selectedParts.empty()) return;
|
||||
if (control.selected_parts.empty()) return;
|
||||
if (rotateAction) return; // not when rotating
|
||||
updateBoundingBox();
|
||||
// Draw handles on all sides
|
||||
@@ -107,12 +107,12 @@ void SymbolSelectEditor::drawRotationCenter(DC& dc, const Vector2D& pos) {
|
||||
|
||||
void SymbolSelectEditor::initUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
tb->AddSeparator();
|
||||
tb->AddTool(ID_PART_MERGE, _("Merge"), loadResourceImage(_("COMBINE_OR")), wxNullBitmap, wxITEM_CHECK, _("Merge with shapes below"), _("Merges this shape with those below it"));
|
||||
tb->AddTool(ID_PART_SUBTRACT, _("Subtract"), loadResourceImage(_("COMBINE_SUB_DARK")), wxNullBitmap, wxITEM_CHECK, _("Subtract from shapes below"), _("Subtracts this shape from shapes below it, leaves only the area in that shape that is not in this shape"));
|
||||
tb->AddTool(ID_PART_INTERSECTION, _("Intersect"), loadResourceImage(_("COMBINE_AND_DARK")), wxNullBitmap, wxITEM_CHECK, _("Intersect with shapes below"), _("Intersects this shape with shapes below it, leaves only the area in both shapes"));
|
||||
tb->AddTool(ID_PART_MERGE, _("Merge"), load_resource_image(_("COMBINE_OR")), wxNullBitmap, wxITEM_CHECK, _("Merge with shapes below"), _("Merges this shape with those below it"));
|
||||
tb->AddTool(ID_PART_SUBTRACT, _("Subtract"), load_resource_image(_("COMBINE_SUB_DARK")), wxNullBitmap, wxITEM_CHECK, _("Subtract from shapes below"), _("Subtracts this shape from shapes below it, leaves only the area in that shape that is not in this shape"));
|
||||
tb->AddTool(ID_PART_INTERSECTION, _("Intersect"), load_resource_image(_("COMBINE_AND_DARK")), wxNullBitmap, wxITEM_CHECK, _("Intersect with shapes below"), _("Intersects this shape with shapes below it, leaves only the area in both shapes"));
|
||||
// note: difference doesn't work (yet)
|
||||
tb->AddTool(ID_PART_OVERLAP, _("Overlap"), loadResourceImage(_("COMBINE_OVER")), wxNullBitmap, wxITEM_CHECK, _("Place above other shapes"), _("Place this shape, and its border above shapes below it"));
|
||||
tb->AddTool(ID_PART_BORDER, _("Border"), loadResourceImage(_("COMBINE_BORDER")), wxNullBitmap, wxITEM_CHECK, _("Draw as a border"), _("Draws this shape as a border"));
|
||||
tb->AddTool(ID_PART_OVERLAP, _("Overlap"), load_resource_image(_("COMBINE_OVER")), wxNullBitmap, wxITEM_CHECK, _("Place above other shapes"), _("Place this shape, and its border above shapes below it"));
|
||||
tb->AddTool(ID_PART_BORDER, _("Border"), load_resource_image(_("COMBINE_BORDER")), wxNullBitmap, wxITEM_CHECK, _("Draw as a border"), _("Draws this shape as a border"));
|
||||
tb->Realize();
|
||||
}
|
||||
void SymbolSelectEditor::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
@@ -127,13 +127,13 @@ void SymbolSelectEditor::destroyUI(wxToolBar* tb, wxMenuBar* mb) {
|
||||
|
||||
void SymbolSelectEditor::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
if (ev.GetId() >= ID_PART && ev.GetId() < ID_PART_MAX) {
|
||||
if (control.selectedParts.empty()) {
|
||||
if (control.selected_parts.empty()) {
|
||||
ev.Check(false);
|
||||
ev.Enable(false);
|
||||
} else {
|
||||
ev.Enable(true);
|
||||
bool check = true;
|
||||
FOR_EACH(p, control.selectedParts) {
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
if (p->combine != ev.GetId() - ID_PART) {
|
||||
check = false;
|
||||
break;
|
||||
@@ -142,7 +142,7 @@ void SymbolSelectEditor::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
ev.Check(check);
|
||||
}
|
||||
} else if (ev.GetId() == ID_EDIT_DUPLICATE) {
|
||||
ev.Enable(!control.selectedParts.empty());
|
||||
ev.Enable(!control.selected_parts.empty());
|
||||
} else {
|
||||
ev.Enable(false); // we don't know about this item
|
||||
}
|
||||
@@ -152,14 +152,14 @@ void SymbolSelectEditor::onCommand(int id) {
|
||||
if (id >= ID_PART && id < ID_PART_MAX) {
|
||||
// change combine mode
|
||||
getSymbol()->actions.add(new CombiningModeAction(
|
||||
control.selectedParts,
|
||||
control.selected_parts,
|
||||
static_cast<SymbolPartCombine>(id - ID_PART)
|
||||
));
|
||||
control.Refresh(false);
|
||||
} else if (id == ID_EDIT_DUPLICATE && !isEditing()) {
|
||||
// duplicate selection, not when dragging
|
||||
DuplicateSymbolPartsAction* action = new DuplicateSymbolPartsAction(
|
||||
*getSymbol(), control.selectedParts
|
||||
*getSymbol(), control.selected_parts
|
||||
);
|
||||
getSymbol()->actions.add(action);
|
||||
control.Refresh(false);
|
||||
@@ -189,26 +189,26 @@ void SymbolSelectEditor::onLeftUp (const Vector2D& pos, wxMouseEvent& ev) {
|
||||
if (part) {
|
||||
if (ev.ShiftDown()) {
|
||||
// toggle selection
|
||||
set<SymbolPartP>::iterator it = control.selectedParts.find(part);
|
||||
if (it != control.selectedParts.end()) {
|
||||
control.selectedParts.erase(it);
|
||||
set<SymbolPartP>::iterator it = control.selected_parts.find(part);
|
||||
if (it != control.selected_parts.end()) {
|
||||
control.selected_parts.erase(it);
|
||||
} else {
|
||||
control.selectedParts.insert(part);
|
||||
control.selected_parts.insert(part);
|
||||
}
|
||||
} else {
|
||||
if (control.selectedParts.find(part) != control.selectedParts.end()) {
|
||||
if (control.selected_parts.find(part) != control.selected_parts.end()) {
|
||||
// already selected, don't change selection
|
||||
// instead switch between rotate and resize mode
|
||||
rotate = !rotate;
|
||||
} else {
|
||||
// select the part under the cursor
|
||||
control.selectedParts.clear();
|
||||
control.selectedParts.insert(part);
|
||||
control.selected_parts.clear();
|
||||
control.selected_parts.insert(part);
|
||||
}
|
||||
}
|
||||
} else if (!ev.ShiftDown()) {
|
||||
// select nothing
|
||||
control.selectedParts.clear();
|
||||
control.selected_parts.clear();
|
||||
}
|
||||
// selection has changed
|
||||
updateBoundingBox();
|
||||
@@ -230,20 +230,20 @@ void SymbolSelectEditor::onMouseMove (const Vector2D& from, const Vector2D& to,
|
||||
highlightPart = findPart(to);
|
||||
// are we on a handle?
|
||||
int dx, dy;
|
||||
if (!control.selectedParts.empty() && onAnyHandle(to, &dx, &dy)) {
|
||||
if (!control.selected_parts.empty() && onAnyHandle(to, &dx, &dy)) {
|
||||
// we are on a handle, don't highlight
|
||||
highlightPart = SymbolPartP();
|
||||
if (rotate) {
|
||||
// shear or rotating?
|
||||
if (dx == 0 || dy == 0) {
|
||||
SetStatusText(String(_("Drag to shear selected shape")) + (control.selectedParts.size() > 1 ? _("s") : _("")));
|
||||
SetStatusText(String(_("Drag to shear selected shape")) + (control.selected_parts.size() > 1 ? _("s") : _("")));
|
||||
control.SetCursor(dx == 0 ? cursorShearX : cursorShearY);
|
||||
} else {
|
||||
SetStatusText(String(_("Drag to rotate selected shape")) + (control.selectedParts.size() > 1 ? _("s") : _("")) + _(", Ctrl constrains angle to multiples of 15 degrees"));
|
||||
SetStatusText(String(_("Drag to rotate selected shape")) + (control.selected_parts.size() > 1 ? _("s") : _("")) + _(", Ctrl constrains angle to multiples of 15 degrees"));
|
||||
control.SetCursor(cursorRotate);
|
||||
}
|
||||
} else {
|
||||
SetStatusText(String(_("Drag to resize selected shape")) + (control.selectedParts.size() > 1 ? _("s") : _("")) + _(", Ctrl constrains size"));
|
||||
SetStatusText(String(_("Drag to resize selected shape")) + (control.selected_parts.size() > 1 ? _("s") : _("")) + _(", Ctrl constrains size"));
|
||||
// what cursor to use?
|
||||
if (dx == dy) control.SetCursor(wxCURSOR_SIZENWSE);
|
||||
else if (dx == -dy) control.SetCursor(wxCURSOR_SIZENESW);
|
||||
@@ -262,7 +262,7 @@ void SymbolSelectEditor::onMouseMove (const Vector2D& from, const Vector2D& to,
|
||||
}
|
||||
|
||||
void SymbolSelectEditor::onMouseDrag (const Vector2D& from, const Vector2D& to, wxMouseEvent& ev) {
|
||||
if (control.selectedParts.empty()) return;
|
||||
if (control.selected_parts.empty()) return;
|
||||
if (!isEditing()) {
|
||||
// we don't have an action yet, determine what to do
|
||||
// note: base it on the from position, which is the position where dragging started
|
||||
@@ -270,22 +270,22 @@ void SymbolSelectEditor::onMouseDrag (const Vector2D& from, const Vector2D& to,
|
||||
if (rotate) {
|
||||
if (scaleX == 0 || scaleY == 0) {
|
||||
// shear, center/fixed point on the opposite side
|
||||
shearAction = new SymbolPartShearAction(control.selectedParts, handlePos(-scaleX, -scaleY));
|
||||
shearAction = new SymbolPartShearAction(control.selected_parts, handlePos(-scaleX, -scaleY));
|
||||
getSymbol()->actions.add(shearAction);
|
||||
} else {
|
||||
// rotate
|
||||
rotateAction = new SymbolPartRotateAction(control.selectedParts, center);
|
||||
rotateAction = new SymbolPartRotateAction(control.selected_parts, center);
|
||||
getSymbol()->actions.add(rotateAction);
|
||||
startAngle = angleTo(to);
|
||||
}
|
||||
} else {
|
||||
// we are on a handle; start scaling
|
||||
scaleAction = new SymbolPartScaleAction(control.selectedParts, scaleX, scaleY);
|
||||
scaleAction = new SymbolPartScaleAction(control.selected_parts, scaleX, scaleY);
|
||||
getSymbol()->actions.add(scaleAction);
|
||||
}
|
||||
} else {
|
||||
// move
|
||||
moveAction = new SymbolPartMoveAction(control.selectedParts);
|
||||
moveAction = new SymbolPartMoveAction(control.selected_parts);
|
||||
getSymbol()->actions.add(moveAction);
|
||||
}
|
||||
}
|
||||
@@ -345,8 +345,8 @@ void SymbolSelectEditor::onKeyChange (wxKeyEvent& ev) {
|
||||
void SymbolSelectEditor::onChar(wxKeyEvent& ev) {
|
||||
if (ev.GetKeyCode() == WXK_DELETE) {
|
||||
// delete selected parts
|
||||
getSymbol()->actions.add(new RemoveSymbolPartsAction(*getSymbol(), control.selectedParts));
|
||||
control.selectedParts.clear();
|
||||
getSymbol()->actions.add(new RemoveSymbolPartsAction(*getSymbol(), control.selected_parts));
|
||||
control.selected_parts.clear();
|
||||
resetActions();
|
||||
control.Refresh(false);
|
||||
} else {
|
||||
@@ -395,7 +395,7 @@ double SymbolSelectEditor::angleTo(const Vector2D& pos) {
|
||||
|
||||
SymbolPartP SymbolSelectEditor::findPart(const Vector2D& pos) {
|
||||
FOR_EACH(p, getSymbol()->parts) {
|
||||
if (pointInPart(pos, *p)) return p;
|
||||
if (point_in_part(pos, *p)) return p;
|
||||
}
|
||||
return SymbolPartP();
|
||||
}
|
||||
@@ -404,18 +404,18 @@ void SymbolSelectEditor::updateBoundingBox() {
|
||||
// Find min and max coordinates
|
||||
minV = Vector2D::infinity();
|
||||
maxV = -Vector2D::infinity();
|
||||
FOR_EACH(p, control.selectedParts) {
|
||||
minV = piecewise_min(minV, p->minPos);
|
||||
maxV = piecewise_max(maxV, p->maxPos);
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
minV = piecewise_min(minV, p->min_pos);
|
||||
maxV = piecewise_max(maxV, p->max_pos);
|
||||
}
|
||||
// Find rotation center
|
||||
center = Vector2D(0,0);
|
||||
FOR_EACH(p, control.selectedParts) {
|
||||
Vector2D size = p->maxPos - p->minPos;
|
||||
size = size.mul(p->rotationCenter);
|
||||
center += p->minPos + size;
|
||||
FOR_EACH(p, control.selected_parts) {
|
||||
Vector2D size = p->max_pos - p->min_pos;
|
||||
size = size.mul(p->rotation_center);
|
||||
center += p->min_pos + size;
|
||||
}
|
||||
center /= control.selectedParts.size();
|
||||
center /= control.selected_parts.size();
|
||||
}
|
||||
|
||||
void SymbolSelectEditor::resetActions() {
|
||||
|
||||
@@ -105,7 +105,7 @@ class SymbolSelectEditor : public SymbolEditorBase {
|
||||
/// Find the first part at the given position
|
||||
SymbolPartP findPart(const Vector2D& pos);
|
||||
|
||||
/// Update minV and maxV to be the bounding box of the selectedParts
|
||||
/// Update minV and maxV to be the bounding box of the selected_parts
|
||||
/// Updates center to be the rotation center of the parts
|
||||
void updateBoundingBox();
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void SymbolViewer::highlightPart(DC& dc, const SymbolPart& part, HighlightStyle
|
||||
vector<wxPoint> points;
|
||||
size_t size = part.points.size();
|
||||
for(size_t i = 0 ; i < size ; ++i) {
|
||||
segmentSubdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
|
||||
segment_subdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
|
||||
}
|
||||
// draw
|
||||
if (style == HIGHLIGHT_BORDER) {
|
||||
@@ -165,7 +165,7 @@ void SymbolViewer::drawSymbolPart(const SymbolPart& part, DC* border, DC* interi
|
||||
vector<wxPoint> points;
|
||||
size_t size = part.points.size();
|
||||
for(size_t i = 0 ; i < size ; ++i) {
|
||||
segmentSubdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
|
||||
segment_subdivide(*part.getPoint((int)i), *part.getPoint((int)i+1), rotation, points);
|
||||
}
|
||||
// draw border
|
||||
if (border) {
|
||||
|
||||
@@ -218,7 +218,7 @@ void SymbolWindow::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
void SymbolWindow::onSelectFromList(wxListEvent& ev) {
|
||||
if (inSelectionEvent) return ;
|
||||
inSelectionEvent = true;
|
||||
parts->getSelectedParts(control->selectedParts);
|
||||
parts->getselected_parts(control->selected_parts);
|
||||
control->onUpdateSelection();
|
||||
inSelectionEvent = false;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ void SymbolWindow::onActivateFromList(wxListEvent& ev) {
|
||||
void SymbolWindow::onSelectFromControl() {
|
||||
if (inSelectionEvent) return ;
|
||||
inSelectionEvent = true;
|
||||
parts->selectParts(control->selectedParts);
|
||||
parts->selectParts(control->selected_parts);
|
||||
inSelectionEvent = false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ void clearDC(DC& dc, const wxBrush& brush) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Image related
|
||||
|
||||
Image loadResourceImage(String name) {
|
||||
Image load_resource_image(String name) {
|
||||
#ifdef __WXMSW__
|
||||
// Load resource
|
||||
// based on wxLoadUserResource
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ void clearDC(DC& dc, const wxBrush& brush = *wxBLACK_BRUSH);
|
||||
// ----------------------------------------------------------------------------- : Resource related
|
||||
|
||||
/// Load an image from a resource
|
||||
Image loadResourceImage(String name);
|
||||
Image load_resource_image(String name);
|
||||
|
||||
// ----------------------------------------------------------------------------- : EOF
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user