Ardour  9.2-320-gbc46a93144
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 <ydkmm/cursor.h>
30 #include <ytkmm/container.h>
31 #include <ytkmm/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  enum DividerMode {
61  AbsoluteAfter
62  };
63 
64  typedef std::vector<std::shared_ptr<Child> > Children;
65 
66  Pane (bool horizontal);
67  ~Pane();
68 
69  void set_divider (std::vector<float>::size_type divider, float fract);
70  float get_divider (std::vector<float>::size_type divider = 0) const;
71  void set_child_minsize (Gtk::Widget const &, int32_t);
72  void set_absolute_divider (std::vector<float>::size_type divider, DividerMode mode);
73 
74  GType child_type_vfunc() const;
76 
78 
79 protected:
80  bool horizontal;
81 
87 
93 
94  void forall_vfunc (gboolean include_internals, GtkCallback callback, gpointer callback_data);
95 
96 private:
98  bool did_move;
99 
100  void reallocate (Gtk::Allocation const &);
101 
103 
104  struct Divider : public Gtk::EventBox {
106 
107  float fract;
108  bool dragging;
111 
113  };
114 
115  typedef std::list<Divider*> Dividers;
119 
120  void add_divider ();
122  float constrain_fract (Dividers::size_type, float fract);
123 
124  static void* notify_child_destroyed (void*);
126 };
127 
128 class LIBWIDGETS_API HPane : public Pane
129 {
130  public:
131  HPane () : Pane (true) {}
132 };
133 
134 class LIBWIDGETS_API VPane : public Pane
135 {
136  public:
137  VPane () : Pane (false) {}
138 };
139 
140 } /* namespace */
141 
142 #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:116
std::vector< std::shared_ptr< Child > > Children
Definition: pane.h:64
void on_remove(Gtk::Widget *)
This is a default handler for the signal signal_remove().
void set_absolute_divider(std::vector< float >::size_type divider, DividerMode mode)
Gdk::Cursor drag_cursor
Definition: pane.h:97
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:102
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:115
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:118
bool horizontal
Definition: pane.h:80
bool handle_leave_event(GdkEventCrossing *, Divider *)
void(* GtkCallback)(GtkWidget *widget, gpointer data)
Definition: gtkwidget.h:508
Definition: ardour_ui.h:182
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