aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-02-28 15:27:51 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-02-28 15:27:51 +0100
commitcd2c9e5b470255366464131492389cb0928cc5d1 (patch)
tree547cc3daf07708dfbc6cde2801209caa73c54d4c /src
parent81d7a419624e79ec3fa6c4bcb52fccaa6004065b (diff)
Improve GUI and debug various classes
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cpp69
-rw-r--r--src/MainWindow.hpp5
-rw-r--r--src/game_tab/GameTab.cpp3
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.cpp13
-rw-r--r--src/game_tab/left_panel/GameTabLeftPanel.hpp1
-rw-r--r--src/gui.cpp16
-rw-r--r--src/gui.h13
7 files changed, 43 insertions, 77 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index d07d93f..7078076 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -13,49 +13,34 @@ wxDEFINE_EVENT(REFRESH_ENGINE_LIST, wxCommandEvent);
/// ---------- MainWindow ----------
MainWindow::MainWindow()
- : wxFrame(NULL, wxID_ANY, "OChess: The Open Chess software",
- wxDefaultPosition, wxSize(1500, 1000)),
+ : MainFrame(NULL, wxID_ANY, "OChess: The Open Chess software",
+ wxDefaultPosition, wxSize(1500, 1000)),
prefsEditor(NULL) {
- CreateStatusBar();
SetStatusText("OChess");
/// File menu
- wxMenu *menuFile = new wxMenu;
- menuFile->Append(1, "Open", "Open file");
- menuFile->AppendSeparator();
- menuFile->Append(10, "Save", "Save current game");
- menuFile->Append(11, "Save As", "Save current game as");
- menuFile->AppendSeparator();
- menuFile->Append(4, "Settings", "Configure OChess");
- menuFile->AppendSeparator();
- menuFile->Append(wxID_EXIT);
+ menu_file->Append(1, "Open", "Open file");
+ menu_file->AppendSeparator();
+ menu_file->Append(10, "Save", "Save current game");
+ menu_file->Append(11, "Save As", "Save current game as");
+ menu_file->AppendSeparator();
+ menu_file->Append(4, "Settings", "Configure OChess");
+ menu_file->AppendSeparator();
+ menu_file->Append(wxID_EXIT);
// Game menu
- menuGame = new wxMenu;
- menuGame->Append(2, "New", "Create new game");
- menuGame->Append(3, "New from FEN", "Create new game using FEN");
+ menu_game->Append(2, "New", "Create new game");
+ menu_game->Append(3, "New from FEN", "Create new game using FEN");
// Game base menu
- wxMenu *menuBase = new wxMenu;
- menuBase->Append(5, "New", "Create new database");
+ menu_db->Append(5, "New", "Create new database");
// Engine menu
- wxMenu *engineMenu = new wxMenu;
- engineMenu->Append(6, "New", "Create a new engine configuration");
+ menu_engine->Append(6, "New", "Create a new engine configuration");
manageMenu = new wxMenu;
- engineMenu->AppendSubMenu(manageMenu, "Manage");
-
- /// Menu bar
- menuBar = new wxMenuBar;
- menuBar->Append(menuFile, "&File");
- menuBar->Append(menuGame, "&Game");
- menuBar->Append(menuBase, "&Database");
- menuBar->Append(engineMenu, "&Engines");
- SetMenuBar(menuBar);
-
- // Create the wxNotebook widget
- notebook = new wxAuiNotebook(this, wxID_ANY);
- NewGame(new Game());
+ menu_engine->AppendSubMenu(manageMenu, "Manage");
+ wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
+ OnRefreshEngineList(dummy);
Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this,
wxID_ANY);
@@ -66,18 +51,8 @@ MainWindow::MainWindow()
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
Bind(REFRESH_ENGINE_LIST, &MainWindow::OnRefreshEngineList, this, wxID_ANY);
- /*BaseTab *bt = new BaseTab((wxFrame *)notebook,
- "/home/loic/hartwig_tests.pgn"); notebook->AddPage(bt, bt->GetLabel());
- notebook->SetSelection(notebook->GetPageIndex(bt));*/
- /*
- EngineTab *bt =
- new EngineTab((wxWindow *)notebook,
- new uciadapter::UCI("/home/loic/.local/bin/stockfish"),
- "/home/loic/.local/bin/stockfish");
- notebook->AddPage(bt, bt->GetLabel());
- notebook->SetSelection(notebook->GetPageIndex(bt));*/
- wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
- OnRefreshEngineList(dummy);
+ // Add new game tab by default
+ NewGame(new Game());
}
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
@@ -108,6 +83,8 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
NewGame(true);
} else if (id == 4) {
OpenSettings();
+ } else if (id == 5) {
+ OpenFile();
} else if (id == 6) {
NewEngine();
}
@@ -222,8 +199,8 @@ void MainWindow::OnPageChange(wxAuiNotebookEvent &event) {
TabInfos *infos = dynamic_cast<TabInfos *>(notebook->GetCurrentPage());
if (infos->type != TabInfos::GAME) {
for (short i = 10; i < 20; i++) {
- if (menuGame->FindChildItem(i) != NULL) {
- menuGame->Enable(i, false);
+ if (menu_game->FindChildItem(i) != NULL) {
+ menu_game->Enable(i, false);
}
}
}
diff --git a/src/MainWindow.hpp b/src/MainWindow.hpp
index 4fa3318..c223701 100644
--- a/src/MainWindow.hpp
+++ b/src/MainWindow.hpp
@@ -13,10 +13,7 @@ wxDECLARE_EVENT(NEW_GAME_EVENT, wxCommandEvent);
wxDECLARE_EVENT(CLOSE_TAB_EVENT, wxCommandEvent);
wxDECLARE_EVENT(REFRESH_ENGINE_LIST, wxCommandEvent);
-class MainWindow : public wxFrame {
- wxAuiNotebook *notebook;
- wxMenu *menuGame;
- wxMenuBar *menuBar;
+class MainWindow : public MainFrame {
wxPreferencesEditor *prefsEditor;
wxMenu *manageMenu;
diff --git a/src/game_tab/GameTab.cpp b/src/game_tab/GameTab.cpp
index cf49991..c3aceb8 100644
--- a/src/game_tab/GameTab.cpp
+++ b/src/game_tab/GameTab.cpp
@@ -7,8 +7,7 @@ GameTab::GameTab(wxFrame *parent, Game *game)
: wxPanel(parent), game(game), TabInfos(TabInfos::GAME) {
// Splitter
wxSplitterWindow *splitter = new wxSplitterWindow(this, wxID_ANY);
- splitter->SetMinimumPaneSize(100);
-
+ splitter->SetSashGravity(0.8);
// Panels
game->BuildAndVerify();
board_panel = new GameTabLeftPanel((wxFrame *)splitter, game);
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.cpp b/src/game_tab/left_panel/GameTabLeftPanel.cpp
index bc33d33..d4c415d 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.cpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.cpp
@@ -13,13 +13,15 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, Game *game)
zoomin_button->SetBitmapLabel(LoadPNG("zoomin"));
zoomout_button->SetBitmapLabel(LoadPNG("zoomout"));
+ // Configure FEN field
+ fen_text_field->SetFont(wxFont(*wxSMALL_FONT).Bold());
+
Bind(PLAY_MOVE_EVENT, &GameTabLeftPanel::OnPlay, this, wxID_ANY);
Bind(PREVIOUS_MOVE_EVENT, &GameTabLeftPanel::OnPreviousMove, this, wxID_ANY);
Bind(NEXT_MOVE_EVENT, &GameTabLeftPanel::OnNextMove, this, wxID_ANY);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnSwap, this, SWAP_BTN);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomIn, this, ZOOM_IN_BTN);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
- Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnCopyFEN, this, COPY_FEN_BTN);
}
void GameTabLeftPanel::OnPreviousMove(wxCommandEvent &event) {
@@ -58,14 +60,6 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
Notify();
}
-void GameTabLeftPanel::OnCopyFEN(wxCommandEvent &event) {
- wxLogDebug("Clicked on copy fen");
- if (wxTheClipboard->Open()) {
- wxTheClipboard->SetData(new wxTextDataObject(game->GetFen()));
- wxTheClipboard->Close();
- }
-}
-
void GameTabLeftPanel::Notify() {
std::string fen = game->GetFen();
std::map<char, std::uint8_t> captures;
@@ -75,6 +69,7 @@ void GameTabLeftPanel::Notify() {
}
board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,
game->IsBlackToPlay(), captures);
+ fen_text_field->SetValue(game->GetFen());
}
void GameTabLeftPanel::NotifyEditor() {
diff --git a/src/game_tab/left_panel/GameTabLeftPanel.hpp b/src/game_tab/left_panel/GameTabLeftPanel.hpp
index d2ad3f1..c4b58b9 100644
--- a/src/game_tab/left_panel/GameTabLeftPanel.hpp
+++ b/src/game_tab/left_panel/GameTabLeftPanel.hpp
@@ -20,7 +20,6 @@ public:
void OnGotoMove(wxCommandEvent &event);
void OnPreviousMove(wxCommandEvent &event);
void OnNextMove(wxCommandEvent &event);
- void OnCopyFEN(wxCommandEvent &event);
void OnZoomIn(wxCommandEvent &event);
void OnZoomOut(wxCommandEvent &event);
void OnSwap(wxCommandEvent &event);
diff --git a/src/gui.cpp b/src/gui.cpp
index 9091001..897ef15 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -428,17 +428,17 @@ TabGameLeftPanel::TabGameLeftPanel( wxWindow* parent, wxWindowID id, const wxPoi
wxBoxSizer* bar_sizer;
bar_sizer = new wxBoxSizer( wxHORIZONTAL );
- swap_button = new wxBitmapButton( this, SWAP_BTN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
- bar_sizer->Add( swap_button, 0, wxALL|wxEXPAND, 5 );
+ swap_button = new wxBitmapButton( this, SWAP_BTN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBORDER_NONE );
+ bar_sizer->Add( swap_button, 0, wxALL|wxEXPAND, 3 );
- zoomin_button = new wxBitmapButton( this, ZOOM_IN_BTN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
- bar_sizer->Add( zoomin_button, 0, wxALL|wxEXPAND, 5 );
+ zoomin_button = new wxBitmapButton( this, ZOOM_IN_BTN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBORDER_NONE );
+ bar_sizer->Add( zoomin_button, 0, wxALL|wxEXPAND, 3 );
- zoomout_button = new wxBitmapButton( this, ZOOM_OUT_BTN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
- bar_sizer->Add( zoomout_button, 0, wxALL|wxEXPAND, 5 );
+ zoomout_button = new wxBitmapButton( this, ZOOM_OUT_BTN, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|wxBORDER_NONE );
+ bar_sizer->Add( zoomout_button, 0, wxALL|wxEXPAND, 3 );
- copy_fen_button = new wxButton( this, COPY_FEN_BTN, wxT("Copy FEN"), wxDefaultPosition, wxDefaultSize, 0 );
- bar_sizer->Add( copy_fen_button, 0, wxALL|wxEXPAND, 5 );
+ fen_text_field = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), wxTE_READONLY );
+ bar_sizer->Add( fen_text_field, 1, wxALL|wxEXPAND, 0 );
main_sizer->Add( bar_sizer, 0, wxEXPAND, 5 );
diff --git a/src/gui.h b/src/gui.h
index 6c52418..e5dae19 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -53,11 +53,10 @@
#define SWAP_BTN 1009
#define ZOOM_IN_BTN 1010
#define ZOOM_OUT_BTN 1011
-#define COPY_FEN_BTN 1012
-#define COMMENT_INPUT_BOX 1013
-#define UPDATE_BTN 1014
-#define DELETE_BTN 1015
-#define LIVE_ANALYSIS_GAME_BUTTON 1016
+#define COMMENT_INPUT_BOX 1012
+#define UPDATE_BTN 1013
+#define DELETE_BTN 1014
+#define LIVE_ANALYSIS_GAME_BUTTON 1015
///////////////////////////////////////////////////////////////////////////////
/// Class MainFrame
@@ -260,11 +259,11 @@ class TabGameLeftPanel : public wxPanel
wxBitmapButton* swap_button;
wxBitmapButton* zoomin_button;
wxBitmapButton* zoomout_button;
- wxButton* copy_fen_button;
+ wxTextCtrl* fen_text_field;
public:
- TabGameLeftPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
+ TabGameLeftPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 998,410 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~TabGameLeftPanel();