summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-04-11 02:06:32 +0200
committerRobin Gareus <robin@gareus.org>2019-04-11 02:06:32 +0200
commit01024e2b4ce71dc30a23aac777e89cebba08bd5a (patch)
tree48e21e7476114b35bd9fe152b3c0376e4ea5d0f1 /libs/gtkmm2ext
parenta16c038ecc6851753e44f6cf70c27509288b69e1 (diff)
Add API to render a reflection
This is to be used sparingly because the pattern is dynamically created every time. Mainly for the benefit of some Mixbus widgets -- compared to ArdourButton::convex_pattern
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h2
-rw-r--r--libs/gtkmm2ext/utils.cc13
2 files changed, 15 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h
index 188da0862d..7e5cc005e0 100644
--- a/libs/gtkmm2ext/gtkmm2ext/utils.h
+++ b/libs/gtkmm2ext/gtkmm2ext/utils.h
@@ -158,6 +158,8 @@ namespace Gtkmm2ext {
LIBGTKMM2EXT_API void rounded_right_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10);
LIBGTKMM2EXT_API void rounded_left_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r=10);
+ LIBGTKMM2EXT_API void add_reflection (cairo_t* cr, double w, double h);
+
LIBGTKMM2EXT_API Gtk::Label* left_aligned_label (std::string const &);
LIBGTKMM2EXT_API Gtk::Label* right_aligned_label (std::string const &);
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index bdb44090c3..f97177de9b 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -800,6 +800,19 @@ Gtkmm2ext::rounded_top_right_rectangle (cairo_t* cr, double x, double y, double
cairo_line_to (cr, x,y); // Line to A
}
+void
+Gtkmm2ext::add_reflection (cairo_t* cr, double w, double h)
+{
+ cairo_pattern_t* convex_pattern = cairo_pattern_create_linear (0.0, 0, 0.3, h * 0.7);
+ cairo_pattern_add_color_stop_rgba (convex_pattern, 0.0, 1, 1, 1, 0.10);
+ cairo_pattern_add_color_stop_rgba (convex_pattern, 0.79, 1, 1, 1, 0.03);
+ cairo_pattern_add_color_stop_rgba (convex_pattern, 1.0, 1, 1, 1, 0.0);
+ cairo_set_source (cr, convex_pattern);
+ Gtkmm2ext::rounded_rectangle (cr, 2, 2, w - 4, h - 4, 4);
+ cairo_fill (cr);
+ cairo_pattern_destroy(convex_pattern);
+}
+
Glib::RefPtr<Gdk::Window>
Gtkmm2ext::window_to_draw_on (Gtk::Widget& w, Gtk::Widget** parent)
{