Merge pull request #761 from archshift/better-toolbar

Changed main toolbar to be flush with the rest of the window.
This commit is contained in:
shuffle2 2014-08-11 20:12:24 -07:00
commit 0b27e0f3f0
6 changed files with 90 additions and 212 deletions

View File

@ -20,6 +20,7 @@
#include <wx/textctrl.h>
#include <wx/textdlg.h>
#include <wx/thread.h>
#include <wx/toolbar.h>
#include <wx/translation.h>
#include <wx/window.h>
#include <wx/windowid.h>
@ -128,9 +129,9 @@ wxMenuBar *CCodeWindow::GetMenuBar()
return Parent->GetMenuBar();
}
wxAuiToolBar *CCodeWindow::GetToolBar()
wxToolBar *CCodeWindow::GetToolBar()
{
return Parent->m_ToolBarDebug;
return Parent->m_ToolBar;
}
// ----------
@ -435,6 +436,22 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParam
pDebugMenu->Append(IDM_STEP, _("Step &Into\tF11"));
pDebugMenu->Append(IDM_STEPOVER, _("Step &Over\tF10"));
pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _("Toggle &Breakpoint\tF9"));
pDebugMenu->AppendSeparator();
wxMenu* pPerspectives = new wxMenu;
Parent->m_SavedPerspectives = new wxMenu;
pDebugMenu->AppendSubMenu(pPerspectives, _("Perspectives"), _("Edit Perspectives"));
pPerspectives->Append(IDM_SAVE_PERSPECTIVE, _("Save perspectives"), _("Save currently-toggled perspectives"));
pPerspectives->Append(IDM_EDIT_PERSPECTIVES, _("Edit perspectives"), _("Toggle editing of perspectives"), wxITEM_CHECK);
pPerspectives->AppendSeparator();
pPerspectives->Append(IDM_ADD_PERSPECTIVE, _("Create new perspective"));
pPerspectives->AppendSubMenu(Parent->m_SavedPerspectives, _("Saved perspectives"));
Parent->PopulateSavedPerspectives();
pPerspectives->AppendSeparator();
pPerspectives->Append(IDM_PERSPECTIVES_ADD_PANE, _("Add new pane"));
pPerspectives->Append(IDM_TAB_SPLIT, _("Tab split"), "", wxITEM_CHECK);
pPerspectives->Append(IDM_NO_DOCKING, _("Disable docking"), "Disable docking of perspective panes to main window", wxITEM_CHECK);
pMenuBar->Append(pDebugMenu, _("&Debug"));
@ -587,7 +604,7 @@ void CCodeWindow::InitBitmaps()
bitmap = wxBitmap(bitmap.ConvertToImage().Scale(24, 24));
}
void CCodeWindow::PopulateToolbar(wxAuiToolBar* toolBar)
void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
{
int w = m_Bitmaps[0].GetWidth(),
h = m_Bitmaps[0].GetHeight();
@ -624,7 +641,7 @@ void CCodeWindow::UpdateButtonStates()
bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED);
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
bool Stepping = CCPU::IsStepping();
wxAuiToolBar* ToolBar = GetToolBar();
wxToolBar* ToolBar = GetToolBar();
// Toolbar
if (!ToolBar)

View File

@ -27,7 +27,7 @@ class DSPDebuggerLLE;
class GFXDebuggerPanel;
struct SCoreStartupParameter;
class wxAuiToolBar;
class wxToolBar;
class wxListBox;
class wxMenu;
class wxMenuBar;
@ -52,7 +52,7 @@ class CCodeWindow
// Parent interaction
CFrame *Parent;
wxMenuBar * GetMenuBar();
wxAuiToolBar * GetToolBar();
wxToolBar * GetToolBar();
wxBitmap m_Bitmaps[ToolbarDebugBitmapMax];
bool UseInterpreter();
@ -67,8 +67,8 @@ class CCodeWindow
void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter, wxMenuBar *pMenuBar);
void CreateMenuOptions(wxMenu *pMenu);
void CreateMenuSymbols(wxMenuBar *pMenuBar);
void RecreateToolbar(wxAuiToolBar*);
void PopulateToolbar(wxAuiToolBar* toolBar);
void RecreateToolbar(wxToolBar*);
void PopulateToolbar(wxToolBar* toolBar);
void UpdateButtonStates();
void OpenPages();
void UpdateManager();

View File

