mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Update tab management system
This commit is contained in:
parent
5df6e9395c
commit
29f330f307
9 changed files with 83 additions and 3 deletions
|
@ -53,6 +53,7 @@ MainWindow::MainWindow()
|
||||||
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
|
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
|
||||||
Bind(REFRESH_ENGINE_LIST, &MainWindow::OnRefreshEngineList, this, wxID_ANY);
|
Bind(REFRESH_ENGINE_LIST, &MainWindow::OnRefreshEngineList, this, wxID_ANY);
|
||||||
Bind(CLOSE_LINKED_TAB, &MainWindow::OnCloseTabLinkedTo, this, wxID_ANY);
|
Bind(CLOSE_LINKED_TAB, &MainWindow::OnCloseTabLinkedTo, this, wxID_ANY);
|
||||||
|
Bind(wxEVT_AUINOTEBOOK_PAGE_CLOSED, &MainWindow::OnAuiNotebookPageClosed, this, wxID_ANY);
|
||||||
|
|
||||||
// Add new game tab by default
|
// Add new game tab by default
|
||||||
NewGame(std::shared_ptr<Game>(new Game()));
|
NewGame(std::shared_ptr<Game>(new Game()));
|
||||||
|
@ -66,10 +67,19 @@ void MainWindow::AddPage(wxWindow* window, TabInfos* infos){
|
||||||
window->SetClientData(infos);
|
window->SetClientData(infos);
|
||||||
notebook->AddPage(window, window->GetLabel());
|
notebook->AddPage(window, window->GetLabel());
|
||||||
notebook->SetSelection(notebook->GetPageIndex(window));
|
notebook->SetSelection(notebook->GetPageIndex(window));
|
||||||
|
// Refresh tab that require knowledge on other tabs
|
||||||
|
for(auto i: wxGetApp().ListTabInfos()){i->Refresh();}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::OnAuiNotebookPageClosed(wxAuiNotebookEvent& event){
|
||||||
|
// Refresh tab that require knowledge on other tabs
|
||||||
|
for(auto i: wxGetApp().ListTabInfos()){i->Refresh();}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
||||||
notebook->DeletePage(notebook->GetSelection());
|
notebook->DeletePage(notebook->GetSelection());
|
||||||
|
// Refresh tab that require knowledge on other tabs
|
||||||
|
for(auto i: wxGetApp().ListTabInfos()){i->Refresh();}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnCloseTabLinkedTo(wxCommandEvent &event){
|
void MainWindow::OnCloseTabLinkedTo(wxCommandEvent &event){
|
||||||
|
|
|
@ -29,6 +29,7 @@ class MainWindow : public MainFrame {
|
||||||
void OnCloseTabEvent(wxCommandEvent &event);
|
void OnCloseTabEvent(wxCommandEvent &event);
|
||||||
void OnRefreshEngineList(wxCommandEvent &event);
|
void OnRefreshEngineList(wxCommandEvent &event);
|
||||||
void OnMenuItemClick(wxCommandEvent &event);
|
void OnMenuItemClick(wxCommandEvent &event);
|
||||||
|
void OnAuiNotebookPageClosed(wxAuiNotebookEvent& event);
|
||||||
void OnCloseTabLinkedTo(wxCommandEvent &event);
|
void OnCloseTabLinkedTo(wxCommandEvent &event);
|
||||||
void AddPage(wxWindow* window, TabInfos* infos);
|
void AddPage(wxWindow* window, TabInfos* infos);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -7,6 +7,8 @@ RefreshImportLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseImportTab::RefreshImportLists(){
|
void BaseImportTab::RefreshImportLists(){
|
||||||
|
opened_game_list->Clear();
|
||||||
|
opened_db_list->Clear();
|
||||||
for (TabInfos *i : wxGetApp().ListTabInfos()) {
|
for (TabInfos *i : wxGetApp().ListTabInfos()) {
|
||||||
if (i->type == TabInfos::GAME) {
|
if (i->type == TabInfos::GAME) {
|
||||||
wxWindow *win = dynamic_cast<wxWindow *>(i);
|
wxWindow *win = dynamic_cast<wxWindow *>(i);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "ochess.hpp"
|
#include "ochess.hpp"
|
||||||
|
|
||||||
class BaseImportTab : public TabBase_TabImport {
|
class BaseImportTab : public TabBase_TabImport {
|
||||||
|
|
||||||
TabInfos *main_tab;
|
TabInfos *main_tab;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -23,4 +23,5 @@ public:
|
||||||
void RefreshLabel();
|
void RefreshLabel();
|
||||||
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>(base)); };
|
std::shared_ptr<GameBase> GetBase() { return (std::shared_ptr<GameBase>(base)); };
|
||||||
|
void Refresh() {import_tab->RefreshImportLists();};
|
||||||
};
|
};
|
|
@ -616,10 +616,14 @@ TabBase_TabImport::TabBase_TabImport( wxWindow* parent, wxWindowID id, const wxP
|
||||||
wxBoxSizer* bSizer33;
|
wxBoxSizer* bSizer33;
|
||||||
bSizer33 = new wxBoxSizer( wxHORIZONTAL );
|
bSizer33 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
m_staticText29 = new wxStaticText( this, wxID_ANY, wxT("Database:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_staticText29->Wrap( -1 );
|
||||||
|
bSizer33->Add( m_staticText29, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
opened_db_list = new wxComboBox( this, wxID_ANY, wxT("No other databases opened"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
opened_db_list = new wxComboBox( this, wxID_ANY, wxT("No other databases opened"), wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||||
bSizer33->Add( opened_db_list, 100, wxALL|wxEXPAND, 5 );
|
bSizer33->Add( opened_db_list, 100, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
import_from_db_button = new wxButton( this, wxID_ANY, wxT("Import Selected Games"), wxDefaultPosition, wxDefaultSize, 0 );
|
import_from_db_button = new wxButton( this, wxID_ANY, wxT("Import Selection"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
bSizer33->Add( import_from_db_button, 0, wxALL, 5 );
|
bSizer33->Add( import_from_db_button, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -342,6 +342,7 @@ class TabBase_TabImport : public wxPanel
|
||||||
wxButton* import_from_game_button;
|
wxButton* import_from_game_button;
|
||||||
wxStaticLine* m_staticline4;
|
wxStaticLine* m_staticline4;
|
||||||
wxStaticText* from_db_label;
|
wxStaticText* from_db_label;
|
||||||
|
wxStaticText* m_staticText29;
|
||||||
wxComboBox* opened_db_list;
|
wxComboBox* opened_db_list;
|
||||||
wxButton* import_from_db_button;
|
wxButton* import_from_db_button;
|
||||||
wxListCtrl* game_list;
|
wxListCtrl* game_list;
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
bool is_linked;
|
bool is_linked;
|
||||||
TabInfos(Type type_) : type(type_), id(tab_count), is_linked(false) { tab_count++; wxLogDebug("Tabid=%d",(int)id); }
|
TabInfos(Type type_) : type(type_), id(tab_count), is_linked(false) { tab_count++; wxLogDebug("Tabid=%d",(int)id); }
|
||||||
void Link(TabInfos *tab);
|
void Link(TabInfos *tab);
|
||||||
|
virtual void Refresh(){};
|
||||||
virtual void ApplyPreferences() = 0;
|
virtual void ApplyPreferences() = 0;
|
||||||
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;
|
||||||
|
|
|
@ -6244,6 +6244,67 @@
|
||||||
<property name="name">bSizer33</property>
|
<property name="name">bSizer33</property>
|
||||||
<property name="orient">wxHORIZONTAL</property>
|
<property name="orient">wxHORIZONTAL</property>
|
||||||
<property name="permission">none</property>
|
<property name="permission">none</property>
|
||||||
|
<object class="sizeritem" expanded="1">
|
||||||
|
<property name="border">5</property>
|
||||||
|
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALL</property>
|
||||||
|
<property name="proportion">0</property>
|
||||||
|
<object class="wxStaticText" expanded="1">
|
||||||
|
<property name="BottomDockable">1</property>
|
||||||
|
<property name="LeftDockable">1</property>
|
||||||
|
<property name="RightDockable">1</property>
|
||||||
|
<property name="TopDockable">1</property>
|
||||||
|
<property name="aui_layer"></property>
|
||||||
|
<property name="aui_name"></property>
|
||||||
|
<property name="aui_position"></property>
|
||||||
|
<property name="aui_row"></property>
|
||||||
|
<property name="best_size"></property>
|
||||||
|
<property name="bg"></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="default_pane">0</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="font"></property>
|
||||||
|
<property name="gripper">0</property>
|
||||||
|
<property name="hidden">0</property>
|
||||||
|
<property name="id">wxID_ANY</property>
|
||||||
|
<property name="label">Database:</property>
|
||||||
|
<property name="markup">0</property>
|
||||||
|
<property name="max_size"></property>
|
||||||
|
<property name="maximize_button">0</property>
|
||||||
|
<property name="maximum_size"></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">m_staticText29</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="resize">Resizable</property>
|
||||||
|
<property name="show">1</property>
|
||||||
|
<property name="size"></property>
|
||||||
|
<property name="style"></property>
|
||||||
|
<property name="subclass">; ; forward_declare</property>
|
||||||
|
<property name="toolbar_pane">0</property>
|
||||||
|
<property name="tooltip"></property>
|
||||||
|
<property name="window_extra_style"></property>
|
||||||
|
<property name="window_name"></property>
|
||||||
|
<property name="window_style"></property>
|
||||||
|
<property name="wrap">-1</property>
|
||||||
|
</object>
|
||||||
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxALL|wxEXPAND</property>
|
<property name="flag">wxALL|wxEXPAND</property>
|
||||||
|
@ -6347,7 +6408,7 @@
|
||||||
<property name="gripper">0</property>
|
<property name="gripper">0</property>
|
||||||
<property name="hidden">0</property>
|
<property name="hidden">0</property>
|
||||||
<property name="id">wxID_ANY</property>
|
<property name="id">wxID_ANY</property>
|
||||||
<property name="label">Import Selected Games</property>
|
<property name="label">Import Selection</property>
|
||||||
<property name="margins"></property>
|
<property name="margins"></property>
|
||||||
<property name="markup">0</property>
|
<property name="markup">0</property>
|
||||||
<property name="max_size"></property>
|
<property name="max_size"></property>
|
||||||
|
|
Loading…
Add table
Reference in a new issue