Ardour  9.0-pre0-582-g084a23a80d
pane.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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_PANE_H_
21 #define _WIDGETS_PANE_H_
22 
23 #include <cstdint>
24 #include <memory>
25 #include <vector>
26 #include <algorithm>
27 
28 
29 #include <gdkmm/cursor.h>
30 #include <gtkmm/container.h>
31 #include <gtkmm/eventbox.h>
32 
33 #include "widgets/visibility.h"
34 
35 namespace Gtk {
36  class Widget;
37 }
38 
39 namespace ArdourWidgets {
40 
42 {
43 private:
44  struct Divider;
45 
46 public:
47  struct Child
48  {
51  int32_t minsize;
52  sigc::connection show_con;
53  sigc::connection hide_con;
54 
55  Child (Pane* p, Gtk::Widget* widget, uint32_t ms) : pane (p), w (widget), minsize (ms) {}
56  };
57 
58  typedef std::vector<std::shared_ptr<Child> > Children;
59 
60  Pane (bool horizontal);
61  ~Pane();
62 
63  void set_divider (std::vector<float>::size_type divider, float fract);
64  float get_divider (std::vector<float>::size_type divider = 0) const;
65  void set_child_minsize (Gtk::Widget const &, int32_t);
66 
67  GType child_type_vfunc() const;
69 
71 
72 protected:
73  bool horizontal;
74 
80 
86 
87  void forall_vfunc (gboolean include_internals, GtkCallback callback, gpointer callback_data);
88 
89 private:
91  bool did_move;
92 
93  void reallocate (Gtk::Allocation const &);
94 
96 
97  struct Divider : public Gtk::EventBox {
98  Divider ();
99 
100  float fract;
101  bool dragging;
102 
104  };
105 
106  typedef std::list<Divider*> Dividers;
110 
111  void add_divider ();
113  float constrain_fract (Dividers::size_type, float fract);
114 
115  static void* notify_child_destroyed (void*);
117 };
118 
119 class LIBWIDGETS_API HPane : public Pane
120 {
121  public:
122  HPane () : Pane (true) {}
123 };
124 
125 class LIBWIDGETS_API VPane : public Pane
126 {
127  public:
128  VPane () : Pane (false) {}
129 };
130 
131 } /* namespace */
132 
133 #endif
float get_divider(std::vector< float >::size_type divider=0) const
void handle_child_visibility()
static void * notify_child_destroyed(void *)
void set_child_minsize(Gtk::Widget const &, int32_t)
bool handle_enter_event(GdkEventCrossing *, Divider *)
GType child_type_vfunc() const
void on_add(Gtk::Widget *)
This is a default handler for the signal signal_add().
Pane(bool horizontal)
bool handle_motion_event(GdkEventMotion *, Divider *)
Dividers dividers
Definition: pane.h:107
std::vector< std::shared_ptr< Child > > Children
Definition: pane.h:58
void on_remove(Gtk::Widget *)
This is a default handler for the signal signal_remove().
Gdk::Cursor drag_cursor
Definition: pane.h:90
bool on_expose_event(GdkEventExpose *)
This is a default handler for the signal signal_expose_event().
float constrain_fract(Dividers::size_type, float fract)
bool handle_release_event(GdkEventButton *, Divider *)
void on_size_allocate(Gtk::Allocation &)
This is a default handler for the signal signal_size_allocate().
void * child_destroyed(Gtk::Widget *)
Children children
Definition: pane.h:95
void reallocate(Gtk::Allocation const &)
void set_drag_cursor(Gdk::Cursor)
void set_divider(std::vector< float >::size_type divider, float fract)
std::list< Divider * > Dividers
Definition: pane.h:106
void on_size_request(GtkRequisition *)
This is a default handler for the signal signal_size_request().
bool handle_press_event(GdkEventButton *, Divider *)
void set_check_divider_position(bool)
void forall_vfunc(gboolean include_internals, GtkCallback callback, gpointer callback_data)
bool check_fract
Definition: pane.h:109
bool horizontal
Definition: pane.h:73
bool handle_leave_event(GdkEventCrossing *, Divider *)
void(* GtkCallback)(GtkWidget *widget, gpointer data)
Definition: gtkwidget.h:508
Definition: ardour_ui.h:188
Gtk::Widget * w
Definition: pane.h:50
Child(Pane *p, Gtk::Widget *widget, uint32_t ms)
Definition: pane.h:55
sigc::connection show_con
Definition: pane.h:52
sigc::connection hide_con
Definition: pane.h:53
bool on_expose_event(GdkEventExpose *ev)
This is a default handler for the signal signal_expose_event().
#define LIBWIDGETS_API