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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <ctime>
|
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
#include <boost/integer/common_factor.hpp>
|
2018-11-15 21:27:20 -05:00
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/i18n.h"
|
|
|
|
|
2021-07-22 20:05:11 -04:00
|
|
|
#ifdef HAVE_BEATBOX
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "ardour/beatbox.h"
|
2021-07-22 20:05:11 -04:00
|
|
|
#endif
|
2018-11-14 22:43:40 -05:00
|
|
|
#include "ardour/parameter_descriptor.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/smf_source.h"
|
|
|
|
#include "ardour/source_factory.h"
|
2018-11-03 23:19:59 -04:00
|
|
|
#include "ardour/step_sequencer.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "ardour/region.h"
|
|
|
|
#include "ardour/region_factory.h"
|
|
|
|
#include "ardour/utils.h"
|
|
|
|
|
|
|
|
#include "canvas/canvas.h"
|
|
|
|
#include "canvas/grid.h"
|
|
|
|
#include "canvas/box.h"
|
2020-07-12 02:01:28 -04:00
|
|
|
#include "canvas/constrained_item.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "canvas/rectangle.h"
|
2018-11-03 23:19:59 -04:00
|
|
|
#include "canvas/polygon.h"
|
|
|
|
#include "canvas/scroll_group.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "canvas/step_button.h"
|
|
|
|
#include "canvas/text.h"
|
|
|
|
#include "canvas/widget.h"
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "gtkmm2ext/utils.h"
|
2018-11-08 17:55:56 -05:00
|
|
|
#include "gtkmm2ext/colors.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
#include "beatbox_gui.h"
|
2018-11-14 22:43:40 -05:00
|
|
|
#include "floating_text_entry.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
#include "timers.h"
|
2018-11-03 23:19:59 -04:00
|
|
|
#include "ui_config.h"
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
using namespace PBD;
|
2018-08-13 08:23:21 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Gtkmm2ext;
|
2018-11-03 23:19:59 -04:00
|
|
|
using namespace ArdourCanvas;
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
using std::cerr;
|
|
|
|
using std::endl;
|
|
|
|
|
2018-11-07 21:36:53 -05:00
|
|
|
const double _step_dimen = 32;
|
2018-11-03 23:19:59 -04:00
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
BBGUI::BBGUI (boost::shared_ptr<BeatBox> bb)
|
|
|
|
: ArdourDialog (_("BeatBox"))
|
|
|
|
, bbox (bb)
|
2018-11-03 23:19:59 -04:00
|
|
|
, horizontal_adjustment (0.0, 0.0, 800.0)
|
|
|
|
, vertical_adjustment (0.0, 0.0, 10.0, 400.0)
|
2020-07-08 23:49:52 -04:00
|
|
|
, export_as_region_button (_("Export as Region"))
|
2018-08-13 08:23:21 -04:00
|
|
|
{
|
2018-11-03 23:19:59 -04:00
|
|
|
_canvas_viewport = new GtkCanvasViewport (horizontal_adjustment, vertical_adjustment);
|
|
|
|
_canvas = _canvas_viewport->canvas();
|
2018-11-08 17:55:56 -05:00
|
|
|
_canvas->set_background_color (UIConfiguration::instance().color ("gtk_bases"));
|
2018-11-03 23:19:59 -04:00
|
|
|
_canvas->use_nsglview ();
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
_sequencer = new SequencerView (bbox->sequencer(), _canvas->root());
|
2018-11-03 23:19:59 -04:00
|
|
|
|
|
|
|
canvas_hbox.pack_start (*_canvas_viewport, true, true);
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
get_vbox()->set_spacing (12);
|
2018-11-03 23:19:59 -04:00
|
|
|
get_vbox()->pack_start (canvas_hbox, true, true);
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
export_as_region_button.signal_clicked.connect (sigc::mem_fun (*this, &BBGUI::export_as_region));
|
|
|
|
get_action_area()->pack_end (export_as_region_button);
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
bbox->sequencer().PropertyChanged.connect (sequencer_connection, invalidator (*this), boost::bind (&BBGUI::sequencer_changed, this, _1), gui_context());
|
|
|
|
|
|
|
|
{
|
|
|
|
/* trigger initial draw */
|
|
|
|
PropertyChange pc;
|
|
|
|
sequencer_changed (pc);
|
|
|
|
}
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-08-13 08:23:21 -04:00
|
|
|
show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
BBGUI::~BBGUI ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
void
|
|
|
|
BBGUI::update ()
|
2018-08-13 08:23:21 -04:00
|
|
|
{
|
2018-11-08 17:55:56 -05:00
|
|
|
_sequencer->update ();
|
2018-08-13 08:23:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-03 23:19:59 -04:00
|
|
|
BBGUI::on_map ()
|
2018-08-13 08:23:21 -04:00
|
|
|
{
|
2018-11-03 23:19:59 -04:00
|
|
|
timer_connection = Timers::rapid_connect (sigc::mem_fun (*this, &BBGUI::update));
|
|
|
|
ArdourDialog::on_map ();
|
2018-08-13 08:23:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-03 23:19:59 -04:00
|
|
|
BBGUI::on_unmap ()
|
2018-08-13 08:23:21 -04:00
|
|
|
{
|
2018-11-03 23:19:59 -04:00
|
|
|
timer_connection.disconnect ();
|
|
|
|
ArdourDialog::on_unmap ();
|
2018-08-13 08:23:21 -04:00
|
|
|
}
|
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
#if 0
|
2018-08-13 08:23:21 -04:00
|
|
|
bool
|
|
|
|
BBGUI::SwitchRow::switch_event (GdkEvent* ev, int col)
|
|
|
|
{
|
|
|
|
Timecode::BBT_Time at;
|
|
|
|
|
|
|
|
const int beats_per_bar = owner.bbox->meter_beats();
|
|
|
|
|
|
|
|
at.bars = col / beats_per_bar;
|
|
|
|
at.beats = col % beats_per_bar;
|
|
|
|
at.ticks = 0;
|
|
|
|
|
|
|
|
at.bars++;
|
|
|
|
at.beats++;
|
|
|
|
|
|
|
|
Switch* s = switches[col];
|
|
|
|
|
|
|
|
if (ev->type == GDK_BUTTON_PRESS) {
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
/* XXX changes should be driven by model */
|
2018-08-13 08:23:21 -04:00
|
|
|
if (s->button->value()) {
|
|
|
|
owner.bbox->remove_note (note, at);
|
|
|
|
s->button->set_value (0);
|
|
|
|
} else {
|
|
|
|
s->button->set_value (64);
|
|
|
|
owner.bbox->add_note (note, rint (s->button->value()), at);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else if (ev->type == GDK_SCROLL) {
|
|
|
|
switch (ev->scroll.direction) {
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
s->button->set_value (s->button->value() + 1);
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
s->button->set_value (s->button->value() - 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2018-11-03 23:19:59 -04:00
|
|
|
#endif
|
2018-08-13 08:23:21 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
BBGUI::clear ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
BBGUI::export_as_region ()
|
|
|
|
{
|
|
|
|
std::string path = bbox->session().new_midi_source_path (bbox->owner()->name());
|
2018-12-03 09:06:09 -05:00
|
|
|
boost::shared_ptr<Source> src = bbox->sequencer().write_to_source (bbox->session(), path);
|
2018-08-13 08:23:21 -04:00
|
|
|
|
2018-12-03 09:06:09 -05:00
|
|
|
if (!src) {
|
2018-08-13 08:23:21 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string region_name = region_name_from_path (src->name(), true);
|
|
|
|
|
|
|
|
PBD::PropertyList plist;
|
|
|
|
|
|
|
|
plist.add (ARDOUR::Properties::start, 0);
|
|
|
|
plist.add (ARDOUR::Properties::length, src->length (0));
|
|
|
|
plist.add (ARDOUR::Properties::name, region_name);
|
|
|
|
plist.add (ARDOUR::Properties::layer, 0);
|
|
|
|
plist.add (ARDOUR::Properties::whole_file, true);
|
|
|
|
plist.add (ARDOUR::Properties::external, false);
|
|
|
|
|
|
|
|
boost::shared_ptr<Region> region = RegionFactory::create (src, plist, true);
|
|
|
|
}
|
2018-11-03 23:19:59 -04:00
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
void
|
|
|
|
BBGUI::sequencer_changed (PropertyChange const &)
|
2018-11-03 23:19:59 -04:00
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
const size_t nsteps = bbox->sequencer().step_capacity ();
|
2018-11-05 23:39:37 -05:00
|
|
|
const size_t nsequences = bbox->sequencer().nsequences();
|
|
|
|
|
|
|
|
_width = _step_dimen * nsteps;
|
2018-11-19 11:31:31 -05:00
|
|
|
_height = (_step_dimen * (1+nsequences)) + SequencerView::mode_button_ydim;
|
2018-11-14 22:43:40 -05:00
|
|
|
|
|
|
|
size_t required_scroll = _height - _canvas_viewport->get_allocation().get_height();
|
|
|
|
|
|
|
|
vertical_adjustment.set_upper (required_scroll);
|
2018-11-05 23:39:37 -05:00
|
|
|
|
Fix typos in gtk2_ardour/ directory
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sur,te,trough,ue`
2022-01-26 12:35:38 -05:00
|
|
|
/* height is 1 step_dimen larger to accommodate the "step indicator"
|
2018-11-05 23:39:37 -05:00
|
|
|
* line at the top
|
|
|
|
*/
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
_canvas_viewport->set_size_request (SequencerView::rhs_xoffset + _width, _height);
|
2018-11-03 23:19:59 -04:00
|
|
|
}
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
/**/
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
Gtkmm2ext::Color SequencerView::current_mode_color = Gtkmm2ext::Color (0);
|
|
|
|
Gtkmm2ext::Color SequencerView::not_current_mode_color = Gtkmm2ext::Color (0);
|
2018-11-14 22:43:40 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
double SequencerView::rhs_xoffset = 250.0;
|
|
|
|
double SequencerView::mode_button_width = 110.0;
|
|
|
|
double SequencerView::mode_button_height = 60.0;
|
|
|
|
double SequencerView::mode_button_spacing = 10;
|
|
|
|
double SequencerView::mode_button_xdim = mode_button_width + mode_button_spacing;
|
|
|
|
double SequencerView::mode_button_ydim = mode_button_height + mode_button_spacing;
|
2018-11-14 22:43:40 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
SequencerView::SequencerView (StepSequencer& s, ArdourCanvas::Item *p)
|
2020-07-12 02:01:28 -04:00
|
|
|
: ConstraintPacker (p, Vertical)
|
2018-11-05 23:39:37 -05:00
|
|
|
, _sequencer (s)
|
2018-11-07 13:46:26 -05:00
|
|
|
, _mode (Velocity)
|
2018-11-03 23:19:59 -04:00
|
|
|
{
|
2020-07-12 02:01:28 -04:00
|
|
|
name = "SequencerView";
|
|
|
|
set_fill (false);
|
|
|
|
|
2018-11-14 22:43:40 -05:00
|
|
|
if (current_mode_color == 0) {
|
|
|
|
current_mode_color = UIConfiguration::instance().color ("gtk_lightest");
|
|
|
|
not_current_mode_color = contrasting_text_color (current_mode_color);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Duple mode_button_center (mode_button_width/2.0, mode_button_height/2.0);
|
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
button_packer = new ArdourCanvas::ConstraintPacker (_canvas, ArdourCanvas::Horizontal);
|
|
|
|
button_packer->name = "ButtonPacker";
|
|
|
|
pack_start (button_packer);
|
2018-11-07 15:19:53 -05:00
|
|
|
|
2020-07-13 00:04:56 -04:00
|
|
|
sequence_hbox = new ConstraintPacker (_canvas, Horizontal);
|
|
|
|
sequence_hbox->name = "shbox";
|
|
|
|
pack_start (sequence_hbox);
|
|
|
|
|
|
|
|
lhs_vbox = new ArdourCanvas::ConstraintPacker (_canvas, Vertical);
|
|
|
|
lhs_vbox->name = "lhs";
|
|
|
|
|
|
|
|
ConstrainedItem* ci;
|
|
|
|
ci = sequence_hbox->pack_start (lhs_vbox);
|
|
|
|
ci->add_constraint (ci->width() == 0.8 * sequence_hbox->width);
|
|
|
|
|
|
|
|
steps_vbox = new ConstraintPacker (_canvas, Vertical);
|
|
|
|
steps_vbox->name = "steps";
|
|
|
|
sequence_hbox->pack_start (steps_vbox, PackOptions (PackExpand|PackFill));
|
|
|
|
|
|
|
|
rhs_vbox = new ConstraintPacker (_canvas, Vertical);
|
|
|
|
rhs_vbox->name = "rhs";
|
|
|
|
sequence_hbox->pack_start (rhs_vbox);
|
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
velocity_mode_button = new Rectangle (_canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
velocity_mode_button->set_corner_radius (10.0);
|
2020-07-08 23:49:52 -04:00
|
|
|
velocity_mode_button->set_intrinsic_size (mode_button_width, mode_button_height);
|
2018-11-14 22:43:40 -05:00
|
|
|
velocity_mode_button->set_fill_color (current_mode_color);
|
2020-07-12 02:01:28 -04:00
|
|
|
velocity_mode_text = new Text (_canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
velocity_mode_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
|
|
|
velocity_mode_text->set (_("Velocity"));
|
|
|
|
velocity_mode_text->set_color (contrasting_text_color (velocity_mode_button->fill_color()));
|
2018-11-10 00:06:22 -05:00
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
pitch_mode_button = new Rectangle (_canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
pitch_mode_button->set_corner_radius (10.0);
|
2020-07-08 23:49:52 -04:00
|
|
|
pitch_mode_button->set_intrinsic_size (mode_button_width, mode_button_height);
|
2018-11-14 22:43:40 -05:00
|
|
|
pitch_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_text = new Text (pitch_mode_button);
|
|
|
|
pitch_mode_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
|
|
|
pitch_mode_text->set (_("Pitch"));
|
|
|
|
pitch_mode_text->set_color (contrasting_text_color (pitch_mode_button->fill_color()));
|
2018-11-10 00:06:22 -05:00
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
gate_mode_button = new Rectangle (_canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
gate_mode_button->set_corner_radius (10.0);
|
2020-07-08 23:49:52 -04:00
|
|
|
gate_mode_button->set_intrinsic_size (mode_button_width, mode_button_height);
|
2018-11-14 22:43:40 -05:00
|
|
|
gate_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
gate_mode_text = new Text (gate_mode_button);
|
|
|
|
gate_mode_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
|
|
|
gate_mode_text->set (_("Gate"));
|
|
|
|
gate_mode_text->set_color (contrasting_text_color (gate_mode_button->fill_color()));
|
2018-11-10 00:06:22 -05:00
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
octave_mode_button = new Rectangle (_canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
octave_mode_button->set_corner_radius (10.0);
|
2020-07-08 23:49:52 -04:00
|
|
|
octave_mode_button->set_intrinsic_size (mode_button_width, mode_button_height);
|
2018-11-14 22:43:40 -05:00
|
|
|
octave_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
octave_mode_text = new Text (octave_mode_button);
|
|
|
|
octave_mode_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
|
|
|
octave_mode_text->set (_("Octave"));
|
|
|
|
octave_mode_text->set_color (contrasting_text_color (octave_mode_button->fill_color()));
|
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
timing_mode_button = new Rectangle (_canvas);
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_button->set_corner_radius (10.0);
|
2020-07-08 23:49:52 -04:00
|
|
|
timing_mode_button->set_intrinsic_size (mode_button_width, mode_button_height);
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
timing_mode_text = new Text (timing_mode_button);
|
|
|
|
timing_mode_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
|
|
|
timing_mode_text->set (_("Timing"));
|
|
|
|
timing_mode_text->set_color (contrasting_text_color (timing_mode_button->fill_color()));
|
2020-07-08 23:49:52 -04:00
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
ConstrainedItem* b;
|
|
|
|
ConstrainedItem* t;
|
|
|
|
|
|
|
|
b = button_packer->pack_start (velocity_mode_button, PackOptions (PackExpand|PackFill), PackOptions (0));
|
|
|
|
t = button_packer->add_constrained (velocity_mode_text);
|
|
|
|
t->centered_on (*b);
|
|
|
|
|
|
|
|
b = button_packer->pack_start (pitch_mode_button, PackOptions (PackExpand|PackFill), PackOptions (0));
|
|
|
|
t = button_packer->add_constrained (pitch_mode_text);
|
|
|
|
t->centered_on (*b);
|
|
|
|
|
|
|
|
b = button_packer->pack_start (gate_mode_button, PackOptions (PackExpand|PackFill), PackOptions (0));
|
|
|
|
t = button_packer->add_constrained (gate_mode_text);
|
|
|
|
t->centered_on (*b);
|
|
|
|
|
|
|
|
b = button_packer->pack_start (octave_mode_button, PackOptions (PackExpand|PackFill), PackOptions (0));
|
|
|
|
t = button_packer->add_constrained (octave_mode_text);
|
|
|
|
t->centered_on (*b);
|
2018-11-14 23:12:33 -05:00
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
b = button_packer->pack_start (timing_mode_button, PackOptions (PackExpand|PackFill), PackOptions (0));
|
|
|
|
t = button_packer->add_constrained (timing_mode_text);
|
|
|
|
t->centered_on (*b);
|
2018-11-14 22:43:40 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
octave_mode_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &SequencerView::mode_button_event), Octave));
|
|
|
|
gate_mode_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &SequencerView::mode_button_event), Duration));
|
|
|
|
pitch_mode_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &SequencerView::mode_button_event), Pitch));
|
|
|
|
velocity_mode_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &SequencerView::mode_button_event), Velocity));
|
|
|
|
timing_mode_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &SequencerView::mode_button_event), Timing));
|
2020-07-13 00:04:56 -04:00
|
|
|
octave_mode_text->set_ignore_events (true);
|
|
|
|
gate_mode_text->set_ignore_events (true);
|
|
|
|
pitch_mode_text->set_ignore_events (true);
|
|
|
|
velocity_mode_text->set_ignore_events (true);
|
|
|
|
timing_mode_text->set_ignore_events (true);
|
2018-11-09 21:27:53 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
_sequencer.PropertyChanged.connect (sequencer_connection, invalidator (*this), boost::bind (&SequencerView::sequencer_changed, this, _1), gui_context());
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
{
|
|
|
|
/* trigger initial draw */
|
|
|
|
PropertyChange pc;
|
|
|
|
sequencer_changed (pc);
|
|
|
|
}
|
2018-11-05 23:39:37 -05:00
|
|
|
}
|
|
|
|
|
2018-11-14 22:43:40 -05:00
|
|
|
bool
|
2018-11-19 11:31:31 -05:00
|
|
|
SequencerView::mode_button_event (GdkEvent* ev, Mode m)
|
2018-11-14 22:43:40 -05:00
|
|
|
{
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
set_mode (m);
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
void
|
2018-11-19 11:31:31 -05:00
|
|
|
SequencerView::update ()
|
2018-11-08 17:55:56 -05:00
|
|
|
{
|
|
|
|
bool running = true;
|
|
|
|
size_t step = _sequencer.last_step ();
|
|
|
|
|
2020-07-13 00:04:56 -04:00
|
|
|
for (SequenceViews::iterator s = sequence_views.begin(); s != sequence_views.end(); ++s) {
|
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
void
|
2018-11-19 11:31:31 -05:00
|
|
|
SequencerView::sequencer_changed (PropertyChange const &)
|
2018-11-05 23:39:37 -05:00
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
const size_t nsteps = _sequencer.step_capacity ();
|
2018-11-07 13:46:26 -05:00
|
|
|
const size_t nsequences = _sequencer.nsequences();
|
2020-07-13 00:04:56 -04:00
|
|
|
size_t n;
|
2018-11-05 23:39:37 -05:00
|
|
|
|
|
|
|
_width = _step_dimen * nsteps;
|
2018-11-07 13:46:26 -05:00
|
|
|
_height = _step_dimen * nsequences;
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-11-07 15:19:53 -05:00
|
|
|
/* indicator row */
|
|
|
|
|
2020-07-13 00:04:56 -04:00
|
|
|
#if 0
|
2018-11-16 21:13:05 -05:00
|
|
|
while (step_indicators.size() > nsteps) {
|
|
|
|
SequencerStepIndicator* ssi = step_indicators.back();
|
|
|
|
step_indicators.pop_back();
|
2020-07-12 02:01:28 -04:00
|
|
|
step_indicator_box->remove (ssi);
|
2018-11-16 21:13:05 -05:00
|
|
|
delete ssi;
|
|
|
|
}
|
|
|
|
|
2020-07-13 00:04:56 -04:00
|
|
|
n = step_indicators.size();
|
2018-11-16 21:13:05 -05:00
|
|
|
|
|
|
|
while (step_indicators.size() < nsteps) {
|
2020-07-08 23:49:52 -04:00
|
|
|
SequencerStepIndicator* ssi = new SequencerStepIndicator (*this, canvas(), n);
|
|
|
|
step_indicator_box->pack_start (ssi, PackOptions (PackExpand|PackFill), PackOptions (0));
|
2018-11-08 17:55:56 -05:00
|
|
|
step_indicators.push_back (ssi);
|
2018-11-16 21:13:05 -05:00
|
|
|
++n;
|
2018-11-07 15:19:53 -05:00
|
|
|
}
|
2020-07-13 00:04:56 -04:00
|
|
|
#endif
|
2018-11-08 17:55:56 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
while (sequence_views.size() > nsequences) {
|
|
|
|
SequenceView* sh = sequence_views.back ();
|
|
|
|
sequence_views.pop_back ();
|
2018-11-16 21:13:05 -05:00
|
|
|
delete sh;
|
|
|
|
}
|
2018-11-14 22:43:40 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
n = sequence_views.size();
|
2018-11-14 22:43:40 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
while (sequence_views.size() < nsequences) {
|
2020-07-12 02:01:28 -04:00
|
|
|
SequenceView* sv = new SequenceView (*this, _sequencer.sequence (n), canvas());
|
2020-07-13 00:04:56 -04:00
|
|
|
|
|
|
|
lhs_vbox->pack_start (sv->lhs_box);
|
|
|
|
steps_vbox->pack_start (sv->step_box);
|
|
|
|
rhs_vbox->pack_start (sv->rhs_box);
|
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
sequence_views.push_back (sv);
|
2018-11-16 21:13:05 -05:00
|
|
|
++n;
|
2018-11-14 22:43:40 -05:00
|
|
|
}
|
2018-11-07 13:46:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-19 11:31:31 -05:00
|
|
|
SequencerView::set_mode (Mode m)
|
2018-11-07 13:46:26 -05:00
|
|
|
{
|
2018-11-14 22:43:40 -05:00
|
|
|
if (_mode == m) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
_mode = m;
|
|
|
|
|
2018-11-14 22:43:40 -05:00
|
|
|
switch (_mode) {
|
|
|
|
case Octave:
|
|
|
|
octave_mode_button->set_fill_color (current_mode_color);
|
|
|
|
octave_mode_text->set_color (contrasting_text_color (current_mode_color));
|
|
|
|
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_button->set_fill_color (not_current_mode_color);
|
2018-11-14 22:43:40 -05:00
|
|
|
velocity_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
gate_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_text->set_color (contrasting_text_color (not_current_mode_color));
|
|
|
|
gate_mode_text->set_color (pitch_mode_text->color ());
|
|
|
|
velocity_mode_text->set_color (pitch_mode_text->color());
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_text->set_color (pitch_mode_text->color());
|
2018-11-14 22:43:40 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Duration:
|
|
|
|
gate_mode_button->set_fill_color (current_mode_color);
|
|
|
|
gate_mode_text->set_color (contrasting_text_color (current_mode_color));
|
|
|
|
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_button->set_fill_color (not_current_mode_color);
|
2018-11-14 22:43:40 -05:00
|
|
|
velocity_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
octave_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_text->set_color (contrasting_text_color (not_current_mode_color));
|
|
|
|
octave_mode_text->set_color (pitch_mode_text->color ());
|
|
|
|
velocity_mode_text->set_color (pitch_mode_text->color());
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_text->set_color (pitch_mode_text->color());
|
2018-11-14 22:43:40 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Pitch:
|
|
|
|
pitch_mode_button->set_fill_color (current_mode_color);
|
|
|
|
pitch_mode_text->set_color (contrasting_text_color (current_mode_color));
|
|
|
|
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_button->set_fill_color (not_current_mode_color);
|
2018-11-14 22:43:40 -05:00
|
|
|
velocity_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
octave_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
gate_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
gate_mode_text->set_color (contrasting_text_color (not_current_mode_color));
|
|
|
|
octave_mode_text->set_color (gate_mode_text->color ());
|
|
|
|
velocity_mode_text->set_color (gate_mode_text->color());
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_text->set_color (gate_mode_text->color());
|
2018-11-14 22:43:40 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Velocity:
|
|
|
|
velocity_mode_button->set_fill_color (current_mode_color);
|
|
|
|
velocity_mode_text->set_color (contrasting_text_color (current_mode_color));
|
|
|
|
|
2018-11-14 23:12:33 -05:00
|
|
|
timing_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
octave_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
gate_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_text->set_color (contrasting_text_color (not_current_mode_color));
|
|
|
|
octave_mode_text->set_color (pitch_mode_text->color ());
|
|
|
|
gate_mode_text->set_color (pitch_mode_text->color());
|
|
|
|
timing_mode_text->set_color (pitch_mode_text->color());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Timing:
|
|
|
|
timing_mode_button->set_fill_color (current_mode_color);
|
|
|
|
timing_mode_text->set_color (contrasting_text_color (current_mode_color));
|
|
|
|
|
|
|
|
velocity_mode_button->set_fill_color (not_current_mode_color);
|
2018-11-14 22:43:40 -05:00
|
|
|
pitch_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
octave_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
gate_mode_button->set_fill_color (not_current_mode_color);
|
|
|
|
pitch_mode_text->set_color (contrasting_text_color (not_current_mode_color));
|
|
|
|
octave_mode_text->set_color (pitch_mode_text->color ());
|
|
|
|
gate_mode_text->set_color (pitch_mode_text->color());
|
2018-11-14 23:12:33 -05:00
|
|
|
velocity_mode_text->set_color (gate_mode_text->color());
|
2018-11-14 22:43:40 -05:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
for (SequenceViews::iterator s = sequence_views.begin(); s != sequence_views.end(); ++s) {
|
2018-11-07 13:46:26 -05:00
|
|
|
(*s)->view_mode_changed ();
|
|
|
|
}
|
|
|
|
|
2018-11-14 23:12:33 -05:00
|
|
|
redraw ();}
|
|
|
|
|
2018-11-03 23:19:59 -04:00
|
|
|
|
|
|
|
void
|
2018-11-19 11:31:31 -05:00
|
|
|
SequencerView::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
2018-11-03 23:19:59 -04:00
|
|
|
{
|
2018-11-16 21:13:05 -05:00
|
|
|
/* might do more one day */
|
2020-07-12 02:01:28 -04:00
|
|
|
ConstraintPacker::render (area, context);
|
2018-11-03 23:19:59 -04:00
|
|
|
}
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
SequenceView&
|
|
|
|
SequencerView::sequence_view (size_t n) const
|
2018-11-14 22:43:40 -05:00
|
|
|
{
|
2018-11-19 11:31:31 -05:00
|
|
|
assert (n < sequence_views.size());
|
|
|
|
return *sequence_views[n];
|
2018-11-14 22:43:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**/
|
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
Gtkmm2ext::Color SequencerStepIndicator::other_color = Gtkmm2ext::Color (0);
|
|
|
|
Gtkmm2ext::Color SequencerStepIndicator::current_color = Gtkmm2ext::Color (0);
|
|
|
|
Gtkmm2ext::Color SequencerStepIndicator::other_text_color = Gtkmm2ext::Color (0);
|
|
|
|
Gtkmm2ext::Color SequencerStepIndicator::current_text_color = Gtkmm2ext::Color (0);
|
2018-11-09 21:27:53 -05:00
|
|
|
Gtkmm2ext::Color SequencerStepIndicator::bright_outline_color = Gtkmm2ext::Color (0);
|
2018-11-08 17:55:56 -05:00
|
|
|
int SequencerStepIndicator::dragging = 0;
|
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
SequencerStepIndicator::SequencerStepIndicator (SequencerView& s, ArdourCanvas::Canvas* c, size_t n)
|
|
|
|
: Rectangle (c)
|
2018-11-19 11:31:31 -05:00
|
|
|
, sv (s)
|
2018-11-08 17:55:56 -05:00
|
|
|
, number (n)
|
2018-11-09 21:27:53 -05:00
|
|
|
, being_dragged (false)
|
2018-11-03 23:19:59 -04:00
|
|
|
{
|
2018-11-08 17:55:56 -05:00
|
|
|
if (current_color == 0) { /* zero alpha? not set */
|
|
|
|
other_color = UIConfiguration::instance().color ("gtk_bases");
|
|
|
|
current_color = UIConfiguration::instance().color ("gtk_bright_color");
|
|
|
|
other_text_color = contrasting_text_color (other_color);
|
|
|
|
current_text_color = contrasting_text_color (current_color);
|
2018-11-09 21:27:53 -05:00
|
|
|
bright_outline_color = UIConfiguration::instance().color ("gtk_bright_indicator");
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
set_intrinsic_size (_step_dimen - 1, _step_dimen - 1);
|
2018-11-21 18:03:05 -05:00
|
|
|
|
|
|
|
set_fill_color (HSV (UIConfiguration::instance().color ("gtk_bases")).lighter (0.1));
|
|
|
|
set_fill (true);
|
2018-11-03 23:19:59 -04:00
|
|
|
set_outline (false);
|
|
|
|
|
|
|
|
poly = new Polygon (this);
|
|
|
|
Points points;
|
2018-11-21 18:03:05 -05:00
|
|
|
points.push_back (Duple (1, 1));
|
2018-11-25 19:10:25 -05:00
|
|
|
points.push_back (Duple (_step_dimen - 3.0, 1));
|
|
|
|
points.push_back (Duple (_step_dimen - 3.0, (_step_dimen - 3.0)/2.0));
|
|
|
|
points.push_back (Duple ((_step_dimen - 3.0)/2.0, _step_dimen - 3.0));
|
|
|
|
points.push_back (Duple (1, (_step_dimen - 3.0)/2.0));
|
2018-11-03 23:19:59 -04:00
|
|
|
poly->set (points);
|
2018-11-08 17:55:56 -05:00
|
|
|
poly->set_fill_color (current_color);
|
2018-11-09 21:27:53 -05:00
|
|
|
poly->set_outline_color (other_color);
|
2018-11-08 17:55:56 -05:00
|
|
|
poly->set_ignore_events (true);
|
2018-11-21 18:03:05 -05:00
|
|
|
poly->move (Duple (-0.5, -0.5));
|
2018-11-08 17:55:56 -05:00
|
|
|
|
|
|
|
text = new Text (this);
|
|
|
|
|
|
|
|
set_text ();
|
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
text->set_font_description (UIConfiguration::instance ().get_NormalFont ());
|
2018-11-08 17:55:56 -05:00
|
|
|
text->set_position (Duple ((_step_dimen/2.0) - (text->width()/2.0), 5.0));
|
|
|
|
text->set_color (other_text_color);
|
|
|
|
text->set_ignore_events (true);
|
2020-07-12 02:01:28 -04:00
|
|
|
text->name = string_compose ("SI %1", n);
|
2018-11-08 17:55:56 -05:00
|
|
|
|
|
|
|
Event.connect (sigc::mem_fun (*this, &SequencerStepIndicator::on_event));
|
2018-11-19 11:31:31 -05:00
|
|
|
sv.sequencer().PropertyChanged.connect (sequencer_connection, invalidator (*this), boost::bind (&SequencerStepIndicator::sequencer_changed, this, _1), gui_context());
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-09 21:27:53 -05:00
|
|
|
SequencerStepIndicator::sequencer_changed (PropertyChange const &)
|
2018-11-08 17:55:56 -05:00
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
set_text ();
|
|
|
|
}
|
2018-11-08 17:55:56 -05:00
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
void
|
|
|
|
SequencerStepIndicator::set_text ()
|
|
|
|
{
|
2018-11-19 11:31:31 -05:00
|
|
|
if (number == sv.sequencer().end_step() - 1) {
|
2018-11-08 17:55:56 -05:00
|
|
|
text->set ("\u21a9");
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (number == sv.sequencer().start_step()) {
|
2018-11-08 17:55:56 -05:00
|
|
|
text->set ("\u21aa");
|
|
|
|
} else {
|
|
|
|
text->set (string_compose ("%1", number+1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SequencerStepIndicator::on_event (GdkEvent* ev)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_ENTER_NOTIFY:
|
|
|
|
switch (dragging) {
|
|
|
|
case 1: /* end */
|
2018-11-09 21:27:53 -05:00
|
|
|
poly->set_outline_color (bright_outline_color);
|
|
|
|
poly->set_fill_color (current_color);
|
|
|
|
being_dragged = true;
|
2018-11-08 17:55:56 -05:00
|
|
|
break;
|
|
|
|
case -1:
|
2018-11-09 21:27:53 -05:00
|
|
|
poly->set_outline_color (bright_outline_color);
|
|
|
|
poly->set_fill_color (current_color);
|
|
|
|
being_dragged = true;
|
2018-11-08 17:55:56 -05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
poly->set_outline_color (other_color);
|
2018-11-09 21:27:53 -05:00
|
|
|
poly->set_fill_color (other_color);
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
if (dragging) {
|
|
|
|
poly->set_outline_color (other_color);
|
2018-11-09 21:27:53 -05:00
|
|
|
poly->set_fill_color (other_color);
|
|
|
|
being_dragged = false;
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
ret = motion_event (&ev->motion);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
ret = button_press_event (&ev->button);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_event (&ev->button);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SequencerStepIndicator::motion_event (GdkEventMotion* ev)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SequencerStepIndicator::button_press_event (GdkEventButton* ev)
|
|
|
|
{
|
2018-11-19 11:31:31 -05:00
|
|
|
if (number == sv.sequencer().end_step() - 1) {
|
2018-11-08 17:55:56 -05:00
|
|
|
dragging = 1;
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (number == sv.sequencer().start_step()) {
|
2018-11-08 17:55:56 -05:00
|
|
|
dragging = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SequencerStepIndicator::button_release_event (GdkEventButton* ev)
|
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
switch (dragging) {
|
|
|
|
case 1:
|
2018-11-19 11:31:31 -05:00
|
|
|
sv.sequencer().set_end_step (number+1);
|
2018-11-08 17:55:56 -05:00
|
|
|
break;
|
2018-11-09 21:27:53 -05:00
|
|
|
case -1:
|
2018-11-19 11:31:31 -05:00
|
|
|
sv.sequencer().set_start_step (number);
|
2018-11-08 17:55:56 -05:00
|
|
|
break;
|
2018-11-09 21:27:53 -05:00
|
|
|
default:
|
2018-11-08 17:55:56 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
dragging = 0;
|
|
|
|
being_dragged = false;
|
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SequencerStepIndicator::set_current (bool yn)
|
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
if (being_dragged) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
if (yn) {
|
|
|
|
poly->set_fill_color (current_color);
|
|
|
|
text->set_color (current_text_color);
|
|
|
|
} else {
|
|
|
|
poly->set_fill_color (other_color);
|
|
|
|
text->set_color (other_text_color);
|
|
|
|
}
|
2018-11-03 23:19:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SequencerStepIndicator::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
|
|
|
{
|
|
|
|
Rectangle::render (area, context);
|
|
|
|
render_children (area, context);
|
|
|
|
}
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
Gtkmm2ext::Color StepView::on_fill_color = Gtkmm2ext::Color (0);
|
|
|
|
Gtkmm2ext::Color StepView::off_fill_color = Gtkmm2ext::Color (0);
|
|
|
|
|
2020-07-08 23:49:52 -04:00
|
|
|
StepView::StepView (SequenceView& sview, Step& s, ArdourCanvas::Canvas* c)
|
|
|
|
: ArdourCanvas::Rectangle (c)
|
2018-11-05 23:39:37 -05:00
|
|
|
, _step (s)
|
2018-11-19 11:31:31 -05:00
|
|
|
, sv (sview)
|
2018-11-07 01:22:50 -05:00
|
|
|
, text (new Text (this))
|
2018-11-07 20:54:22 -05:00
|
|
|
, grabbed (false)
|
2018-11-05 23:39:37 -05:00
|
|
|
{
|
2020-07-12 02:01:28 -04:00
|
|
|
set_intrinsic_size (_step_dimen - 1, _step_dimen - 1);
|
2018-11-21 18:03:05 -05:00
|
|
|
name = string_compose ("stepview for %1", _step.index());
|
2018-11-25 19:10:25 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
if (on_fill_color == 0) {
|
|
|
|
on_fill_color = UIConfiguration::instance().color ("gtk_bases");
|
|
|
|
off_fill_color = HSV (on_fill_color).lighter (0.1);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_fill_color (off_fill_color);
|
|
|
|
set_outline_color (UIConfiguration::instance().color ("gtk_bright_color"));
|
2020-07-12 02:01:28 -04:00
|
|
|
set_outline (true);
|
2018-11-05 23:39:37 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
text->set_color (contrasting_text_color (fill_color()));
|
2018-11-07 13:46:26 -05:00
|
|
|
text->set_font_description (UIConfiguration::instance ().get_SmallFont ());
|
2018-11-07 01:22:50 -05:00
|
|
|
text->hide ();
|
2020-07-12 02:01:28 -04:00
|
|
|
text->name = string_compose ("step %1", _step.index());
|
2018-11-07 01:22:50 -05:00
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
Event.connect (sigc::mem_fun (*this, &StepView::on_event));
|
|
|
|
_step.PropertyChanged.connect (step_connection, invalidator (*this), boost::bind (&StepView::step_changed, this, _1), gui_context());
|
|
|
|
}
|
|
|
|
|
2018-11-07 13:46:26 -05:00
|
|
|
void
|
|
|
|
StepView::view_mode_changed ()
|
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
/* this should leave the text to the last text-displaying mode */
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
switch (sv.mode()) {
|
|
|
|
case SequencerView::Octave:
|
2018-11-08 17:55:56 -05:00
|
|
|
set_octave_text ();
|
2018-11-15 21:27:20 -05:00
|
|
|
break;
|
2018-11-19 11:31:31 -05:00
|
|
|
case SequencerView::Group:
|
2018-11-08 17:55:56 -05:00
|
|
|
set_group_text ();
|
2018-11-15 21:27:20 -05:00
|
|
|
break;
|
2018-11-19 11:31:31 -05:00
|
|
|
case SequencerView::Timing:
|
2018-11-15 21:27:20 -05:00
|
|
|
set_timing_text ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
text->hide ();
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepView::set_group_text ()
|
|
|
|
{
|
2018-11-09 21:27:53 -05:00
|
|
|
text->set ("-");
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
2018-11-07 13:46:26 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
void
|
|
|
|
StepView::set_octave_text ()
|
|
|
|
{
|
|
|
|
if (_step.octave_shift() > 0) {
|
|
|
|
text->set (string_compose ("+%1", _step.octave_shift()));
|
2018-11-07 13:46:26 -05:00
|
|
|
text->show ();
|
2018-11-08 17:55:56 -05:00
|
|
|
} else if (_step.octave_shift() == 0) {
|
|
|
|
text->hide ();
|
|
|
|
} else {
|
|
|
|
text->set (string_compose ("%1", _step.octave_shift()));
|
|
|
|
text->show ();
|
|
|
|
}
|
2018-11-07 13:46:26 -05:00
|
|
|
|
2018-11-08 17:55:56 -05:00
|
|
|
if (text->self_visible()) {
|
2018-11-07 13:46:26 -05:00
|
|
|
const double w = text->width();
|
|
|
|
const double h = text->height();
|
|
|
|
text->set_position (Duple (_step_dimen/2 - (w/2), _step_dimen/2 - (h/2)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-15 21:27:20 -05:00
|
|
|
void
|
|
|
|
StepView::set_timing_text ()
|
|
|
|
{
|
|
|
|
if (!_step.velocity()) {
|
|
|
|
text->hide ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_step.offset() == Temporal::Beats()) {
|
|
|
|
text->set (X_("0"));
|
|
|
|
} else {
|
2020-07-08 23:49:52 -04:00
|
|
|
const int64_t gcd = boost::integer::gcd (_step.offset().to_ticks(), int64_t (1920));
|
2018-11-15 21:27:20 -05:00
|
|
|
const int64_t n = _step.offset().to_ticks() / gcd;
|
|
|
|
const int64_t d = 1920 / gcd;
|
|
|
|
text->set (string_compose ("%1/%2", n, d));
|
|
|
|
text->show ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (text->self_visible()) {
|
|
|
|
const double w = text->width();
|
|
|
|
const double h = text->height();
|
|
|
|
text->set_position (Duple (_step_dimen/2 - (w/2), _step_dimen/2 - (h/2)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
void
|
|
|
|
StepView::step_changed (PropertyChange const &)
|
|
|
|
{
|
2018-11-19 11:31:31 -05:00
|
|
|
if (sv.mode() == SequencerView::Octave) {
|
2018-11-08 17:55:56 -05:00
|
|
|
set_octave_text ();
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Timing) {
|
2018-11-15 21:27:20 -05:00
|
|
|
set_timing_text ();
|
2018-11-08 17:55:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_step.velocity()) {
|
|
|
|
set_fill_color (on_fill_color);
|
|
|
|
} else {
|
|
|
|
set_fill_color (off_fill_color);
|
|
|
|
}
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
redraw ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepView::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
|
|
|
|
{
|
2018-11-08 17:55:56 -05:00
|
|
|
Rectangle::render (area, context);
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
if (sv.mode() == SequencerView::Velocity) {
|
2018-11-09 21:27:53 -05:00
|
|
|
if (_step.velocity()) {
|
|
|
|
const double height = (_step_dimen - 4) * _step.velocity();
|
|
|
|
const Duple origin = item_to_window (Duple (0, 0));
|
|
|
|
set_source_rgba (context, outline_color());
|
|
|
|
context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height);
|
|
|
|
context->fill ();
|
|
|
|
}
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Pitch) {
|
2018-11-09 21:27:53 -05:00
|
|
|
if (_step.velocity()) {
|
|
|
|
const double height = (_step_dimen - 4) * (_step.note() / 128.0);
|
|
|
|
const Duple origin = item_to_window (Duple (0, 0));
|
|
|
|
set_source_rgba (context, outline_color());
|
|
|
|
context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height);
|
|
|
|
context->fill ();
|
|
|
|
}
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Duration) {
|
2018-11-09 21:27:53 -05:00
|
|
|
if (_step.velocity()) {
|
|
|
|
const Step::DurationRatio d (_step.duration());
|
|
|
|
const double height = ((_step_dimen - 4.0) * d.numerator()) / d.denominator();
|
|
|
|
const Duple origin = item_to_window (Duple (0, 0));
|
|
|
|
set_source_rgba (context, outline_color());
|
|
|
|
context->rectangle (origin.x + 2, origin.y + (_step_dimen - height - 2), _step_dimen - 4, height);
|
|
|
|
context->fill ();
|
|
|
|
}
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Timing) {
|
2018-11-14 23:12:33 -05:00
|
|
|
if (_step.velocity()) {
|
2018-11-15 17:35:36 -05:00
|
|
|
Temporal::Beats offset = _step.offset ();
|
2018-11-19 11:31:31 -05:00
|
|
|
const double fract = offset.to_ticks() / (double) sequencer().step_size().to_ticks();
|
2018-11-15 17:35:36 -05:00
|
|
|
const double width = ((_step_dimen - 4.0)/2.0) * fract;
|
|
|
|
const Duple origin = item_to_window (Duple (_step_dimen / 2.0, 0.0));
|
2018-11-14 23:12:33 -05:00
|
|
|
|
2018-11-15 17:35:36 -05:00
|
|
|
/* draw sideways "bars" from center" to indicate extent
|
|
|
|
* of time displacement from nominal time for this step
|
|
|
|
*/
|
|
|
|
|
|
|
|
set_source_rgba (context, outline_color());
|
|
|
|
context->rectangle (origin.x + 2.0, origin.y + 2.0, width, _step_dimen - 4.0);
|
|
|
|
context->fill ();
|
2018-11-14 23:12:33 -05:00
|
|
|
}
|
2018-11-07 01:22:50 -05:00
|
|
|
}
|
2018-11-07 13:46:26 -05:00
|
|
|
|
|
|
|
/* now deal with any children (e.g. text) */
|
|
|
|
|
|
|
|
render_children (area, context);
|
2018-11-05 23:39:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepView::on_event (GdkEvent *ev)
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_MOTION_NOTIFY:
|
|
|
|
ret = motion_event (&ev->motion);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
ret = button_press_event (&ev->button);
|
|
|
|
break;
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
ret = button_release_event (&ev->button);
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL:
|
|
|
|
ret = scroll_event (&ev->scroll);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepView::motion_event (GdkEventMotion* ev)
|
|
|
|
{
|
2018-11-07 20:54:22 -05:00
|
|
|
if (!grabbed) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-12-03 20:56:26 -05:00
|
|
|
int distance;
|
2018-11-15 17:35:36 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
switch (sv.mode()) {
|
|
|
|
case SequencerView::Timing:
|
2018-11-15 17:35:36 -05:00
|
|
|
distance = ev->x - last_motion.first;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
distance = last_motion.second - ev->y;
|
|
|
|
break;
|
|
|
|
}
|
2018-11-07 20:54:22 -05:00
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
if ((ev->state & GDK_MOD1_MASK) || sv.mode() == SequencerView::Pitch) {
|
2018-11-07 20:54:22 -05:00
|
|
|
adjust_step_pitch (distance);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Velocity) {
|
2018-11-07 20:54:22 -05:00
|
|
|
adjust_step_velocity (distance);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Duration) {
|
2018-11-07 20:54:22 -05:00
|
|
|
adjust_step_duration (Step::DurationRatio (distance, 32)); /* adjust by 1/32 of the sequencer step size */
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Octave) {
|
2018-11-07 20:54:22 -05:00
|
|
|
adjust_step_octave (distance);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Timing) {
|
2018-11-15 17:35:36 -05:00
|
|
|
adjust_step_timing (distance/(_step_dimen / 2.0));
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Group) {
|
2018-11-07 20:54:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
last_motion = std::make_pair (ev->x, ev->y);
|
2018-11-05 23:39:37 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepView::button_press_event (GdkEventButton* ev)
|
|
|
|
{
|
|
|
|
grab_at = std::make_pair (ev->x, ev->y);
|
2018-11-07 20:54:22 -05:00
|
|
|
last_motion = grab_at;
|
|
|
|
grab ();
|
|
|
|
grabbed = true;
|
2018-11-07 21:36:53 -05:00
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepView::button_release_event (GdkEventButton* ev)
|
|
|
|
{
|
2018-11-07 21:36:53 -05:00
|
|
|
if (grabbed) {
|
|
|
|
ungrab ();
|
|
|
|
grabbed = false;
|
|
|
|
|
2018-11-15 17:35:36 -05:00
|
|
|
int distance_moved;
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
switch (sv.mode()) {
|
|
|
|
case SequencerView::Timing:
|
2018-11-15 17:35:36 -05:00
|
|
|
distance_moved = grab_at.first - last_motion.first;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
distance_moved = last_motion.second - grab_at.second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (::abs (distance_moved) < 4) {
|
2018-11-07 21:36:53 -05:00
|
|
|
/* just a click */
|
|
|
|
|
2018-11-09 21:27:53 -05:00
|
|
|
/* in all modes except octave, turn step on if it is off */
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
if (sv.mode() == SequencerView::Octave) {
|
2018-11-09 21:27:53 -05:00
|
|
|
if (_step.velocity()) {
|
|
|
|
_step.set_octave_shift (0);
|
|
|
|
} else {
|
|
|
|
_step.set_velocity (0.8);
|
|
|
|
}
|
|
|
|
} else {
|
2018-11-08 17:55:56 -05:00
|
|
|
if (_step.velocity()) {
|
|
|
|
_step.set_velocity (0.0);
|
|
|
|
} else {
|
2018-11-09 21:27:53 -05:00
|
|
|
_step.set_velocity (0.8);
|
2018-11-07 21:36:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
StepView::scroll_event (GdkEventScroll* ev)
|
|
|
|
{
|
|
|
|
int amt = 0;
|
|
|
|
|
|
|
|
switch (ev->direction) {
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
amt = 1;
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
amt = -1;
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
amt = 1;
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
amt = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
if ((ev->state & GDK_MOD1_MASK) || sv.mode() == SequencerView::Pitch) {
|
2018-11-05 23:39:37 -05:00
|
|
|
adjust_step_pitch (amt);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Velocity) {
|
2018-11-05 23:39:37 -05:00
|
|
|
adjust_step_velocity (amt);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Duration) {
|
2018-11-09 21:27:53 -05:00
|
|
|
/* adjust by 1/32 of the sequencer step size */
|
|
|
|
adjust_step_duration (Step::DurationRatio (amt, 32));
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Octave) {
|
2018-11-07 13:46:26 -05:00
|
|
|
adjust_step_octave (amt);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Timing) {
|
2018-11-15 17:35:36 -05:00
|
|
|
adjust_step_timing (amt);
|
2018-11-19 11:31:31 -05:00
|
|
|
} else if (sv.mode() == SequencerView::Group) {
|
2018-11-05 23:39:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-11-15 17:35:36 -05:00
|
|
|
void
|
|
|
|
StepView::adjust_step_timing (double fract)
|
|
|
|
{
|
|
|
|
_step.adjust_offset (fract);
|
|
|
|
}
|
|
|
|
|
2018-11-05 23:39:37 -05:00
|
|
|
void
|
|
|
|
StepView::adjust_step_pitch (int amt)
|
|
|
|
{
|
|
|
|
_step.adjust_pitch (amt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
StepView::adjust_step_velocity (int amt)
|
|
|
|
{
|
|
|
|
_step.adjust_velocity (amt);
|
|
|
|
}
|
2018-11-07 13:46:26 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
StepView::adjust_step_octave (int amt)
|
|
|
|
{
|
|
|
|
_step.adjust_octave (amt);
|
|
|
|
}
|
2018-11-07 15:19:53 -05:00
|
|
|
|
|
|
|
void
|
2018-11-07 16:25:29 -05:00
|
|
|
StepView::adjust_step_duration (Step::DurationRatio const & amt)
|
2018-11-07 15:19:53 -05:00
|
|
|
{
|
|
|
|
_step.adjust_duration (amt);
|
|
|
|
}
|
2018-11-14 22:43:40 -05:00
|
|
|
|
|
|
|
/**/
|
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
SequenceView::SequenceView (SequencerView& sview, StepSequence& sq, Canvas* canvas)
|
2020-07-13 00:04:56 -04:00
|
|
|
: sv (sview)
|
2018-11-14 22:43:40 -05:00
|
|
|
, sequence (sq)
|
|
|
|
{
|
2020-07-12 02:01:28 -04:00
|
|
|
lhs_box = new ArdourCanvas::ConstraintPacker (canvas, ArdourCanvas::Horizontal);
|
|
|
|
lhs_box->set_padding (12);
|
|
|
|
rhs_box = new ArdourCanvas::ConstraintPacker (canvas, ArdourCanvas::Horizontal);
|
|
|
|
rhs_box->set_padding (12);
|
|
|
|
step_box = new ArdourCanvas::ConstraintPacker (canvas, ArdourCanvas::Horizontal);
|
|
|
|
step_box->set_padding (6);
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
lhs_box->set_fill_color (UIConfiguration::instance().color ("gtk_bright_color"));
|
|
|
|
lhs_box->set_fill (true);
|
|
|
|
lhs_box->set_outline (false);
|
2018-11-28 11:04:06 -05:00
|
|
|
lhs_box->set_spacing (5.0);
|
|
|
|
lhs_box->name = string_compose ("lhs box for %1", sequence.index());
|
2018-11-19 11:31:31 -05:00
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
number_text = new Text (canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
number_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
2020-07-12 02:01:28 -04:00
|
|
|
number_text->set_intrinsic_size (_step_dimen - 1, _step_dimen - 1);
|
|
|
|
number_text->name = string_compose ("%1 text bit", sequence.index() + 1);
|
|
|
|
number_text->set_color (contrasting_text_color (lhs_box->fill_color()));
|
2018-11-14 22:43:40 -05:00
|
|
|
number_text->set (string_compose ("%1", sequence.index() + 1));
|
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
name_text = new Text (canvas);
|
2018-11-14 22:43:40 -05:00
|
|
|
name_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
2020-07-12 02:01:28 -04:00
|
|
|
name_text->set_color (contrasting_text_color (lhs_box->fill_color()));
|
2018-11-19 11:31:31 -05:00
|
|
|
name_text->Event.connect (sigc::mem_fun (*this, &SequenceView::name_text_event));
|
2020-07-12 02:01:28 -04:00
|
|
|
name_text->set (_("Snare"));
|
2020-07-13 00:04:56 -04:00
|
|
|
name_text->set_intrinsic_size (name_text->width(), name_text->height());
|
2018-11-15 17:35:36 -05:00
|
|
|
|
2020-07-12 02:01:28 -04:00
|
|
|
root_text = new Text (canvas);
|
|
|
|
root_text->set ("F#2"); // likely widest root label
|
2018-11-14 22:43:40 -05:00
|
|
|
root_text->set (ParameterDescriptor::midi_note_name (sequence.root()));
|
|
|
|
root_text->set_font_description (UIConfiguration::instance().get_LargeFont());
|
2020-07-13 00:04:56 -04:00
|
|
|
root_text->set_intrinsic_size (root_text->width(), _step_dimen - 1);
|
2020-07-12 02:01:28 -04:00
|
|
|
root_text->set_color (contrasting_text_color (lhs_box->fill_color()));
|
2018-11-25 19:10:25 -05:00
|
|
|
|
2020-07-13 00:04:56 -04:00
|
|
|
lhs_box->pack_start (name_text);
|
2020-07-12 02:01:28 -04:00
|
|
|
lhs_box->pack_start (number_text);
|
|
|
|
lhs_box->pack_start (root_text);
|
2018-11-19 11:31:31 -05:00
|
|
|
|
2020-07-13 00:04:56 -04:00
|
|
|
step_cnt_button = new Rectangle (canvas);
|
|
|
|
step_cnt_button->set_fill_color (0x0000ffff);
|
|
|
|
step_cnt_button->set_fill (true);
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
const size_t nsteps = sequencer().nsteps();
|
|
|
|
|
|
|
|
for (size_t n = 0; n < nsteps; ++n) {
|
2020-07-12 02:01:28 -04:00
|
|
|
StepView* stepview = new StepView (*this, sequence.step (n), canvas);
|
2018-11-19 11:31:31 -05:00
|
|
|
step_views.push_back (stepview);
|
2020-07-12 02:01:28 -04:00
|
|
|
step_box->pack_start (stepview, PackOptions (PackExpand|PackFill), PackOptions (PackExpand|PackFill));
|
2018-11-19 11:31:31 -05:00
|
|
|
}
|
2020-07-13 00:04:56 -04:00
|
|
|
|
|
|
|
step_box->pack_start (step_cnt_button, PackOptions (PackExpand|PackFill), PackOptions (PackExpand|PackFill));
|
|
|
|
|
|
|
|
speed_slide = new Rectangle (canvas);
|
|
|
|
speed_slide->set_intrinsic_size (_step_dimen - 1, _step_dimen - 1);
|
|
|
|
speed_slide->set_fill_color (0xff0000ff);
|
|
|
|
speed_slide->set_fill (true);
|
|
|
|
|
|
|
|
rhs_box->pack_start (speed_slide, PackOptions (PackExpand|PackFill));
|
|
|
|
|
2018-11-19 11:31:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SequenceView::view_mode_changed ()
|
|
|
|
{
|
|
|
|
for (StepViews::iterator s = step_views.begin(); s != step_views.end(); ++s) {
|
|
|
|
(*s)->view_mode_changed ();
|
|
|
|
}
|
2018-11-14 22:43:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2018-11-19 11:31:31 -05:00
|
|
|
SequenceView::name_text_event (GdkEvent *ev)
|
2018-11-14 22:43:40 -05:00
|
|
|
{
|
|
|
|
switch (ev->type) {
|
|
|
|
case GDK_2BUTTON_PRESS:
|
|
|
|
edit_name ();
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-19 11:31:31 -05:00
|
|
|
SequenceView::edit_name ()
|
2018-11-14 22:43:40 -05:00
|
|
|
{
|
|
|
|
GtkCanvas* gc = dynamic_cast<GtkCanvas*> (name_text->canvas());
|
|
|
|
assert (gc);
|
|
|
|
Gtk::Window* toplevel = (Gtk::Window*) gc->get_toplevel();
|
|
|
|
assert (toplevel);
|
|
|
|
|
|
|
|
floating_entry = new FloatingTextEntry (toplevel, name_text->text());
|
2018-11-19 11:31:31 -05:00
|
|
|
floating_entry->use_text.connect (sigc::mem_fun (*this, &SequenceView::name_edited));
|
2018-11-14 22:43:40 -05:00
|
|
|
floating_entry->set_name (X_("LargeTextEntry"));
|
|
|
|
|
|
|
|
/* move fte top left corner to top left corner of name text */
|
|
|
|
|
|
|
|
Duple wc = name_text->item_to_window (Duple (0,0));
|
|
|
|
int x, y;
|
|
|
|
int wx, wy;
|
|
|
|
|
|
|
|
gc->translate_coordinates (*toplevel, wc.x, wc.y, x, y);
|
|
|
|
toplevel->get_window()->get_origin (wx, wy);
|
|
|
|
|
|
|
|
floating_entry->move (wx + x, wy + y);
|
|
|
|
floating_entry->present ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2018-11-19 11:31:31 -05:00
|
|
|
SequenceView::name_edited (std::string str, int next)
|
2018-11-14 22:43:40 -05:00
|
|
|
{
|
|
|
|
name_text->set (str);
|
|
|
|
|
|
|
|
switch (next) {
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1:
|
2018-11-19 11:31:31 -05:00
|
|
|
if (sequence.index() < sv.sequencer().nsequences() - 1) {
|
|
|
|
sv.sequence_view (sequence.index() + 1).edit_name();
|
2018-11-14 22:43:40 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
if (sequence.index() > 0) {
|
2018-11-19 11:31:31 -05:00
|
|
|
sv.sequence_view (sequence.index() - 1).edit_name();
|
2018-11-14 22:43:40 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|