Ardour  9.0-pre0-822-g12e3bc5c20
shuttle_control.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2014-2019 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 __gtk2_ardour_shuttle_control_h__
21 #define __gtk2_ardour_shuttle_control_h__
22 
23 #include <ytkmm/drawingarea.h>
24 
25 #include "pbd/controllable.h"
26 
27 #include "ardour/session_handle.h"
28 #include "ardour/types.h"
29 
30 #include "gtkmm2ext/cairo_widget.h"
31 
32 #include "widgets/ardour_button.h"
33 #include "widgets/binding_proxy.h"
34 
35 #include "varispeed_dialog.h"
36 
37 namespace Gtk {
38  class Menu;
39 }
40 
42 {
43 public:
46 
47  bool on_button_press_event (GdkEventButton*);
48 
50 
51 private:
52  void parameter_changed (std::string);
54  Gtk::Menu* disp_context_menu;
56 
58 };
59 
61 {
62 public:
65 
67  void set_shuttle_fract (double, bool zero_ok = false);
68  double get_shuttle_fract () const
69  {
70  return shuttle_fract;
71  }
73 
74  void do_blink (bool);
75  void set_colors ();
76 
80  double get_value (void) const;
81 
82  double lower () const { return -1.0; }
83  double upper () const { return 1.0; }
84 
86  };
87 
88  std::shared_ptr<ShuttleControllable> controllable () const
89  {
90  return _controllable;
91  }
92 
94  {
95  return &_info_button;
96  }
97 
99  {
100  return &_vari_button;
101  }
102 
103 public:
104  float speed_as_fract (float) const;
105  float fract_as_speed (float) const;
106 
107  static int speed_as_semitones (float, bool&);
108  static int speed_as_cents (float, bool&);
109 
110 protected:
111  bool _hovering;
119  std::shared_ptr<ShuttleControllable> _controllable;
120  cairo_pattern_t* pattern;
121  cairo_pattern_t* shine_pattern;
128  float bg_r, bg_g, bg_b;
130  void set_shuttle_max_speed (float);
131 
135  bool varispeed_button_scroll_event (GdkEventScroll*);
136 
137  bool on_enter_notify_event (GdkEventCrossing*);
138  bool on_leave_notify_event (GdkEventCrossing*);
139  bool on_button_press_event (GdkEventButton*);
140  bool on_button_release_event (GdkEventButton*);
141  bool on_motion_notify_event (GdkEventMotion*);
142 
143  bool on_button_press_event_for_display (GdkEventButton*);
144 
145  void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
146 
147  void on_size_allocate (Gtk::Allocation&);
148  bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
149 
150  gint mouse_shuttle (double x, bool force);
151  void use_shuttle_fract (bool force, bool zero_ok = false);
152  void parameter_changed (std::string);
153 
155 
157 };
158 
159 #endif /* __gtk2_ardour_shuttle_control_h__ */
ArdourWidgets::ArdourButton * vari_button()
PBD::ScopedConnection parameter_connection
bool on_query_tooltip(int, int, bool, const Glib::RefPtr< Gtk::Tooltip > &)
bool on_button_press_event_for_display(GdkEventButton *)
static int speed_as_cents(float, bool &)
static int speed_as_semitones(float, bool &)
void build_shuttle_context_menu()
ArdourWidgets::ArdourButton * info_button()
void map_transport_state()
void on_size_allocate(Gtk::Allocation &)
void set_shuttle_fract(double, bool zero_ok=false)
cairo_pattern_t * pattern
PBD::microseconds_t last_shuttle_request
void use_shuttle_fract(bool force, bool zero_ok=false)
std::shared_ptr< ShuttleControllable > controllable() const
cairo_pattern_t * shine_pattern
bool on_button_release_event(GdkEventButton *)
bool on_leave_notify_event(GdkEventCrossing *)
ShuttleInfoButton _info_button
void do_blink(bool)
bool on_motion_notify_event(GdkEventMotion *)
float fract_as_speed(float) const
PBD::ScopedConnection port_connection
void set_shuttle_max_speed(float)
void parameter_changed(std::string)
bool on_button_press_event(GdkEventButton *)
double get_shuttle_fract() const
ArdourWidgets::ArdourButton _vari_button
bool on_enter_notify_event(GdkEventCrossing *)
void set_session(ARDOUR::Session *)
ArdourWidgets::BindingProxy binding_proxy
float last_speed_displayed
float speed_as_fract(float) const
bool varispeed_button_scroll_event(GdkEventScroll *)
VarispeedDialog _vari_dialog
gint mouse_shuttle(double x, bool force)
void varispeed_button_clicked()
void render(Cairo::RefPtr< Cairo::Context > const &, cairo_rectangle_t *)
double shuttle_speed_on_grab
Gtk::Menu * shuttle_context_menu
void set_shuttle_units(ARDOUR::ShuttleUnits)
std::shared_ptr< ShuttleControllable > _controllable
void parameter_changed(std::string)
void set_shuttle_units(ARDOUR::ShuttleUnits s)
bool on_button_press_event(GdkEventButton *)
void build_disp_context_menu()
Gtk::Menu * disp_context_menu
PBD::ScopedConnection parameter_connection
Definition: ardour_ui.h:189
int64_t microseconds_t
Definition: microseconds.h:28
void set_value(double, PBD::Controllable::GroupControlDisposition group_override)