GTK docking interfaces

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 gpanthera.hh

View raw Download
text/x-c++ • 5.9 kiB
C++ source, ASCII text
        
            
1
#ifndef GPANTHERA_LIBRARY_H
2
#define GPANTHERA_LIBRARY_H
3
4
#include <gtkmm.h>
5
#include <glibmm.h>
6
#include <glibmm/ustring.h>
7
#include <utility>
8
#include <vector>
9
#include <memory>
10
11
namespace gPanthera {
12
void init();
13
14
class DockStack;
15
class DockWindow;
16
class LayoutManager;
17
18
class DockablePane : public Gtk::Box {
19
private:
20
Gtk::Label label;
21
Glib::ustring name;
22
Gtk::Image *icon;
23
DockStack *stack;
24
DockWindow *window = nullptr;
25
std::unique_ptr<Gtk::HeaderBar> header;
26
Gtk::Widget *child;
27
Glib::RefPtr<Gio::SimpleActionGroup> action_group;
28
public:
29
std::shared_ptr<LayoutManager> layout;
30
DockStack *last_stack = nullptr;
31
DockablePane(std::shared_ptr<LayoutManager> layout, Gtk::Widget &child, const Glib::ustring &name, const Glib::ustring &label, Gtk::Image *icon, DockStack *stack = nullptr, Gtk::Widget *custom_header = nullptr);
32
Gtk::Stack *get_stack() const;
33
Glib::ustring get_identifier() const;
34
Gtk::Image *get_icon() const;
35
Gtk::Label *get_label();
36
void redock(DockStack *stack);
37
void pop_out();
38
Gtk::Widget *get_child() const;
39
};
40
41
class DockWindow : public Gtk::Window {
42
private:
43
DockablePane *pane;
44
public:
45
explicit DockWindow(DockablePane *pane);
46
};
47
48
class LayoutManager : public Glib::ObjectBase {
49
private:
50
public:
51
std::vector<DockablePane*> panes;
52
std::vector<DockStack*> stacks;
53
LayoutManager();
54
55
void add_pane(DockablePane *pane);
56
57
void add_stack(DockStack *stack);
58
void remove_pane(DockablePane *pane);
59
void remove_stack(DockStack *stack);
60
};
61
62
class BaseStack : public Gtk::Stack {
63
public:
64
sigc::signal<void(Gtk::Widget*)> signal_child_added;
65
sigc::signal<void(Gtk::Widget*)> signal_child_removed;
66
BaseStack();
67
void add(Gtk::Widget &child, const Glib::ustring &name);
68
void remove(Gtk::Widget &child);
69
void add(Gtk::Widget &child);
70
void add(Gtk::Widget &child, const Glib::ustring &name, const Glib::ustring &title) = delete;
71
};
72
73
class DockStack : public BaseStack {
74
private:
75
public:
76
std::shared_ptr<LayoutManager> layout;
77
Glib::ustring name;
78
explicit DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name);
79
80
void add_pane(DockablePane &child);
81
};
82
83
class DockButton : public Gtk::ToggleButton {
84
private:
85
sigc::connection active_style_handler;
86
std::shared_ptr<Gtk::DragSource> drag_source;
87
Glib::Value<DockablePane*> value;
88
void update_active_style();
89
public:
90
DockablePane *pane;
91
explicit DockButton(DockablePane *pane);
92
~DockButton() override;
93
};
94
95
class DockStackSwitcher : public Gtk::Box {
96
private:
97
DockStack *stack;
98
sigc::connection add_handler, remove_handler;
99
std::shared_ptr<Gtk::DropTarget> drop_target;
100
public:
101
void update_buttons();
102
explicit DockStackSwitcher(DockStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
103
DockStack *get_stack() const;
104
~DockStackSwitcher() override;
105
};
106
107
class ContentStack;
108
109
class ContentManager : public Glib::ObjectBase {
110
private:
111
public:
112
std::vector<ContentStack*> stacks;
113
ContentManager();
114
115
void add_stack(ContentStack *stack);
116
void remove_stack(ContentStack *stack);
117
};
118
119
class ContentPage : public Gtk::Box {
120
private:
121
Gtk::Widget *tab_widget;
122
ContentStack *stack;
123
Gtk::Widget *child;
124
public:
125
std::shared_ptr<ContentManager> content_manager;
126
ContentStack *last_stack = nullptr;
127
ContentPage(std::shared_ptr<ContentManager> content_manager, ContentStack *stack, Gtk::Widget *child, Gtk::Widget *tab_widget);
128
Gtk::Widget *get_child() const;
129
Gtk::Widget *get_tab_widget() const;
130
void redock(ContentStack *stack);
131
void set_tab_widget(Gtk::Widget *tab_widget);
132
void set_child(Gtk::Widget *child);
133
Gtk::Stack *get_stack() const;
134
};
135
136
class ContentTab : public Gtk::ToggleButton {
137
private:
138
std::shared_ptr<Gtk::DragSource> drag_source;
139
std::shared_ptr<Gtk::DropTarget> drop_target;
140
Glib::Value<ContentPage*> value;
141
void update_active_style();
142
sigc::connection active_style_handler;
143
public:
144
explicit ContentTab(ContentPage *page);
145
ContentPage *page;
146
~ContentTab() override;
147
};
148
149
class ContentStack : public BaseStack {
150
private:
151
public:
152
sigc::signal<bool(ContentPage*)> signal_detach;
153
std::shared_ptr<ContentManager> content_manager;
154
std::shared_ptr<Gtk::DropTarget> drop_target;
155
explicit ContentStack(std::shared_ptr<ContentManager> content_manager);
156
void make_paned(Gtk::Orientation orientation, Gtk::PackType pack_type);
157
void add_page(ContentPage &child);
158
void remove_with_paned();
159
};
160
161
class ContentTabBar : public Gtk::Box {
162
// TODO; should be similar to DockStackSwitcher
163
// Dragging a tab to an empty space should split the view;
164
// dragging a tab outside the window should pop it out with user-defined behaviour
165
private:
166
ContentStack *stack;
167
sigc::connection add_handler, remove_handler;
168
std::shared_ptr<Gtk::DropTarget> drop_target;
169
public:
170
void update_buttons();
171
explicit ContentTabBar(ContentStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
172
ContentStack *get_stack() const;
173
~ContentTabBar() override;
174
};
175
176
class ContentNotebook : public Gtk::Box {
177
private:
178
ContentStack *stack;
179
ContentTabBar *switcher;
180
public:
181
ContentNotebook(ContentStack *stack, ContentTabBar *switcher);
182
};
183
} // namespace gPanthera
184
185
#endif // GPANTHERA_LIBRARY_H