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(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 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(); diff --git a/tools/wxFrameBuilder.fbp b/tools/wxFrameBuilder.fbp index b02a8a4..d7cf014 100644 --- a/tools/wxFrameBuilder.fbp +++ b/tools/wxFrameBuilder.fbp @@ -4173,7 +4173,7 @@ TabGameLeftPanel - 500,300 + 998,410 ; ; forward_declare 0 @@ -4189,16 +4189,16 @@ 5 wxEXPAND 0 - + bar_sizer wxHORIZONTAL none - - 5 + + 3 wxALL|wxEXPAND 0 - + 1 1 1 @@ -4254,7 +4254,7 @@ Resizable 1 - + wxBORDER_NONE ; ; forward_declare 0 @@ -4267,11 +4267,11 @@ - - 5 + + 3 wxALL|wxEXPAND 0 - + 1 1 1 @@ -4327,7 +4327,7 @@ Resizable 1 - + wxBORDER_NONE ; ; forward_declare 0 @@ -4340,11 +4340,11 @@ - - 5 + + 3 wxALL|wxEXPAND 0 - + 1 1 1 @@ -4400,7 +4400,7 @@ Resizable 1 - + wxBORDER_NONE ; ; forward_declare 0 @@ -4414,10 +4414,10 @@ - 5 + 0 wxALL|wxEXPAND - 0 - + 1 + 1 1 1 @@ -4426,54 +4426,44 @@ - 0 - 1 0 1 1 - - 0 0 - Dock 0 Left 1 1 - 0 0 - COPY_FEN_BTN - Copy FEN - - 0 + wxID_ANY 0 + 0 1 - copy_fen_button + fen_text_field 1 protected 1 - - Resizable 1 - - + -1,-1 + wxTE_READONLY ; ; forward_declare 0 @@ -4481,6 +4471,7 @@ wxFILTER_NONE wxDefaultValidator +