Add a missing #define to our MSVC project (portaudio_backend)
[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/types.h"
29 #include "ardour/session_handle.h"
30
31 #include "gtkmm2ext/cairo_widget.h"
32 #include "gtkmm2ext/utils.h"
33
34 #include "audio_clock.h"
35
36 namespace ARDOUR {
37         class Session;
38 }
39
40 namespace Gtk {
41         class Menu;
42 }
43
44 class MiniTimeline : public CairoWidget, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
45 {
46
47 public:
48         MiniTimeline ();
49         ~MiniTimeline ();
50
51         void set_session (ARDOUR::Session *);
52
53 private:
54         void session_going_away ();
55         void super_rapid_update ();
56
57         void on_size_request (Gtk::Requisition*);
58         void on_size_allocate (Gtk::Allocation&);
59         void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
60         void on_name_changed ();
61         void set_colors ();
62         void parameter_changed (std::string const &);
63
64         void calculate_time_width ();
65         void calculate_time_spacing ();
66         void update_minitimeline ();
67         void draw_dots (cairo_t*, int left, int right, int y, ArdourCanvas::Color);
68         int  draw_mark (cairo_t*, int x0, int x1, const std::string&, bool& prelight);
69
70         void render (cairo_t*, cairo_rectangle_t*);
71         void format_time (framepos_t when);
72
73         bool on_button_press_event (GdkEventButton*);
74         bool on_button_release_event (GdkEventButton*);
75         bool on_scroll_event (GdkEventScroll*);
76         bool on_motion_notify_event (GdkEventMotion*);
77         bool on_leave_notify_event (GdkEventCrossing*);
78
79         void build_minitl_context_menu ();
80         void show_minitl_context_menu ();
81         void set_span (ARDOUR::framecnt_t);
82
83         Glib::RefPtr<Pango::Layout> _layout;
84         sigc::connection super_rapid_connection;
85         PBD::ScopedConnectionList marker_connection;
86         PBD::ScopedConnectionList session_connection;
87
88         framepos_t _last_update_frame;
89         AudioClock::Mode _clock_mode;
90         int _time_width;
91         int _time_height;
92
93         int _n_labels;
94         double _px_per_sample;
95         ARDOUR::framecnt_t _time_granularity;
96         ARDOUR::framecnt_t _time_span_samples;
97         int _marker_height;
98
99         int _pointer_x;
100         int _pointer_y;
101
102         Gtk::Menu* _minitl_context_menu;
103
104         struct JumpRange {
105                 JumpRange (int l, int r, framepos_t t, bool p = false)
106                         : left (l), right (r), to (t), prelight (p) {}
107                 int left;
108                 int right;
109                 framepos_t to;
110                 bool prelight;
111         };
112
113         typedef std::list <JumpRange> JumpList;
114         JumpList _jumplist;
115 };
116
117 #endif