2018-08-13 08:23:21 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2017 Paul Davis
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __gtk2_ardour_beatbox_gui_h__
|
|
|
|
#define __gtk2_ardour_beatbox_gui_h__
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
|
|
|
#include <gtkmm/radiobutton.h>
|
|
|
|
#include <gtkmm/togglebutton.h>
|
|
|
|
#include <gtkmm/button.h>
|
2018-11-03 23:19:59 -04:00
|
|
|
#include <gtkmm/scrollbar.h>
|
2018-08-13 08:23:21 -04:00
|
|
|
#include <gtkmm/spinbutton.h>
|
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/notebook.h>
|
|
|
|
|
|
|
|
#include "gtkmm2ext/colors.h"
|
|
|
|
|
2018-11-07 01:22:50 -05:00
|
|
|
#include "widgets/ardour_button.h"
|
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
#include "canvas/box.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "canvas/canvas.h"
|
2018-11-03 23:19:59 -04:00
|
|
|
#include "canvas/rectangle.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-07 16:25:29 -05:00
|
|
|
#include "ardour/step_sequencer.h"
|
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "widgets/ardour_button.h"
|
|
|
|
#include "widgets/ardour_dropdown.h"
|
|
|
|
#include "ardour_dialog.h"
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
namespace PBD {
|
|
|
|
class PropertyChange;
|
|
|
|
}
|
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
namespace ArdourCanvas {
|
|
|
|
class Grid;
|
|
|
|
class Item;
|
|
|
|
class StepButton;
|
2018-11-03 23:19:59 -04:00
|
|
|
class Polygon;
|
2018-08-13 08:23:21 -04:00
|
|
|
class Text;
|
|
|
|
class VBox;
|
|
|
|
class Widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ARDOUR {
|
|
|
|
class BeatBox;
|
|
|
|
}
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
class SequencerGrid;
|
2018-11-14 22:43:40 -05:00
|
|
|
class FloatingTextEntry;
|
|
|
|
|
|
|
|
class SequenceHeader : public ArdourCanvas::Rectangle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SequenceHeader (SequencerGrid&, ARDOUR::StepSequence&, ArdourCanvas::Item* parent);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SequencerGrid& grid;
|
|
|
|
ARDOUR::StepSequence& sequence;
|
|
|
|
|
|
|
|
ArdourCanvas::Rectangle* number_display;
|
|
|
|
ArdourCanvas::Rectangle* root_display;
|
|
|
|
|
|
|
|
ArdourCanvas::Text* number_text;
|
|
|
|
ArdourCanvas::Text* name_text;
|
|
|
|
ArdourCanvas::Text* root_text;
|
|
|
|
|
|
|
|
bool name_text_event (GdkEvent*);
|
|
|
|
void edit_name ();
|
|
|
|
void name_edited (std::string, int);
|
|
|
|
|
|
|
|
FloatingTextEntry* floating_entry;
|
|
|
|
};
|
2018-11-05 23:39:37 -05:00
|
|
|
|
|
|
|
class StepView : public ArdourCanvas::Rectangle, public sigc::trackable {
|
|
|
|
public:
|
2018-11-07 13:46:26 -05:00
|
|
|
StepView (SequencerGrid&, ARDOUR::Step&, ArdourCanvas::Item*);
|
2018-11-05 23:39:37 -05:00
|
|
|
|
|
|
|
void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
|
|
|
|
bool on_event (GdkEvent*);
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
void view_mode_changed ();
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
private:
|
|
|
|
ARDOUR::Step& _step;
|
2018-11-07 13:46:26 -05:00
|
|
|
SequencerGrid& _seq;
|
2018-11-07 01:22:50 -05:00
|
|
|
ArdourCanvas::Text* text;
|
2018-11-07 20:54:22 -05:00
|
|
|
bool grabbed;
|
2018-11-05 23:39:37 -05:00
|
|
|
|
|
|
|
std::pair<double,double> grab_at;
|
2018-11-07 20:54:22 -05:00
|
|
|
std::pair<double,double> last_motion;
|
2018-11-05 23:39:37 -05:00
|
|
|
|
|
|
|
bool motion_event (GdkEventMotion*);
|
|
|
|
bool button_press_event (GdkEventButton*);
|
|
|
|
bool button_release_event (GdkEventButton*);
|
|
|
|
bool scroll_event (GdkEventScroll*);
|
|
|
|
|
|
|
|
void adjust_step_pitch (int amt);
|
|
|
|
void adjust_step_velocity (int amt);
|
2018-11-07 16:25:29 -05:00
|
|
|
void adjust_step_duration (ARDOUR::Step::DurationRatio const &);
|
2018-11-07 13:46:26 -05:00
|
|
|
void adjust_step_octave (int amt);
|
2018-11-15 17:35:36 -05:00
|
|
|
void adjust_step_timing (double fract);
|
2018-11-05 23:39:37 -05:00
|
|
|
|
|
|
|
void step_changed (PBD::PropertyChange const &);
|
|
|
|
PBD::ScopedConnection step_connection;
|
2018-11-07 01:22:50 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
void set_octave_text ();
|
|
|
|
void set_group_text ();
|
2018-11-15 21:27:20 -05:00
|
|
|
void set_timing_text ();
|
2018-11-16 21:13:05 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
static Gtkmm2ext::Color on_fill_color;
|
|
|
|
static Gtkmm2ext::Color off_fill_color;
|
|
|
|
};
|
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
class SequencerStepIndicator : public ArdourCanvas::Rectangle, public sigc::trackable {
|
2018-11-08 17:55:56 -05:00
|
|
|
public:
|
2018-11-16 21:13:05 -05:00
|
|
|
SequencerStepIndicator (SequencerGrid&, ArdourCanvas::Canvas*, size_t n);
|
2018-11-08 17:55:56 -05:00
|
|
|
void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
|
|
|
|
bool on_event (GdkEvent*);
|
|
|
|
|
|
|
|
void set_current (bool);
|
|
|
|
|
|
|
|
private:
|
|
|
|
SequencerGrid& grid;
|
|
|
|
size_t number;
|
|
|
|
ArdourCanvas::Polygon* poly;
|
|
|
|
ArdourCanvas::Text* text;
|
2018-11-09 21:27:53 -05:00
|
|
|
bool being_dragged;
|
2018-11-08 17:55:56 -05:00
|
|
|
|
|
|
|
static int dragging;
|
|
|
|
|
|
|
|
bool motion_event (GdkEventMotion*);
|
|
|
|
bool button_press_event (GdkEventButton*);
|
|
|
|
bool button_release_event (GdkEventButton*);
|
|
|
|
|
|
|
|
void set_text ();
|
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
void sequencer_changed (PBD::PropertyChange const &);
|
|
|
|
PBD::ScopedConnection sequencer_connection;
|
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
static Gtkmm2ext::Color current_color;
|
|
|
|
static Gtkmm2ext::Color other_color;
|
|
|
|
static Gtkmm2ext::Color current_text_color;
|
|
|
|
static Gtkmm2ext::Color other_text_color;
|
2018-11-09 21:27:53 -05:00
|
|
|
static Gtkmm2ext::Color bright_outline_color;
|
2018-11-05 23:39:37 -05:00
|
|
|
};
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
class SequencerGrid : public ArdourCanvas::Rectangle, public sigc::trackable {
|
2018-11-03 23:19:59 -04:00
|
|
|
public:
|
2018-11-07 13:46:26 -05:00
|
|
|
enum Mode {
|
|
|
|
Velocity,
|
|
|
|
Pitch,
|
2018-11-07 15:19:53 -05:00
|
|
|
Duration,
|
2018-11-07 13:46:26 -05:00
|
|
|
Octave,
|
|
|
|
Group,
|
2018-11-14 23:12:33 -05:00
|
|
|
Timing,
|
2018-11-07 13:46:26 -05:00
|
|
|
};
|
|
|
|
|
2018-11-07 15:19:53 -05:00
|
|
|
SequencerGrid (ARDOUR::StepSequencer&, ArdourCanvas::Canvas*);
|
2018-11-03 23:19:59 -04:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
ARDOUR::StepSequencer& sequencer() const { return _sequencer; }
|
|
|
|
|
2018-11-14 22:43:40 -05:00
|
|
|
SequenceHeader& sequence_header (size_t n) const;
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
Mode mode() const { return _mode; }
|
|
|
|
void set_mode (Mode m);
|
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
|
2018-11-08 17:55:56 -05:00
|
|
|
void update ();
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-11-14 22:43:40 -05:00
|
|
|
static double rhs_xoffset;
|
|
|
|
static double mode_button_width;
|
|
|
|
static double mode_button_height;
|
|
|
|
static double mode_button_spacing;
|
|
|
|
static double mode_button_xdim;
|
|
|
|
static double mode_button_ydim;
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
private:
|
|
|
|
ARDOUR::StepSequencer& _sequencer;
|
2018-11-07 13:46:26 -05:00
|
|
|
typedef std::vector<StepView*> StepViews;
|
2018-11-08 17:55:56 -05:00
|
|
|
StepViews step_views;
|
|
|
|
typedef std::vector<SequencerStepIndicator*> StepIndicators;
|
|
|
|
StepIndicators step_indicators;
|
2018-11-14 22:43:40 -05:00
|
|
|
typedef std::vector<SequenceHeader*> SequenceHeaders;
|
|
|
|
SequenceHeaders sequence_headers;
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
double _width;
|
|
|
|
double _height;
|
2018-11-07 13:46:26 -05:00
|
|
|
Mode _mode;
|
2018-11-07 15:19:53 -05:00
|
|
|
ArdourCanvas::ScrollGroup* v_scroll_group;
|
|
|
|
ArdourCanvas::Container* no_scroll_group;
|
|
|
|
ArdourCanvas::Rectangle* step_indicator_bg;
|
2018-11-16 21:13:05 -05:00
|
|
|
ArdourCanvas::HBox* step_indicator_box;
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
ArdourCanvas::Rectangle* velocity_mode_button;
|
|
|
|
ArdourCanvas::Rectangle* pitch_mode_button;
|
|
|
|
ArdourCanvas::Rectangle* octave_mode_button;
|
|
|
|
ArdourCanvas::Rectangle* gate_mode_button;
|
2018-11-14 23:12:33 -05:00
|
|
|
ArdourCanvas::Rectangle* timing_mode_button;
|
2018-11-09 21:27:53 -05:00
|
|
|
|
2018-11-14 22:43:40 -05:00
|
|
|
ArdourCanvas::Text* velocity_mode_text;
|
|
|
|
ArdourCanvas::Text* pitch_mode_text;
|
|
|
|
ArdourCanvas::Text* octave_mode_text;
|
|
|
|
ArdourCanvas::Text* gate_mode_text;
|
2018-11-14 23:12:33 -05:00
|
|
|
ArdourCanvas::Text* timing_mode_text;
|
2018-11-14 22:43:40 -05:00
|
|
|
|
|
|
|
static Gtkmm2ext::Color current_mode_color;
|
|
|
|
static Gtkmm2ext::Color not_current_mode_color;
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
void sequencer_changed (PBD::PropertyChange const &);
|
2018-11-14 22:43:40 -05:00
|
|
|
bool mode_button_event (GdkEvent*, SequencerGrid::Mode);
|
2018-11-07 13:46:26 -05:00
|
|
|
|
|
|
|
PBD::ScopedConnection sequencer_connection;
|
2018-11-14 22:43:40 -05:00
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
};
|
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
class BBGUI : public ArdourDialog {
|
|
|
|
public:
|
|
|
|
BBGUI (boost::shared_ptr<ARDOUR::BeatBox> bb);
|
|
|
|
~BBGUI ();
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
double width() const { return _width; }
|
|
|
|
double height() const { return _height; }
|
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
protected:
|
|
|
|
void on_map ();
|
|
|
|
void on_unmap ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
boost::shared_ptr<ARDOUR::BeatBox> bbox;
|
2018-11-05 23:39:37 -05:00
|
|
|
double _width;
|
|
|
|
double _height;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
Gtk::Adjustment horizontal_adjustment;
|
|
|
|
Gtk::Adjustment vertical_adjustment;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
ArdourCanvas::GtkCanvasViewport* _canvas_viewport;
|
|
|
|
ArdourCanvas::GtkCanvas* _canvas;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
SequencerGrid* _sequencer;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
ArdourWidgets::ArdourButton start_button;
|
|
|
|
void toggle_play ();
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
ArdourWidgets::ArdourButton export_as_region_button;
|
|
|
|
void export_as_region ();
|
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
Gtk::HBox canvas_hbox;
|
|
|
|
Gtk::VScrollbar vscrollbar;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
void clear ();
|
2018-11-03 23:19:59 -04:00
|
|
|
void update ();
|
|
|
|
void update_sequencer ();
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
sigc::connection timer_connection;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
void sequencer_changed (PBD::PropertyChange const &);
|
2018-11-07 01:22:50 -05:00
|
|
|
|
|
|
|
Gtk::HBox mode_box;
|
|
|
|
ArdourWidgets::ArdourButton mode_velocity_button;
|
|
|
|
ArdourWidgets:: ArdourButton mode_pitch_button;
|
|
|
|
ArdourWidgets::ArdourButton mode_octave_button;
|
|
|
|
ArdourWidgets::ArdourButton mode_group_button;
|
2018-11-07 15:19:53 -05:00
|
|
|
ArdourWidgets::ArdourButton mode_duration_button;
|
2018-11-07 01:22:50 -05:00
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
PBD::ScopedConnection sequencer_connection;
|
2018-08-13 08:23:21 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __gtk2_ardour_beatbox_gui_h__ */
|