mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Improve editor drawing loop
This commit is contained in:
parent
f0e6f0b665
commit
88430eec29
3 changed files with 12 additions and 6 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 3271972f9eef3069bf80de8be4c057102fff1138
|
Subproject commit 31c332da9ab426daa73b68772d0ef9c1b0744a50
|
|
@ -1,7 +1,7 @@
|
||||||
#include "EditorCanvas.hpp"
|
#include "EditorCanvas.hpp"
|
||||||
|
|
||||||
EditorCanvas::EditorCanvas(wxFrame *parent, std::shared_ptr<Game> game)
|
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,
|
hide_icon = LoadPNG("hide", wxSize(CGEditor::status.MoveIconWidth,
|
||||||
CGEditor::status.MoveIconWidth));
|
CGEditor::status.MoveIconWidth));
|
||||||
t.ResizePieces(CGEditor::status.MoveIconWidth);
|
t.ResizePieces(CGEditor::status.MoveIconWidth);
|
||||||
|
@ -210,10 +210,17 @@ void EditorCanvas::MouseEvent(wxMouseEvent &event) {
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should another draw of CGEditor be made?
|
// Handle editor events
|
||||||
if (NeedRedraw) {
|
Update();
|
||||||
|
bool need_redraw=false;
|
||||||
|
for(auto event: status.Events){
|
||||||
|
HandleEvent(event);
|
||||||
|
need_redraw=true;
|
||||||
|
}
|
||||||
|
if(need_redraw){
|
||||||
|
status.Events.clear();
|
||||||
Refresh();
|
Refresh();
|
||||||
NeedRedraw = false;
|
Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ wxDECLARE_EVENT(GAME_CHANGE, wxCommandEvent);
|
||||||
|
|
||||||
class EditorCanvas : public wxPanel, public cgeditor::CGEditor {
|
class EditorCanvas : public wxPanel, public cgeditor::CGEditor {
|
||||||
wxPaintDC *dc;
|
wxPaintDC *dc;
|
||||||
bool NeedRedraw;
|
|
||||||
wxPoint Middle(cgeditor::Element e);
|
wxPoint Middle(cgeditor::Element e);
|
||||||
wxBitmap hide_icon;
|
wxBitmap hide_icon;
|
||||||
Theme t;
|
Theme t;
|
||||||
|
|
Loading…
Add table
Reference in a new issue