diff options
author | Ben Loftis <ben@harrisonconsoles.com> | 2018-02-19 08:01:27 -0600 |
---|---|---|
committer | Ben Loftis <ben@harrisonconsoles.com> | 2018-02-19 08:01:27 -0600 |
commit | 7fd1fc1dcff93dd3a3e0e4ce65d691126fbd2158 (patch) | |
tree | 7718e2d6473a7948ca7e4fb575517e0dfccee691 /libs/widgets | |
parent | 9ac15801d34cb1a9cbabbf0357b4322b8dcf2790 (diff) |
Add flag for corners, where top+left shadows are both required.
Diffstat (limited to 'libs/widgets')
-rw-r--r-- | libs/widgets/ardour_spacer.cc | 3 | ||||
-rw-r--r-- | 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<Cairo::Context> const& ctx, cairo_rectangle_t*) { float width = get_width(); float height = get_height(); - Cairo::RefPtr<Cairo::LinearGradient> _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<Cairo::LinearGradient> _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 */ |