mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Improve UI
This commit is contained in:
parent
27ac369fb6
commit
2045a1250a
6 changed files with 26 additions and 19 deletions
|
@ -26,6 +26,7 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
board_panel->Notify(false, false);
|
board_panel->Notify(false, false);
|
||||||
editor_panel->Notify();
|
editor_panel->Notify();
|
||||||
|
|
||||||
|
board_panel->Bind(wxEVT_TOOL,&GameTab::OnToolClick,this);
|
||||||
Bind(REFRESH_TAB_TITLE, &GameTab::OnRefreshTabTitle, this, wxID_ANY);
|
Bind(REFRESH_TAB_TITLE, &GameTab::OnRefreshTabTitle, this, wxID_ANY);
|
||||||
Bind(GAME_CHANGE, &GameTab::OnGameChange, this, wxID_ANY);
|
Bind(GAME_CHANGE, &GameTab::OnGameChange, this, wxID_ANY);
|
||||||
splitter->Bind(wxEVT_KEY_DOWN, [p=this,bp=board_panel,ed=editor_panel](wxKeyEvent &e){
|
splitter->Bind(wxEVT_KEY_DOWN, [p=this,bp=board_panel,ed=editor_panel](wxKeyEvent &e){
|
||||||
|
@ -46,6 +47,22 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameTab::OnToolClick(wxCommandEvent &event){
|
||||||
|
short id=event.GetId();
|
||||||
|
if(id==0){
|
||||||
|
if(!related_file.size()>0){
|
||||||
|
wxFileDialog
|
||||||
|
newFileDialog(this, _("Save Game"), "", "",
|
||||||
|
"PGN files (*.pgn)|*.pgn", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
||||||
|
if (newFileDialog.ShowModal() == wxID_CANCEL)
|
||||||
|
return;
|
||||||
|
// Create and open new db
|
||||||
|
related_file = newFileDialog.GetPath().ToStdString();
|
||||||
|
}
|
||||||
|
SaveGame(related_file,game);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameTab::OnGameChange(wxCommandEvent &event) {
|
void GameTab::OnGameChange(wxCommandEvent &event) {
|
||||||
board_panel->Notify(false,false);
|
board_panel->Notify(false,false);
|
||||||
editor_panel->Notify();
|
editor_panel->Notify();
|
||||||
|
|
|
@ -17,6 +17,7 @@ class GameTab : public wxPanel, public TabInfos {
|
||||||
GameTabRightPanel *editor_panel;
|
GameTabRightPanel *editor_panel;
|
||||||
GameTabLeftPanel *board_panel;
|
GameTabLeftPanel *board_panel;
|
||||||
std::shared_ptr<Game> game;
|
std::shared_ptr<Game> game;
|
||||||
|
std::string related_file;
|
||||||
|
|
||||||
void RefreshLabel();
|
void RefreshLabel();
|
||||||
void OnRefreshTabTitle(wxCommandEvent &event);
|
void OnRefreshTabTitle(wxCommandEvent &event);
|
||||||
|
@ -27,4 +28,6 @@ public:
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
std::shared_ptr<Game> GetGame() { return (std::shared_ptr<Game>(game)); }
|
std::shared_ptr<Game> GetGame() { return (std::shared_ptr<Game>(game)); }
|
||||||
std::shared_ptr<GameBase> GetBase() { return (std::shared_ptr<GameBase>(NULL)); };
|
std::shared_ptr<GameBase> GetBase() { return (std::shared_ptr<GameBase>(NULL)); };
|
||||||
|
void OnToolClick(wxCommandEvent &event);
|
||||||
|
void OnLink(){board_panel->DisableSaveTool();};
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
: TabGameLeftPanel(parent), game(game), repeat(false) {
|
: TabGameLeftPanel(parent), game(game), repeat(false) {
|
||||||
|
|
||||||
// Configure toolbal
|
// Configure toolbal
|
||||||
game_toolbar->AddTool(0, wxT("Exit application"),
|
game_toolbar->AddTool(0, wxT("Save As"),
|
||||||
wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_TOOLBAR));
|
wxArtProvider::GetBitmap(wxART_FILE_SAVE, wxART_TOOLBAR));
|
||||||
|
|
||||||
// Add board
|
// Add board
|
||||||
|
@ -26,24 +26,9 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game)
|
||||||
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
|
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
|
||||||
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
Bind(wxEVT_KEY_DOWN, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
Bind(wxEVT_KEY_UP, [p=this](wxKeyEvent &e){e.ResumePropagation(1);e.Skip();});
|
||||||
game_toolbar->Bind(wxEVT_TOOL,&GameTabLeftPanel::OnToolClick,this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameTabLeftPanel::OnToolClick(wxCommandEvent &event){
|
|
||||||
short id=event.GetId();
|
|
||||||
if(id==0){
|
|
||||||
if(!related_file.size()>0){
|
|
||||||
wxFileDialog
|
|
||||||
newFileDialog(this, _("Save Game"), "", "",
|
|
||||||
"PGN files (*.pgn)|*.pgn", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
|
||||||
if (newFileDialog.ShowModal() == wxID_CANCEL)
|
|
||||||
return;
|
|
||||||
// Create and open new db
|
|
||||||
related_file = newFileDialog.GetPath().ToStdString();
|
|
||||||
}
|
|
||||||
SaveGame(related_file,game);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameTabLeftPanel::PreviousMove(bool isKeyDown) {
|
void GameTabLeftPanel::PreviousMove(bool isKeyDown) {
|
||||||
if(isKeyDown){
|
if(isKeyDown){
|
||||||
|
|
|
@ -15,7 +15,6 @@ class GameTabLeftPanel : public TabGameLeftPanel {
|
||||||
void NotifyEditor();
|
void NotifyEditor();
|
||||||
std::string last_absolute_move;
|
std::string last_absolute_move;
|
||||||
bool repeat;
|
bool repeat;
|
||||||
std::string related_file;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
|
GameTabLeftPanel(wxFrame *parent, std::shared_ptr<Game> game);
|
||||||
|
@ -29,5 +28,5 @@ public:
|
||||||
void OnSwap(wxCommandEvent &event);
|
void OnSwap(wxCommandEvent &event);
|
||||||
void OnRefreshBoard(wxCommandEvent &event);
|
void OnRefreshBoard(wxCommandEvent &event);
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
void OnToolClick(wxCommandEvent &event);
|
void DisableSaveTool(){game_toolbar->EnableTool(0,false);};
|
||||||
};
|
};
|
|
@ -39,4 +39,5 @@ long TabInfos::tab_count=0;
|
||||||
void TabInfos::Link(TabInfos *tab){
|
void TabInfos::Link(TabInfos *tab){
|
||||||
this->is_linked=true;
|
this->is_linked=true;
|
||||||
this->linked_id=tab->id;
|
this->linked_id=tab->id;
|
||||||
|
this->OnLink();
|
||||||
}
|
}
|
|
@ -56,6 +56,8 @@ public:
|
||||||
TabInfos(Type type_) : type(type_), id(tab_count), is_linked(false) { tab_count++; }
|
TabInfos(Type type_) : type(type_), id(tab_count), is_linked(false) { tab_count++; }
|
||||||
void Link(TabInfos *tab);
|
void Link(TabInfos *tab);
|
||||||
virtual void Refresh(){};
|
virtual void Refresh(){};
|
||||||
|
/// @brief Call when tab is linked to another one
|
||||||
|
virtual void OnLink(){};
|
||||||
virtual void ApplyPreferences() {};
|
virtual void ApplyPreferences() {};
|
||||||
virtual std::shared_ptr<Game> GetGame() = 0;
|
virtual std::shared_ptr<Game> GetGame() = 0;
|
||||||
virtual std::shared_ptr<GameBase> GetBase() = 0;
|
virtual std::shared_ptr<GameBase> GetBase() = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue