diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-02-07 17:43:55 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-02-07 17:43:55 +0000 |
commit | b08d13706f9e98fc75a727822209942c00d8f1b3 (patch) | |
tree | 4a6fd2881755a340cabcd4a79657f6bb682625de /libs/gtkmm2ext | |
parent | 86a9d45ad072809c06e41e3c10683f0f0ee6a4a6 (diff) |
remove additional "mid" color from ArdourButton; replace Active/Mid widget state with ExplicitActive/ImplicitActive; represent implicit-active state with colored border around ArdourButton; tune button colors; new rounded_foo() functions, some in use, some not in use right now
git-svn-id: svn://localhost/ardour2/branches/3.0@11466 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/cairo_widget.cc | 6 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/cairo_widget.h | 6 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/utils.h | 5 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/widget_state.h | 6 | ||||
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 120 |
5 files changed, 63 insertions, 80 deletions
diff --git a/libs/gtkmm2ext/cairo_widget.cc b/libs/gtkmm2ext/cairo_widget.cc index b6717252ab..e2149b9238 100644 --- a/libs/gtkmm2ext/cairo_widget.cc +++ b/libs/gtkmm2ext/cairo_widget.cc @@ -23,8 +23,8 @@ static const char* has_cairo_widget_background_info = "has_cairo_widget_background_info"; CairoWidget::CairoWidget () - : _active_state (Gtkmm2ext::ActiveState (0)) - , _visual_state (Gtkmm2ext::VisualState (0)) + : _active_state (Gtkmm2ext::Off) + , _visual_state (Gtkmm2ext::NoVisualState) , _need_bg (true) { @@ -134,7 +134,7 @@ CairoWidget::set_active (bool yn) */ if (yn) { - set_active_state (Gtkmm2ext::Active); + set_active_state (Gtkmm2ext::ExplicitActive); } else { unset_active_state (); } diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h index e3ef7bafad..eb741b7e98 100644 --- a/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h +++ b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h @@ -44,14 +44,14 @@ public: virtual void set_active_state (Gtkmm2ext::ActiveState); virtual void set_visual_state (Gtkmm2ext::VisualState); - void unset_active_state () { set_active_state (Gtkmm2ext::ActiveState (0)); } - void unset_visual_state () { set_visual_state (Gtkmm2ext::VisualState (0)); } + void unset_active_state () { set_active_state (Gtkmm2ext::Off); } + void unset_visual_state () { set_visual_state (Gtkmm2ext::NoVisualState); } /* this is an API simplification for widgets that only use the Active and Normal active states. */ void set_active (bool); - bool get_active () { return active_state() != Gtkmm2ext::ActiveState (0); } + bool get_active () { return active_state() != Gtkmm2ext::Off; } /* widgets can be told to only draw their "foreground, and thus leave in place whatever background is drawn by their parent. the default diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h index bf9c5ff405..97c6e7758b 100644 --- a/libs/gtkmm2ext/gtkmm2ext/utils.h +++ b/libs/gtkmm2ext/gtkmm2ext/utils.h @@ -96,11 +96,16 @@ namespace Gtkmm2ext { void rounded_top_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10); void rounded_top_left_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10); void rounded_top_right_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r=10); + void rounded_top_half_rectangle (Cairo::RefPtr<Cairo::Context>, double x, double y, double w, double h, double r=10); + void rounded_bottom_half_rectangle (Cairo::RefPtr<Cairo::Context>, double x, double y, double w, double h, double r=10); void rounded_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); void rounded_top_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); void rounded_top_left_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); void rounded_top_right_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); + + void rounded_top_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); + void rounded_bottom_half_rectangle (cairo_t*, double x, double y, double w, double h, double r=10); }; #endif /* __gtkmm2ext_utils_h__ */ diff --git a/libs/gtkmm2ext/gtkmm2ext/widget_state.h b/libs/gtkmm2ext/gtkmm2ext/widget_state.h index e3fd410d9d..6067b0f2ce 100644 --- a/libs/gtkmm2ext/gtkmm2ext/widget_state.h +++ b/libs/gtkmm2ext/gtkmm2ext/widget_state.h @@ -8,12 +8,14 @@ namespace Gtkmm2ext { */ enum ActiveState { - Active = 1, - Mid, + Off, + ExplicitActive, + ImplicitActive, }; enum VisualState { /* these can be OR-ed together */ + NoVisualState = 0x0, Selected = 0x1, Prelight = 0x2, Insensitive = 0x4, diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index 7d14896438..7ecb481e33 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -382,36 +382,40 @@ Gtkmm2ext::container_clear (Gtk::Container& c) } } -#if 1 void Gtkmm2ext::rounded_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r) { rounded_rectangle (context->cobj(), x, y, w, h, r); } - void Gtkmm2ext::rounded_top_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r) { rounded_top_rectangle (context->cobj(), x, y, w, h, r); } - void Gtkmm2ext::rounded_top_left_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r) { rounded_top_left_rectangle (context->cobj(), x, y, w, h, r); } - void Gtkmm2ext::rounded_top_right_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r) { rounded_top_right_rectangle (context->cobj(), x, y, w, h, r); } +void +Gtkmm2ext::rounded_top_half_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r) +{ + rounded_top_half_rectangle (context->cobj(), x, y, w, h, r); +} +void +Gtkmm2ext::rounded_bottom_half_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double w, double h, double r) +{ + rounded_bottom_half_rectangle (context->cobj(), x, y, w, h, r); +} void Gtkmm2ext::rounded_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { - /* renders small shapes better than most others */ - /* A****BQ H C * * @@ -430,10 +434,45 @@ Gtkmm2ext::rounded_rectangle (cairo_t* cr, double x, double y, double w, double } void -Gtkmm2ext::rounded_top_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) +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 +} + +void +Gtkmm2ext::rounded_bottom_half_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { - /* renders small shapes better than most others */ +/* 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 +} + +void +Gtkmm2ext::rounded_top_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) +{ /* A****BQ H C * * @@ -452,8 +491,6 @@ Gtkmm2ext::rounded_top_rectangle (cairo_t* cr, double x, double y, double w, dou void Gtkmm2ext::rounded_top_left_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { - /* renders small shapes better than most others */ - /* A****B H * * * @@ -471,15 +508,13 @@ Gtkmm2ext::rounded_top_left_rectangle (cairo_t* cr, double x, double y, double w void Gtkmm2ext::rounded_top_right_rectangle (cairo_t* cr, double x, double y, double w, double h, double r) { - /* renders small shapes better than most others */ - /* A****BQ * C * * * * F****E */ - cairo_move_to (cr, x+r,y); // Move to A + cairo_move_to (cr, x,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 @@ -487,65 +522,6 @@ Gtkmm2ext::rounded_top_right_rectangle (cairo_t* cr, double x, double y, double cairo_line_to (cr, x,y); // Line to A } -#else - -void -Gtkmm2ext::rounded_rectangle (Cairo::RefPtr<Cairo::Context> context, double x, double y, double width, double height, double radius) -{ - /* doesn't render small shapes well at all, and does not absolutely honor width & height */ - - double x0 = x+radius/2.0; - double y0 = y+radius/2.0; - double rect_width = width - radius; - double rect_height = height - radius; - - context->save(); - - double x1=x0+rect_width; - double y1=y0+rect_height; - - if (rect_width/2<radius) { - if (rect_height/2<radius) { - context->move_to (x0, (y0 + y1)/2); - context->curve_to (x0 ,y0, x0, y0, (x0 + x1)/2, y0); - context->curve_to (x1, y0, x1, y0, x1, (y0 + y1)/2); - context->curve_to (x1, y1, x1, y1, (x1 + x0)/2, y1); - context->curve_to (x0, y1, x0, y1, x0, (y0 + y1)/2); - } else { - context->move_to (x0, y0 + radius); - context->curve_to (x0 ,y0, x0, y0, (x0 + x1)/2, y0); - context->curve_to (x1, y0, x1, y0, x1, y0 + radius); - context->line_to (x1 , y1 - radius); - context->curve_to (x1, y1, x1, y1, (x1 + x0)/2, y1); - context->curve_to (x0, y1, x0, y1, x0, y1- radius); - } - } else { - if (rect_height/2<radius) { - context->move_to (x0, (y0 + y1)/2); - context->curve_to (x0 , y0, x0 , y0, x0 + radius, y0); - context->line_to (x1 - radius, y0); - context->curve_to (x1, y0, x1, y0, x1, (y0 + y1)/2); - context->curve_to (x1, y1, x1, y1, x1 - radius, y1); - context->line_to (x0 + radius, y1); - context->curve_to (x0, y1, x0, y1, x0, (y0 + y1)/2); - } else { - context->move_to (x0, y0 + radius); - context->curve_to (x0 , y0, x0 , y0, x0 + radius, y0); - context->line_to (x1 - radius, y0); - context->curve_to (x1, y0, x1, y0, x1, y0 + radius); - context->line_to (x1 , y1 - radius); - context->curve_to (x1, y1, x1, y1, x1 - radius, y1); - context->line_to (x0 + radius, y1); - context->curve_to (x0, y1, x0, y1, x0, y1- radius); - } - } - - context->close_path (); - context->restore(); -} - -#endif - Glib::RefPtr<Gdk::Window> Gtkmm2ext::window_to_draw_on (Gtk::Widget& w, Gtk::Widget** parent) { |