Added nieve PanelManager::switch_panel

This commit is contained in:
Joel Holdsworth 2009-04-04 23:01:50 +01:00
parent fb20cb5e07
commit 1814669301
7 changed files with 58 additions and 0 deletions

View file

@ -89,6 +89,12 @@ Panel::is_shown() const
return GTK_WIDGET_VISIBLE((GtkWidget*)dock_item);
}
workspace::WorkspaceWindow&
Panel::get_workspace_window()
{
return workspace;
}
void
Panel::internal_setup()
{

View file

@ -90,6 +90,11 @@ public:
* Returns true if the panel is currently visible.
*/
bool is_shown() const;
/**
* Returns a reference to the owner workspace window object.
**/
workspace::WorkspaceWindow& get_workspace_window();
private:
/**

View file

@ -21,6 +21,7 @@
* *****************************************************/
#include "panel-bar.hpp"
#include "../workspace/workspace-window.hpp"
#include "../workspace/panel-manager.hpp"
#include "../panels/panel.hpp"
#include "../util/rectangle.hpp"
@ -129,6 +130,10 @@ void
PanelBar::on_panel_type(int type_index)
{
g_message("on_panel_type %d", type_index);
workspace::PanelManager &manager = panel.get_workspace_window().
get_panel_manager();
manager.switch_panel(panel, type_index);
}
void

View file

@ -111,6 +111,37 @@ PanelManager::get_dock_bar() const
return dockBar;
}
void PanelManager::switch_panel(panels::Panel &old_panel,
int new_panel_description_index)
{
REQUIRE(new_panel_description_index >= 0 &&
new_panel_description_index < get_panel_description_count());
shared_ptr<panels::Panel> new_panel(
panelDescriptionList[new_panel_description_index].create(
workspaceWindow));
new_panel->show_all();
panels.push_back(new_panel);
gdl_dock_object_dock (GDL_DOCK_OBJECT(old_panel.get_dock_item()),
GDL_DOCK_OBJECT(new_panel->get_dock_item()),
GDL_DOCK_CENTER, NULL);
gdl_dock_object_unbind(GDL_DOCK_OBJECT(old_panel.get_dock_item()));
list< boost::shared_ptr<panels::Panel> >::iterator i;
for(i = panels.begin(); i != panels.end(); i++)
{
if((*i).get() == &old_panel)
{
panels.erase(i);
break;
}
}
}
int
PanelManager::get_panel_description_count()
{

View file

@ -76,6 +76,9 @@ public:
**/
GdlDockBar* get_dock_bar() const;
void switch_panel(panels::Panel &old_panel,
int new_panel_description_index);
public:
/**

View file

@ -69,6 +69,12 @@ WorkspaceWindow::get_controller()
return controller;
}
PanelManager&
WorkspaceWindow::get_panel_manager()
{
return panelManager;
}
void
WorkspaceWindow::create_ui()
{

View file

@ -66,6 +66,8 @@ public:
gui::model::Project& get_project();
gui::controller::Controller& get_controller();
PanelManager& get_panel_manager();
private:
void create_ui();