Ardour  9.0-pre0-582-g084a23a80d
beatbox_gui.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 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 __gtk2_ardour_beatbox_gui_h__
21 #define __gtk2_ardour_beatbox_gui_h__
22 
23 #include <memory>
24 #include <string>
25 
26 #include <gtkmm/radiobutton.h>
27 #include <gtkmm/togglebutton.h>
28 #include <gtkmm/button.h>
29 #include <gtkmm/scrollbar.h>
30 #include <gtkmm/spinbutton.h>
31 #include <gtkmm/box.h>
32 #include <gtkmm/notebook.h>
33 
34 #include "gtkmm2ext/colors.h"
35 
36 #include "widgets/ardour_button.h"
37 
38 #include "canvas/box.h"
39 #include "canvas/canvas.h"
40 #include "canvas/constraint_packer.h"
41 #include "canvas/rectangle.h"
42 
43 #include "ardour/step_sequencer.h"
44 
45 #include "widgets/ardour_button.h"
47 #include "ardour_dialog.h"
48 
49 namespace PBD {
50 class PropertyChange;
51 }
52 
53 namespace ArdourCanvas {
54 class Item;
55 class StepButton;
56 class Polygon;
57 class Text;
58 class VBox;
59 class Widget;
60 }
61 
62 namespace ARDOUR {
63 class BeatBox;
64 }
65 
66 class SequencerView;
67 class SequenceView;
68 class StepView;
69 class FloatingTextEntry;
71 
72 class SequencerView : public ArdourCanvas::ConstraintPacker, public sigc::trackable {
73  public:
74  enum Mode {
81  };
82 
84 
86 
87  SequenceView& sequence_view (size_t n) const;
88 
89  Mode mode() const { return _mode; }
90  void set_mode (Mode m);
91 
92  void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
93  void update ();
94 
95  static double rhs_xoffset;
96  static double mode_button_width;
97  static double mode_button_height;
98  static double mode_button_spacing;
99  static double mode_button_xdim;
100  static double mode_button_ydim;
101 
102  private:
104  typedef std::vector<SequencerStepIndicator*> StepIndicators;
106  typedef std::vector<SequenceView*> SequenceViews;
108 
109  double _width;
110  double _height;
112  ArdourCanvas::ConstraintPacker* button_packer;
113 
114  ArdourCanvas::ConstraintPacker* step_indicator_box;
115 
116  ArdourCanvas::ConstraintPacker* sequence_hbox;
117  ArdourCanvas::ConstraintPacker* lhs_vbox;
118  ArdourCanvas::ConstraintPacker* steps_vbox;
119  ArdourCanvas::ConstraintPacker* rhs_vbox;
120 
126 
132 
135 
138 
140 
141 };
142 
143 class SequenceView : public sigc::trackable
144 {
145  public:
147 
149  SequencerView::Mode mode() const { return sv.mode(); }
151 
152  ArdourCanvas::ConstraintPacker* lhs_box;
153  ArdourCanvas::ConstraintPacker* rhs_box;
154  ArdourCanvas::ConstraintPacker* step_box;
155 
156  private:
159 
165 
167  void edit_name ();
168  void name_edited (std::string, int);
169 
171 
172  typedef std::vector<StepView*> StepViews;
174 
177 };
178 
179 class StepView : public ArdourCanvas::Rectangle, public sigc::trackable {
180  public:
182 
183  void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
185 
188 
189  private:
193  bool grabbed;
194 
195  std::pair<double,double> grab_at;
196  std::pair<double,double> last_motion;
197 
202 
203  void adjust_step_pitch (int amt);
204  void adjust_step_velocity (int amt);
206  void adjust_step_octave (int amt);
207  void adjust_step_timing (double fract);
208 
211 
213  void set_group_text ();
215 
218 };
219 
220 class SequencerStepIndicator : public ArdourCanvas::Rectangle, public sigc::trackable {
221  public:
223  void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
225 
226  void set_current (bool);
227 
228  private:
230  size_t number;
234 
235  static int dragging;
236 
240 
241  void set_text ();
242 
245 
251 };
252 
253 class BBGUI : public ArdourDialog {
254  public:
255  BBGUI (std::shared_ptr<ARDOUR::BeatBox> bb);
256  ~BBGUI ();
257 
258  double width() const { return _width; }
259  double height() const { return _height; }
260 
261  protected:
262  void on_map ();
263  void on_unmap ();
264 
265  private:
266  std::shared_ptr<ARDOUR::BeatBox> bbox;
267  double _width;
268  double _height;
269 
272 
275 
277 
279  void toggle_play ();
280 
283 
286 
287  void clear ();
288  void update ();
290 
291  sigc::connection timer_connection;
292 
295 };
296 
297 #endif /* __gtk2_ardour_beatbox_gui_h__ */
Declaration of the main canvas classes.
boost::rational< int > DurationRatio
Canvas * canvas() const
void update()
double _height
Definition: beatbox_gui.h:268
ArdourCanvas::GtkCanvasViewport * _canvas_viewport
Definition: beatbox_gui.h:273
Gtk::Adjustment horizontal_adjustment
Definition: beatbox_gui.h:270
ArdourWidgets::ArdourButton export_as_region_button
Definition: beatbox_gui.h:281
Gtk::Adjustment vertical_adjustment
Definition: beatbox_gui.h:271
PBD::ScopedConnection sequencer_connection
Definition: beatbox_gui.h:294
void update_sequencer()
void on_unmap()
This is a default handler for the signal signal_unmap().
BBGUI(std::shared_ptr< ARDOUR::BeatBox > bb)
ArdourWidgets::ArdourButton start_button
Definition: beatbox_gui.h:278
Gtk::VScrollbar vscrollbar
Definition: beatbox_gui.h:285
double height() const
Definition: beatbox_gui.h:259
void toggle_play()
SequencerView * _sequencer
Definition: beatbox_gui.h:276
double _width
Definition: beatbox_gui.h:267
void on_map()
This is a default handler for the signal signal_map().
ArdourCanvas::GtkCanvas * _canvas
Definition: beatbox_gui.h:274
Gtk::HBox canvas_hbox
Definition: beatbox_gui.h:284
void clear()
sigc::connection timer_connection
Definition: beatbox_gui.h:291
double width() const
Definition: beatbox_gui.h:258
void export_as_region()
void sequencer_changed(PBD::PropertyChange const &)
std::shared_ptr< ARDOUR::BeatBox > bbox
Definition: beatbox_gui.h:266
void edit_name()
void sequence_changed()
ArdourCanvas::Text * name_text
Definition: beatbox_gui.h:161
ArdourCanvas::Text * number_text
Definition: beatbox_gui.h:160
SequencerView & sv
Definition: beatbox_gui.h:157
SequencerView::Mode mode() const
Definition: beatbox_gui.h:149
StepViews step_views
Definition: beatbox_gui.h:173
void name_edited(std::string, int)
ArdourCanvas::Rectangle * speed_slide
Definition: beatbox_gui.h:164
std::vector< StepView * > StepViews
Definition: beatbox_gui.h:172
FloatingTextEntry * floating_entry
Definition: beatbox_gui.h:170
ARDOUR::StepSequence & sequence
Definition: beatbox_gui.h:158
ArdourCanvas::ConstraintPacker * step_box
Definition: beatbox_gui.h:154
bool name_text_event(GdkEvent *)
void view_mode_changed()
ArdourCanvas::ConstraintPacker * rhs_box
Definition: beatbox_gui.h:153
ArdourCanvas::Text * root_text
Definition: beatbox_gui.h:162
ArdourCanvas::Rectangle * step_cnt_button
Definition: beatbox_gui.h:163
PBD::ScopedConnection sequence_connection
Definition: beatbox_gui.h:176
ArdourCanvas::ConstraintPacker * lhs_box
Definition: beatbox_gui.h:152
SequenceView(SequencerView &, ARDOUR::StepSequence &, ArdourCanvas::Canvas *canvas)
ARDOUR::StepSequencer & sequencer() const
Definition: beatbox_gui.h:150
bool motion_event(GdkEventMotion *)
bool button_press_event(GdkEventButton *)
SequencerStepIndicator(SequencerView &, ArdourCanvas::Canvas *, size_t n)
SequencerView & sv
Definition: beatbox_gui.h:229
static Gtkmm2ext::Color bright_outline_color
Definition: beatbox_gui.h:250
void sequencer_changed(PBD::PropertyChange const &)
bool button_release_event(GdkEventButton *)
bool on_event(GdkEvent *)
static Gtkmm2ext::Color current_text_color
Definition: beatbox_gui.h:248
ArdourCanvas::Text * text
Definition: beatbox_gui.h:232
PBD::ScopedConnection sequencer_connection
Definition: beatbox_gui.h:244
ArdourCanvas::Polygon * poly
Definition: beatbox_gui.h:231
void render(ArdourCanvas::Rect const &, Cairo::RefPtr< Cairo::Context >) const
static Gtkmm2ext::Color other_color
Definition: beatbox_gui.h:247
static Gtkmm2ext::Color current_color
Definition: beatbox_gui.h:246
static Gtkmm2ext::Color other_text_color
Definition: beatbox_gui.h:249
SequenceView & sequence_view(size_t n) const
ArdourCanvas::ConstraintPacker * lhs_vbox
Definition: beatbox_gui.h:117
void render(ArdourCanvas::Rect const &, Cairo::RefPtr< Cairo::Context >) const
PBD::ScopedConnection sequencer_connection
Definition: beatbox_gui.h:139
bool mode_button_event(GdkEvent *, SequencerView::Mode)
static double mode_button_width
Definition: beatbox_gui.h:96
ArdourCanvas::Text * timing_mode_text
Definition: beatbox_gui.h:131
ArdourCanvas::Rectangle * timing_mode_button
Definition: beatbox_gui.h:125
void set_mode(Mode m)
static double mode_button_spacing
Definition: beatbox_gui.h:98
double _height
Definition: beatbox_gui.h:110
ArdourCanvas::Rectangle * octave_mode_button
Definition: beatbox_gui.h:123
ARDOUR::StepSequencer & _sequencer
Definition: beatbox_gui.h:103
Mode mode() const
Definition: beatbox_gui.h:89
ArdourCanvas::ConstraintPacker * button_packer
Definition: beatbox_gui.h:112
ArdourCanvas::Rectangle * pitch_mode_button
Definition: beatbox_gui.h:122
SequencerView(ARDOUR::StepSequencer &, ArdourCanvas::Item *)
static double rhs_xoffset
Definition: beatbox_gui.h:95
static double mode_button_xdim
Definition: beatbox_gui.h:99
ArdourCanvas::Text * pitch_mode_text
Definition: beatbox_gui.h:128
static double mode_button_ydim
Definition: beatbox_gui.h:100
std::vector< SequenceView * > SequenceViews
Definition: beatbox_gui.h:106
ArdourCanvas::ConstraintPacker * rhs_vbox
Definition: beatbox_gui.h:119
ArdourCanvas::Rectangle * velocity_mode_button
Definition: beatbox_gui.h:121
ArdourCanvas::ConstraintPacker * step_indicator_box
Definition: beatbox_gui.h:114
ArdourCanvas::ConstraintPacker * sequence_hbox
Definition: beatbox_gui.h:116
void sequencer_changed(PBD::PropertyChange const &)
std::vector< SequencerStepIndicator * > StepIndicators
Definition: beatbox_gui.h:104
ArdourCanvas::Text * velocity_mode_text
Definition: beatbox_gui.h:127
StepIndicators step_indicators
Definition: beatbox_gui.h:105
ArdourCanvas::Rectangle * gate_mode_button
Definition: beatbox_gui.h:124
ArdourCanvas::ConstraintPacker * steps_vbox
Definition: beatbox_gui.h:118
ARDOUR::StepSequencer & sequencer() const
Definition: beatbox_gui.h:85
static Gtkmm2ext::Color current_mode_color
Definition: beatbox_gui.h:133
ArdourCanvas::Text * gate_mode_text
Definition: beatbox_gui.h:130
static Gtkmm2ext::Color not_current_mode_color
Definition: beatbox_gui.h:134
static double mode_button_height
Definition: beatbox_gui.h:97
ArdourCanvas::Text * octave_mode_text
Definition: beatbox_gui.h:129
SequenceViews sequence_views
Definition: beatbox_gui.h:107
StepView(SequenceView &, ARDOUR::Step &, ArdourCanvas::Canvas *canvas)
bool grabbed
Definition: beatbox_gui.h:193
void adjust_step_duration(ARDOUR::Step::DurationRatio const &)
std::pair< double, double > grab_at
Definition: beatbox_gui.h:195
bool on_event(GdkEvent *)
std::pair< double, double > last_motion
Definition: beatbox_gui.h:196
bool motion_event(GdkEventMotion *)
static Gtkmm2ext::Color on_fill_color
Definition: beatbox_gui.h:216
void view_mode_changed()
void adjust_step_octave(int amt)
void adjust_step_pitch(int amt)
static Gtkmm2ext::Color off_fill_color
Definition: beatbox_gui.h:217
void step_changed(PBD::PropertyChange const &)
void render(ArdourCanvas::Rect const &, Cairo::RefPtr< Cairo::Context >) const
bool button_press_event(GdkEventButton *)
void set_timing_text()
ArdourCanvas::Text * text
Definition: beatbox_gui.h:192
void adjust_step_velocity(int amt)
ARDOUR::StepSequencer & sequencer() const
Definition: beatbox_gui.h:187
PBD::ScopedConnection step_connection
Definition: beatbox_gui.h:210
void set_octave_text()
bool button_release_event(GdkEventButton *)
void set_group_text()
bool scroll_event(GdkEventScroll *)
SequenceView & sv
Definition: beatbox_gui.h:191
ARDOUR::Step & _step
Definition: beatbox_gui.h:190
void adjust_step_timing(double fract)
uint32_t Color
Definition: colors.h:33
Definition: axis_view.h:42