13
0

redesign cue editor layout to use ArdourButton and GtkBoxen

This commit is contained in:
Paul Davis 2024-11-12 08:12:16 -07:00
parent a1dd7ae4c3
commit 0622f26b2a
4 changed files with 71 additions and 80 deletions

View File

@ -74,10 +74,9 @@ MidiCueEditor::MidiCueEditor()
build_grid_type_menu ();
build_draw_midi_menus();
build_upper_toolbar ();
build_canvas ();
setup_toolbar ();
_toolbox.pack_start (viewport(), true, true);
build_lower_toolbar ();
set_mouse_mode (Editing::MouseContent, true);
}
@ -126,7 +125,33 @@ MidiCueEditor::canvas_pre_event (GdkEvent* ev)
}
void
MidiCueEditor::setup_toolbar ()
MidiCueEditor::build_lower_toolbar ()
{
velocity_button = new ArdourButton (_("Velocity"), ArdourButton::Text, true);
bender_button = new ArdourButton (_("Bender"), ArdourButton::Text, true);
pressure_button = new ArdourButton (_("Pressure"), ArdourButton::Text, true);
expression_button = new ArdourButton (_("Expression"), ArdourButton::Text, true);
modulation_button = new ArdourButton (_("Modulation"), ArdourButton::Text, true);
// button_bar.set_homogeneous (true);
button_bar.set_spacing (6);
button_bar.set_border_width (6);
button_bar.pack_start (*velocity_button, false, false);
button_bar.pack_start (*bender_button, false, false);
button_bar.pack_start (*pressure_button, false, false);
button_bar.pack_start (*modulation_button, false, false);
velocity_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiVelocityAutomation, 0), false);
pressure_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiChannelPressureAutomation, 0), false);
bender_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiPitchBenderAutomation, 0), false);
modulation_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_MODWHEEL), false);
expression_button->signal_button_press_event().connect (sigc::bind (sigc::mem_fun (*this, &MidiCueEditor::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_EXPRESSION), false);
_toolbox.pack_start (button_bar, false, false);
}
void
MidiCueEditor::build_upper_toolbar ()
{
Gtk::HBox* mode_box = manage(new Gtk::HBox);
mode_box->set_border_width (2);
@ -299,6 +324,8 @@ MidiCueEditor::build_canvas ()
_canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
_canvas->set_can_focus ();
_toolbox.pack_start (*_canvas_viewport, true, true);
bindings_changed ();
}
@ -1775,3 +1802,29 @@ MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiRegion> r)
reset_zoom (spp);
}
}
bool
MidiCueEditor::automation_button_event (GdkEventButton* ev, Evoral::ParameterType type, int id)
{
SelectionOperation op = ArdourKeyboard::selection_type (ev->state);
switch (ev->type) {
case GDK_BUTTON_RELEASE:
automation_button_click (type, id, op);
break;
default:
break;
}
return false;
}
void
MidiCueEditor::automation_button_click (Evoral::ParameterType type, int id, SelectionOperation op)
{
#warning paul allow channel selection (2nd param)
if (view) {
view->update_automation_display (Evoral::Parameter (type, 0, id), op);
}
}

View File

@ -171,11 +171,20 @@ class MidiCueEditor : public CueEditor
Gtk::VBox _toolbox;
Gtk::HBox button_bar;
ArdourWidgets::ArdourButton* velocity_button;
ArdourWidgets::ArdourButton* bender_button;
ArdourWidgets::ArdourButton* pressure_button;
ArdourWidgets::ArdourButton* expression_button;
ArdourWidgets::ArdourButton* modulation_button;
CueMidiBackground* bg;
MidiCueView* view;
void build_canvas ();
void canvas_allocate (Gtk::Allocation);
void build_upper_toolbar ();
void build_lower_toolbar ();
RegionSelection region_selection();
@ -199,7 +208,6 @@ class MidiCueEditor : public CueEditor
BBTMetric bbt_metric;
bool canvas_pre_event (GdkEvent*);
void setup_toolbar ();
/* autoscrolling */
@ -222,6 +230,9 @@ class MidiCueEditor : public CueEditor
std::atomic<int> idle_update_queued;
PBD::ScopedConnectionList capture_connections;
samplecnt_t data_capture_duration;
bool automation_button_event (GdkEventButton*, Evoral::ParameterType type, int id);
void automation_button_click (Evoral::ParameterType type, int id, ARDOUR::SelectionOperation);
};

View File

@ -78,40 +78,6 @@ MidiCueView::MidiCueView (std::shared_ptr<ARDOUR::MidiTrack> mt,
automation_group->set_fill_color (UIConfiguration::instance().color ("midi automation track fill"));
automation_group->set_data ("linemerger", this);
button_bar = new ArdourCanvas::Box (&noscroll_parent, ArdourCanvas::Box::Horizontal);
CANVAS_DEBUG_NAME (button_bar, "button bar");
button_bar->set_spacing (12.);
/* Right-side padding only */
button_bar->set_padding (0., 0., 0., 24.);
button_bar->set_margin (5., 5., 5., 5.);
Pango::FontDescription button_font = UIConfiguration::instance().get_NormalFont();
velocity_button = new ArdourCanvas::Button (button_bar, _("Velocity"), button_font);
velocity_button->text()->set_color (UIConfiguration::instance().color ("neutral:foreground"));
CANVAS_DEBUG_NAME (velocity_button, "velocity button");
bender_button = new ArdourCanvas::Button (button_bar, _("Bender"), button_font);
bender_button->text()->set_color (UIConfiguration::instance().color ("neutral:foreground"));
CANVAS_DEBUG_NAME (bender_button, "bender button");
pressure_button = new ArdourCanvas::Button (button_bar, _("Pressure"), button_font);
pressure_button->text()->set_color (UIConfiguration::instance().color ("neutral:foreground"));
CANVAS_DEBUG_NAME (pressure_button, "pressure button");
expression_button = new ArdourCanvas::Button (button_bar, _("Expression"), button_font);
expression_button->text()->set_color (UIConfiguration::instance().color ("neutral:foreground"));
CANVAS_DEBUG_NAME (expression_button, "expression button");
modulation_button = new ArdourCanvas::Button (button_bar, _("Modulation"), button_font);
modulation_button->text()->set_color (UIConfiguration::instance().color ("neutral:foreground"));
CANVAS_DEBUG_NAME (modulation_button, "modulation button");
velocity_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &MidiCueView::automation_button_event), ARDOUR::MidiVelocityAutomation, 0));
pressure_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &MidiCueView::automation_button_event), ARDOUR::MidiChannelPressureAutomation, 0));
bender_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &MidiCueView::automation_button_event), ARDOUR::MidiPitchBenderAutomation, 0));
modulation_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &MidiCueView::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_MODWHEEL));
expression_button->Event.connect (sigc::bind (sigc::mem_fun (*this, &MidiCueView::automation_button_event), ARDOUR::MidiCCAutomation, MIDI_CTL_MSB_EXPRESSION));
set_extensible (true);
@ -128,11 +94,8 @@ MidiCueView::~MidiCueView ()
void
MidiCueView::set_height (double h)
{
double bbw, bbh;
button_bar->size_request (bbw, bbh);
double note_area_height = ceil ((h - bbh) / 2.);
double automation_height = ceil (h - bbh - note_area_height);
double note_area_height = ceil (h / 2.);
double automation_height = ceil (h - note_area_height);
event_rect->set (ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, note_area_height));
midi_context().set_size (midi_context().width(), note_area_height);
@ -140,8 +103,6 @@ MidiCueView::set_height (double h)
automation_group->set_position (ArdourCanvas::Duple (0., note_area_height));
automation_group->set (ArdourCanvas::Rect (0., 0., ArdourCanvas::COORD_MAX, automation_height));
button_bar->size_allocate (ArdourCanvas::Rect (0., note_area_height + automation_height, ArdourCanvas::COORD_MAX, note_area_height + automation_height + bbh));
for (auto & ads : automation_map) {
ads.second.set_height (automation_height);
}
@ -274,29 +235,6 @@ MidiCueView::update_hit (Hit* h)
}
}
bool
MidiCueView::automation_button_event (GdkEvent* ev, Evoral::ParameterType type, int id)
{
SelectionOperation op = ArdourKeyboard::selection_type (ev->button.state);
switch (ev->type) {
case GDK_BUTTON_RELEASE:
automation_button_click (type, id, op);
break;
default:
break;
}
return false;
}
void
MidiCueView::automation_button_click (Evoral::ParameterType type, int id, SelectionOperation op)
{
#warning paul allow channel selection (2nd param)
update_automation_display (Evoral::Parameter (type, 0, id), op);
}
void
MidiCueView::update_automation_display (Evoral::Parameter const & param, SelectionOperation op)
{

View File

@ -35,7 +35,6 @@ class MidiCueAutomationLine;
namespace ArdourCanvas {
class Box;
class Button;
}
class MidiCueView : public MidiView
@ -110,20 +109,10 @@ class MidiCueView : public MidiView
VelocityDisplay* velocity_display;
ArdourCanvas::Box* button_bar;
ArdourCanvas::Button* velocity_button;
ArdourCanvas::Button* bender_button;
ArdourCanvas::Button* pressure_button;
ArdourCanvas::Button* expression_button;
ArdourCanvas::Button* modulation_button;
std::shared_ptr<Temporal::TempoMap const> tempo_map;
ArdourCanvas::Rectangle* event_rect;
uint32_t _slot_index;
void update_sustained (Note *);
void update_hit (Hit *);
bool automation_button_event (GdkEvent*, Evoral::ParameterType type, int id);
void automation_button_click (Evoral::ParameterType type, int id, ARDOUR::SelectionOperation);
};