@ -41,7 +41,6 @@
#include <wx/translation.h>
#include <wx/window.h>
#include <wx/windowid.h>
#include <wx/aui/auibar.h>
#include <wx/aui/auibook.h>
#include <wx/aui/framemanager.h>
@ -227,16 +226,14 @@ EVT_MENU(IDM_CONFIG_PAD_PLUGIN, CFrame::OnConfigPAD)
EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN, CFrame::OnConfigWiimote)
EVT_MENU(IDM_CONFIG_HOTKEYS, CFrame::OnConfigHotkey)
EVT_MENU(IDM_SAVE_PERSPECTIVE, CFrame::OnToolBar)
EVT_AUITOOLBAR_TOOL_DROPDOWN(IDM_SAVE_PERSPECTIVE, CFrame::OnDropDownToolbarItem)
EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnToolBar)
EVT_AUITOOLBAR_TOOL_DROPDOWN(IDM_EDIT_PERSPECTIVES, CFrame::OnDropDownSettingsToolbar)
EVT_MENU(IDM_SAVE_PERSPECTIVE, CFrame::OnPerspectiveMenu)
EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnPerspectiveMenu)
// Drop down
EVT_MENU(IDM_PERSPECTIVES_ADD_PANE, CFrame::OnToolBar)
EVT_MENU(IDM_PERSPECTIVES_ADD_PANE, CFrame::OnPerspectiveMenu)
EVT_MENU_RANGE(IDM_PERSPECTIVES_0, IDM_PERSPECTIVES_100, CFrame::OnSelectPerspective)
EVT_MENU(IDM_ADD_PERSPECTIVE, CFrame::OnDropDownToolbarSelect)
EVT_MENU(IDM_TAB_SPLIT, CFrame::OnDropDownToolbarSelect)
EVT_MENU(IDM_NO_DOCKING, CFrame::OnDropDownToolbarSelect)
EVT_MENU(IDM_ADD_PERSPECTIVE, CFrame::OnPerspectiveMenu)
EVT_MENU(IDM_TAB_SPLIT, CFrame::OnPerspectiveMenu)
EVT_MENU(IDM_NO_DOCKING, CFrame::OnPerspectiveMenu)
// Drop down float
EVT_MENU_RANGE(IDM_FLOAT_LOGWINDOW, IDM_FLOAT_CODEWINDOW, CFrame::OnFloatWindow)
@ -310,7 +307,7 @@ CFrame::CFrame(wxFrame* parent,
long style)
: CRenderFrame(parent, id, title, pos, size, style)
, g_pCodeWindow(nullptr), g_NetPlaySetupDiag(nullptr), g_CheatsWindow(nullptr)
, m_ToolBar(nullptr), m_ToolBarDebug(nullptr), m_ToolBarAui(nullptr)
, m_SavedPerspectives(nullptr), m_ToolBar(nullptr)
, m_GameListCtrl(nullptr), m_Panel(nullptr)
, m_RenderFrame(nullptr), m_RenderParent(nullptr)
, m_LogWindow(nullptr), m_LogConfigWindow(nullptr)

View File

@ -44,8 +44,6 @@ class wxAuiManager;
class wxAuiManagerEvent;
class wxAuiNotebook;
class wxAuiNotebookEvent;
class wxAuiToolBar;
class wxAuiToolBarEvent;
class wxListEvent;
class wxMenuItem;
class wxWindow;
@ -124,6 +122,7 @@ public:
void DoFullscreen(bool bF);
void ToggleDisplayMode (bool bFullscreen);
void UpdateWiiMenuChoice(wxMenuItem *WiiMenuItem=nullptr);
void PopulateSavedPerspectives();
static void ConnectWiimote(int wm_idx, bool connect);
const CGameListCtrl *GetGameListCtrl() const;
@ -138,9 +137,11 @@ public:
X11Utils::XRRConfiguration *m_XRRConfig;
#endif
wxMenu* m_SavedPerspectives;
wxToolBar *m_ToolBar;
// AUI
wxAuiManager *m_Mgr;
wxAuiToolBar *m_ToolBar, *m_ToolBarDebug, *m_ToolBarAui;
bool bFloatWindow[IDM_CODEWINDOW - IDM_LOGWINDOW + 1];
// Perspectives (Should find a way to make all of this private)
@ -195,8 +196,7 @@ private:
wxBitmap m_Bitmaps[EToolbar_Max];
wxBitmap m_BitmapsMenu[EToolbar_Max];
void PopulateToolbar(wxAuiToolBar* toolBar);
void PopulateToolbarAui(wxAuiToolBar* toolBar);
void PopulateToolbar(wxToolBar* toolBar);
void RecreateToolbar();
void CreateMenu();
@ -221,7 +221,6 @@ private:
void ShowResizePane();
void TogglePane();
void SetPaneSize();
void ResetToolbarStyle();
void TogglePaneStyle(bool On, int EventId);
void ToggleNotebookStyle(bool On, long Style);
// Float window
@ -240,9 +239,7 @@ private:
void OnPaneClose(wxAuiManagerEvent& evt);
void ReloadPanes();
void DoLoadPerspective();
void OnDropDownToolbarSelect(wxCommandEvent& event);
void OnDropDownSettingsToolbar(wxAuiToolBarEvent& event);
void OnDropDownToolbarItem(wxAuiToolBarEvent& event);
void OnPerspectiveMenu(wxCommandEvent& event);
void OnSelectPerspective(wxCommandEvent& event);
#ifdef _WIN32
@ -252,8 +249,6 @@ private:
// Event functions
void OnQuit(wxCommandEvent& event);
void OnHelp(wxCommandEvent& event);
void OnToolBar(wxCommandEvent& event);
void OnAuiToolBar(wxAuiToolBarEvent& event);
void OnOpen(wxCommandEvent& event); // File menu
void DoOpen(bool Boot);

