From c862b604e1c129a52cfd2c014ddf9ffe6b0856d4 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sun, 12 Dec 2021 11:20:11 -0600 Subject: [PATCH] TriggerBox: change highlight behavior and experiment with black borders --- gtk2_ardour/cuebox_ui.cc | 67 ++++++++++++++++++++++++++------- gtk2_ardour/trigger_master.cc | 70 +++++++++++++++++++++------------- gtk2_ardour/trigger_master.h | 2 - gtk2_ardour/triggerbox_ui.cc | 71 ++++++++++++++++++++++++++++++----- 4 files changed, 159 insertions(+), 51 deletions(-) diff --git a/gtk2_ardour/cuebox_ui.cc b/gtk2_ardour/cuebox_ui.cc index 6624fc9afd..d853938f89 100644 --- a/gtk2_ardour/cuebox_ui.cc +++ b/gtk2_ardour/cuebox_ui.cc @@ -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 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 diff --git a/gtk2_ardour/trigger_master.cc b/gtk2_ardour/trigger_master.cc index 55c4a9da29..2a7985217e 100644 --- a/gtk2_ardour/trigger_master.cc +++ b/gtk2_ardour/trigger_master.cc @@ -119,18 +119,25 @@ TriggerMaster::render (Rect const & area, Cairo::RefPtr 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 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 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 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 diff --git a/gtk2_ardour/trigger_master.h b/gtk2_ardour/trigger_master.h index 8dbd17fccf..f2312c62dd 100644 --- a/gtk2_ardour/trigger_master.h +++ b/gtk2_ardour/trigger_master.h @@ -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; diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index fbda0dbf28..6c86c9e820 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -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 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: