Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
panel-bar.cpp
Go to the documentation of this file.
1/*
2 PanelBar - container to place widgets into the GDL dock attachment area
3
4 Copyright (C)
5 2009, Joel Holdsworth <joel@airwebreathe.org.uk>
6 2012, Michael R. Fisher <mfisher31@gmail.com>
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
25#include "stage/panel/panel.hpp"
27#include "include/logging.h"
28
29#include <boost/foreach.hpp>
30#include <algorithm>
31
32
33namespace stage {
34namespace widget {
35
36 using sigc::slot;
37 using sigc::bind;
38 using sigc::mem_fun;
40
41
42 PanelBar::PanelBar (panel::Panel& owner_panel, gchar const*stock_id)
43 : Box()
44 , panel_{owner_panel}
45 , panelButton_{Gtk::StockID(stock_id)}
46 , lockItem_(NULL)
47 {
48 set_border_width(1);
49
50 panelButton_.set_relief (Gtk::RELIEF_NONE);
51 panelButton_.set_can_focus(false);
52 panelButton_.show();
53 pack_start (panelButton_, Gtk::PACK_SHRINK);
54
56 }
57
58
63 void
65 {
66 REQUIRE (lockItem_ == NULL);
67
68 // Add items for each type of panel
69 for (int i = 0; i < PanelManager::getPanelDescriptionCount(); i++)
70 {
72 uString slug {title};
73
74 /* Slug should be a char only string, no spaces, numbers, or
75 * symbols. Currently all panel titles are single words.
76 * So the above works OK for now.
77 */
78
79 slot<void> func = bind(mem_fun(*this,
81
82 panelButton_.append (slug, title, func);
83
84 /* Keeping this snippet for easy reference //////////////////////////////////////////TICKET #937 : complete Port to GTK-3
85 * list.push_back( Menu_Helpers::StockMenuElem(
86 * StockID(PanelManager::get_panel_stock_id(i)),
87 * bind(mem_fun(*this, &PanelBar::on_panel_type), i) ));
88 */
89 }
90
91#if false
92 list.push_back( Menu_Helpers::SeparatorElem() );
93#endif
94
95 // Add extra commands
96 slot<void> hide = mem_fun(*this, &PanelBar::on_hide);
97 panelButton_.append("Hide","_Hide", hide);
98
99 slot<void> lock = mem_fun(*this, &PanelBar::on_lock);
100 panelButton_.append ("Lock", "_Lock", lock);
101
102#if false
103 lockItem_ = dynamic_cast<CheckMenuItem*>(&list.back());
104 ENSURE (lockItem_);
105 lockItem_->set_active (panel_.is_locked());
106#endif
107
108
109 slot<void> hfunc = bind (mem_fun(*this, &PanelBar::on_split_panel), Gtk::ORIENTATION_HORIZONTAL);
110
111 panelButton_.append("SplitHorizontal", "Split _Horizontal",hfunc);
112
113 slot<void> vfunc = bind (mem_fun(*this, &PanelBar::on_split_panel), Gtk::ORIENTATION_VERTICAL);
114 panelButton_.append("SplitVertical", "Split _Vertical", vfunc);
115
116 }
117
118
119
124 void
125 PanelBar::on_panel_type (int type_index)
126 {
128 }
129
134 void
135 PanelBar::on_split_panel (Gtk::Orientation split_direction)
136 {
137 panel_.getPanelManager().splitPanel (panel_, split_direction);
138 }
139
140
142 void
144 {
145 panel_.show(false);
146 }
147
149 void
151 {
152 REQUIRE(lockItem_);
153
154 bool lockState{not panel_.is_locked()};
155 panel_.lock (lockState);
156 lockItem_->set_active(lockState);
157 }
158
159
160
161}}// stage::widget
Utility functions for working with elements from the Cairo vector drawing library.
The base class for all dockable panels.
Definition panel.hpp:42
bool is_locked() const
Definition panel.cpp:132
workspace::PanelManager & getPanelManager()
Definition panel.cpp:139
void lock(bool show=true)
Locks or unlocks the panel against modifications.
Definition panel.cpp:125
void show(bool show=true)
Shows or hides the panel.
Definition panel.cpp:92
void append(uString &slug, uString &title, sigc::slot< void > &callback, bool toggle=false)
Append a Menu Item to the Menu.
void on_hide() override
An event handler for when the "Hide" menu item is clicked.
void setupPanelButton()
Sets up panelButton, populating it with menu items.
Definition panel-bar.cpp:64
Gtk::CheckMenuItem * lockItem_
pointer to the lock menu item.
Definition panel-bar.hpp:58
void on_split_panel(Gtk::Orientation split_direction)
Event handler for when the split panel menu item is clicked.
panel::Panel & panel_
reference to the owner panel
Definition panel-bar.hpp:49
void on_lock()
Event handler for when the "Lock" menu item is clicked.
MenuButton panelButton_
The panel menu drop-down button widget, that will be displayed in the corner of the bar.
Definition panel-bar.hpp:53
PanelBar(panel::Panel &owner_panel, const gchar *stock_id)
create a PanelBar with a given stock_id.
Definition panel-bar.cpp:42
void on_panel_type(int type_index)
An event handler for when a panel type is chosen.
A class to manage DockItem objects for WorkspaceWindow.
static int getPanelDescriptionCount()
Gets the number of panel descriptions.
static const char * getPanelTitle(int index)
Gets a panel description's title.
void splitPanel(panel::Panel &panel, Gtk::Orientation split_direction, panel::Panel *toAdd=nullptr)
Splits a panel into two panels of the same type.
void switchPanel(panel::Panel &old_panel, const int description_index)
Switches a panel from one type to another, without touching the underlying GdlDockItem.
return NULL
Definition llist.h:586
This header is for including and configuring NoBug.
Lumiera GTK UI implementation root.
Definition guifacade.cpp:37
Glib::ustring uString
Definition gtk-base.hpp:92
Custom container widget to allow placing toolbar buttons into the active docking header area of GDL d...
Management of dockable panels.
Base class and interface for all dockable panels.
This file contains the definition of the main workspace window parent, which is the toplevel parent o...