Improve editor drawing loop

This commit is contained in:
Loic Guegan 2023-01-01 17:30:55 +01:00
parent f0e6f0b665
commit 88430eec29
3 changed files with 12 additions and 6 deletions

View file

@ -1,7 +1,7 @@
#include "EditorCanvas.hpp"
EditorCanvas::EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game)
: wxPanel(parent), game(game), NeedRedraw(false) {
: wxPanel(parent), game(game) {
hide_icon = LoadPNG("hide", wxSize(CGEditor::status.MoveIconWidth,
CGEditor::status.MoveIconWidth));
t.ResizePieces(CGEditor::status.MoveIconWidth);
@ -210,10 +210,17 @@ void EditorCanvas::MouseEvent(wxMouseEvent &event) {
Refresh();
}
// Should another draw of CGEditor be made?
if (NeedRedraw) {
// Handle editor events
Update();
bool need_redraw=false;
for(auto event: status.Events){
HandleEvent(event);
need_redraw=true;
}
if(need_redraw){
status.Events.clear();
Refresh();
NeedRedraw = false;
Update();
}
}