Ardour  9.0-pre0-822-g12e3bc5c20
tabbable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef _WIDGETS_TABBABLE_H_
21 #define _WIDGETS_TABBABLE_H_
22 
23 #include <ytkmm/box.h>
24 #include <ytkmm/button.h>
25 #include <ytkmm/eventbox.h>
26 #include <ytkmm/image.h>
27 #include <ytkmm/label.h>
28 #include <ytkmm/notebook.h>
29 
30 #include "gtkmm2ext/window_proxy.h"
31 
32 #include "widgets/ardour_button.h"
33 #include "widgets/eventboxext.h"
34 #include "widgets/pane.h"
35 #include "widgets/visibility.h"
36 
37 namespace Gtk {
38  class Window;
39  class Notebook;
40 }
41 
42 namespace Gtkmm2ext {
43  class VisibilityTracker;
44 }
45 
46 namespace ArdourWidgets {
47 
49 {
50 public:
51  enum PaneLayout {
52  NoPanes = 0x00,
53  PaneLeft = 0x01,
54  PaneRight = 0x02,
55  PaneBottom = 0x04,
56  AttLeft = 0x08,
57  AttBottom = 0x10,
58  };
59 
60  Tabbable (const std::string& user_visible_name, std::string const & untranslated_name, Gtk::Widget* top = NULL, bool tabbed_by_default = true, PaneLayout pl = PaneRight);
62 
63  void add_to_notebook (Gtk::Notebook& notebook);
64  void make_visible ();
65  void make_invisible ();
67  void attach ();
68  void detach ();
69 
70  Gtk::Widget& contents() const { return *_contents; }
71 
72  /* this is where ArdourUI packs the tab switchers
73  * (record/cues/edit/mix) into my toolbar area,
74  * in the case where I'm attached to the main window
75  */
76  Gtk::EventBox& tab_btn_box () {return content_tabbables;}
77 
78  Gtk::Window* get (bool create = false);
79  Gtk::Window* own_window () { return get (false); }
80  virtual Gtk::Window* use_own_window (bool and_pack_it);
81 
82  void set_default_tabbed (bool yn);
83 
84  virtual void show_window ();
85 
86  bool window_visible () const;
87  bool tabbed() const;
88  bool tabbed_by_default () const;
89 
90  Gtk::Window* current_toplevel () const;
91 
92  Gtk::Notebook* tab_root_drop ();
93 
94  int set_state (const XMLNode&, int version);
95  XMLNode& get_state () const;
96 
97  static std::string xml_node_name();
98 
99  sigc::signal1<void,Tabbable&> StateChange;
100 
104 
105  bool att_left_visible () const { return content_att_left.get_visible (); }
106  bool att_right_visible () const { return content_att_right.get_visible (); }
107  bool att_bottom_visible () const { return content_att_bottom.get_visible (); }
108 
109 protected:
110  virtual void showhide_att_left (bool yn);
111  virtual void showhide_att_right (bool yn);
112  virtual void showhide_att_bottom (bool yn);
113 
114  bool delete_event_handler (GdkEventAny *ev);
115 
116  /* This is the heirarchy of a Tabbable's widget packing.
117  *
118  * The end result is to provide 8 event-boxes (marked with a $) where the tab can put its contents.
119  *
120  * +--_content_vbox---------------------------------------------------------------------------------------------------------------+
121  * | |
122  * | /--toolbar_frame-----------------------------------------------------------------------------------------------------------\ |
123  * | | +--content_header_hbox-------------------------------------------------------------------------------------------------+ | |
124  * | | | | | |
125  * | | | +--content_app_bar-------------------------------------------------+ +--attachment_hbox--+ +--content_tabbables--+ | | |
126  * | | | $ (EBOX) | | (internal) | $ (EBOX) | | | |
127  * | | | | MAIN APPLICATION BAR | | (attachment btns) | | PAGE SWITCHER BTN | | | |
128  * | | | | | | | | | | | |
129  * | | | +------------------------------------------------------------------+ +-------------------+ +---------------------+ | | |
130  * | | | | | |
131  * | | +----------------------------------------------------------------------------------------------------------------------+ | |
132  * | \--------------------------------------------------------------------------------------------------------------------------/ |
133  * | |
134  * | +--content_hbox--OR--content_left_pane--(EXPAND|FILL)----------------------------------------------------------------------+ |
135  * | | | |
136  * | | +--att_left--+ +--content_midlevel_vbox------------------------------------------------------------------------------+ | |
137  * | | $ (EBOX) | | +--content_right_pane--(EXPAND|FILL)--------------------------------------------------------------+ | | |
138  * | | | | | | +--content_inner_hbox----------------------------------------------+ +--content_right_vbox--+ | | | |
139  * | | | O | | | | +--content_bottom_pane-(OPTIONAL)-------+ +--content_bus_vbox-+ | | | | | | |
140  * | | | P S | | | | | +--content_main_vbox----------------+ | | | | | +--att_right-------+ | | | | |
141  * | | | T I | | | | | | | | | +--content_bus--+ | | | $ (EBOX) | | | | | |
142  * | | | I D | | | | | | +--content_main_top-------------+ | | | $ (EBOX) | | | | | | | | | | |
143  * | | | O E |<->| | | | | $ OPTIONAL TOOLBAR (EBOX) | | | | | M | | | | | OPTIONAL | | | | | |
144  * | | | N B | O | | | | | +-------------------------------+ | | | | O | | | | | | | | | | |
145  * | | | A A | P | | | | | | | | | N | | |<->| | | | | | | |
146  * | | | L R | T | | | | | +--content_main-----------------+ | | | | I | | | P | | | | | | | |
147  * | | | | . | | | | | $ (EBOX) | | | | | T | | | A | | (LIST) | | | | | |
148  * | | | | P | | | | | | !! MAIN PAGE CONTENT !! | | | | | O | | | N | | | | | | | |
149  * | | | | A | | | | | | | | | | R | | | E | | | | | | | |
150  * | | | | N | | | | | +-------------------------------+ | | | | | | |<->| | | | | | | |
151  * | | | (STRIP) | E | | | | | | | | | | | | | | | | | | | |
152  * | | | |<->| | | | +-----------------------------------+ | | | S | | | | | | | | | | |
153  * | | | | | | | | /\ OPTIONAL /\ | | | E | | | | | | | | | | |
154  * | | | | | | | | || || | | | C | | | | | | | | | | |
155  * | | | | | | | | \/ PANE \/ | | | T | | | | | | | | | | |
156  * | | | | | | | | +-content_att_bottom----------------+ | | | I | | | | | | | | | | |
157  * | | | | | | | | $ (EBOX) | | | | O | | | | | | | | | | |
158  * | | | | | | | | | OPTIONAL BOTTOM (PROPERTIES) | | | | N | | | | | | | | | | |
159  * | | | | | | | | | | | | | | | | | | | | | | | |
160  * | | | | | | | | +-----------------------------------+ | | +---------------+ | | | | | | | | | |
161  * | | | | | | | +---------------------------------------+ +-------------------+ | | +------------------+ | | | | |
162  * | | | | | | +------------------------------------------------------------------+ +----------------------+ | | | |
163  * | | | | | +-------------------------------------------------------------------------------------------------+ | | |
164  * | | +------------+ +-----------------------------------------------------------------------------------------------------+ | |
165  * | +--------------------------------------------------------------------------------------------------------------------------+ |
166  * | |
167  * +------------------------------------------------------------------------------------------------------------------------------+
168  *
169  */
170 
171  /* clang-format off */
172  /* _content_vbox * toplevel
173  * toolbar_frame * the frame is managed in the implementation */
175  EventBoxExt content_app_bar; /* a placeholder for the transport bar, if you want one */
176  Gtk::EventBox content_attachments; /* a placeholder the (strip, list, props) visibility buttons for this tab */
178  EventBoxExt content_tabbables; /* a placeholder for the tabbable switching buttons (used by ArdourUI) */
180  Gtk::HBox content_hbox;
181  EventBoxExt content_att_left; /* a placeholder for the mixer strip, if you want one */
185  VPane content_bottom_pane; /* optional, replaced by content_main_vbox when no bottom att is present */
186  Gtk::VBox content_main_vbox;
187  EventBoxExt content_main_top; /* a placeholder for the content-specific toolbar, if you want one */
188  EventBoxExt content_main; /* a placeholder for the innermost content (recorder, cues, editor, mixer) */
189  EventBoxExt content_att_bottom; /* a placeholder for the property box, if you want one */
190  Gtk::VBox content_bus_vbox;
191  EventBoxExt content_bus; /* a placeholder for the monitor section */
193  EventBoxExt content_att_right; /* a placeholder for the sidebar list, if you want one */
194  /* clang-format on */
195 
196  /* visibility controls */
200 
201 private:
202  void default_layout ();
203  void show_tab ();
204  void hide_tab ();
205  bool tab_close_clicked (GdkEventButton*);
206  void show_own_window (bool and_pack_it);
207  void window_mapped ();
209 
210  EventBoxExt _content_ebox; /* this is the root widget for a * full-featured tabbable, which * contains ... */
211  Gtk::VBox _content_vbox; /* a VBox for packing the internal contains into */
212  Gtk::Widget* _contents; /* for most Tabbables this will be content_ebox; but rc_options, for example, does something different. */
213  Gtk::Notebook _own_notebook;
214  Gtk::Notebook* _parent_notebook;
217 
218 };
219 
220 } /* end namespace */
221 
222 #endif
EventBoxExt content_att_left
Definition: tabbable.h:181
Gtk::HBox content_hbox
Definition: tabbable.h:180
EventBoxExt _content_ebox
Definition: tabbable.h:210
Gtk::HBox content_inner_hbox
Definition: tabbable.h:184
sigc::signal1< void, Tabbable & > StateChange
Definition: tabbable.h:99
EventBoxExt content_tabbables
Definition: tabbable.h:178
Gtk::Window * get(bool create=false)
bool tabbed_by_default() const
EventBoxExt content_app_bar
Definition: tabbable.h:175
ArdourWidgets::ArdourButton right_attachment_button
Definition: tabbable.h:198
virtual void showhide_att_right(bool yn)
virtual void showhide_att_left(bool yn)
virtual void showhide_att_bottom(bool yn)
EventBoxExt content_main_top
Definition: tabbable.h:187
Gtk::Widget & contents() const
Definition: tabbable.h:70
bool att_right_visible() const
Definition: tabbable.h:106
Gtk::EventBox & tab_btn_box()
Definition: tabbable.h:76
void add_to_notebook(Gtk::Notebook &notebook)
int set_state(const XMLNode &, int version)
PaneLayout _panelayout
Definition: tabbable.h:216
Tabbable(const std::string &user_visible_name, std::string const &untranslated_name, Gtk::Widget *top=NULL, bool tabbed_by_default=true, PaneLayout pl=PaneRight)
Gtk::VBox content_bus_vbox
Definition: tabbable.h:190
static std::string xml_node_name()
Gtk::EventBox content_attachments
Definition: tabbable.h:176
EventBoxExt content_bus
Definition: tabbable.h:191
EventBoxExt content_att_right
Definition: tabbable.h:193
Gtk::Notebook * _parent_notebook
Definition: tabbable.h:214
bool att_bottom_visible() const
Definition: tabbable.h:107
Gtk::Widget * _contents
Definition: tabbable.h:212
virtual Gtk::Window * use_own_window(bool and_pack_it)
bool tab_close_clicked(GdkEventButton *)
Gtk::Window * own_window()
Definition: tabbable.h:79
Gtk::VBox _content_vbox
Definition: tabbable.h:211
ArdourWidgets::ArdourButton bottom_attachment_button
Definition: tabbable.h:199
Gtk::VBox content_midlevel_vbox
Definition: tabbable.h:182
EventBoxExt content_att_bottom
Definition: tabbable.h:189
Gtk::HBox content_attachment_hbox
Definition: tabbable.h:177
EventBoxExt content_main
Definition: tabbable.h:188
bool delete_event_handler(GdkEventAny *ev)
Gtk::Notebook _own_notebook
Definition: tabbable.h:213
XMLNode & get_state() const
Gtk::Window * current_toplevel() const
Gtk::VBox content_main_vbox
Definition: tabbable.h:186
bool window_visible() const
bool att_left_visible() const
Definition: tabbable.h:105
Gtk::HBox content_header_hbox
Definition: tabbable.h:174
Gtk::VBox content_right_vbox
Definition: tabbable.h:192
Gtk::Notebook * tab_root_drop()
virtual void show_window()
void show_own_window(bool and_pack_it)
void set_default_tabbed(bool yn)
ArdourWidgets::ArdourButton left_attachment_button
Definition: tabbable.h:197
Definition: Window.h:41
Definition: xml++.h:114
Definition: ardour_ui.h:189
#define LIBWIDGETS_API