TriggerBox: change highlight behavior and experiment with black borders

This commit is contained in:
Ben Loftis 2021-12-12 11:20:11 -06:00
parent f5049cda74
commit c862b604e1
4 changed files with 159 additions and 51 deletions

View File

@ -97,14 +97,15 @@ CueEntry::event_handler (GdkEvent* ev)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
play_shape->set_outline_color (UIConfiguration::instance().color ("neutral:foreground"));
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:foregroundest"));
play_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
play_shape->set_outline_color (UIConfiguration::instance().color ("neutral:midground"));
name_text->set_color (UIConfiguration::instance().color("neutral:midground"));
set_default_colors();
}
break;
default:
@ -145,6 +146,49 @@ void
CueEntry::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
Rectangle::render(area, context);
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
*/
Rect self (item_to_window (_rect));
const Rect draw = self.intersection (area);
if (!draw) {
return;
}
float width = _rect.width();
float height = _rect.height();
const double scale = UIConfiguration::instance().get_ui_scale();
if (_fill && !_transparent) {
setup_fill_context (context);
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
context->fill ();
}
render_children (area, context);
if (_cue_idx%2==0) {
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
context->fill ();
context->set_identity_matrix();
}
{
//line at right
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(width-1, 0, width, height);
context->fill ();
context->set_identity_matrix();
}
}
void
@ -152,12 +196,9 @@ CueEntry::shape_play_button ()
{
Points p;
{
/* region exists; draw triangle to show that we can trigger */
p.push_back (Duple (poly_margin, poly_margin));
p.push_back (Duple (poly_margin, poly_size));
p.push_back (Duple (poly_size, 0.5+poly_size / 2.));
}
p.push_back (Duple (poly_margin, poly_margin));
p.push_back (Duple (poly_margin, poly_size));
p.push_back (Duple (poly_size, 0.5+poly_size / 2.));
play_shape->set (p);
@ -188,10 +229,10 @@ CueEntry::set_default_colors ()
name_button->set_outline_color (HSV (fill_color()).darker(0.15).color ());
}
name_text->set_color (UIConfiguration::instance().color("neutral:midground"));
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
}
void

View File

@ -119,18 +119,25 @@ TriggerMaster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context)
context->fill ();
}
//fade-over at top
uint32_t bg_color = UIConfiguration::instance().color ("theme:bg");
double bg_r,bg_g,bg_b, unused;
Gtkmm2ext::color_to_rgba( bg_color, bg_r, bg_g, bg_b, unused);
Cairo::RefPtr<Cairo::LinearGradient> left_pattern = Cairo::LinearGradient::create (0, 0, 0, 6.*scale);
left_pattern->add_color_stop_rgba (0, 0, 0, 0, 1);
left_pattern->add_color_stop_rgba (1, 0, 0, 0, 0);
context->set_source (left_pattern);
context->rectangle(0, 0, width, 6.*scale);
context->fill ();
render_children (area, context);
{
//line at right
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(width-1, 0, width, height);
context->fill ();
context->set_identity_matrix();
}
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
context->fill ();
context->set_identity_matrix();
}
void
@ -157,13 +164,15 @@ TriggerMaster::event_handler (GdkEvent* ev)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foregroundest"));
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
}
redraw ();
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
set_default_colors();
}
redraw ();
break;
@ -255,7 +264,7 @@ TriggerMaster::set_default_colors ()
{
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
}
@ -324,18 +333,25 @@ CueMaster::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) con
context->fill ();
}
//fade-over at top
uint32_t bg_color = UIConfiguration::instance().color ("theme:bg");
double bg_r,bg_g,bg_b, unused;
Gtkmm2ext::color_to_rgba( bg_color, bg_r, bg_g, bg_b, unused);
Cairo::RefPtr<Cairo::LinearGradient> left_pattern = Cairo::LinearGradient::create (0, 0, 0, 6.*scale);
left_pattern->add_color_stop_rgba (0, 0, 0, 0, 1);
left_pattern->add_color_stop_rgba (1, 0, 0, 0, 0);
context->set_source (left_pattern);
context->rectangle(0, 0, width, 6.*scale);
context->fill ();
render_children (area, context);
{
//line at right
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(width-1, 0, width, height);
context->fill ();
context->set_identity_matrix();
}
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
context->fill ();
context->set_identity_matrix();
}
bool
@ -350,12 +366,14 @@ CueMaster::event_handler (GdkEvent* ev)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foregroundest"));
set_fill_color (HSV (fill_color()).lighter(0.15).color ());
}
break;
case GDK_LEAVE_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
set_default_colors();
}
break;
default:
@ -408,7 +426,7 @@ CueMaster::set_default_colors ()
{
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
stop_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
}
void

