13
0

trigger_ui: convenience functions to set Color for a column or row

This commit is contained in:
Ben Loftis 2021-12-27 17:35:24 -06:00
parent 414f3611ee
commit 4736b8338c
4 changed files with 68 additions and 0 deletions

View File

@ -318,6 +318,8 @@ CueBoxUI::context_menu (uint64_t idx)
items.push_back (MenuElem (_("Set All Launch Styles..."), *launch_menu));
items.push_back (MenuElem (_("Set All Quantizations..."), *quant_menu));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Set All Colors..."), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::set_all_colors), idx)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Clear All..."), sigc::bind (sigc::mem_fun (*this, &CueBoxUI::clear_all_triggers), idx)));
_context_menu->popup (1, gtk_get_current_event_time ());
@ -348,6 +350,35 @@ CueBoxUI::clear_all_triggers (uint64_t idx)
}
}
void
CueBoxUI::set_all_colors (uint64_t idx)
{
_color_dialog.get_colorsel()->set_has_opacity_control (false);
_color_dialog.get_colorsel()->set_has_palette (true);
_color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
_color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
Gdk::Color c = ARDOUR_UI_UTILS::gdk_color_from_rgba(0xBEBEBEFF);
_color_dialog.get_colorsel()->set_previous_color (c);
_color_dialog.get_colorsel()->set_current_color (c);
switch (_color_dialog.run()) {
case Gtk::RESPONSE_ACCEPT: {
c = _color_dialog.get_colorsel()->get_current_color();
color_t ct = ARDOUR_UI_UTILS::gdk_color_to_rgba(c);
TriggerList tl;
get_slots(tl, idx);
for (TriggerList::iterator t = tl.begin(); t != tl.end(); ++t) {
(*t)->set_color(ct);
}
} break;
default:
break;
}
_color_dialog.hide ();
}
void
CueBoxUI::set_all_follow_action (Trigger::FollowAction fa, uint64_t idx)
{

View File

@ -21,6 +21,7 @@
#define _gtk_ardour_cuebox_ui_h_
#include <gtkmm/window.h>
#include <gtkmm/colorselection.h>
#include "pbd/properties.h"
@ -88,11 +89,13 @@ private:
void get_slots (TriggerList &triggerlist, uint64_t idx);
void clear_all_triggers(uint64_t idx);
void set_all_colors (uint64_t idx);
void set_all_follow_action (ARDOUR::Trigger::FollowAction, uint64_t idx);
void set_all_launch_style (ARDOUR::Trigger::LaunchStyle, uint64_t idx);
void set_all_quantization (Temporal::BBT_Offset const&, uint64_t idx);
Gtk::Menu* _context_menu;
Gtk::ColorSelectionDialog _color_dialog;
static Gtkmm2ext::Bindings* bindings;

View File

@ -402,6 +402,8 @@ TriggerMaster::context_menu ()
items.push_back (MenuElem (_("Set All Launch Styles..."), *launch_menu));
items.push_back (MenuElem (_("Set All Quantizations..."), *quant_menu));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Set All Colors..."), sigc::mem_fun (*this, &TriggerMaster::set_all_colors)));
items.push_back (SeparatorElem());
items.push_back (MenuElem (_("Clear All..."), sigc::mem_fun (*this, &TriggerMaster::clear_all_triggers)));
_context_menu->popup (1, gtk_get_current_event_time ());
@ -423,6 +425,34 @@ TriggerMaster::clear_all_triggers ()
_triggerbox->clear_all_triggers();
}
void
TriggerMaster::set_all_colors ()
{
_color_dialog.get_colorsel()->set_has_opacity_control (false);
_color_dialog.get_colorsel()->set_has_palette (true);
_color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_ACCEPT));
_color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (_color_dialog, &Gtk::Dialog::response), Gtk::RESPONSE_CANCEL));
Gdk::Color c = ARDOUR_UI_UTILS::gdk_color_from_rgba(0xBEBEBEFF);
_color_dialog.get_colorsel()->set_previous_color (c);
_color_dialog.get_colorsel()->set_current_color (c);
switch (_color_dialog.run()) {
case Gtk::RESPONSE_ACCEPT: {
c = _color_dialog.get_colorsel()->get_current_color();
color_t ct = ARDOUR_UI_UTILS::gdk_color_to_rgba(c);
for (int n = 0; n< TriggerBox::default_triggers_per_box; n++) {
_triggerbox->trigger (n)->set_color(ct);
}
} break;
default:
break;
}
_color_dialog.hide ();
}
void
TriggerMaster::set_all_follow_action (Trigger::FollowAction fa)
{

View File

@ -20,6 +20,8 @@
#ifndef _gtk_ardour_trigger_master_h_
#define _gtk_ardour_ardour_trigger_master_h_
#include <gtkmm/colorselection.h>
#include "pbd/properties.h"
#include "ardour/triggerbox.h"
@ -83,6 +85,7 @@ private:
void context_menu ();
void clear_all_triggers();
void set_all_colors();
void set_all_follow_action (ARDOUR::Trigger::FollowAction);
void set_all_launch_style (ARDOUR::Trigger::LaunchStyle);
void set_all_quantization (Temporal::BBT_Offset const&);
@ -98,6 +101,7 @@ private:
Loopster* _loopster;
PassThru* _passthru;
Gtk::ColorSelectionDialog _color_dialog;
Gtk::Menu* _context_menu;
bool _ignore_menu_action;