13
0

trigger_ui: implement direct-Jump actions from trigger slots; context-menu and icons

This commit is contained in:
Ben Loftis 2022-01-21 14:48:28 -06:00
parent 8ed6f685cf
commit b0a2d678dc
2 changed files with 51 additions and 66 deletions

View File

@ -588,40 +588,18 @@ TriggerUI::follow_context_menu ()
_ignore_menu_action = true;
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::None)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::None))));
if (trigger ()->follow_action (0) == FollowAction::None) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::Stop)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::Stop))));
if (trigger ()->follow_action (0) == FollowAction::Stop) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::Again)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::Again))));
if (trigger ()->follow_action (0) == FollowAction::Again) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::ForwardTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::ForwardTrigger))));
if (trigger ()->follow_action (0) == FollowAction::ForwardTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::ReverseTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::ReverseTrigger))));
if (trigger ()->follow_action (0) == FollowAction::ReverseTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
#if 0
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::FirstTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::FirstTrigger))));
if (trigger ()->follow_action (0) == FollowAction::FirstTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::LastTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::LastTrigger))));
if (trigger ()->follow_action (0) == FollowAction::LastTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
}
#endif
fitems.push_back (RadioMenuElem (fagroup, TriggerUI::follow_action_to_string(FollowAction (FollowAction::JumpTrigger)), sigc::bind(sigc::mem_fun (*this, &TriggerUI::set_follow_action), FollowAction (FollowAction::JumpTrigger))));
if (trigger ()->follow_action (0) == FollowAction::JumpTrigger) {
dynamic_cast<Gtk::CheckMenuItem*> (&fitems.back ())->set_active (true);
Menu* jump_menu = manage (new Menu);
MenuList& jitems = jump_menu->items ();
for (int i = 0; i < default_triggers_per_box; i++) {
FollowAction jump_fa = (FollowAction::JumpTrigger);
jump_fa.targets.set(i);
jitems.push_back (MenuElem (string_compose ("%1", (char)('A' + i)), sigc::bind (sigc::mem_fun (*this, &TriggerUI::set_follow_action), jump_fa)));
}
fitems.push_back (MenuElem (_("Jump..."), *jump_menu));
_ignore_menu_action = false;

View File

@ -212,53 +212,60 @@ TriggerEntry::draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, FollowAct
break;
case FollowAction::ForwardTrigger:
context->move_to (size / 2, 3 * scale);
context->line_to (size / 2, size - 3 * scale);
context->line_to (size / 2, size - 5 * scale);
context->stroke ();
context->arc (size / 2, 7 * scale, 2 * scale, 0, 2 * M_PI);
set_source_rgba (context, fg_color);
context->fill ();
context->arc (size / 2, 7 * scale, 1 * scale, 0, 2 * M_PI);
set_source_rgba (context, fill_color ());
context->fill ();
set_source_rgba (context, fg_color);
context->arc (size / 2, size - 3 * scale, 2 * scale, 0, 2 * M_PI); // arrow head
context->arc (size / 2, size - 5 * scale, 2 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
break;
case FollowAction::ReverseTrigger:
context->arc (size / 2, 3 * scale, 2 * scale, 0, 2 * M_PI); // arrow head
set_source_rgba (context, fg_color);
context->fill ();
context->move_to (size / 2, 3 * scale);
context->move_to (size / 2, 5 * scale);
context->line_to (size / 2, size - 3 * scale);
context->stroke ();
context->arc (size / 2, size - 7 * scale, 2 * scale, 0, 2 * M_PI);
set_source_rgba (context, fg_color);
context->arc (size / 2, 5 * scale, 2 * scale, 0, 2 * M_PI); // arrow head
context->fill ();
context->arc (size / 2, size - 7 * scale, 1 * scale, 0, 2 * M_PI);
set_source_rgba (context, bg_color);
context->fill ();
break;
/* ben: new shape here ? */
case FollowAction::JumpTrigger: {
context->set_line_width (1.5 * scale);
set_source_rgba (context, HSV (UIConfiguration::instance ().color ("neutral:midground")).lighter (0.25).color ()); // needs to be brighter to maintain balance
for (int i = 0; i < 6; i++) {
Cairo::Matrix m = context->get_matrix ();
context->translate (size / 2, size / 2);
context->rotate (i * M_PI / 3);
context->move_to (0, 2 * scale);
context->line_to (0, (size / 2) - 4 * scale);
context->stroke ();
context->set_matrix (m);
if ( icon.targets.count() == 1 ) { //jump to a specific row
int cue_idx = -1;
for (int i = 0; i < default_triggers_per_box; i++) {
if (icon.targets.test(i)) {
cue_idx = i;
break;
}
}
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
layout->set_font_description (UIConfiguration::instance ().get_SmallMonospaceFont ());
layout->set_text (string_compose ("%1", (char)('A' + cue_idx))); //XXX translate?
int tw, th;
layout->get_pixel_size (tw, th);
context->move_to (size / 2, size / 2);
context->rel_move_to (-tw / 2, -th / 2);
layout->show_in_cairo_context (context);
} else if (false) { // 'ANY' jump
for (int i = 0; i < 6; i++) {
Cairo::Matrix m = context->get_matrix ();
context->translate (size / 2, size / 2);
context->rotate (i * M_PI / 3);
context->move_to (0, 0);
context->line_to (0, (size / 2) - 4 * scale);
context->stroke ();
context->set_matrix (m);
}
context->set_identity_matrix ();
} else { // 'OTHER' jump
context->set_line_width (1.5 * scale);
set_source_rgba (context, HSV (UIConfiguration::instance ().color ("neutral:midground")).lighter (0.25).color ()); // needs to be brighter to maintain balance
for (int i = 0; i < 6; i++) {
Cairo::Matrix m = context->get_matrix ();
context->translate (size / 2, size / 2);
context->rotate (i * M_PI / 3);
context->move_to (0, 2 * scale);
context->line_to (0, (size / 2) - 4 * scale);
context->stroke ();
context->set_matrix (m);
}
context->set_identity_matrix ();
}
context->set_identity_matrix ();
} break;
case FollowAction::None:
default: