summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-04-07 22:33:43 +0200
committerRobin Gareus <robin@gareus.org>2015-04-07 22:34:09 +0200
commitde7d6a7f2ca97116dc71a98a0855296933f60ad6 (patch)
treed294523fed234279bcbc71eb0b17c79eb0b7c61e
parentd25e8f22333ff00b51fbadb1892ba63cb90bb918 (diff)
renice transport buttons (part one)
-rw-r--r--gtk2_ardour/ardour_button.cc79
-rw-r--r--gtk2_ardour/ardour_button.h8
-rw-r--r--gtk2_ardour/ardour_ui2.cc20
3 files changed, 101 insertions, 6 deletions
diff --git a/gtk2_ardour/ardour_button.cc b/gtk2_ardour/ardour_button.cc
index d4fee88fee..ee4f3af5f2 100644
--- a/gtk2_ardour/ardour_button.cc
+++ b/gtk2_ardour/ardour_button.cc
@@ -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
diff --git a/gtk2_ardour/ardour_button.h b/gtk2_ardour/ardour_button.h
index 8a1055d4ee..628806e56b 100644
--- a/gtk2_ardour/ardour_button.h
+++ b/gtk2_ardour/ardour_button.h
@@ -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;
diff --git a/gtk2_ardour/ardour_ui2.cc b/gtk2_ardour/ardour_ui2.cc
index dc2bcb2b1f..f5f9f62b66 100644
--- a/gtk2_ardour/ardour_ui2.cc
+++ b/gtk2_ardour/ardour_ui2.cc
@@ -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);