renice transport buttons (part one)
authorRobin Gareus <robin@gareus.org>
Tue, 7 Apr 2015 20:33:43 +0000 (22:33 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 7 Apr 2015 20:34:09 +0000 (22:34 +0200)
gtk2_ardour/ardour_button.cc
gtk2_ardour/ardour_button.h
gtk2_ardour/ardour_ui2.cc

index d4fee88fee1983e3052d06e6060eb6ed790893c8..ee4f3af5f27f30e5369d26b9b1d95ab9b0a215de 100644 (file)
@@ -285,6 +285,13 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
                }
        }
 
+#define VECTORICONSTROKEFILL \
+       cairo_set_line_width(cr, 1.5); \
+       cairo_set_source_rgba (cr, 0, 0, 0, 1.0); \
+       cairo_stroke_preserve(cr); \
+       cairo_set_source_rgba (cr, 1, 1, 1, 1.0); \
+       cairo_fill(cr);
+
        //Pixbuf, if any
        if (_pixbuf) {
                double x = rint((get_width() - _pixbuf->get_width()) * .5);
@@ -457,6 +464,78 @@ ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
                cairo_arc (cr, x, y+r, r * .28, 1.05 * M_PI, 1.95 * M_PI);
                cairo_stroke(cr);
        }
+       else if ((_elements & VectorIcon) && _icon == BtnStop) {
+               const int wh = std::min (get_width(), get_height());
+               cairo_rectangle (cr,
+                               (get_width() - wh) * .5 + wh * .25,
+                               (get_height() - wh) * .5 + wh * .25,
+                               wh * .5, wh * .5);
+
+               VECTORICONSTROKEFILL;
+       }
+       else if ((_elements & VectorIcon) && _icon == BtnPlay) {
+               const int wh = std::min (get_width(), get_height()) * .5;
+               const double y = get_height() * .5;
+               const double x = get_width() - wh;
+
+               const float tri = ceil(.577 * wh); // 1/sqrt(3)
+
+               cairo_move_to (cr,  x + wh * .5, y);
+               cairo_line_to (cr,  x - wh * .5, y - tri);
+               cairo_line_to (cr,  x - wh * .5, y + tri);
+               cairo_close_path (cr);
+
+               VECTORICONSTROKEFILL;
+       }
+       else if ((_elements & VectorIcon) && _icon == BtnPanic) {
+               const int wh = std::min (get_width(), get_height()) * .1;
+               const double xc = get_width() * .5;
+               const double yh = get_height();
+               cairo_rectangle (cr,
+                               xc - wh, yh *.2,
+                               wh * 2,  yh *.4);
+               VECTORICONSTROKEFILL;
+
+               cairo_arc (cr, xc, yh *.75, wh, 0, 2 * M_PI);
+               VECTORICONSTROKEFILL;
+       }
+       else if ((_elements & VectorIcon) && (_icon == BtnStart || _icon == BtnEnd || _icon == BtnRange)) {
+               // small play triangle
+               int wh = std::min (get_width(), get_height());
+               const double y = get_height() * .5;
+               const double x = get_width() - wh * .5;
+               wh *= .18;
+               const float tri = ceil(.577 * wh * 2); // 1/sqrt(3)
+
+               const int ln = std::min (get_width(), get_height()) * .07;
+
+               if (_icon == BtnStart || _icon == BtnRange) {
+                       cairo_rectangle (cr,
+                                       x - wh - ln, y  - tri * 1.7,
+                                       ln * 2,  tri * 3.4);
+
+                       VECTORICONSTROKEFILL;
+               }
+
+               if (_icon == BtnEnd || _icon == BtnRange) {
+                       cairo_rectangle (cr,
+                                       x + wh - ln, y  - tri * 1.7,
+                                       ln * 2,  tri * 3.4);
+
+                       VECTORICONSTROKEFILL;
+               }
+
+               cairo_move_to (cr,  x + wh, y);
+               cairo_line_to (cr,  x - wh, y - tri);
+               cairo_line_to (cr,  x - wh, y + tri);
+               cairo_close_path (cr);
+
+               VECTORICONSTROKEFILL;
+       }
+       else if (_elements & VectorIcon) {
+               // missing icon
+               assert(0);
+       }
 
        const int text_margin = char_pixel_width();
        // Text, if any
index 8a1055d4ee5c4e0248fbac95ae4047622cdfa5b5..628806e56b997e80601635786cb4a45f48b50098 100644 (file)
@@ -50,6 +50,14 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
                CloseCross,
                StripWidth,
                DinMidi,
+               BtnStop,
+               BtnPlay,
+               BtnLoop,
+               BtnRange,
+               BtnStart,
+               BtnEnd,
+               BtnPanic,
+               BtnMetronom,
        };
 
        static Element default_elements;
index dc2bcb2b1f9b8b93dd8cf82a2945fa6a6ce2e52e..f5f9f62b6613ce3bb8f996126cf82707b00f3301 100644 (file)
@@ -272,17 +272,25 @@ ARDOUR_UI::setup_transport ()
 
        stop_button.set_active (true);
 
-       goto_start_button.set_image (get_icon (X_("transport_start")));
-       goto_end_button.set_image (get_icon (X_("transport_end")));
-       roll_button.set_image (get_icon (X_("transport_play")));
-       stop_button.set_image (get_icon (X_("transport_stop")));
-       play_selection_button.set_image (get_icon (X_("transport_range")));
+       goto_start_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
+       goto_start_button.set_icon (ArdourButton::BtnStart);
+       goto_end_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
+       goto_end_button.set_icon (ArdourButton::BtnEnd);
+       roll_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
+       roll_button.set_icon (ArdourButton::BtnPlay);
+       stop_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
+       stop_button.set_icon (ArdourButton::BtnStop);
+       play_selection_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
+       play_selection_button.set_icon (ArdourButton::BtnRange);
+
        auto_loop_button.set_image (get_icon (X_("transport_loop")));
 
        rec_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
        rec_button.set_icon (ArdourButton::RecButton);
 
-       midi_panic_button.set_image (get_icon (X_("midi_panic")));
+       midi_panic_button.set_elements ((ArdourButton::Element) (ArdourButton::Edge|ArdourButton::Body|ArdourButton::VectorIcon));
+       midi_panic_button.set_icon (ArdourButton::BtnPanic);
+
        /* the icon for this has an odd aspect ratio, so fatten up the button */
        midi_panic_button.set_size_request (25, -1);