mini-tl: subscribe to location add/remove signals
[ardour.git] / gtk2_ardour / mini_timeline.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef __gtkardour_mini_timeline_h__
20 #define __gtkardour_mini_timeline_h__
21
22 #include <list>
23 #include <pangomm.h>
24
25 #include "pbd/signals.h"
26
27 #include "ardour/ardour.h"
28 #include "ardour/session_handle.h"
29
30 #include "gtkmm2ext/cairo_widget.h"
31 #include "gtkmm2ext/utils.h"
32
33 #include "audio_clock.h"
34
35 namespace ARDOUR {
36         class Session;
37 }
38
39 class MiniTimeline : public CairoWidget, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
40 {
41
42 public:
43         MiniTimeline ();
44         ~MiniTimeline ();
45
46         void set_session (ARDOUR::Session *);
47
48 private:
49         void session_going_away ();
50         void super_rapid_update ();
51
52         void on_size_request (Gtk::Requisition*);
53         void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
54         void on_name_changed ();
55         void set_colors ();
56         void parameter_changed (std::string const &);
57
58         void calculate_time_width ();
59         void update_minitimeline ();
60         void draw_dots (cairo_t*, int left, int right, int y, ArdourCanvas::Color);
61         int  draw_mark (cairo_t*, int x0, int x1, int h, const std::string&);
62
63         void render (cairo_t*, cairo_rectangle_t*);
64         void format_time (framepos_t when);
65
66         bool on_button_release_event (GdkEventButton *ev);
67         bool on_scroll_event (GdkEventScroll*);
68
69         Glib::RefPtr<Pango::Layout> _layout;
70         sigc::connection super_rapid_connection;
71         PBD::ScopedConnectionList marker_connection;
72         PBD::ScopedConnectionList session_connection;
73
74         framepos_t _last_update_frame;
75         AudioClock::Mode _clock_mode;
76         int _time_width;
77         int _time_height;
78
79         struct JumpRange {
80                 JumpRange (int l, int r, framepos_t t)
81                         : left (l), right (r), to (t) {}
82                 int left;
83                 int right;
84                 framepos_t to;
85         };
86
87         typedef std::list <JumpRange> JumpList;
88         JumpList _jumplist;
89 };
90
91 #endif