GTK docking interfaces and more

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++ • 3.77 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
std::shared_ptr<LayoutManager> layout;
28
Glib::RefPtr<Gio::SimpleActionGroup> action_group;
29
public:
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<Gtk::Widget*> value;
88
void update_active_style();
89
public:
90
DockablePane *pane;
91
explicit DockButton(DockablePane *pane);
92
~DockButton();
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 ContentStack : public BaseStack {
120
private:
121
std::shared_ptr<ContentManager> content_manager;
122
public:
123
explicit ContentStack(std::shared_ptr<ContentManager> content_manager);
124
void add_page(Gtk::Widget &child);
125
};
126
} // namespace gPanthera
127
128
#endif // GPANTHERA_LIBRARY_H