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

@ -161,21 +161,23 @@ PassThru::render (Rect const& area, Cairo::RefPtr<Cairo::Context> 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<Cairo::Context> 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<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 {
//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<Cairo::Context> 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<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 {
//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