From 7fd1fc1dcff93dd3a3e0e4ce65d691126fbd2158 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Mon, 19 Feb 2018 08:01:27 -0600 Subject: [PATCH 1/1] Add flag for corners, where top+left shadows are both required. --- libs/widgets/ardour_spacer.cc | 3 ++- libs/widgets/widgets/ardour_spacer.h | 37 +++++++++++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/libs/widgets/ardour_spacer.cc b/libs/widgets/ardour_spacer.cc index 712792a710..941b9d34da 100644 --- a/libs/widgets/ardour_spacer.cc +++ b/libs/widgets/ardour_spacer.cc @@ -26,8 +26,9 @@ ArdourVSpacer::ArdourVSpacer (float r) { } -ArdourDropShadow::ArdourDropShadow (float a) +ArdourDropShadow::ArdourDropShadow (ShadowMode m, float a) : CairoWidget () , alpha (a) + , mode (m) { } diff --git a/libs/widgets/widgets/ardour_spacer.h b/libs/widgets/widgets/ardour_spacer.h index e9f6ad1448..d7c915a007 100644 --- a/libs/widgets/widgets/ardour_spacer.h +++ b/libs/widgets/widgets/ardour_spacer.h @@ -54,24 +54,43 @@ protected: class LIBWIDGETS_API ArdourDropShadow : public CairoWidget { public: - ArdourDropShadow (float a = 0.75f); + enum ShadowMode { + DropShadowLongSideOnly, + DropShadowBoth, + }; + + ArdourDropShadow (ShadowMode m = DropShadowLongSideOnly, float a = 0.55f); + + void set_mode(ShadowMode m) {mode = m;} protected: void render (Cairo::RefPtr const& ctx, cairo_rectangle_t*) { float width = get_width(); float height = get_height(); - Cairo::RefPtr _gradient = Cairo::LinearGradient::create (0, 0, 0, height); - _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha); - _gradient->add_color_stop_rgba (1, 0, 0, 0, 0); - - ctx->set_source (_gradient); - - ctx->rectangle (0, 0, width, height); - ctx->fill (); + Cairo::RefPtr _gradient; + + if ( (width>height) || mode == DropShadowBoth ) { + _gradient = Cairo::LinearGradient::create (0, 0, 0, 4); + _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha); + _gradient->add_color_stop_rgba (1, 0, 0, 0, 0); + ctx->set_source (_gradient); + ctx->rectangle (0, 0, width, 4); + ctx->fill (); + } + + if ( (height>width) || mode == DropShadowBoth ) { + _gradient = Cairo::LinearGradient::create (0, 0, 4, 0); + _gradient->add_color_stop_rgba (0, 0, 0, 0, alpha); + _gradient->add_color_stop_rgba (1, 0, 0, 0, 0); + ctx->set_source (_gradient); + ctx->rectangle (0, 0, 4, height); + ctx->fill (); + } } float alpha; + ShadowMode mode; }; } /* end namespace */ -- 2.30.2