Lumiera  0.pre.03
»edit your freedom«
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 
39 using namespace stage::panel;
40 
41 namespace stage {
42 namespace workspace {
43 
44 
49  class DockArea
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 
110  WorkspaceWindow& getWorkspaceWindow();
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 (const char* 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 
198  panel::Panel* createPanel_by_name (const char* class_name);
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 
248  CreatePanelProc createPanelProc_;
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 
302  panel::Panel*
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:
322  Panel()
323  : PanelDescription (typeid(P)
324  ,P::getTitle()
325  ,P::getStockID()
326  ,Panel::createPanel)
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 
344  static const PanelDescription panelDescriptionList[];
345  };
346 
347 
348 
349 
350  template<class P>
351  inline int
352  DockArea::findPanelID()
353  {
354  return DockArea::findPanelDescription (typeid(P).name());
355  }
356 
357 
358 
359 }}// namespace stage::workspace
360 #endif /*STAGE_WORKSPACE_DOCK_AREA_H*/
A helper class that will create PanelDescription objects.
Definition: dock-area.hpp:318
std::list< panel::Panel * > panels_
list of all panels created
Definition: dock-area.hpp:75
panel::Panel * create(DockArea &panelManager, Gdl::DockItem &dockItem) const
Creates an instance of this panel.
Definition: dock-area.hpp:303
WorkspaceWindow & workspaceWindow_
reference to the owner workspace window object
Definition: dock-area.hpp:52
const char *const titleName_
localised title that will be shown on the panel.
Definition: dock-area.hpp:242
const std::type_info & classInfo_
reference to the typeID of this class
Definition: dock-area.hpp:239
Gdl::DockBar dockBar_
The pointer to GDL dock bar widget.
Definition: dock-area.hpp:62
Docking panel classes.
const gchar *const stockID_
Stock ID for this type of panel.
Definition: dock-area.hpp:245
The base class for all dockable panels.
Definition: panel.hpp:40
Base class and interface for all dockable panels.
A class to manage DockItem objects for WorkspaceWindow.
Definition: dock-area.hpp:49
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
A class to describe and instantiate Panel types.
Definition: dock-area.hpp:232
Gdl::Dock dock_
The pointer to GDL dock widget.
Definition: dock-area.hpp:57
The main Lumiera workspace window.
static panel::Panel * createPanel(DockArea &panelManager, Gdl::DockItem &dockItem)
helper function to create a panel of type P
Definition: dock-area.hpp:336
CreatePanelProc createPanelProc_
pointer to a function that will instantiate the panel object
Definition: dock-area.hpp:248
PanelDescription(std::type_info const &classInfo, const char *title, const gchar *stockID, CreatePanelProc createPanelProc)
Definition: dock-area.hpp:258
static unsigned short panelID
An accumulator for the panel id.
Definition: dock-area.hpp:80
Glib::RefPtr< Gdl::DockLayout > dockLayout_
The pointer to GDL dock layout object.
Definition: dock-area.hpp:67
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption
const char * getTitle() const
the localised title that will be shown on the panel
Definition: dock-area.hpp:283