pixel pushing: return of drop-shadows (maybe)

This commit is contained in:
Ben Loftis 2021-12-17 08:18:06 -06:00
parent 27ba2c7ea6
commit 26df9ccdf8
4 changed files with 113 additions and 94 deletions

View file

@ -170,7 +170,14 @@ CueEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context>
render_children (area, context); render_children (area, context);
if (_cue_idx%2==0) { if (_cue_idx==0) {
Cairo::RefPtr<Cairo::LinearGradient> 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 //line at top
context->set_identity_matrix(); context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5); context->translate (self.x0, self.y0-0.5);
@ -179,16 +186,6 @@ CueEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context>
context->fill (); context->fill ();
context->set_identity_matrix(); 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 void

View file

@ -161,21 +161,23 @@ PassThru::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) const
const double scale = UIConfiguration::instance ().get_ui_scale (); const double scale = UIConfiguration::instance ().get_ui_scale ();
if (_enabled) { if (_enabled) {
/* outer white circle */ //outer white circle
set_source_rgba (context, rgba_to_color (1,1,1,1)); 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->arc ( size/2, size/2, size/2 - 3*scale, 0, 2*M_PI );
context->fill(); context->fill();
/* black circle */ //black circle
set_source_rgba (context, rgba_to_color (0,0,0,1)); 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->arc ( size/2, size/2, size/2 - 5*scale, 0, 2*M_PI );
context->fill(); context->fill();
/* inner white circle */ //inner white circle
set_source_rgba (context, rgba_to_color (1,1,1,1)); 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->arc ( size/2, size/2, size/2 - 7*scale, 0, 2*M_PI );
context->fill(); context->fill();
} }
context->set_identity_matrix();
} }
TriggerMaster::TriggerMaster (Item* parent) TriggerMaster::TriggerMaster (Item* parent)
@ -188,6 +190,13 @@ TriggerMaster::TriggerMaster (Item* parent)
Event.connect (sigc::mem_fun (*this, &TriggerMaster::event_handler)); 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 = new Text (this);
name_text->set (""); name_text->set ("");
name_text->set_ignore_events (false); name_text->set_ignore_events (false);
@ -250,15 +259,16 @@ TriggerMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context)
render_children (area, context); render_children (area, context);
/* line at right */ //drop-shadow at top
context->set_identity_matrix (); if (true) {
context->translate (self.x0, self.y0 - 0.5); Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale);
set_source_rgba (context, rgba_to_color (0, 0, 0, 1)); drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
context->rectangle (width - 1, 0, width, height); 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 (); context->fill ();
context->set_identity_matrix (); } else {
//line at top
/* line at top */
context->set_identity_matrix(); context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5); context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1)); set_source_rgba (context, rgba_to_color (0,0,0,1));
@ -266,6 +276,7 @@ TriggerMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context)
context->fill (); context->fill ();
context->set_identity_matrix(); context->set_identity_matrix();
} }
}
void void
TriggerMaster::owner_prop_change (PropertyChange const& pc) TriggerMaster::owner_prop_change (PropertyChange const& pc)
@ -296,6 +307,7 @@ TriggerMaster::event_handler (GdkEvent* ev)
case GDK_ENTER_NOTIFY: case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) { if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest")); 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 ()); set_fill_color (HSV (fill_color()).lighter(0.15).color ());
} }
redraw (); redraw ();
@ -311,10 +323,7 @@ TriggerMaster::event_handler (GdkEvent* ev)
case 3: case 3:
context_menu (); context_menu ();
return true; return true;
default:
break;
} }
break;
default: default:
break; break;
} }
@ -441,6 +450,13 @@ TriggerMaster::_size_allocate (ArdourCanvas::Rect const& alloc)
_poly_size = height - (_poly_margin * 2); _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 tleft = _poly_size + (_poly_margin * 3);
float twidth = width - _poly_size - (_poly_margin * 3); float twidth = width - _poly_size - (_poly_margin * 3);
@ -471,6 +487,7 @@ TriggerMaster::prop_change (PropertyChange const& change)
if (!trigger) { if (!trigger) {
name_text->set (text); name_text->set (text);
_loopster->hide(); _loopster->hide();
stop_shape->show();
return; return;
} }
@ -486,8 +503,10 @@ TriggerMaster::prop_change (PropertyChange const& change)
double f = trigger->position_as_fraction (); double f = trigger->position_as_fraction ();
_loopster->set_fraction(f); _loopster->set_fraction(f);
_loopster->show(); _loopster->show();
stop_shape->hide();
} else { } else {
_loopster->hide(); _loopster->hide();
stop_shape->show();
} }
} }
@ -496,6 +515,7 @@ TriggerMaster::set_default_colors ()
{ {
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ()); set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
name_text->set_color (UIConfiguration::instance().color("neutral:foreground")); name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
} }
void void
@ -516,8 +536,8 @@ CueMaster::CueMaster (Item* parent)
Event.connect (sigc::mem_fun (*this, &CueMaster::event_handler)); Event.connect (sigc::mem_fun (*this, &CueMaster::event_handler));
stop_shape = new ArdourCanvas::Polygon (this); stop_shape = new ArdourCanvas::Polygon (this);
stop_shape->set_outline (false); stop_shape->set_outline (true);
stop_shape->set_fill (true); stop_shape->set_fill (false);
stop_shape->name = X_("stopbutton"); stop_shape->name = X_("stopbutton");
stop_shape->set_ignore_events (true); stop_shape->set_ignore_events (true);
stop_shape->show (); stop_shape->show ();
@ -561,16 +581,15 @@ CueMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) cons
render_children (area, context); render_children (area, context);
{ //drop-shadow at top
//line at right if (true) {
context->set_identity_matrix (); Cairo::RefPtr<Cairo::LinearGradient> drop_shadow_pattern = Cairo::LinearGradient::create (0.0, 0.0, 0.0, 6*scale);
context->translate (self.x0, self.y0 - 0.5); drop_shadow_pattern->add_color_stop_rgba (0, 0, 0, 0, 0.7);
set_source_rgba (context, rgba_to_color (0, 0, 0, 1)); drop_shadow_pattern->add_color_stop_rgba (1, 0, 0, 0, 0.0);
context->rectangle (width - 1, 0, width, height); context->set_source (drop_shadow_pattern);
context->rectangle(0, 0, width, 6*scale );
context->fill (); context->fill ();
context->set_identity_matrix (); } else {
}
//line at top //line at top
context->set_identity_matrix(); context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5); context->translate (self.x0, self.y0-0.5);
@ -579,6 +598,7 @@ CueMaster::render (Rect const& area, Cairo::RefPtr<Cairo::Context> context) cons
context->fill (); context->fill ();
context->set_identity_matrix (); context->set_identity_matrix ();
} }
}
bool bool
CueMaster::event_handler (GdkEvent* ev) CueMaster::event_handler (GdkEvent* ev)
@ -593,7 +613,7 @@ CueMaster::event_handler (GdkEvent* ev)
case GDK_ENTER_NOTIFY: case GDK_ENTER_NOTIFY:
if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) { if (ev->crossing.detail != GDK_NOTIFY_INFERIOR) {
name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest")); name_text->set_color (UIConfiguration::instance().color("neutral:foregroundest"));
stop_shape->set_fill_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 ()); set_fill_color (HSV (fill_color()).lighter(0.15).color ());
} }
break; break;
@ -627,11 +647,13 @@ CueMaster::_size_allocate (ArdourCanvas::Rect const& alloc)
_poly_size = height - (_poly_margin * 2); _poly_size = height - (_poly_margin * 2);
float centering_offset = (width/2)-_poly_margin-_poly_size/2;
Points p; Points p;
p.push_back (Duple (_poly_margin, _poly_margin)); p.push_back (Duple (centering_offset+ _poly_margin, _poly_margin));
p.push_back (Duple (_poly_margin, _poly_size)); p.push_back (Duple (centering_offset+ _poly_margin, _poly_size));
p.push_back (Duple (_poly_size, _poly_size)); p.push_back (Duple (centering_offset+ _poly_size, _poly_size));
p.push_back (Duple (_poly_size, _poly_margin)); p.push_back (Duple (centering_offset+ _poly_size, _poly_margin));
stop_shape->set (p); stop_shape->set (p);
float tleft = _poly_size + (_poly_margin * 3); float tleft = _poly_size + (_poly_margin * 3);
@ -651,7 +673,7 @@ CueMaster::set_default_colors ()
{ {
set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ()); set_fill_color (HSV (UIConfiguration::instance().color("theme:bg")).darker(0.25).color ());
name_text->set_color (UIConfiguration::instance().color("neutral:foreground")); name_text->set_color (UIConfiguration::instance().color("neutral:foreground"));
stop_shape->set_fill_color (UIConfiguration::instance ().color ("neutral:foreground")); stop_shape->set_outline_color (UIConfiguration::instance().color("neutral:midground"));
} }
void void

View file

@ -72,6 +72,7 @@ public:
void _size_allocate (ArdourCanvas::Rect const&); void _size_allocate (ArdourCanvas::Rect const&);
ArdourCanvas::Text* name_text; ArdourCanvas::Text* name_text;
ArdourCanvas::Polygon* stop_shape;
void toggle_thru (); void toggle_thru ();
void maybe_update (); void maybe_update ();

View file

@ -254,26 +254,25 @@ TriggerEntry::render (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Cont
render_children (area, context); render_children (area, context);
if (_trigger.index()%2==0) { if (_trigger.index()==1) {
//drop-shadow at top
Cairo::RefPtr<Cairo::LinearGradient> 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 //line at top
context->set_identity_matrix(); context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5); context->translate (self.x0, self.y0-0.5);
set_source_rgba (context, rgba_to_color (0,0,0,1)); set_source_rgba (context, rgba_to_color (0,0,0,1));
context->rectangle(0, 0, width, 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->fill ();
context->set_identity_matrix(); context->set_identity_matrix();
} }
//follow-action icon
if (_trigger.region()) { if (_trigger.region()) {
context->set_identity_matrix(); context->set_identity_matrix();
context->translate (self.x0, self.y0-0.5); context->translate (self.x0, self.y0-0.5);