mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-06 01:56:28 +02:00
Improve GUI and debug various classes
This commit is contained in:
parent
81d7a41962
commit
cd2c9e5b47
8 changed files with 66 additions and 109 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
16
src/gui.cpp
16
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 );
|
||||
|
|
13
src/gui.h
13
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();
|
||||
|
||||
|
|
|
@ -4173,7 +4173,7 @@
|
|||
<property name="minimum_size"></property>
|
||||
<property name="name">TabGameLeftPanel</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">500,300</property>
|
||||
<property name="size">998,410</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="two_step_creation">0</property>
|
||||
|
@ -4189,16 +4189,16 @@
|
|||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bar_sizer</property>
|
||||
<property name="orient">wxHORIZONTAL</property>
|
||||
<property name="permission">none</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBitmapButton" expanded="1">
|
||||
<object class="wxBitmapButton" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -4254,7 +4254,7 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="style">wxBORDER_NONE</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -4267,11 +4267,11 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBitmapButton" expanded="1">
|
||||
<object class="wxBitmapButton" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -4327,7 +4327,7 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="style">wxBORDER_NONE</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -4340,11 +4340,11 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">3</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxBitmapButton" expanded="1">
|
||||
<object class="wxBitmapButton" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -4400,7 +4400,7 @@
|
|||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="style">wxBORDER_NONE</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -4414,10 +4414,10 @@
|
|||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="border">0</property>
|
||||
<property name="flag">wxALL|wxEXPAND</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" expanded="1">
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxTextCtrl" expanded="1">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -4426,54 +4426,44 @@
|
|||
<property name="aui_name"></property>
|
||||
<property name="aui_position"></property>
|
||||
<property name="aui_row"></property>
|
||||
<property name="auth_needed">0</property>
|
||||
<property name="best_size"></property>
|
||||
<property name="bg"></property>
|
||||
<property name="bitmap"></property>
|
||||
<property name="caption"></property>
|
||||
<property name="caption_visible">1</property>
|
||||
<property name="center_pane">0</property>
|
||||
<property name="close_button">1</property>
|
||||
<property name="context_help"></property>
|
||||
<property name="context_menu">1</property>
|
||||
<property name="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></property>
|
||||
<property name="dock">Dock</property>
|
||||
<property name="dock_fixed">0</property>
|
||||
<property name="docking">Left</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="fg"></property>
|
||||
<property name="floatable">1</property>
|
||||
<property name="focus"></property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">COPY_FEN_BTN</property>
|
||||
<property name="label">Copy FEN</property>
|
||||
<property name="margins"></property>
|
||||
<property name="markup">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
<property name="maxlength"></property>
|
||||
<property name="min_size"></property>
|
||||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size"></property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">copy_fen_button</property>
|
||||
<property name="name">fen_text_field</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
<property name="permission">protected</property>
|
||||
<property name="pin_button">1</property>
|
||||
<property name="pos"></property>
|
||||
<property name="position"></property>
|
||||
<property name="pressed"></property>
|
||||
<property name="resize">Resizable</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style"></property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="style">wxTE_READONLY</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -4481,6 +4471,7 @@
|
|||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="value"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
|
|
Loading…
Add table
Reference in a new issue