Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
panel-manager.hpp
Go to the documentation of this file.
1/*
2 PANEL-MANAGER.hpp - management of dockable GDL panels
3
4 Copyright (C)
5 2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
25#ifndef STAGE_WORKSPACE_PANEL_MANAGER_H
26#define STAGE_WORKSPACE_PANEL_MANAGER_H
27
28#include "stage/panel/panel.hpp"
29
30#include <gdlmm.h>
31#include <typeinfo>
32
33
34using namespace stage::panel;
35
36namespace stage {
37namespace workspace {
38
39
45 {
48
52 Gdl::Dock dock_;
53
57 Gdl::DockBar dockBar_;
58
62 Glib::RefPtr<Gdl::DockLayout> dockLayout_;
63
67 GdlDockPlaceholder *dockPlaceholders_[4];
68
70 std::list<panel::Panel*> panels_;
71
75 static unsigned short panelID;
76
77
78 public:
81
86 void setupDock();
87
92 Gdl::Dock& getDock();
93
98 Gdl::DockBar& getDockBar();
99
104
110 panel::Panel& showPanel (const int description_index);
111
113 bool hasPanel (const int description_index);
114
122 void switchPanel (panel::Panel& old_panel, const int description_index);
123
129 void splitPanel (panel::Panel& panel, Gtk::Orientation split_direction, panel::Panel* toAdd =nullptr);
130
131
132 public:
138 template<class P>
139 static int findPanelID();
140
142 static int getPanelDescriptionCount();
143
149 static const gchar* getPanelStockID (const int index);
150
156 static const char* getPanelTitle (int index);
157
158
159 private:
161 void createPanels();
162
169 static int findPanelDescription (CStr class_name);
170
176 panel::Panel* createPanel_by_index (const int index);
177
184 panel::Panel* createPanel_by_index (const int index, Gdl::DockItem& dock_item);
185
192
199 int getPanelType (panel::Panel* const panel) const;
200
205 void removePanel (panel::Panel* const panel);
206
208 void clearPanels();
209
210
211 private:
216 void on_panel_shown (panel::Panel *panel);
217
218
219
220 private:
221
226 {
227 protected:
228 typedef panel::Panel* (*const CreatePanelProc)(PanelManager&, Gdl::DockItem&);
230 private:
232 const std::type_info& classInfo_;
233
235 const char* const titleName_;
236
238 const gchar* const stockID_;
239
242
243
244 protected:
251 PanelDescription (std::type_info const& classInfo
252 ,const char* title
253 ,const gchar* stockID
254 ,CreatePanelProc createPanelProc)
255 : classInfo_(classInfo)
256 , titleName_(title)
257 , stockID_(stockID)
258 , createPanelProc_(createPanelProc)
259 {
260 REQUIRE(titleName_);
261 }
262
263
264 public:
265 const std::type_info& getClassInfo() const
266 {
267 return classInfo_;
268 }
269
270 const char* getClassName() const
271 {
272 return classInfo_.name();
273 }
274
276 const char* getTitle() const
277 {
278 ENSURE(titleName_);
279 return titleName_;
280 }
281
282 const gchar* getStockID() const
283 {
284 ENSURE(stockID_);
285 return stockID_;
286 }
287
288
296 create (PanelManager& panelManager, Gdl::DockItem& dockItem) const
297 {
298 REQUIRE(createPanelProc_);
299 return createPanelProc_ (panelManager, dockItem);
300 }
301 };
302
303
304
309 template<class P>
310 class Panel
311 : public PanelDescription
312 {
313 public:
315 : PanelDescription (typeid(P)
316 ,P::getTitle()
317 ,P::getStockID()
319 { }
320
321 private:
327 static panel::Panel*
328 createPanel (PanelManager& panelManager, Gdl::DockItem& dockItem)
329 {
330 return new P(panelManager, dockItem);
331 }
332 };
333
334
337 };
338
339
340
341
342 template<class P>
343 inline int
345 {
346 return PanelManager::findPanelDescription (typeid(P).name());
347 }
348
349
350
351}}// namespace stage::workspace
352#endif /*STAGE_WORKSPACE_PANEL_MANAGER_H*/
The base class for all dockable panels.
Definition panel.hpp:42
A class to describe and instantiate Panel types.
const char * getTitle() const
the localised title that will be shown on the panel
PanelDescription(std::type_info const &classInfo, const char *title, const gchar *stockID, CreatePanelProc createPanelProc)
CreatePanelProc createPanelProc_
pointer to a function that will instantiate the panel object
const char *const titleName_
localised title that will be shown on the panel.
const gchar *const stockID_
Stock ID for this type of panel.
panel::Panel *(*const CreatePanelProc)(PanelManager &, Gdl::DockItem &)
const std::type_info & classInfo_
reference to the typeID of this class
panel::Panel * create(PanelManager &panelManager, Gdl::DockItem &dockItem) const
Creates an instance of this panel.
A helper class that will create PanelDescription objects.
static panel::Panel * createPanel(PanelManager &panelManager, Gdl::DockItem &dockItem)
helper function to create a panel of type P
A class to manage DockItem objects for WorkspaceWindow.
std::list< panel::Panel * > panels_
list of all panels created
void createPanels()
Creates the standard panel layout.
Glib::RefPtr< Gdl::DockLayout > dockLayout_
The pointer to GDL dock layout object.
panel::Panel * createPanel_by_name(CStr class_name)
Creates a panel by class name.
Gdl::Dock & getDock()
Gets a pointer to the dock object.
panel::Panel * createPanel_by_index(const int index)
Creates a panel by description index.
WorkspaceWindow & workspaceWindow_
reference to the owner workspace window object
WorkspaceWindow & getWorkspaceWindow()
Returns a reference to the owner workspace window.
GdlDockPlaceholder * dockPlaceholders_[4]
Pointers to the 4 root place holders.
static const PanelDescription panelDescriptionList[]
The list of panel descriptions.
static int getPanelDescriptionCount()
Gets the number of panel descriptions.
static const char * getPanelTitle(int index)
Gets a panel description's title.
void on_panel_shown(panel::Panel *panel)
An event handler for when the panel is shown or hidden.
static unsigned short panelID
An accumulator for the panel id.
void splitPanel(panel::Panel &panel, Gtk::Orientation split_direction, panel::Panel *toAdd=nullptr)
Splits a panel into two panels of the same type.
bool hasPanel(const int description_index)
was the indicated panel already allocated within this PanelManager's realm?
Gdl::DockBar & getDockBar()
Gets a pointer to the dock bar.
void setupDock()
Initialises this dock manager and creates the dock and all it's widgets.
static int findPanelDescription(CStr class_name)
Find the index of a panel description given the class name.
panel::Panel & showPanel(const int description_index)
Shows a panel given a description index.
void removePanel(panel::Panel *const panel)
Removes a panel from the panel list and deletes it.
int getPanelType(panel::Panel *const panel) const
Gets the type of a given panel.
Gdl::Dock dock_
The pointer to GDL dock widget.
static int findPanelID()
retrieve the internal type-ID corresponding to the given panel implementation type.
void switchPanel(panel::Panel &old_panel, const int description_index)
Switches a panel from one type to another, without touching the underlying GdlDockItem.
Gdl::DockBar dockBar_
The pointer to GDL dock bar widget.
void clearPanels()
Removes all panels from the panel list and deletes them.
static const gchar * getPanelStockID(const int index)
Gets a panel description's stock id.
The main Lumiera workspace window.
const char * CStr
Definition error.hpp:42
Docking panel classes.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Base class and interface for all dockable panels.