diff options
author | Ben Loftis <ben@glw.com> | 2012-12-06 20:48:44 +0000 |
---|---|---|
committer | Ben Loftis <ben@glw.com> | 2012-12-06 20:48:44 +0000 |
commit | 92e5a13fd41eba37a2634caf921606b7d915c557 (patch) | |
tree | 07bdc131a1f0a640983ae66a771104f3bec41ec1 /libs | |
parent | 9884773eea9764b6dacd3ade6a1d49cf389fe398 (diff) |
several theme changes. changed drawing of rounded_rectangle to be more correct. operation and feel should be more consistent. rec-mute-solo buttons are now dull until enabled. this might be debatable. otherwise if it looks weird, try loading Window->Theme Manager and clicking Restore Defaults
git-svn-id: svn://localhost/ardour2/branches/3.0@13611 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gtkmm2ext/barcontroller.cc | 88 | ||||
-rw-r--r-- | libs/gtkmm2ext/cairo_packer.cc | 2 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/barcontroller.h | 7 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/pixfader.h | 6 | ||||
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 86 |
5 files changed, 112 insertions, 77 deletions
diff --git a/libs/gtkmm2ext/barcontroller.cc b/libs/gtkmm2ext/barcontroller.cc index 59c313621e..baa36418b1 100644 --- a/libs/gtkmm2ext/barcontroller.cc +++ b/libs/gtkmm2ext/barcontroller.cc @@ -81,11 +81,18 @@ BarController::BarController (Gtk::Adjustment& adj, spinner.signal_output().connect (mem_fun (*this, &BarController::entry_output)); spinner.set_digits (9); spinner.set_numeric (true); - + add (darea); + show_all (); } +BarController::~BarController () +{ +// delete pattern; +// delete shine_pattern; +} + void BarController::drop_grab () { @@ -263,17 +270,53 @@ BarController::mouse_control (double x, GdkWindow* window, double scaling) return TRUE; } +void +BarController::create_patterns () +{ + Glib::RefPtr<Gdk::Window> win (darea.get_window()); + Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context(); + + Gdk::Color c = get_style()->get_fg (get_state()); + float r, g, b; + r = c.get_red_p (); + g = c.get_green_p (); + b = c.get_blue_p (); + + float rheight = darea.get_height()-2; + + cairo_pattern_t* pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, rheight); + cairo_pattern_add_color_stop_rgba (pat, 0, r*0.3,g*0.3,b*0.3, 1.0); + cairo_pattern_add_color_stop_rgba (pat, 1, r, g, b, 1.0); + Cairo::RefPtr<Cairo::Pattern> p (new Cairo::Pattern (pat, false)); + pattern = p; + cairo_pattern_destroy(pat); + + pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, rheight); + cairo_pattern_add_color_stop_rgba (pat, 0, 1,1,1,0.0); + cairo_pattern_add_color_stop_rgba (pat, 0.2, 1,1,1,0.3); + cairo_pattern_add_color_stop_rgba (pat, 0.5, 1,1,1,0.0); + cairo_pattern_add_color_stop_rgba (pat, 1, 1,1,1,0.0); + Cairo::RefPtr<Cairo::Pattern> p2 (new Cairo::Pattern (pat, false)); + shine_pattern = p2; + cairo_pattern_destroy(pat); + +} + bool BarController::expose (GdkEventExpose* /*event*/) { Glib::RefPtr<Gdk::Window> win (darea.get_window()); - Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context(); - Gdk::Color c; + Cairo::RefPtr<Cairo::Context> context = win->create_cairo_context(); + + if( !pattern ) + create_patterns(); + + Gdk::Color c; Widget* parent; gint x1=0, x2=0, y1=0, y2=0; gint w, h; - double fract; - float r, g, b; + double fract, radius; + float r, g, b; fract = ((adjustment.get_value() - adjustment.get_lower()) / (adjustment.get_upper() - adjustment.get_lower())); @@ -396,20 +439,19 @@ BarController::expose (GdkEventExpose* /*event*/) w = darea.get_width() - 2; h = darea.get_height() - 2; - x1 = 0; - x2 = (gint) floor (w * fract); - y1 = 0; + x2 = (gint) floor (w * (0.1+0.9*fract)); y2 = h; + radius = 4; - /* bounding box */ + /* border */ c = get_style()->get_bg (get_state()); r = c.get_red_p (); g = c.get_green_p (); b = c.get_blue_p (); - context->set_source_rgb (r, g, b); - rounded_rectangle (context, 0, 0, darea.get_width(), darea.get_height()); - context->stroke (); + context->set_source_rgb (0,0,0); + rounded_rectangle (context, 0, 0, darea.get_width(), darea.get_height() , radius); + context->fill (); /* draw active box */ @@ -417,19 +459,23 @@ BarController::expose (GdkEventExpose* /*event*/) r = c.get_red_p (); g = c.get_green_p (); b = c.get_blue_p (); - context->set_source_rgb (r, g, b); - rounded_rectangle (context, 1 + x1, 1 + y1, x2, y2); + context->set_source (pattern); + rounded_rectangle (context, 1, 1, x2, y2, radius-1.5); + context->fill (); + + context->set_source (shine_pattern); + rounded_rectangle (context, 2, 3, x2-2, y2-8, radius-2); context->fill (); /* draw inactive box */ - c = get_style()->get_fg (STATE_INSENSITIVE); - r = c.get_red_p (); - g = c.get_green_p (); - b = c.get_blue_p (); - context->set_source_rgb (r, g, b); - rounded_rectangle (context, 1 + x2, 1 + y1, w - x2, y2); - context->fill (); +// c = get_style()->get_fg (STATE_INSENSITIVE); + // r = c.get_red_p (); + // g = c.get_green_p (); + // b = c.get_blue_p (); + // context->set_source_rgb (r, g, b); + // rounded_rectangle (context, 1 + x2, 1 + y1, w - x2, y2); + // context->fill (); break; diff --git a/libs/gtkmm2ext/cairo_packer.cc b/libs/gtkmm2ext/cairo_packer.cc index 822f943939..85a5055270 100644 --- a/libs/gtkmm2ext/cairo_packer.cc +++ b/libs/gtkmm2ext/cairo_packer.cc @@ -17,7 +17,7 @@ CairoPacker::draw_background (Gtk::Widget& w, GdkEventExpose*) Gdk::Color bg = get_bg (); context->set_source_rgba (bg.get_red_p(), bg.get_green_p(), bg.get_blue_p(), 1.0); - Gtkmm2ext::rounded_rectangle (context, x, y, w.get_allocation().get_width(), w.get_allocation().get_height(), 9); + Gtkmm2ext::rounded_rectangle (context, x, y, w.get_allocation().get_width(), w.get_allocation().get_height(), 4); context->fill (); } } diff --git a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h index b0721fba45..76dc8f2d49 100644 --- a/libs/gtkmm2ext/gtkmm2ext/barcontroller.h +++ b/libs/gtkmm2ext/gtkmm2ext/barcontroller.h @@ -22,6 +22,7 @@ #include <gtkmm/frame.h> #include <gtkmm/drawingarea.h> #include <gtkmm2ext/binding_proxy.h> +#include <cairo.h> namespace Gtkmm2ext { @@ -31,7 +32,7 @@ class BarController : public Gtk::Frame public: BarController (Gtk::Adjustment& adj, boost::shared_ptr<PBD::Controllable>); - virtual ~BarController () {} + virtual ~BarController (); enum barStyle { LeftToRight, @@ -89,6 +90,10 @@ class BarController : public Gtk::Frame return ""; } + void create_patterns(); + Cairo::RefPtr<Cairo::Pattern> pattern; + Cairo::RefPtr<Cairo::Pattern> shine_pattern; + virtual bool button_press (GdkEventButton *); virtual bool button_release (GdkEventButton *); virtual bool motion (GdkEventMotion *); diff --git a/libs/gtkmm2ext/gtkmm2ext/pixfader.h b/libs/gtkmm2ext/gtkmm2ext/pixfader.h index 9f1e4b75ca..fcf3c61b54 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixfader.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixfader.h @@ -40,6 +40,8 @@ class PixFader : public Gtk::DrawingArea void set_default_value (float); + void create_patterns (); + protected: Gtk::Adjustment& adjustment; @@ -69,6 +71,10 @@ class PixFader : public Gtk::DrawingArea Cairo::RefPtr<Cairo::Context> belt_context[STATES]; Cairo::RefPtr<Cairo::ImageSurface> belt_surface[STATES]; Glib::RefPtr<Gdk::Pixbuf> pixbuf[STATES]; + + Cairo::RefPtr<Cairo::Pattern> pattern; + Cairo::RefPtr<Cairo::Pattern> shine_pattern; + int span, girth; int _orien; float left_r; diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index c0c7a88362..61f93234ff 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -417,76 +417,54 @@ Gtkmm2ext::rounded_bottom_half_rectangle (Cairo::RefPtr<Cairo::Context> context, void Gtkmm2ext::rounded_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { -/* A****BQ - H C - * * - G D - F****E -*/ - cairo_move_to (cr, x+r,y); // Move to A - cairo_line_to (cr, x+w-r,y); // Straight line to B - cairo_curve_to (cr, x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q - cairo_line_to (cr, x+w,y+h-r); // Move to D - cairo_curve_to (cr, x+w,y+h,x+w,y+h,x+w-r,y+h); // Curve to E - cairo_line_to (cr, x+r,y+h); // Line to F - cairo_curve_to (cr, x,y+h,x,y+h,x,y+h-r); // Curve to G - cairo_line_to (cr, x,y+r); // Line to H - cairo_curve_to (cr, x,y,x,y,x+r,y); // Curve to A + double degrees = M_PI / 180.0; + + cairo_new_sub_path (cr); + cairo_arc (cr, x + w - r, y + r, r, -90 * degrees, 0 * degrees); //tr + cairo_arc (cr, x + w - r, y + h - r, r, 0 * degrees, 90 * degrees); //br + cairo_arc (cr, x + r, y + h - r, r, 90 * degrees, 180 * degrees); //bl + cairo_arc (cr, x + r, y + r, r, 180 * degrees, 270 * degrees); //tl + cairo_close_path (cr); } void Gtkmm2ext::rounded_top_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { -/* A****BQ - H C - * * - G D - F****E -*/ - cairo_move_to (cr, x+r,y); // Move to A - cairo_line_to (cr, x+w-r,y); // Straight line to B - cairo_curve_to (cr, x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q - cairo_line_to (cr, x+w,y+h); // Move to E - cairo_line_to (cr, x,y+h); // Line to F - cairo_line_to (cr, x,y+r); // Line to H - cairo_curve_to (cr, x,y,x,y,x+r,y); // Curve to A + double degrees = M_PI / 180.0; + + cairo_new_sub_path (cr); + cairo_move_to (cr, x+w, y+h); + cairo_line_to (cr, x, y+h); + cairo_arc (cr, x + r, y + r, r, 180 * degrees, 270 * degrees); //tl + cairo_arc (cr, x + w - r, y + r, r, -90 * degrees, 0 * degrees); //tr + cairo_close_path (cr); } void Gtkmm2ext::rounded_bottom_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { -/* A****BQ - H C - * * - G D - F****E -*/ - cairo_move_to (cr, x,y); // Move to A - cairo_line_to (cr, x+w,y); // Straight line to B - cairo_line_to (cr, x+w,y+h-r); // Move to D - cairo_curve_to (cr, x+w,y+h,x+w,y+h,x+w-r,y+h); // Curve to E - cairo_line_to (cr, x+r,y+h); // Line to F - cairo_curve_to (cr, x,y+h,x,y+h,x,y+h-r); // Curve to G - cairo_line_to (cr, x,y); // Line to A + double degrees = M_PI / 180.0; + + cairo_new_sub_path (cr); + cairo_move_to (cr, x, y); + cairo_line_to (cr, x+w, y); + cairo_arc (cr, x + w - r, y + h - r, r, 0 * degrees, 90 * degrees); //br + cairo_arc (cr, x + r, y + h - r, r, 90 * degrees, 180 * degrees); //bl + cairo_close_path (cr); } void Gtkmm2ext::rounded_top_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { -/* A****BQ - H C - * * - * * - F****E -*/ - cairo_move_to (cr, x+r,y); // Move to A - cairo_line_to (cr, x+w-r,y); // Straight line to B - cairo_curve_to (cr, x+w,y,x+w,y,x+w,y+r); // Curve to C, Control points are both at Q - cairo_line_to (cr, x+w,y+h); // Move to E - cairo_line_to (cr, x,y+h); // Line to F - cairo_line_to (cr, x,y+r); // Line to H - cairo_curve_to (cr, x,y,x,y,x+r,y); // Curve to A + double degrees = M_PI / 180.0; + + cairo_new_sub_path (cr); + cairo_move_to (cr, x+w, y+h); + cairo_line_to (cr, x, y+h); + cairo_arc (cr, x + r, y + r, r, 180 * degrees, 270 * degrees); //tl + cairo_arc (cr, x + w - r, y + r, r, -90 * degrees, 0 * degrees); //tr + cairo_close_path (cr); } void |