Ardour  9.0-pre0-582-g084a23a80d
ardour_ctrl_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2017-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 _WIDGETS_ARDOUR_CTRL_BASE_H_
21 #define _WIDGETS_ARDOUR_CTRL_BASE_H_
22 
23 #include <list>
24 #include <stdint.h>
25 
26 #include <gtkmm/action.h>
27 
28 #include "pbd/signals.h"
29 
30 #include "gtkmm2ext/activatable.h"
31 #include "gtkmm2ext/cairo_widget.h"
33 
34 #include "widgets/binding_proxy.h"
35 #include "widgets/visibility.h"
36 
37 namespace ArdourWidgets {
38 
40 {
41 public:
43 
44  void start_drag ();
45  void stop_drag ();
46  bool dragging () const;
47 
48 private:
49  bool _dragging;
50 };
51 
52 
54 {
55 public:
56  enum Flags {
57  NoFlags = 0x0,
58  Detent = 0x1,
59  ArcToZero = 0x2,
60  NoHorizontal = 0x4,
61  NoVertical = 0x8,
62  Reverse = 0x10,
63  };
64 
65  ArdourCtrlBase (Flags flags = NoFlags);
66  virtual ~ArdourCtrlBase ();
67 
70 
71  void set_tooltip_prefix (std::string pfx) { _tooltip_prefix = pfx; controllable_changed (true); }
72 
73  std::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
74  void set_controllable (std::shared_ptr<PBD::Controllable> c);
75 
80 
81  void color_handler ();
82 
83  sigc::signal<void,int> StartGesture;
84  sigc::signal<void,int> StopGesture;
85 
86  void set_size_request (int, int);
87 
88 protected:
89  virtual void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*) = 0;
90 
92  void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
93  void on_name_changed ();
98 
101 
102  bool _hovering;
103 
104  float _val; // current value [0..1]
105  float _normal; // default value, arc
106 
109 
110 private:
111  void controllable_changed (bool force_update = false);
115 
117 
119 
120  float _grabbed_x;
121  float _grabbed_y;
123 
124  std::string _tooltip_prefix;
125 };
126 
127 } /* namespace */
128 
129 #endif /* __gtk2_ardour_ardour_knob_h__ */
CtrlPersistentTooltip _tooltip
bool on_focus_in_event(GdkEventFocus *)
This is a default handler for the signal signal_focus_in_event().
bool on_focus_out_event(GdkEventFocus *)
This is a default handler for the signal signal_focus_out_event().
bool on_button_release_event(GdkEventButton *)
This is a default handler for the signal signal_button_release_event().
PBD::ScopedConnection watch_connection
bool on_motion_notify_event(GdkEventMotion *ev)
This is a default handler for the signal signal_motion_notify_event().
void set_controllable(std::shared_ptr< PBD::Controllable > c)
bool on_enter_notify_event(GdkEventCrossing *)
This is a default handler for the signal signal_enter_notify_event().
void controllable_changed(bool force_update=false)
ArdourCtrlBase(Flags flags=NoFlags)
sigc::signal< void, int > StartGesture
void on_size_request(Gtk::Requisition *req)
This is a default handler for the signal signal_size_request().
virtual void render(Cairo::RefPtr< Cairo::Context > const &, cairo_rectangle_t *)=0
std::shared_ptr< PBD::Controllable > get_controllable()
sigc::signal< void, int > StopGesture
bool on_leave_notify_event(GdkEventCrossing *)
This is a default handler for the signal signal_leave_notify_event().
void set_active_state(Gtkmm2ext::ActiveState)
void set_visual_state(Gtkmm2ext::VisualState)
bool on_button_press_event(GdkEventButton *)
This is a default handler for the signal signal_button_press_event().
bool on_scroll_event(GdkEventScroll *ev)
This is a default handler for the signal signal_scroll_event().
void set_tooltip_prefix(std::string pfx)
void on_style_changed(const Glib::RefPtr< Gtk::Style > &)
#define LIBWIDGETS_API