View File

@ -475,72 +475,26 @@ void CFrame::DoAddPage(wxWindow *Win, int i, bool Float)
Win->GetName(), Win);
}
// Toolbar
void CFrame::OnDropDownSettingsToolbar(wxAuiToolBarEvent& event)
void CFrame::PopulateSavedPerspectives()
{
event.Skip();
ClearStatusBar();
// If the perspective submenu hasn't been created yet, return
if (!m_SavedPerspectives) return;
if (event.IsDropDownClicked())
// Delete all saved perspective menu items
while (m_SavedPerspectives->GetMenuItemCount() != 0)
{
wxAuiToolBar* Tb = static_cast<wxAuiToolBar*>(event.GetEventObject());
Tb->SetToolSticky(event.GetId(), true);
// Create the popup menu
wxMenu* menuPopup = new wxMenu;
wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_ADD_PANE,
_("Add new pane"));
menuPopup->Append(Item);
menuPopup->Append(new wxMenuItem(menuPopup));
Item = new wxMenuItem(menuPopup, IDM_TAB_SPLIT, _("Tab split"), "", wxITEM_CHECK);
menuPopup->Append(Item);
Item->Check(m_bTabSplit);
Item = new wxMenuItem(menuPopup, IDM_NO_DOCKING, _("No docking"), "", wxITEM_CHECK);
menuPopup->Append(Item);
Item->Check(m_bNoDocking);
// Line up our menu with the button
wxRect rect = Tb->GetToolRect(event.GetId());
wxPoint Pt = Tb->ClientToScreen(rect.GetBottomLeft());
Pt = ScreenToClient(Pt);
// Show
PopupMenu(menuPopup, Pt);
// Make the button un-stuck again
if (!m_bEdit)
{
Tb->SetToolSticky(event.GetId(), false);
// Delete the first menu item in the list (while there are menu items)
m_SavedPerspectives->Delete(m_SavedPerspectives->FindItemByPosition(0));
}
}
}
void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event)
{
event.Skip();
ClearStatusBar();
if (event.IsDropDownClicked())
{
wxAuiToolBar* tb = static_cast<wxAuiToolBar*>(event.GetEventObject());
tb->SetToolSticky(event.GetId(), true);
// create the popup menu
wxMenu* menuPopup = new wxMenu;
wxMenuItem* Item = new wxMenuItem(menuPopup, IDM_ADD_PERSPECTIVE,
_("Create new perspective"));
menuPopup->Append(Item);
if (Perspectives.size() > 0)
{
menuPopup->Append(new wxMenuItem(menuPopup));
for (u32 i = 0; i < Perspectives.size(); i++)
{
wxMenuItem* mItem = new wxMenuItem(menuPopup, IDM_PERSPECTIVES_0 + i,
wxMenuItem* mItem = new wxMenuItem(m_SavedPerspectives, IDM_PERSPECTIVES_0 + i,
StrToWxStr(Perspectives[i].Name), "", wxITEM_CHECK);
menuPopup->Append(mItem);
m_SavedPerspectives->Append(mItem);
if (i == ActivePerspective)
{
@ -548,21 +502,9 @@ void CFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& event)
}
}
}
// line up our menu with the button
wxRect rect = tb->GetToolRect(event.GetId());
wxPoint pt = tb->ClientToScreen(rect.GetBottomLeft());
pt = ScreenToClient(pt);
// show
PopupMenu(menuPopup, pt);
// make sure the button is "un-stuck"
tb->SetToolSticky(event.GetId(), false);
}
}
void CFrame::OnToolBar(wxCommandEvent& event)
void CFrame::OnPerspectiveMenu(wxCommandEvent& event)
{
ClearStatusBar();
@ -583,26 +525,15 @@ void CFrame::OnToolBar(wxCommandEvent& event)
AddPane();
break;
case IDM_EDIT_PERSPECTIVES:
m_bEdit = !m_bEdit;
m_ToolBarAui->SetToolSticky(IDM_EDIT_PERSPECTIVES, m_bEdit);
m_bEdit = event.IsChecked();
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
break;
}
}
void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event)
{
ClearStatusBar();
switch (event.GetId())
{
case IDM_ADD_PERSPECTIVE:
{
wxTextEntryDialog dlg(this,
_("Enter a name for the new perspective:"),
_("Create new perspective"));
wxString DefaultValue = wxString::Format(_("Perspective %d"),
Perspectives.size() + 1);
wxString DefaultValue = wxString::Format(_("Perspective %d"), (int)(Perspectives.size() + 1));
dlg.SetValue(DefaultValue);
int Return = 0;
@ -643,6 +574,7 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event)
Perspectives.push_back(Tmp);
UpdateCurrentPerspective();
PopulateSavedPerspectives();
}
break;
case IDM_TAB_SPLIT:
@ -656,26 +588,6 @@ void CFrame::OnDropDownToolbarSelect(wxCommandEvent& event)
}
}
void CFrame::ResetToolbarStyle()
{
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i)
{
wxAuiPaneInfo& Pane = AllPanes[i];
if (Pane.window->IsKindOf(CLASSINFO(wxAuiToolBar)))
{
Pane.Show();
// Show all of it
if (Pane.rect.GetLeft() > GetClientSize().GetX() - 50)
{
Pane.Position(GetClientSize().GetX() - Pane.window->GetClientSize().GetX());
}
}
}
m_Mgr->Update();
}
void CFrame::TogglePaneStyle(bool On, int EventId)
{
wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes();
@ -798,8 +710,6 @@ void CFrame::ReloadPanes()
// Perspectives
m_Mgr->LoadPerspective(Perspectives[ActivePerspective].Perspective, false);
// Reset toolbars
ResetToolbarStyle();
// Restore settings
TogglePaneStyle(m_bNoDocking, IDM_NO_DOCKING);
TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
@ -809,6 +719,9 @@ void CFrame::ReloadPanes()
// Open notebook pages
AddRemoveBlankPage();
g_pCodeWindow->OpenPages();
// Repopulate perspectives
PopulateSavedPerspectives();
}
void CFrame::DoLoadPerspective()

