13
0

trigger_ui: implement icons for new launch-styles and follow-actions

This commit is contained in:
Ben Loftis 2022-01-04 15:59:24 -06:00
parent 8a49d274fb
commit fdd92c82fb

View File

@ -177,6 +177,9 @@ TriggerEntry::_size_allocate (ArdourCanvas::Rect const& alloc)
void void
TriggerEntry::draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, Trigger::FollowAction icon, float size, float scale) const TriggerEntry::draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, Trigger::FollowAction icon, float size, float scale) const
{ {
uint32_t bg_color = fill_color();
uint32_t fg_color = UIConfiguration::instance ().color ("neutral:midground");
//in the case where there is a random follow-action, just put a "?" //in the case where there is a random follow-action, just put a "?"
if (trigger()->follow_action_probability()>0) { if (trigger()->follow_action_probability()>0) {
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context); Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
@ -190,6 +193,7 @@ TriggerEntry::draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, Trigger::
return; return;
} }
set_source_rgba (context, fg_color);
context->set_line_width (1 * scale); context->set_line_width (1 * scale);
switch (icon) { switch (icon) {
@ -207,30 +211,50 @@ TriggerEntry::draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, Trigger::
context->move_to (size / 2, 3 * scale); context->move_to (size / 2, 3 * scale);
context->line_to (size / 2, size - 5 * scale); context->line_to (size / 2, size - 5 * scale);
context->stroke (); context->stroke ();
context->arc (size / 2, size - 5 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head context->arc (size / 2, size - 5 * scale, 2 * scale, 0, 2 * M_PI); // arrow head
context->fill (); context->fill ();
break; break;
case Trigger::PrevTrigger: case Trigger::PrevTrigger:
context->move_to (size / 2, 5 * scale); context->move_to (size / 2, 5 * scale);
context->line_to (size / 2, size - 3 * scale); context->line_to (size / 2, size - 3 * scale);
context->stroke (); context->stroke ();
context->arc (size / 2, 5 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head context->arc (size / 2, 5 * scale, 2 * scale, 0, 2 * M_PI); // arrow head
context->fill (); context->fill ();
break; break;
/* XXX Ben to add new icons for next two */
case Trigger::ForwardTrigger: case Trigger::ForwardTrigger:
context->move_to (size / 2, 3 * scale); context->move_to (size / 2, 3 * scale);
context->line_to (size / 2, size - 5 * scale); context->line_to (size / 2, size - 3 * scale);
context->stroke (); context->stroke ();
context->arc (size / 2, size - 5 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
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->fill (); context->fill ();
break; break;
case Trigger::ReverseTrigger: case Trigger::ReverseTrigger:
context->move_to (size / 2, 5 * scale); 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->line_to (size / 2, size - 3 * scale); context->line_to (size / 2, size - 3 * scale);
context->stroke (); context->stroke ();
context->arc (size / 2, 5 * scale, 1.5 * scale, 0, 2 * M_PI); // arrow head
context->arc (size / 2, size - 7 * scale, 2 * scale, 0, 2 * M_PI);
set_source_rgba (context, fg_color);
context->fill (); context->fill ();
context->arc (size / 2, size - 7 * scale, 1 * scale, 0, 2 * M_PI);
set_source_rgba (context, bg_color);
context->fill ();
break; break;
case Trigger::QueuedTrigger: { case Trigger::QueuedTrigger: {
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context); Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
@ -255,6 +279,8 @@ TriggerEntry::draw_follow_icon (Cairo::RefPtr<Cairo::Context> context, Trigger::
context->set_identity_matrix (); context->set_identity_matrix ();
} break; } break;
case Trigger::OtherTrigger: { case Trigger::OtherTrigger: {
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++) { for (int i = 0; i<6; i++) {
Cairo::Matrix m = context->get_matrix(); Cairo::Matrix m = context->get_matrix();
context->translate (size / 2, size /2); context->translate (size / 2, size /2);
@ -281,8 +307,9 @@ TriggerEntry::draw_launch_icon (Cairo::RefPtr<Cairo::Context> context, float sz,
float margin = 4*scale; float margin = 4*scale;
float size = sz - 2*margin; float size = sz - 2*margin;
if (trigger()->active()) { bool active = trigger()->active();
if (trigger()->launch_style()==Trigger::Toggle) {
if (active && trigger()->launch_style()==Trigger::Toggle) {
//clicking again will Stop this clip //clicking again will Stop this clip
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground")); set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground"));
context->move_to (margin, margin); context->move_to (margin, margin);
@ -292,18 +319,7 @@ TriggerEntry::draw_launch_icon (Cairo::RefPtr<Cairo::Context> context, float sz,
context->rel_line_to (0, -size); context->rel_line_to (0, -size);
context->fill (); context->fill ();
return; //done return; //done
} else {
//actively playing; draw a filled play triangle
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground"));
context->move_to (margin, margin);
context->rel_line_to (0, size);
context->rel_line_to (size, -size/2);
context->fill ();
return; //done
} }
}
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
if (!trigger()->region ()) { if (!trigger()->region ()) {
//no content in this slot, it is only a Stop button //no content in this slot, it is only a Stop button
@ -312,26 +328,73 @@ TriggerEntry::draw_launch_icon (Cairo::RefPtr<Cairo::Context> context, float sz,
context->rel_line_to (0, size); context->rel_line_to (0, size);
context->rel_line_to (-size, 0); context->rel_line_to (-size, 0);
context->rel_line_to (0, -size); context->rel_line_to (0, -size);
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
context->stroke (); context->stroke ();
return; //done return; //done
} }
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
switch (trigger()->launch_style()) { switch (trigger()->launch_style()) {
case Trigger::Toggle: case Trigger::Toggle:
if (active) {
context->move_to (margin, margin); //special case: now it's a square Stop button
context->rel_line_to (size, 0);
context->rel_line_to (0, size);
context->rel_line_to (-size, 0);
context->line_to (margin, margin);
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground"));
context->fill ();
context->stroke ();
} else {
context->move_to (margin, margin); //boxy arrow
context->rel_line_to (0, size);
context->rel_line_to (size*1/3, 0);
context->rel_line_to (size*2/3, -size/2);
context->rel_line_to (-size*2/3, -size/2);
context->line_to (margin, margin);
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
context->stroke ();
}
break;
case Trigger::OneShot: case Trigger::OneShot:
context->move_to (margin, margin); context->move_to (margin, margin);
context->rel_line_to (0, size); context->rel_line_to (0, size);
context->rel_line_to (size, -size/2); context->rel_line_to (size, -size/2);
context->line_to (margin, margin); context->line_to (margin, margin);
if (active) {
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground"));
context->fill ();
context->stroke (); context->stroke ();
} else {
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
context->stroke ();
}
break; break;
/* XXX ben this needs a new icon */ case Trigger::ReTrigger: //line + boxy arrow + line
case Trigger::ReTrigger: if (active) {
context->move_to (margin, margin); set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground"));
context->rel_line_to (0, size); } else {
context->rel_line_to (size, -size/2); set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
context->line_to (margin, margin); }
//vertical line at left
context->set_line_width (2 * scale);
context->move_to (margin + 1*scale, margin);
context->line_to (margin + 1*scale, margin+size);
context->stroke (); context->stroke ();
//small triangle
context->set_line_width (1 * scale);
context->move_to (margin + scale*4, margin + 2*scale);
context->line_to (margin + size, margin+size/2);
context->line_to (margin + scale*4, margin+size-2*scale);
context->line_to (margin + scale*4, margin + 2*scale);
if (active) {
context->fill ();
} else {
context->stroke ();
}
break; break;
case Trigger::Gate: //diamond shape case Trigger::Gate: //diamond shape
context->move_to ( margin+size/2, margin ); context->move_to ( margin+size/2, margin );
@ -339,10 +402,16 @@ TriggerEntry::draw_launch_icon (Cairo::RefPtr<Cairo::Context> context, float sz,
context->rel_line_to ( -size/2, size/2); context->rel_line_to ( -size/2, size/2);
context->rel_line_to ( -size/2, -size/2); context->rel_line_to ( -size/2, -size/2);
context->rel_line_to ( size/2, -size/2); context->rel_line_to ( size/2, -size/2);
if (active) {
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foreground"));
context->fill ();
context->stroke (); context->stroke ();
} else {
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:midground"));
context->stroke ();
}
break; break;
case Trigger::Repeat: //'stutter' shape case Trigger::Repeat: //'stutter' shape
set_source_rgba (context, HSV (UIConfiguration::instance ().color ("neutral:midground")).lighter (0.25).color ()); //stutter shape needs to be brighter to maintain balance
context->set_line_width (1 * scale); context->set_line_width (1 * scale);
context->move_to ( margin, margin ); context->move_to ( margin, margin );
context->rel_line_to ( 0, size); context->rel_line_to ( 0, size);
@ -353,6 +422,11 @@ TriggerEntry::draw_launch_icon (Cairo::RefPtr<Cairo::Context> context, float sz,
context->move_to ( margin + scale*6, margin + scale*3 ); context->move_to ( margin + scale*6, margin + scale*3 );
context->rel_line_to ( 0, size - scale*6); context->rel_line_to ( 0, size - scale*6);
if (active) {
set_source_rgba (context, UIConfiguration::instance ().color ("neutral:foregroundest"));
} else {
set_source_rgba (context, HSV (UIConfiguration::instance ().color ("neutral:midground")).lighter (0.25).color ()); //stutter shape needs to be brighter to maintain balance
}
context->stroke (); context->stroke ();
break; break;
default: default: