aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-01 17:25:27 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-01 17:25:27 +0100
commit31c332da9ab426daa73b68772d0ef9c1b0744a50 (patch)
tree4e85d9a2a4b18d97e6bed242181e85f015be9e09 /examples
parent3271972f9eef3069bf80de8be4c057102fff1138 (diff)
Decouple editor event from the Draw class
Diffstat (limited to 'examples')
-rw-r--r--examples/wxWidgets/main.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/wxWidgets/main.cpp b/examples/wxWidgets/main.cpp
index 35a3100..9d5274a 100644
--- a/examples/wxWidgets/main.cpp
+++ b/examples/wxWidgets/main.cpp
@@ -12,7 +12,6 @@
*/
class MyFrame : public wxFrame, public cgeditor::CGEditor {
wxPaintDC *dc;
- bool NeedRedraw = false;
public:
MyFrame()
@@ -72,10 +71,16 @@ private:
Refresh();
}
- // Should another draw of CGEditor be made?
- if (NeedRedraw) {
+ // Now handle event
+ bool redraw=false;
+ Update();
+ for(const cgeditor::Event &e: status.Events){
+ HandleEvent(e);
+ redraw=true;
+ }
+ status.Events.clear();
+ if(redraw){
Refresh();
- NeedRedraw = false;
}
}
@@ -163,7 +168,6 @@ private:
else if (e.type == cgeditor::Event::Type::Promote) {
str = "Promote";
static_cast<MyHalfMove *>(e.move)->MyHalfMove::Promote();
- NeedRedraw = true;
} else if (e.type == cgeditor::Event::Type::Delete) {
str = "Delete";
if (e.move->Parent != NULL) {
@@ -172,11 +176,9 @@ private:
} else {
CGEditor::status.Moves = NULL;
}
- NeedRedraw = true;
} else if (e.type == cgeditor::Event::Type::SetAsMainline) {
str = "Set as main line";
static_cast<MyHalfMove *>(e.move)->MyHalfMove::SetAsMainline();
- NeedRedraw = true;
} else if (e.type == cgeditor::Event::Type::Goto) {
str = "Goto move";
}