ardour
scroomer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifndef __gtkmm2ext_scroomer_h__
21 #define __gtkmm2ext_scroomer_h__
22 
23 #include <gtkmm/drawingarea.h>
24 #include <gtkmm/adjustment.h>
25 #include <gdkmm.h>
26 
27 #include "gtkmm2ext/visibility.h"
28 
29 namespace Gtkmm2ext {
30 
31 class LIBGTKMM2EXT_API Scroomer : public Gtk::DrawingArea
32 {
33 public:
34  enum Component {
35  TopBase = 0,
36  Handle1 = 1,
37  Slider = 2,
38  Handle2 = 3,
39  BottomBase = 4,
40  Total = 5,
41  None = 6
42  };
43 
44  Scroomer(Gtk::Adjustment& adjustment);
45  ~Scroomer();
46 
47  bool on_motion_notify_event (GdkEventMotion*);
48  bool on_button_press_event (GdkEventButton*);
49  bool on_button_release_event (GdkEventButton*);
50  bool on_scroll_event (GdkEventScroll*);
51  virtual void on_size_allocate (Gtk::Allocation&);
52 
53  void set_comp_rect(GdkRectangle&, Component) const;
54 
55  Component point_in(double point) const;
56 
57  void set_min_page_size(double page_size);
58  int get_handle_size() { return handle_size; }
59 
60  inline int position_of(Component comp) { return position[comp]; }
61 
62  sigc::signal0<void> DragStarting;
63  sigc::signal0<void> DragFinishing;
64 
65  sigc::signal0<void> DoubleClicked;
66 
67 protected:
68  Gtk::Adjustment& adj;
69 
70 private:
71  struct UpdateRect {
72  GdkRectangle rect;
74  };
75 
76  void update();
77  void adjustment_changed ();
78 
79  int position[6];
80  int old_pos[6];
82  double min_page_size;
83  GdkWindow* grab_window;
85  double grab_y;
86  double unzoomed_val;
87  double unzoomed_page;
88  bool pinch;
89 };
90 
91 } // namespace
92 
93 #endif /* __gtkmm2ext_scroomer_h__ */
Component grab_comp
Definition: scroomer.h:84
LIBGTKMM2EXT_API
GdkWindow * grab_window
Definition: scroomer.h:83
int position_of(Component comp)
Definition: scroomer.h:60
sigc::signal0< void > DragFinishing
Definition: scroomer.h:63
double unzoomed_val
Definition: scroomer.h:86
sigc::signal0< void > DoubleClicked
Definition: scroomer.h:65
sigc::signal0< void > DragStarting
Definition: scroomer.h:62
Gtk::Adjustment & adj
Definition: scroomer.h:68
double unzoomed_page
Definition: scroomer.h:87
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
Definition: region.cc:65
static double const handle_size
int get_handle_size()
Definition: scroomer.h:58
double min_page_size
Definition: scroomer.h:82