allow GUI to modify step duration (gate length)
This commit is contained in:
parent
870b142f9b
commit
c37d81e0c1
@ -71,26 +71,15 @@ BBGUI::BBGUI (boost::shared_ptr<BeatBox> bb)
|
|||||||
, mode_pitch_button (_("Pitch"))
|
, mode_pitch_button (_("Pitch"))
|
||||||
, mode_octave_button (_("Octave"))
|
, mode_octave_button (_("Octave"))
|
||||||
, mode_group_button (_("Group"))
|
, mode_group_button (_("Group"))
|
||||||
|
, mode_duration_button (_("Gate"))
|
||||||
|
|
||||||
{
|
{
|
||||||
_canvas_viewport = new GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
|
_canvas_viewport = new GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
|
||||||
_canvas = _canvas_viewport->canvas();
|
_canvas = _canvas_viewport->canvas();
|
||||||
|
|
||||||
_canvas->set_background_color (UIConfiguration::instance().color ("gtk_bright_color"));
|
_canvas->set_background_color (UIConfiguration::instance().color ("gtk_bright_color"));
|
||||||
_canvas->use_nsglview ();
|
_canvas->use_nsglview ();
|
||||||
|
|
||||||
no_scroll_group = new ArdourCanvas::Container (_canvas->root());
|
_sequencer = new SequencerGrid (bbox->sequencer(), _canvas);
|
||||||
|
|
||||||
step_indicator_box = new ArdourCanvas::Container (no_scroll_group);
|
|
||||||
|
|
||||||
step_indicator_bg = new ArdourCanvas::Rectangle (step_indicator_box);
|
|
||||||
step_indicator_bg->set_fill_color (UIConfiguration::instance().color ("gtk_lightest"));
|
|
||||||
step_indicator_bg->set_outline (false);
|
|
||||||
|
|
||||||
v_scroll_group = new ScrollGroup (_canvas->root(), ScrollGroup::ScrollsVertically);
|
|
||||||
_canvas->add_scroller (*v_scroll_group);
|
|
||||||
|
|
||||||
_sequencer = new SequencerGrid (bbox->sequencer(), v_scroll_group);
|
|
||||||
_sequencer->set_position (Duple (0, _step_dimen));
|
_sequencer->set_position (Duple (0, _step_dimen));
|
||||||
_sequencer->set_fill_color (UIConfiguration::instance().color ("gtk_contrasting_indicator"));
|
_sequencer->set_fill_color (UIConfiguration::instance().color ("gtk_contrasting_indicator"));
|
||||||
|
|
||||||
@ -101,6 +90,7 @@ BBGUI::BBGUI (boost::shared_ptr<BeatBox> bb)
|
|||||||
|
|
||||||
mode_box.pack_start (mode_velocity_button);
|
mode_box.pack_start (mode_velocity_button);
|
||||||
mode_box.pack_start (mode_pitch_button);
|
mode_box.pack_start (mode_pitch_button);
|
||||||
|
mode_box.pack_start (mode_duration_button);
|
||||||
mode_box.pack_start (mode_octave_button);
|
mode_box.pack_start (mode_octave_button);
|
||||||
mode_box.pack_start (mode_group_button);
|
mode_box.pack_start (mode_group_button);
|
||||||
|
|
||||||
@ -108,6 +98,7 @@ BBGUI::BBGUI (boost::shared_ptr<BeatBox> bb)
|
|||||||
mode_pitch_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Pitch));
|
mode_pitch_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Pitch));
|
||||||
mode_octave_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Octave));
|
mode_octave_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Octave));
|
||||||
mode_group_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Group));
|
mode_group_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Group));
|
||||||
|
mode_duration_button.signal_clicked.connect (sigc::bind (sigc::mem_fun (*this, &BBGUI::mode_clicked), SequencerGrid::Duration));
|
||||||
|
|
||||||
get_vbox()->set_spacing (12);
|
get_vbox()->set_spacing (12);
|
||||||
get_vbox()->pack_start (mode_box, false, false);
|
get_vbox()->pack_start (mode_box, false, false);
|
||||||
@ -298,27 +289,26 @@ BBGUI::sequencer_changed (PropertyChange const &)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_canvas_viewport->set_size_request (_width, _height + _step_dimen);
|
_canvas_viewport->set_size_request (_width, _height + _step_dimen);
|
||||||
|
|
||||||
step_indicator_bg->set (Rect (0, 0, _width, _step_dimen));
|
|
||||||
step_indicator_box->clear (true); /* delete all existing step indicators */
|
|
||||||
|
|
||||||
/* indicator row */
|
|
||||||
|
|
||||||
for (size_t n = 0; n < nsteps; ++n) {
|
|
||||||
SequencerStepIndicator* ssi = new SequencerStepIndicator (step_indicator_box, n+1);
|
|
||||||
ssi->set (Rect (n * _step_dimen, 0, (n+1) * _step_dimen, _step_dimen));
|
|
||||||
ssi->set_position (Duple (n * _step_dimen, 0.0));
|
|
||||||
ssi->set_fill_color (random());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
SequencerGrid::SequencerGrid (StepSequencer& s, Item *parent)
|
SequencerGrid::SequencerGrid (StepSequencer& s, Canvas* c)
|
||||||
: Rectangle (parent)
|
: Rectangle (c)
|
||||||
, _sequencer (s)
|
, _sequencer (s)
|
||||||
, _mode (Velocity)
|
, _mode (Velocity)
|
||||||
{
|
{
|
||||||
|
no_scroll_group = new ArdourCanvas::Container (_canvas->root());
|
||||||
|
step_indicator_box = new ArdourCanvas::Container (no_scroll_group);
|
||||||
|
|
||||||
|
step_indicator_bg = new ArdourCanvas::Rectangle (step_indicator_box);
|
||||||
|
step_indicator_bg->set_fill_color (UIConfiguration::instance().color ("gtk_lightest"));
|
||||||
|
step_indicator_bg->set_outline (false);
|
||||||
|
|
||||||
|
v_scroll_group = new ScrollGroup (_canvas->root(), ScrollGroup::ScrollsVertically);
|
||||||
|
_canvas->add_scroller (*v_scroll_group);
|
||||||
|
v_scroll_group->add (this);
|
||||||
|
|
||||||
_sequencer.PropertyChanged.connect (sequencer_connection, invalidator (*this), boost::bind (&SequencerGrid::sequencer_changed, this, _1), gui_context());
|
_sequencer.PropertyChanged.connect (sequencer_connection, invalidator (*this), boost::bind (&SequencerGrid::sequencer_changed, this, _1), gui_context());
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -339,6 +329,17 @@ SequencerGrid::sequencer_changed (PropertyChange const &)
|
|||||||
|
|
||||||
set (Rect (0, 0, _width, _height));
|
set (Rect (0, 0, _width, _height));
|
||||||
|
|
||||||
|
step_indicator_bg->set (Rect (0, 0, _width, _step_dimen));
|
||||||
|
step_indicator_box->clear (true); /* delete all existing step indicators */
|
||||||
|
|
||||||
|
/* indicator row */
|
||||||
|
|
||||||
|
for (size_t n = 0; n < nsteps; ++n) {
|
||||||
|
SequencerStepIndicator* ssi = new SequencerStepIndicator (step_indicator_box, n+1);
|
||||||
|
ssi->set (Rect (n * _step_dimen, 0, (n+1) * _step_dimen, _step_dimen));
|
||||||
|
ssi->set_position (Duple (n * _step_dimen, 0.0));
|
||||||
|
ssi->set_fill_color (random());
|
||||||
|
}
|
||||||
/* step views, one per step per sequence */
|
/* step views, one per step per sequence */
|
||||||
|
|
||||||
clear (true);
|
clear (true);
|
||||||
@ -346,7 +347,8 @@ SequencerGrid::sequencer_changed (PropertyChange const &)
|
|||||||
|
|
||||||
for (size_t s = 0; s < nsequences; ++s) {
|
for (size_t s = 0; s < nsequences; ++s) {
|
||||||
for (size_t n = 0; n < nsteps; ++n) {
|
for (size_t n = 0; n < nsteps; ++n) {
|
||||||
StepView* sv = new StepView (*this, _sequencer.sequence (s).step (n), Item::parent());
|
StepView* sv = new StepView (*this, _sequencer.sequence (s).step (n), v_scroll_group);
|
||||||
|
/* sequence row is 1-row down ... because of the step indicator row */
|
||||||
sv->set_position (Duple (n * _step_dimen, (s+1) * _step_dimen));
|
sv->set_position (Duple (n * _step_dimen, (s+1) * _step_dimen));
|
||||||
sv->set (Rect (1, 1, _step_dimen - 2, _step_dimen - 2));
|
sv->set (Rect (1, 1, _step_dimen - 2, _step_dimen - 2));
|
||||||
_step_views.push_back (sv);
|
_step_views.push_back (sv);
|
||||||
@ -483,6 +485,7 @@ StepView::view_mode_changed ()
|
|||||||
text->set_position (Duple (_step_dimen/2 - (w/2), _step_dimen/2 - (h/2)));
|
text->set_position (Duple (_step_dimen/2 - (w/2), _step_dimen/2 - (h/2)));
|
||||||
|
|
||||||
} else if (_seq.mode() == SequencerGrid::Group) {
|
} else if (_seq.mode() == SequencerGrid::Group) {
|
||||||
|
text->set (std::string());
|
||||||
text->show ();
|
text->show ();
|
||||||
} else {
|
} else {
|
||||||
text->hide ();
|
text->hide ();
|
||||||
@ -508,6 +511,11 @@ StepView::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context>
|
|||||||
const Duple origin = item_to_window (Duple (0, 0));
|
const Duple origin = item_to_window (Duple (0, 0));
|
||||||
context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height);
|
context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height);
|
||||||
context->fill ();
|
context->fill ();
|
||||||
|
} else if (_seq.mode() == SequencerGrid::Duration) {
|
||||||
|
const double height = (_step_dimen - 4) * (_step.duration());
|
||||||
|
const Duple origin = item_to_window (Duple (0, 0));
|
||||||
|
context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height);
|
||||||
|
context->fill ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now deal with any children (e.g. text) */
|
/* now deal with any children (e.g. text) */
|
||||||
@ -585,6 +593,9 @@ StepView::scroll_event (GdkEventScroll* ev)
|
|||||||
} else if (_seq.mode() == SequencerGrid::Velocity) {
|
} else if (_seq.mode() == SequencerGrid::Velocity) {
|
||||||
cerr << "adjust velocity by " << amt << endl;
|
cerr << "adjust velocity by " << amt << endl;
|
||||||
adjust_step_velocity (amt);
|
adjust_step_velocity (amt);
|
||||||
|
} else if (_seq.mode() == SequencerGrid::Duration) {
|
||||||
|
cerr << "adjust velocity by " << amt << endl;
|
||||||
|
adjust_step_duration (amt/32.0); /* adjust by 1/32 of the sequencer step size */
|
||||||
} else if (_seq.mode() == SequencerGrid::Octave) {
|
} else if (_seq.mode() == SequencerGrid::Octave) {
|
||||||
adjust_step_octave (amt);
|
adjust_step_octave (amt);
|
||||||
} else if (_seq.mode() == SequencerGrid::Group) {
|
} else if (_seq.mode() == SequencerGrid::Group) {
|
||||||
@ -610,3 +621,9 @@ StepView::adjust_step_octave (int amt)
|
|||||||
{
|
{
|
||||||
_step.adjust_octave (amt);
|
_step.adjust_octave (amt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StepView::adjust_step_duration (double amt)
|
||||||
|
{
|
||||||
|
_step.adjust_duration (amt);
|
||||||
|
}
|
||||||
|
@ -88,6 +88,7 @@ class StepView : public ArdourCanvas::Rectangle, public sigc::trackable {
|
|||||||
|
|
||||||
void adjust_step_pitch (int amt);
|
void adjust_step_pitch (int amt);
|
||||||
void adjust_step_velocity (int amt);
|
void adjust_step_velocity (int amt);
|
||||||
|
void adjust_step_duration (double);
|
||||||
void adjust_step_octave (int amt);
|
void adjust_step_octave (int amt);
|
||||||
|
|
||||||
void step_changed (PBD::PropertyChange const &);
|
void step_changed (PBD::PropertyChange const &);
|
||||||
@ -101,11 +102,12 @@ class SequencerGrid : public ArdourCanvas::Rectangle, public sigc::trackable {
|
|||||||
enum Mode {
|
enum Mode {
|
||||||
Velocity,
|
Velocity,
|
||||||
Pitch,
|
Pitch,
|
||||||
|
Duration,
|
||||||
Octave,
|
Octave,
|
||||||
Group,
|
Group,
|
||||||
};
|
};
|
||||||
|
|
||||||
SequencerGrid (ARDOUR::StepSequencer&, ArdourCanvas::Item* parent);
|
SequencerGrid (ARDOUR::StepSequencer&, ArdourCanvas::Canvas*);
|
||||||
|
|
||||||
Mode mode() const { return _mode; }
|
Mode mode() const { return _mode; }
|
||||||
void set_mode (Mode m);
|
void set_mode (Mode m);
|
||||||
@ -119,6 +121,10 @@ class SequencerGrid : public ArdourCanvas::Rectangle, public sigc::trackable {
|
|||||||
double _width;
|
double _width;
|
||||||
double _height;
|
double _height;
|
||||||
Mode _mode;
|
Mode _mode;
|
||||||
|
ArdourCanvas::ScrollGroup* v_scroll_group;
|
||||||
|
ArdourCanvas::Container* no_scroll_group;
|
||||||
|
ArdourCanvas::Rectangle* step_indicator_bg;
|
||||||
|
ArdourCanvas::Container* step_indicator_box;
|
||||||
|
|
||||||
void sequencer_changed (PBD::PropertyChange const &);
|
void sequencer_changed (PBD::PropertyChange const &);
|
||||||
|
|
||||||
@ -156,12 +162,8 @@ class BBGUI : public ArdourDialog {
|
|||||||
|
|
||||||
ArdourCanvas::GtkCanvasViewport* _canvas_viewport;
|
ArdourCanvas::GtkCanvasViewport* _canvas_viewport;
|
||||||
ArdourCanvas::GtkCanvas* _canvas;
|
ArdourCanvas::GtkCanvas* _canvas;
|
||||||
ArdourCanvas::ScrollGroup* v_scroll_group;
|
|
||||||
ArdourCanvas::Container* no_scroll_group;
|
|
||||||
|
|
||||||
SequencerGrid* _sequencer;
|
SequencerGrid* _sequencer;
|
||||||
ArdourCanvas::Rectangle* step_indicator_bg;
|
|
||||||
ArdourCanvas::Container* step_indicator_box;
|
|
||||||
|
|
||||||
ArdourWidgets::ArdourButton start_button;
|
ArdourWidgets::ArdourButton start_button;
|
||||||
void toggle_play ();
|
void toggle_play ();
|
||||||
@ -185,6 +187,7 @@ class BBGUI : public ArdourDialog {
|
|||||||
ArdourWidgets:: ArdourButton mode_pitch_button;
|
ArdourWidgets:: ArdourButton mode_pitch_button;
|
||||||
ArdourWidgets::ArdourButton mode_octave_button;
|
ArdourWidgets::ArdourButton mode_octave_button;
|
||||||
ArdourWidgets::ArdourButton mode_group_button;
|
ArdourWidgets::ArdourButton mode_group_button;
|
||||||
|
ArdourWidgets::ArdourButton mode_duration_button;
|
||||||
|
|
||||||
void mode_clicked (SequencerGrid::Mode);
|
void mode_clicked (SequencerGrid::Mode);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user