Skip to content

Commit

Permalink
Windows: revert back to clGenericNotebook on Windows due to very no…
Browse files Browse the repository at this point in the history
…ticeable slowness when using `wxAuiNotebook`
  • Loading branch information
eranif committed Apr 15, 2024
1 parent 903353c commit da96839
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
16 changes: 15 additions & 1 deletion Interfaces/imanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ class NavMgr;
class IMacroManager;
class wxAuiManager;
class clInfoBar;
class clGenericNotebook;
class clAuiBook;

#ifdef __WXMSW__
#define MAINBOOK_AUIBOOK 0
#else
#define MAINBOOK_AUIBOOK 1
#endif

#if MAINBOOK_AUIBOOK
using MainNotebook = clAuiBook;
#else
using MainNotebook = clGenericNotebook;
#endif

//--------------------------
// Auxulary class
Expand Down Expand Up @@ -273,7 +287,7 @@ class IManager
/**
* @brief return the main editor notebook
*/
virtual wxAuiNotebook* GetMainNotebook() = 0;
virtual MainNotebook* GetMainNotebook() = 0;

/**
* @brief append text line to the tab in the "Output View"
Expand Down
15 changes: 14 additions & 1 deletion LiteEditor/mainbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@ void MainBook::CreateGuiControls()
{
wxBoxSizer* sz = new wxBoxSizer(wxVERTICAL);
SetSizer(sz);

#if MAINBOOK_AUIBOOK
long style = wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_MOVE | wxAUI_NB_CLOSE_ON_ACTIVE_TAB |
wxAUI_NB_WINDOWLIST_BUTTON | wxAUI_NB_SCROLL_BUTTONS | wxAUI_NB_MIDDLE_CLICK_CLOSE;

if (!EditorConfigST::Get()->GetOptions()->IsTabHasXButton()) {
style &= ~wxAUI_NB_CLOSE_ON_ALL_TABS;
style &= ~wxAUI_NB_CLOSE_ON_ACTIVE_TAB;
}
#else
long style = kNotebook_NewButton | kNotebook_AllowDnD | kNotebook_CloseButtonOnActiveTab |
kNotebook_ShowFileListButton | kNotebook_EnableNavigationEvent;
#endif

// load the notebook style from the configuration settings
m_book = new clAuiBook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
m_book = new MainNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
sz->Add(m_book, 1, wxEXPAND);
sz->Layout();
}
Expand Down Expand Up @@ -314,7 +320,9 @@ void MainBook::SaveSession(SessionEntry& session, wxArrayInt* excludeArr) { Crea

void MainBook::DoRestoreSession(const SessionEntry& session)
{
#if MAINBOOK_AUIBOOK
clAuiBookEventsDisabler events_disabler{ m_book };
#endif

size_t sel = session.GetSelectedTab();
clEditor* active_editor = nullptr;
Expand Down Expand Up @@ -351,9 +359,12 @@ void MainBook::DoRestoreSession(const SessionEntry& session)
}
}
SelectPage(active_editor);

#if MAINBOOK_AUIBOOK
// now that all the pages have been loaded into the book, ensure that our Ctrl-TAB window
// will display all of them
m_book->UpdateHistory();
#endif
}

void MainBook::RestoreSession(const SessionEntry& session)
Expand Down Expand Up @@ -999,7 +1010,9 @@ bool MainBook::CloseAll(bool cancellable)
}

// Delete the files without notifications (it will be faster)
#if MAINBOOK_AUIBOOK
clAuiBookEventsDisabler events_disabler{ m_book };
#endif

SendCmdEvent(wxEVT_ALL_EDITORS_CLOSING);

Expand Down
4 changes: 2 additions & 2 deletions LiteEditor/mainbook.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MainBook : public wxPanel
private:
FileHistory m_recentFiles;
clEditorBar* m_navBar;
clAuiBook* m_book = nullptr;
MainNotebook* m_book = nullptr;
bool m_useBuffereLimit;
bool m_isWorkspaceReloading;
bool m_reloadingDoRaise; // Prevents multiple Raises() during RestoreSession()
Expand Down Expand Up @@ -289,7 +289,7 @@ class MainBook : public wxPanel
void SetUseBuffereLimit(bool useBuffereLimit) { this->m_useBuffereLimit = useBuffereLimit; }
bool GetUseBuffereLimit() const { return m_useBuffereLimit; }

clAuiBook* GetNotebook() { return m_book; }
MainNotebook* GetNotebook() { return m_book; }
};

#endif // MAINBOOK_H
2 changes: 1 addition & 1 deletion LiteEditor/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ clTreeCtrl* PluginManager::GetWorkspaceTree() { return clMainFrame::Get()->GetWo

clTreeCtrl* PluginManager::GetFileExplorerTree() { return clMainFrame::Get()->GetFileExplorer()->GetTree(); }

clAuiBook* PluginManager::GetMainNotebook() { return clMainFrame::Get()->GetMainBook()->GetNotebook(); }
MainNotebook* PluginManager::GetMainNotebook() { return clMainFrame::Get()->GetMainBook()->GetNotebook(); }

IEditor* PluginManager::OpenFile(const wxString& fileName, const wxString& bmpResourceName, const wxString& tooltip)
{
Expand Down
2 changes: 1 addition & 1 deletion LiteEditor/pluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class PluginManager : public IManager
TreeItemInfo GetSelectedTreeItemInfo(TreeType type) override;
clTreeCtrl* GetFileExplorerTree() override;
clTreeCtrl* GetWorkspaceTree() override;
clAuiBook* GetMainNotebook() override;
MainNotebook* GetMainNotebook() override;
IEditor* OpenFile(const wxString& fileName, const wxString& projectName = wxEmptyString, int lineno = wxNOT_FOUND,
OF_extra flags = OF_AddJump) override;
IEditor* OpenFile(const wxString& fileName, const wxString& bmpResourceName,
Expand Down

0 comments on commit da96839

Please sign in to comment.