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.42 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
Glib::Value<ContentPage*> value;
140
void update_active_style();
141
sigc::connection active_style_handler;
142
public:
143
explicit ContentTab(ContentPage *page);
144
ContentPage *page;
145
~ContentTab() override;
146
};
147
148
class ContentStack : public BaseStack {
149
private:
150
public:
151
std::shared_ptr<ContentManager> content_manager;
152
explicit ContentStack(std::shared_ptr<ContentManager> content_manager);
153
void add_page(ContentPage &child);
154
};
155
156
class ContentTabBar : public Gtk::Box {
157
// TODO; should be similar to DockStackSwitcher
158
// Dragging a tab to an empty space should split the view;
159
// dragging a tab outside the window should pop it out with user-defined behaviour
160
private:
161
ContentStack *stack;
162
sigc::connection add_handler, remove_handler;
163
std::shared_ptr<Gtk::DropTarget> drop_target;
164
public:
165
void update_buttons();
166
explicit ContentTabBar(ContentStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
167
ContentStack *get_stack() const;
168
~ContentTabBar() override;
169
};
170
} // namespace gPanthera
171
172
#endif // GPANTHERA_LIBRARY_H