Bind settings of the Editor (still ongoing)

This commit is contained in:
Loic Guegan 2023-01-09 14:43:54 +01:00
parent 445cc09d01
commit 518edf6f30
8 changed files with 36 additions and 17 deletions

View file

@ -243,17 +243,17 @@ void BoardCanvas::DrawBoard(wxDC &dc) {
type=s[2];
// Default highlight (type='a' or something else not supported)
dc.SetPen(wxNullPen);
dc.SetBrush(wxColour(255,0,0,110));
dc.SetBrush(wxColour(255, 102, 122));
if(type=='b')
dc.SetBrush(wxColour(0,255,0,110));
dc.SetBrush(wxColour(120, 255, 102));
else if(type=='c')
dc.SetBrush(wxColour(0,0,255,110));
dc.SetBrush(wxColour(102, 196, 255));
else if(type=='d')
dc.SetBrush(wxColour(255,0,0,50));
dc.SetBrush(wxColour(255, 204, 213));
else if(type=='e')
dc.SetBrush(wxColour(0,255,0,50));
dc.SetBrush(wxColour(220, 255, 204));
else if(type=='f')
dc.SetBrush(wxColour(0,0,255,50));
dc.SetBrush(wxColour(204, 231, 255));
dc.DrawRectangle(wxRect(x,y,square_width,square_width));
}
}
@ -505,7 +505,7 @@ void BoardCanvas::MouseEvent(wxMouseEvent &event) {
if(std::count(squares_hl.begin(), squares_hl.end(), src)){
squares_hl.erase(std::remove(squares_hl.begin(), squares_hl.end(), src), squares_hl.end());
}else{
squares_hl.push_back(src);
squares_hl.push_back(src+"f");
wxLogDebug("Highlight square %s",src);
}
}

View file

@ -156,8 +156,8 @@ void GameTabRightPanel::ApplyPreferences() {
engine_list->Append(engine_name);
} while (conf->GetNextGroup(engine_name, index));
}
CONFIG_CLOSE(conf);
editor_canvas->ApplyPreferences();
}
void GameTabRightPanel::RefreshTagsList() {

View file

@ -31,8 +31,6 @@ void EditorCanvas::OnPaint(wxPaintEvent &event) {
wxSize sz = GetClientSize();
CGEditor::status.CanvasWidth = sz.GetWidth();
CGEditor::status.CanvasHeight = sz.GetHeight();
CGEditor::status.UseMoveIcons =
true; // Piece image should be drawn before the move ?
const wxPoint pt = wxGetMousePosition();
CGEditor::status.MouseX = pt.x - this->GetScreenPosition().x;
@ -229,5 +227,15 @@ void EditorCanvas::SetMoves(HalfMove *moves, HalfMove *current) {
Refresh();
}
void EditorCanvas::ApplyPreferences(){
CONFIG_OPEN(conf);
conf->SetPath("editor/");
CGEditor::status.MoveHeight=conf->Read("row_size", 50);
CGEditor::status.MoveWidth=conf->Read("col_size", 100);
CGEditor::status.UseMoveIcons=conf->Read("show_move_icons", true);
CONFIG_CLOSE(conf);
Refresh();
}
wxBEGIN_EVENT_TABLE(EditorCanvas, wxPanel) EVT_PAINT(EditorCanvas::OnPaint)
EVT_MOUSE_EVENTS(EditorCanvas::MouseEvent) wxEND_EVENT_TABLE()

View file

@ -31,6 +31,6 @@ public:
void DrawElement(const cgeditor::Element &e);
void HandleEvent(const cgeditor::Event &e);
void SetMoves(HalfMove *moves, HalfMove *current);
void ApplyPreferences();
DECLARE_EVENT_TABLE()
};