View File

@ -56,7 +56,6 @@ class TriggerMaster : public ArdourCanvas::Rectangle
void _size_allocate (ArdourCanvas::Rect const & alloc);
ArdourCanvas::Rectangle* stop_button;
ArdourCanvas::Rectangle* active_bar;
ArdourCanvas::Polygon* stop_shape;
ArdourCanvas::Text* name_text;
@ -92,7 +91,6 @@ class CueMaster : public ArdourCanvas::Rectangle
void _size_allocate (ArdourCanvas::Rect const & alloc);
ArdourCanvas::Rectangle* stop_button;
ArdourCanvas::Polygon* stop_shape;
ArdourCanvas::Text* name_text;

View File

@ -148,7 +148,6 @@ TriggerEntry::_size_allocate (ArdourCanvas::Rect const & alloc)
shape_play_button ();
float tleft = height; //make room for the play button
float twidth = name_button->width() - poly_margin*2;
name_text->size_allocate (Rect(0, 0, width, height));
name_text->set_position (Duple (tleft + poly_margin, poly_margin -0.5));
@ -162,6 +161,51 @@ void
TriggerEntry::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{
Rectangle::render(area, context);
/* Note that item_to_window() already takes _position into account (as
part of item_to_canvas()
*/
Rect self (item_to_window (_rect));
const Rect draw = self.intersection (area);
if (!draw) {
return;
}
float width = _rect.width();
float height = _rect.height();
const double scale = UIConfiguration::instance().get_ui_scale();
if (_fill && !_transparent) {
setup_fill_context (context);
context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
context->fill ();
}
render_children (area, context);
if (_trigger.index()%2==0) {
//line at top
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 1.);
context->fill ();
context->set_identity_matrix();
}
{
//line at right
context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(width-1, 0, width, height);
context->fill ();
context->set_identity_matrix();
}
}
void
@ -233,10 +277,16 @@ TriggerEntry::set_default_colors ()
name_button->set_outline_color (HSV (fill_color()).darker(0.15).color ());
}
name_text->set_color (UIConfiguration::instance().color("neutral:midground"));
name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
name_text->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
if (_trigger.region()) {
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:foreground"));
} else {
play_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
play_shape->set_fill_color (UIConfiguration::instance().color("neutral:midground"));
}
/*preserve selection border*/
if (PublicEditor::instance().get_selection().selected (this)) {
@ -374,8 +424,8 @@ TriggerBoxUI::text_button_event (GdkEvent* ev, uint64_t n)
switch (ev->type) {
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
_slots[n]->name_text->set_fill_color (UIConfiguration::instance().color ("neutral:foreground"));
_slots[n]->name_text->set_color (UIConfiguration::instance().color ("neutral:foreground"));
_slots[n]->name_text->set_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->name_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
}
break;
case GDK_LEAVE_NOTIFY:
@ -387,8 +437,8 @@ TriggerBoxUI::text_button_event (GdkEvent* ev, uint64_t n)
if (_slots[n]->trigger().region()) {
PublicEditor::instance().get_selection().set (_slots[n]);
//a side-effect of selection-change is that the slot's color is reset. retain the "entered-color" here:
_slots[n]->name_text->set_fill_color (UIConfiguration::instance().color ("neutral:foreground"));
_slots[n]->name_text->set_color (UIConfiguration::instance().color ("neutral:foreground"));
_slots[n]->name_text->set_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->name_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
}
break;
case GDK_2BUTTON_PRESS:
@ -451,8 +501,9 @@ TriggerBoxUI::play_button_event (GdkEvent *ev, uint64_t n)
break;
case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
_slots[n]->play_shape->set_fill_color (UIConfiguration::instance().color ("neutral:foreground"));
_slots[n]->play_shape->set_outline_color (UIConfiguration::instance().color ("neutral:foreground"));
_slots[n]->play_button->set_fill_color (HSV (fill_color()).lighter(0.15).color ());
_slots[n]->play_shape->set_fill_color (UIConfiguration::instance().color ("neutral:foregroundest"));
_slots[n]->play_shape->set_outline_color (UIConfiguration::instance().color ("neutral:foregroundest"));
}
break;
case GDK_LEAVE_NOTIFY: