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