more work on RID and editor/mixer order matching; when a track/bus is hidden in the...
[ardour.git] / libs / gtkmm2ext / gtkmm2ext / scroomer.h
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 namespace Gtkmm2ext {
28
29 class Scroomer : public Gtk::DrawingArea
30 {
31 public:
32         enum Component {
33                 TopBase = 0,
34                 Handle1 = 1,
35                 Slider = 2,
36                 Handle2 = 3,
37                 BottomBase = 4,
38                 Total = 5,
39                 None = 6
40         };
41
42         Scroomer(Gtk::Adjustment& adjustment);
43         ~Scroomer();
44
45         bool on_motion_notify_event (GdkEventMotion*);
46         bool on_button_press_event (GdkEventButton*);
47         bool on_button_release_event (GdkEventButton*);
48         bool on_scroll_event (GdkEventScroll*);
49         virtual void on_size_allocate (Gtk::Allocation&);
50
51         void set_comp_rect(GdkRectangle&, Component) const;
52
53         Component point_in(double point) const;
54
55         void set_min_page_size(double page_size);
56         int get_handle_size() { return handle_size; }
57         
58         inline int position_of(Component comp) { return position[comp]; }
59
60         sigc::signal0<void> DragStarting;
61         sigc::signal0<void> DragFinishing;
62
63 protected:
64         Gtk::Adjustment& adj;
65
66 private:
67         struct UpdateRect {
68                 GdkRectangle rect;
69                 Component first_comp;
70         };
71
72         void update();
73         void adjustment_changed ();
74
75         int position[6];
76         int old_pos[6];
77         int handle_size;
78         double min_page_size;
79         GdkWindow* grab_window;
80         Component grab_comp;
81         double grab_y;
82         double unzoomed_val;
83         double unzoomed_page;
84         bool pinch;
85 };
86
87 } // namespace
88
89 #endif /* __gtkmm2ext_scroomer_h__ */