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.14 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 DockStack : public Gtk::Stack {
63
private:
64
public:
65
sigc::signal<void(Gtk::Widget*)> signal_child_added;
66
sigc::signal<void(Gtk::Widget*)> signal_child_removed;
67
std::shared_ptr<LayoutManager> layout;
68
Glib::ustring name;
69
explicit DockStack(std::shared_ptr<LayoutManager> layout, const Glib::ustring &name);
70
71
void add_pane(DockablePane &child);
72
void add(Gtk::Widget &child, const Glib::ustring &name);
73
void remove(Gtk::Widget &child);
74
void add(Gtk::Widget &child) = delete;
75
void add(Gtk::Widget &child, const Glib::ustring &name, const Glib::ustring &title) = delete;
76
};
77
78
class DockButton : public Gtk::Button {
79
private:
80
sigc::connection active_style_handler;
81
std::shared_ptr<Gtk::DragSource> drag_source;
82
Glib::Value<Gtk::Widget*> value;
83
void update_active_style();
84
public:
85
DockablePane *pane;
86
explicit DockButton(DockablePane *pane);
87
~DockButton();
88
};
89
90
class DockStackSwitcher : public Gtk::Box {
91
private:
92
DockStack *stack;
93
sigc::connection add_handler, remove_handler;
94
std::shared_ptr<Gtk::DropTarget> drop_target;
95
public:
96
void update_buttons();
97
explicit DockStackSwitcher(DockStack *stack, Gtk::Orientation orientation = Gtk::Orientation::HORIZONTAL);
98
~DockStackSwitcher() override;
99
};
100
} // namespace gPanthera
101
102
#endif // GPANTHERA_LIBRARY_H