View File

@ -36,11 +36,11 @@ Core::GetWindowHandle().
#include <wx/strconv.h>
#include <wx/string.h>
#include <wx/thread.h>
#include <wx/toolbar.h>
#include <wx/toplevel.h>
#include <wx/translation.h>
#include <wx/utils.h>
#include <wx/window.h>
#include <wx/aui/auibar.h>
#include <wx/aui/framemanager.h>
#ifdef __APPLE__
@ -501,7 +501,7 @@ wxString CFrame::GetMenuLabel(int Id)
// Create toolbar items
// ---------------------
void CFrame::PopulateToolbar(wxAuiToolBar* ToolBar)
void CFrame::PopulateToolbar(wxToolBar* ToolBar)
{
int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(),
h = m_Bitmaps[Toolbar_FileOpen].GetHeight();
@ -528,21 +528,6 @@ void CFrame::PopulateToolbar(wxAuiToolBar* ToolBar)
ToolBar->Realize();
}
void CFrame::PopulateToolbarAui(wxAuiToolBar* ToolBar)
{
int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(),
h = m_Bitmaps[Toolbar_FileOpen].GetHeight();
ToolBar->SetToolBitmapSize(wxSize(w, h));
ToolBar->AddTool(IDM_SAVE_PERSPECTIVE, _("Save"), g_pCodeWindow->m_Bitmaps[Toolbar_GotoPC], _("Save current perspective"));
ToolBar->AddTool(IDM_EDIT_PERSPECTIVES, _("Edit"), g_pCodeWindow->m_Bitmaps[Toolbar_GotoPC], _("Edit current perspective"));
ToolBar->SetToolDropDown(IDM_SAVE_PERSPECTIVE, true);
ToolBar->SetToolDropDown(IDM_EDIT_PERSPECTIVES, true);
ToolBar->Realize();
}
// Delete and recreate the toolbar
void CFrame::RecreateToolbar()
@ -553,32 +538,19 @@ void CFrame::RecreateToolbar()
m_ToolBar->Destroy();
}
long TOOLBAR_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT /*wxAUI_TB_OVERFLOW overflow visible*/;
m_ToolBar = new wxAuiToolBar(this, ID_TOOLBAR, wxDefaultPosition, wxDefaultSize, TOOLBAR_STYLE);
long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT;
if (!m_ToolBar)
{
m_ToolBar = CreateToolBar(TOOLBAR_STYLE, wxID_ANY, "TBMain");
if (g_pCodeWindow)
{
g_pCodeWindow->PopulateToolbar(m_ToolBar);
m_ToolBar->AddSeparator();
}
PopulateToolbar(m_ToolBar);
m_Mgr->AddPane(m_ToolBar, wxAuiPaneInfo().
Name("TBMain").Caption("TBMain").
ToolbarPane().Top().
LeftDockable(false).RightDockable(false).Floatable(false));
if (g_pCodeWindow && !m_ToolBarDebug)
{
m_ToolBarDebug = new wxAuiToolBar(this, ID_TOOLBAR_DEBUG, wxDefaultPosition, wxDefaultSize, TOOLBAR_STYLE);
g_pCodeWindow->PopulateToolbar(m_ToolBarDebug);
m_Mgr->AddPane(m_ToolBarDebug, wxAuiPaneInfo().
Name("TBDebug").Caption("TBDebug").
ToolbarPane().Top().
LeftDockable(false).RightDockable(false).Floatable(false));
m_ToolBarAui = new wxAuiToolBar(this, ID_TOOLBAR_AUI, wxDefaultPosition, wxDefaultSize, TOOLBAR_STYLE);
PopulateToolbarAui(m_ToolBarAui);
m_Mgr->AddPane(m_ToolBarAui, wxAuiPaneInfo().
Name("TBAui").Caption("TBAui").
ToolbarPane().Top().
LeftDockable(false).RightDockable(false).Floatable(false));
}
UpdateGUI();
@ -1721,22 +1693,25 @@ void CFrame::UpdateGUI()
AccessWiiMote(0x0104)->IsConnected());
}
if (Running)
{
if (m_ToolBar)
{
m_ToolBar->SetToolBitmap(IDM_PLAY, m_Bitmaps[Toolbar_Pause]);
m_ToolBar->SetToolShortHelp(IDM_PLAY, _("Pause"));
m_ToolBar->SetToolLabel(IDM_PLAY, _("Pause"));
}
// Get the tool that controls pausing/playing
wxToolBarToolBase * PlayTool = m_ToolBar->FindById(IDM_PLAY);
if (PlayTool)
{
if (Running)
{
PlayTool->SetLabel(_("Pause"));
PlayTool->SetShortHelp(_("Pause"));
m_ToolBar->SetToolNormalBitmap(IDM_PLAY, m_Bitmaps[Toolbar_Pause]);
}
else
{
if (m_ToolBar)
{
m_ToolBar->SetToolBitmap(IDM_PLAY, m_Bitmaps[Toolbar_Play]);
m_ToolBar->SetToolShortHelp(IDM_PLAY, _("Play"));
m_ToolBar->SetToolLabel(IDM_PLAY, _("Play"));
PlayTool->SetLabel(_("Play"));
PlayTool->SetShortHelp(_("Play"));
m_ToolBar->SetToolNormalBitmap(IDM_PLAY, m_Bitmaps[Toolbar_Play]);
}
}
}
@ -1898,26 +1873,7 @@ void CFrame::OnToggleToolbar(wxCommandEvent& event)
}
void CFrame::DoToggleToolbar(bool _show)
{
if (_show)
{
m_Mgr->GetPane("TBMain").Show();
if (g_pCodeWindow)
{
m_Mgr->GetPane("TBDebug").Show();
m_Mgr->GetPane("TBAui").Show();
}
m_Mgr->Update();
}
else
{
m_Mgr->GetPane("TBMain").Hide();
if (g_pCodeWindow)
{
m_Mgr->GetPane("TBDebug").Hide();
m_Mgr->GetPane("TBAui").Hide();
}
m_Mgr->Update();
}
GetToolBar()->Show(_show);
}
// Enable and disable the status bar