+ cairo_set_line_width (cr, 2);
+ cairo_set_source_rgba (cr, 0, 0, 0, 1.0);
+
+ cairo_matrix_t matrix;
+ Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET, w-CORNER_SIZE, h-CORNER_SIZE, CORNER_RADIUS);
+ // we use a 'trick' here: The stoke is off by .5px but filling the interior area
+ // after a stroke of 2px width results in an outline of 1px
+ cairo_stroke_preserve(cr);
+
+ if (_orien == VERT) {
+
+ if (ds > h - FADER_RESERVE - CORNER_OFFSET) {
+ ds = h - FADER_RESERVE - CORNER_OFFSET;
+ }
+
+ if (!CairoWidget::flat_buttons() ) {
+ cairo_set_source (cr, _pattern);
+ cairo_matrix_init_translate (&matrix, 0, (h - ds));
+ cairo_pattern_set_matrix (_pattern, &matrix);
+ } else {
+ CairoWidget::set_source_rgb_a (cr, get_style()->get_bg (get_state()), 1);
+ cairo_fill (cr);
+ CairoWidget::set_source_rgb_a (cr, get_style()->get_fg (get_state()), 1);
+ Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, ds + CORNER_OFFSET,
+ w - CORNER_SIZE, h - ds - CORNER_SIZE, CORNER_RADIUS);
+ }
+ cairo_fill (cr);
+
+ } else {
+
+ if (ds < FADER_RESERVE) {
+ ds = FADER_RESERVE;
+ }
+ assert(ds <= w);
+
+ /*
+ * if ds == w, the pattern does not need to be translated
+ * if ds == 0 (or FADER_RESERVE), the pattern needs to be moved
+ * w to the left, which is -w in pattern space, and w in user space
+ * if ds == 10, then the pattern needs to be moved w - 10
+ * to the left, which is -(w-10) in pattern space, which
+ * is (w - 10) in user space
+ * thus: translation = (w - ds)
+ */
+
+ if (!CairoWidget::flat_buttons() ) {
+ cairo_set_source (cr, _pattern);
+ cairo_matrix_init_translate (&matrix, w - ds, 0);
+ cairo_pattern_set_matrix (_pattern, &matrix);
+ } else {
+ CairoWidget::set_source_rgb_a (cr, get_style()->get_bg (get_state()), 1);
+ cairo_fill (cr);
+ CairoWidget::set_source_rgb_a (cr, get_style()->get_fg (get_state()), 1);
+ Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET,
+ ds - CORNER_SIZE, h - CORNER_SIZE, CORNER_RADIUS);
+ }
+ cairo_fill (cr);
+ }
+
+ /* draw the unity-position line if it's not at either end*/
+ if (!(_tweaks & NoShowUnityLine) && _unity_loc > CORNER_RADIUS) {
+ cairo_set_line_width(cr, 1);
+ cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
+ Gdk::Color c = get_style()->get_fg (Gtk::STATE_ACTIVE);
+ cairo_set_source_rgba (cr, c.get_red_p() * 1.5, c.get_green_p() * 1.5, c.get_blue_p() * 1.5, 0.85);
+ if (_orien == VERT) {
+ if (_unity_loc < h - CORNER_RADIUS) {
+ cairo_move_to (cr, 1.5, _unity_loc + CORNER_OFFSET + .5);
+ cairo_line_to (cr, _girth - 1.5, _unity_loc + CORNER_OFFSET + .5);
+ cairo_stroke (cr);
+ }
+ } else {
+ if (_unity_loc < w - CORNER_RADIUS) {
+ cairo_move_to (cr, _unity_loc - CORNER_OFFSET + .5, 1.5);
+ cairo_line_to (cr, _unity_loc - CORNER_OFFSET + .5, _girth - 1.5);
+ cairo_stroke (cr);
+ }
+ }
+ }
+
+ if (_layout && !_text.empty() && _orien == HORIZ) {
+ cairo_save (cr);
+ if (_centered_text) {
+ /* center text */
+ cairo_move_to (cr, (w - _text_width)/2.0, h/2.0 - _text_height/2.0);
+ } else if (ds > .5 * w) {
+ cairo_move_to (cr, CORNER_OFFSET + 3, h/2.0 - _text_height/2.0);
+ cairo_set_operator(cr, CAIRO_OPERATOR_XOR);
+ } else {
+ cairo_move_to (cr, w - _text_width - CORNER_OFFSET - 3, h/2.0 - _text_height/2.0);
+ }
+ CairoWidget::set_source_rgb_a (cr, get_style()->get_text (get_state()), 1);
+ pango_cairo_show_layout (cr, _layout->gobj());
+ cairo_restore (cr);
+ }
+
+ if (!get_sensitive()) {
+ Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET, w-CORNER_SIZE, h-CORNER_SIZE, CORNER_RADIUS);
+ cairo_set_source_rgba (cr, 0.505, 0.517, 0.525, 0.4);
+ cairo_fill (cr);
+ } else if (_hovering && CairoWidget::widget_prelight()) {
+ Gtkmm2ext::rounded_rectangle (cr, CORNER_OFFSET, CORNER_OFFSET, w-CORNER_SIZE, h-CORNER_SIZE, CORNER_RADIUS);
+ cairo_set_source_rgba (cr, 0.905, 0.917, 0.925, 0.1);
+ cairo_fill (cr);
+ }