From 26df9ccdf8dabc5a8cb2be14e8bb084a8c7b9008 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Fri, 17 Dec 2021 08:18:06 -0600 Subject: [PATCH] pixel pushing: return of drop-shadows (maybe) --- gtk2_ardour/cuebox_ui.cc | 19 ++-- gtk2_ardour/trigger_master.cc | 162 +++++++++++++++++++--------------- gtk2_ardour/trigger_master.h | 3 +- gtk2_ardour/triggerbox_ui.cc | 23 +++-- 4 files changed, 113 insertions(+), 94 deletions(-) diff --git a/gtk2_ardour/cuebox_ui.cc b/gtk2_ardour/cuebox_ui.cc index 36f36ce8ba..043bd0dfcc 100644 --- a/gtk2_ardour/cuebox_ui.cc +++ b/gtk2_ardour/cuebox_ui.cc @@ -170,7 +170,14 @@ CueEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr render_children (area, context); - if (_cue_idx%2==0) { + if (_cue_idx==0) { + Cairo::RefPtr drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale); + drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7); + drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0); + context->set_source (drop_shadow_pattern); + context->rectangle(0, 0, width, 6*scale ); + context->fill (); + } else if (_cue_idx%2==0) { //line at top context->set_identity_matrix(); context->translate (self.x0, self.y0-0.5); @@ -179,16 +186,6 @@ CueEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr 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 diff --git a/gtk2_ardour/trigger_master.cc b/gtk2_ardour/trigger_master.cc index 817d1949a3..a5fff1d2dc 100644 --- a/gtk2_ardour/trigger_master.cc +++ b/gtk2_ardour/trigger_master.cc @@ -161,21 +161,23 @@ PassThru::render (Rect const& area, Cairo::RefPtr context) const const double scale = UIConfiguration::instance ().get_ui_scale (); if (_enabled) { - /* outer white circle */ - set_source_rgba (context, rgba_to_color (1, 1, 1, 1)); - context->arc (size / 2, size / 2, size / 2 - 3 * scale, 0, 2 * M_PI); - context->fill (); + //outer white circle + set_source_rgba (context, rgba_to_color (1,1,1,1)); + context->arc ( size/2, size/2, size/2 - 3*scale, 0, 2*M_PI ); + context->fill(); - /* black circle */ - set_source_rgba (context, rgba_to_color (0, 0, 0, 1)); - context->arc (size / 2, size / 2, size / 2 - 5 * scale, 0, 2 * M_PI); - context->fill (); + //black circle + set_source_rgba (context, rgba_to_color (0,0,0,1)); + context->arc ( size/2, size/2, size/2 - 5*scale, 0, 2*M_PI ); + context->fill(); - /* inner white circle */ - set_source_rgba (context, rgba_to_color (1, 1, 1, 1)); - context->arc (size / 2, size / 2, size / 2 - 7 * scale, 0, 2 * M_PI); - context->fill (); + //inner white circle + set_source_rgba (context, rgba_to_color (1,1,1,1)); + context->arc ( size/2, size/2, size/2 - 7*scale, 0, 2*M_PI ); + context->fill(); } + + context->set_identity_matrix(); } TriggerMaster::TriggerMaster (Item* parent) @@ -188,6 +190,13 @@ TriggerMaster::TriggerMaster (Item* parent) Event.connect (sigc::mem_fun (*this, &TriggerMaster::event_handler)); + stop_shape = new ArdourCanvas::Polygon (this); + stop_shape->set_outline (true); + stop_shape->set_fill (false); + stop_shape->name = X_("stopbutton"); + stop_shape->set_ignore_events (true); + stop_shape->show (); + name_text = new Text (this); name_text->set (""); name_text->set_ignore_events (false); @@ -250,21 +259,23 @@ TriggerMaster::render (Rect const& area, Cairo::RefPtr context) 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 (); + //drop-shadow at top + if (true) { + Cairo::RefPtr drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale); + drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7); + drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0); + context->set_source (drop_shadow_pattern); + context->rectangle(0, 0, width, 6*scale ); + context->fill (); + } else { + //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 @@ -295,26 +306,24 @@ 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")); - set_fill_color (HSV (fill_color ()).lighter (0.15).color ()); + name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest")); + stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground")); + set_fill_color (HSV (fill_color()).lighter(0.15).color ()); } redraw (); break; case GDK_LEAVE_NOTIFY: if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) { - set_default_colors (); + set_default_colors(); } redraw (); break; case GDK_BUTTON_RELEASE: switch (ev->button.button) { - case 3: - context_menu (); - return true; - default: - break; + case 3: + context_menu (); + return true; } - break; default: break; } @@ -441,6 +450,13 @@ TriggerMaster::_size_allocate (ArdourCanvas::Rect const& alloc) _poly_size = height - (_poly_margin * 2); + Points p; + p.push_back (Duple (_poly_margin, _poly_margin)); + p.push_back (Duple (_poly_margin, _poly_size)); + p.push_back (Duple (_poly_size, _poly_size)); + p.push_back (Duple (_poly_size, _poly_margin)); + stop_shape->set (p); + float tleft = _poly_size + (_poly_margin * 3); float twidth = width - _poly_size - (_poly_margin * 3); @@ -470,7 +486,8 @@ TriggerMaster::prop_change (PropertyChange const& change) ARDOUR::Trigger* trigger = _triggerbox->currently_playing (); if (!trigger) { name_text->set (text); - _loopster->hide (); + _loopster->hide(); + stop_shape->show(); return; } @@ -484,18 +501,21 @@ TriggerMaster::prop_change (PropertyChange const& change) if (trigger->active ()) { double f = trigger->position_as_fraction (); - _loopster->set_fraction (f); - _loopster->show (); + _loopster->set_fraction(f); + _loopster->show(); + stop_shape->hide(); } else { - _loopster->hide (); + _loopster->hide(); + stop_shape->show(); } } void 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")); + 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_outline_color (UIConfiguration::instance().color("neutral:midground")); } void @@ -516,8 +536,8 @@ CueMaster::CueMaster (Item* parent) Event.connect (sigc::mem_fun (*this, &CueMaster::event_handler)); stop_shape = new ArdourCanvas::Polygon (this); - stop_shape->set_outline (false); - stop_shape->set_fill (true); + stop_shape->set_outline (true); + stop_shape->set_fill (false); stop_shape->name = X_("stopbutton"); stop_shape->set_ignore_events (true); stop_shape->show (); @@ -561,23 +581,23 @@ CueMaster::render (Rect const& area, Cairo::RefPtr context) cons 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); + //drop-shadow at top + if (true) { + Cairo::RefPtr drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale); + drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7); + drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0); + context->set_source (drop_shadow_pattern); + context->rectangle(0, 0, width, 6*scale ); + context->fill (); + } else { + //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 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 @@ -586,20 +606,20 @@ CueMaster::event_handler (GdkEvent* ev) switch (ev->type) { case GDK_BUTTON_PRESS: if (ev->button.button == 1) { - _session->stop_all_triggers (); + _session->stop_all_triggers(); return true; } 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 ()); + name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest")); + stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:foreground")); + set_fill_color (HSV (fill_color()).lighter(0.15).color ()); } break; case GDK_LEAVE_NOTIFY: if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) { - set_default_colors (); + set_default_colors(); } break; default: @@ -627,11 +647,13 @@ CueMaster::_size_allocate (ArdourCanvas::Rect const& alloc) _poly_size = height - (_poly_margin * 2); + float centering_offset = (width/2)-_poly_margin-_poly_size/2; + Points p; - p.push_back (Duple (_poly_margin, _poly_margin)); - p.push_back (Duple (_poly_margin, _poly_size)); - p.push_back (Duple (_poly_size, _poly_size)); - p.push_back (Duple (_poly_size, _poly_margin)); + p.push_back (Duple (centering_offset+ _poly_margin, _poly_margin)); + p.push_back (Duple (centering_offset+ _poly_margin, _poly_size)); + p.push_back (Duple (centering_offset+ _poly_size, _poly_size)); + p.push_back (Duple (centering_offset+ _poly_size, _poly_margin)); stop_shape->set (p); float tleft = _poly_size + (_poly_margin * 3); @@ -649,9 +671,9 @@ CueMaster::_size_allocate (ArdourCanvas::Rect const& alloc) void 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:foreground")); + 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_outline_color (UIConfiguration::instance().color("neutral:midground")); } void diff --git a/gtk2_ardour/trigger_master.h b/gtk2_ardour/trigger_master.h index e55d77ff4a..dab2a59f52 100644 --- a/gtk2_ardour/trigger_master.h +++ b/gtk2_ardour/trigger_master.h @@ -71,7 +71,8 @@ public: void _size_allocate (ArdourCanvas::Rect const&); - ArdourCanvas::Text* name_text; + ArdourCanvas::Text* name_text; + ArdourCanvas::Polygon* stop_shape; void toggle_thru (); void maybe_update (); diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index d0c9f2dda1..7361707d2f 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -254,26 +254,25 @@ TriggerEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale); + drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7); + drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0); + context->set_source (drop_shadow_pattern); + context->rectangle(0, 0, width, 6*scale ); + context->fill (); + } else 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->rectangle(0, 0, width, 1); context->fill (); context->set_identity_matrix(); } + //follow-action icon if (_trigger.region()) { context->set_identity_matrix(); context->translate (self.x0, self.y0-0.5);