From 12155ddee45588b2d17a36e0ac037b2d79349e8c Mon Sep 17 00:00:00 2001
From: skidau <skidau@gmail.com>
Date: Sat, 7 Mar 2015 12:33:33 +1100
Subject: [PATCH] Added the ability to split the Debugger window horizontally
 and vertically via the Add Panes menu.

---
 Source/Core/DolphinWX/Debugger/CodeWindow.cpp |  8 +++-
 Source/Core/DolphinWX/Frame.cpp               |  6 ++-
 Source/Core/DolphinWX/Frame.h                 | 19 +++++++-
 Source/Core/DolphinWX/FrameAui.cpp            | 45 ++++++++++++++++---
 Source/Core/DolphinWX/Globals.h               |  6 ++-
 5 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp
index 8c7bbb4927..23f4d5c989 100644
--- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp
+++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp
@@ -510,7 +510,13 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& core_startup_parameter
 	pPerspectives->AppendSubMenu(Parent->m_SavedPerspectives, _("Saved perspectives"));
 	Parent->PopulateSavedPerspectives();
 	pPerspectives->AppendSeparator();
-	pPerspectives->Append(IDM_PERSPECTIVES_ADD_PANE, _("Add new pane"));
+	wxMenu* pAddPane = new wxMenu;
+	pPerspectives->AppendSubMenu(pAddPane, _("Add new pane to"));
+	pAddPane->Append(IDM_PERSPECTIVES_ADD_PANE_TOP, _("Top"));
+	pAddPane->Append(IDM_PERSPECTIVES_ADD_PANE_BOTTOM, _("Bottom"));
+	pAddPane->Append(IDM_PERSPECTIVES_ADD_PANE_LEFT, _("Left"));
+	pAddPane->Append(IDM_PERSPECTIVES_ADD_PANE_RIGHT, _("Right"));
+	pAddPane->Append(IDM_PERSPECTIVES_ADD_PANE_CENTER, _("Center"));
 	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);
 
diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp
index 82a089eb7e..63b66725c3 100644
--- a/Source/Core/DolphinWX/Frame.cpp
+++ b/Source/Core/DolphinWX/Frame.cpp
@@ -278,7 +278,11 @@ EVT_MENU(IDM_CONFIG_MENU_COMMANDS, CFrame::OnConfigMenuCommands)
 EVT_MENU(IDM_SAVE_PERSPECTIVE, CFrame::OnPerspectiveMenu)
 EVT_MENU(IDM_EDIT_PERSPECTIVES, CFrame::OnPerspectiveMenu)
 // Drop down
-EVT_MENU(IDM_PERSPECTIVES_ADD_PANE, CFrame::OnPerspectiveMenu)
+EVT_MENU(IDM_PERSPECTIVES_ADD_PANE_TOP, CFrame::OnPerspectiveMenu)
+EVT_MENU(IDM_PERSPECTIVES_ADD_PANE_BOTTOM, CFrame::OnPerspectiveMenu)
+EVT_MENU(IDM_PERSPECTIVES_ADD_PANE_LEFT, CFrame::OnPerspectiveMenu)
+EVT_MENU(IDM_PERSPECTIVES_ADD_PANE_RIGHT, CFrame::OnPerspectiveMenu)
+EVT_MENU(IDM_PERSPECTIVES_ADD_PANE_CENTER, CFrame::OnPerspectiveMenu)
 EVT_MENU_RANGE(IDM_PERSPECTIVES_0, IDM_PERSPECTIVES_100, CFrame::OnSelectPerspective)
 EVT_MENU(IDM_ADD_PERSPECTIVE, CFrame::OnPerspectiveMenu)
 EVT_MENU(IDM_TAB_SPLIT, CFrame::OnPerspectiveMenu)
diff --git a/Source/Core/DolphinWX/Frame.h b/Source/Core/DolphinWX/Frame.h
index 749d1d861e..baeaa3a11c 100644
--- a/Source/Core/DolphinWX/Frame.h
+++ b/Source/Core/DolphinWX/Frame.h
@@ -196,6 +196,23 @@ private:
 		EToolbar_Max
 	};
 
+	enum
+	{
+		Toolbar_Delete,
+		Toolbar_Add_BP,
+		Toolbar_Add_MC,
+		Num_Bitmaps
+	};
+
+	enum
+	{
+		ADD_PANE_TOP,
+		ADD_PANE_BOTTOM,
+		ADD_PANE_LEFT,
+		ADD_PANE_RIGHT,
+		ADD_PANE_CENTER
+	};
+
 	wxTimer m_poll_hotkey_timer;
 
 	wxBitmap m_Bitmaps[EToolbar_Max];
