From 31c332da9ab426daa73b68772d0ef9c1b0744a50 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 1 Jan 2023 17:25:27 +0100 Subject: Decouple editor event from the Draw class --- examples/wxWidgets/main.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'examples/wxWidgets/main.cpp') 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(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(e.move)->MyHalfMove::SetAsMainline(); - NeedRedraw = true; } else if (e.type == cgeditor::Event::Type::Goto) { str = "Goto move"; } -- cgit v1.2.3