Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
dock-area.hpp
Go to the documentation of this file.
1/*
2 DOCK-AREA.hpp - maintain a docking area within the WorkspaceWindow
3
4 Copyright (C)
5 2008, Joel Holdsworth <joel@airwebreathe.org.uk>
6 2018, Hermann Vosseler <Ichthyostega@web.de>
7
8  **Lumiera** is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by the
10  Free Software Foundation; either version 2 of the License, or (at your
11  option) any later version. See the file COPYING for further details.
12
13*/
14
15
30#ifndef STAGE_WORKSPACE_DOCK_AREA_H
31#define STAGE_WORKSPACE_DOCK_AREA_H
32
33#include "stage/panel/panel.hpp"
34
35#include <gdlmm.h>
36#include <typeinfo>
37
38
39using namespace stage::panel;
40
41namespace stage {
42namespace workspace {
43
44
50 {
53
57 Gdl::Dock dock_;
58
62 Gdl::DockBar dockBar_;
63
67 Glib::RefPtr<Gdl::DockLayout> dockLayout_;
68
72 GdlDockPlaceholder *dockPlaceholders_[4];
73
75 std::list<panel::Panel*> panels_;
76
80 static unsigned short panelID;
81
82
83 public:
85 ~DockArea();
86
93 void setupDock();
94
99 Gdl::Dock& getDock();
100
105 Gdl::DockBar& getDockBar();
106
111
117 panel::Panel& showPanel (const int description_index);
118
120 bool hasPanel (const int description_index);
121
129 void switchPanel (panel::Panel& old_panel, const int description_index);
130
136 void splitPanel (panel::Panel& panel, Gtk::Orientation split_direction);
137
138
139 public:
145 template<class P>
146 static int findPanelID();
147
149 static int getPanelDescriptionCount();
150
156 static const gchar* getPanelStockID (const int index);
157
163 static const char* getPanelTitle (int index);
164
165
166 private:
168 void createPanels();
169
176 static int findPanelDescription (CStr class_name);
177
183 panel::Panel* createPanel_by_index (const int index);
184
191 panel::Panel* createPanel_by_index (const int index, Gdl::DockItem& dock_item);
192
199
206 int getPanelType (panel::Panel* const panel) const;
207
212 void removePanel (panel::Panel* const panel);
213
215 void clearPanels();
216
217
218 private:
223 void on_panel_shown (panel::Panel *panel);
224
225
226
227 private:
228
233 {
234 protected:
235 typedef panel::Panel* (*const CreatePanelProc)(DockArea&, Gdl::DockItem&);
237 private:
239 const std::type_info& classInfo_;
240
242 const char* const titleName_;
243
245 const gchar* const stockID_;
246
249
250
251 protected:
258 PanelDescription (std::type_info const& classInfo
259 ,const char* title
260 ,const gchar* stockID
261 ,CreatePanelProc createPanelProc)
262 : classInfo_(classInfo)
263 , titleName_(title)
264 , stockID_(stockID)
265 , createPanelProc_(createPanelProc)
266 {
267 REQUIRE(titleName_);
268 }
269
270
271 public:
272 const std::type_info& getClassInfo() const
273 {
274 return classInfo_;
275 }
276
277 const char* getClassName() const
278 {
279 return classInfo_.name();
280 }
281
283 const char* getTitle() const
284 {
285 ENSURE(titleName_);
286 return titleName_;
287 }
288
289 const gchar* getStockID() const
290 {
291 ENSURE(stockID_);
292 return stockID_;
293 }
294
295
303 create (DockArea& panelManager, Gdl::DockItem& dockItem) const
304 {
305 REQUIRE(createPanelProc_);
306 return createPanelProc_ (panelManager, dockItem);
307 }
308 };
309
310
311
317 template<class P>
318 class Panel
319 : public PanelDescription
320 {
321 public:
323 : PanelDescription (typeid(P)
324 ,P::getTitle()
325 ,P::getStockID()
327 { }
328
329 private:
335 static panel::Panel*
336 createPanel (DockArea& panelManager, Gdl::DockItem& dockItem)
337 {
338 return new P(panelManager, dockItem);
339 }
340 };
341
342
345 };
346
347
348
349
350 template<class P>
351 inline int
353 {
354 return DockArea::findPanelDescription (typeid(P).name());
355 }
356
357
358
359}}// namespace stage::workspace
360#endif /*STAGE_WORKSPACE_DOCK_AREA_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
panel::Panel *(*const CreatePanelProc)(DockArea &, Gdl::DockItem &)
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.
const std::type_info & getClassInfo() const
const std::type_info & classInfo_
reference to the typeID of this class
panel::Panel * create(DockArea &panelManager, Gdl::DockItem &dockItem) const
Creates an instance of this panel.
A helper class that will create PanelDescription objects.
static panel::Panel * createPanel(DockArea &panelManager, Gdl::DockItem &dockItem)
helper function to create a panel of type P
A class to manage DockItem objects for WorkspaceWindow.
Definition dock-area.hpp:50
std::list< panel::Panel * > panels_
list of all panels created
Definition dock-area.hpp:75
void createPanels()
Creates the standard panel layout.
Glib::RefPtr< Gdl::DockLayout > dockLayout_
The pointer to GDL dock layout object.
Definition dock-area.hpp:67
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
Definition dock-area.hpp:52
WorkspaceWindow & getWorkspaceWindow()
Returns a reference to the owner workspace window.
GdlDockPlaceholder * dockPlaceholders_[4]
Pointers to the 4 root place holders.
Definition dock-area.hpp:72
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.
Definition dock-area.hpp:80
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.
Definition dock-area.cpp:94
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.
Definition dock-area.hpp:57
static const PanelDescription panelDescriptionList[]
The list of panel descriptions.
void splitPanel(panel::Panel &panel, Gtk::Orientation split_direction)
Splits a panel into two panels of the same type.
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.
Definition dock-area.hpp:62
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.