@@ -239,7 +256,7 @@ private:
 			const wxString& title = "",
 			wxWindow * = nullptr);
 	wxString AuiFullscreen, AuiCurrent;
-	void AddPane();
+	void AddPane(int dir);
 	void UpdateCurrentPerspective();
 	void SaveIniPerspectives();
 	void LoadIniPerspectives();
diff --git a/Source/Core/DolphinWX/FrameAui.cpp b/Source/Core/DolphinWX/FrameAui.cpp
index f11ef1d1e6..6dc70d52c0 100644
--- a/Source/Core/DolphinWX/FrameAui.cpp
+++ b/Source/Core/DolphinWX/FrameAui.cpp
@@ -527,8 +527,20 @@ void CFrame::OnPerspectiveMenu(wxCommandEvent& event)
 			GetStatusBar()->SetStatusText(StrToWxStr(std::string
 						("Saved " + Perspectives[ActivePerspective].Name)), 0);
 			break;
-		case IDM_PERSPECTIVES_ADD_PANE:
-			AddPane();
+		case IDM_PERSPECTIVES_ADD_PANE_TOP:
+			AddPane(ADD_PANE_TOP);
+			break;
+		case IDM_PERSPECTIVES_ADD_PANE_BOTTOM:
+			AddPane(ADD_PANE_BOTTOM);
+			break;
+		case IDM_PERSPECTIVES_ADD_PANE_LEFT:
+			AddPane(ADD_PANE_LEFT);
+			break;
+		case IDM_PERSPECTIVES_ADD_PANE_RIGHT:
+			AddPane(ADD_PANE_RIGHT);
+			break;
+		case IDM_PERSPECTIVES_ADD_PANE_CENTER:
+			AddPane(ADD_PANE_CENTER);
 			break;
 		case IDM_EDIT_PERSPECTIVES:
 			m_bEdit = event.IsChecked();
@@ -877,14 +889,37 @@ void CFrame::SaveIniPerspectives()
 	TogglePaneStyle(m_bEdit, IDM_EDIT_PERSPECTIVES);
 }
 
-void CFrame::AddPane()
+void CFrame::AddPane(int dir)
 {
 	int PaneNum = GetNotebookCount() + 1;
 	wxString PaneName = wxString::Format("Pane %i", PaneNum);
-	m_Mgr->AddPane(CreateEmptyNotebook(), wxAuiPaneInfo()
+	wxAuiPaneInfo PaneInfo = wxAuiPaneInfo()
 		.CaptionVisible(m_bEdit).Dockable(!m_bNoDocking)
 		.Name(PaneName).Caption(PaneName)
-		.Position(GetNotebookCount()));
+		.Position(GetNotebookCount());
+
+	switch (dir)
+	{
+		case ADD_PANE_TOP:
+			PaneInfo = PaneInfo.Top();
+			break;
+		case ADD_PANE_BOTTOM:
+			PaneInfo = PaneInfo.Bottom();
+			break;
+		case ADD_PANE_LEFT:
+			PaneInfo = PaneInfo.Left();
+			break;
+		case ADD_PANE_RIGHT:
+			PaneInfo = PaneInfo.Right();
+			break;
+		case ADD_PANE_CENTER:
+			PaneInfo = PaneInfo.Center();
+			break;
+		default:
+			break;
+	}
+
+	m_Mgr->AddPane(CreateEmptyNotebook(), PaneInfo);
 
 	AddRemoveBlankPage();
 	m_Mgr->Update();
diff --git a/Source/Core/DolphinWX/Globals.h b/Source/Core/DolphinWX/Globals.h
index 9a2187f2ff..7d3a5e6686 100644
--- a/Source/Core/DolphinWX/Globals.h
+++ b/Source/Core/DolphinWX/Globals.h
@@ -250,7 +250,11 @@ enum
 	ID_TOOLBAR_AUI,
 	IDM_SAVE_PERSPECTIVE,
 	IDM_ADD_PERSPECTIVE,
-	IDM_PERSPECTIVES_ADD_PANE,
+	IDM_PERSPECTIVES_ADD_PANE_TOP,
+	IDM_PERSPECTIVES_ADD_PANE_BOTTOM,
+	IDM_PERSPECTIVES_ADD_PANE_LEFT,
+	IDM_PERSPECTIVES_ADD_PANE_RIGHT,
+	IDM_PERSPECTIVES_ADD_PANE_CENTER,
 	IDM_EDIT_PERSPECTIVES,
 	IDM_TAB_SPLIT,
 	IDM_NO_DOCKING,