#include "ardour/rc_configuration.h" // for widget prelight preference
#include "canvas/utils.h"
+#include "canvas/colors.h"
#include "ardour_button.h"
#include "ardour_ui.h"
, text_inactive_color(0)
, led_active_color(0)
, led_inactive_color(0)
+ , led_custom_color (0)
+ , use_custom_led_color (false)
, convex_pattern (0)
, concave_pattern (0)
, led_inset_pattern (0)
, text_inactive_color(0)
, led_active_color(0)
, led_inactive_color(0)
+ , led_custom_color (0)
+ , use_custom_led_color (false)
, convex_pattern (0)
, concave_pattern (0)
, led_inset_pattern (0)
led_color = led_inactive_color;
}
+ if (use_custom_led_color) {
+ led_color = led_custom_color;
+ }
+
void (*rounded_function)(cairo_t*, double, double, double, double, double);
switch (_corner_mask) {
//show the "convex" or "concave" gradient
if (!_flat_buttons) {
- if ( active_state() == Gtkmm2ext::ExplicitActive && !((_elements & Indicator)==Indicator) ) {
+ if ( active_state() == Gtkmm2ext::ExplicitActive && ( !((_elements & Indicator)==Indicator) || use_custom_led_color) ) {
//concave
cairo_set_source (cr, concave_pattern);
Gtkmm2ext::rounded_rectangle (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
cairo_restore (cr);
}
- // a transparent gray layer to indicate insensitivity
+ // a transparent overlay to indicate insensitivity
if ((visual_state() & Gtkmm2ext::Insensitive)) {
- rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
- cairo_set_source_rgba (cr, 0.505, 0.517, 0.525, 0.6);
+ rounded_function (cr, 0, 0, get_width(), get_height(), _corner_radius);
+ uint32_t ins_color = ARDOUR_UI::config()->color ("gtk_background");
+ ArdourCanvas::set_source_rgb_a (cr, ins_color, 0.6);
cairo_fill (cr);
}
// if requested, show hovering
- if (ARDOUR::Config->get_widget_prelight()
+ if (ARDOUR_UI::config()->get_widget_prelight()
&& !((visual_state() & Gtkmm2ext::Insensitive))) {
if (_hovering) {
rounded_function (cr, 1, 1, get_width() - 2, get_height() - 2, _corner_radius);
CairoWidget::on_size_request (req);
if (_diameter == 0) {
- const float newdia = rint (ARDOUR::Config->get_font_scale () / 1024. / 7.5); // 11px with 80% font-scaling
+ const float newdia = rint (ARDOUR_UI::config()->get_font_scale () / 9600.0); // 11px with 100% font-scaling
if (_diameter != newdia) {
_pattern_height = 0;
_diameter = newdia;
if (failed) {
led_active_color = ARDOUR_UI::config()->color ("generic button: led active");
}
- led_inactive_color = ARDOUR_UI::config()->color (string_compose ("%1: led", name), &failed);
- if (failed) {
- led_inactive_color = ARDOUR_UI::config()->color ("generic button: led");
- }
+
+ /* The inactive color for the LED is just a fairly dark version of the
+ * active color.
+ */
+
+ ArdourCanvas::HSV inactive (led_active_color);
+ inactive.v = 0.35;
+
+ led_inactive_color = inactive.color ();
}
/**
{
focus_handler ();
- if ((_elements & Indicator) && _led_rect && _distinct_led_click) {
+ if (ev->button == 1 && (_elements & Indicator) && _led_rect && _distinct_led_click) {
if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
return true;
_grabbed = true;
CairoWidget::set_dirty ();
- if (!_act_on_release) {
+ if (ev->button == 1 && !_act_on_release) {
if (_action) {
_action->activate ();
return true;
bool
ArdourButton::on_button_release_event (GdkEventButton *ev)
{
- if (_hovering && (_elements & Indicator) && _led_rect && _distinct_led_click) {
+ if (ev->button == 1 && _hovering && (_elements & Indicator) && _led_rect && _distinct_led_click) {
if (ev->x >= _led_rect->x && ev->x < _led_rect->x + _led_rect->width &&
ev->y >= _led_rect->y && ev->y < _led_rect->y + _led_rect->height) {
signal_led_clicked(); /* EMIT SIGNAL */
_grabbed = false;
CairoWidget::set_dirty ();
- if (_hovering) {
+ if (ev->button == 1 && _hovering) {
signal_clicked ();
if (_act_on_release) {
if (_action) {
{
_hovering = (_elements & Inactive) ? false : true;
- if (ARDOUR::Config->get_widget_prelight()) {
+ if (ARDOUR_UI::config()->get_widget_prelight()) {
CairoWidget::set_dirty ();
}
{
_hovering = false;
- if (ARDOUR::Config->get_widget_prelight()) {
+ if (ARDOUR_UI::config()->get_widget_prelight()) {
CairoWidget::set_dirty ();
}
}
void
-ArdourButton::set_layout_ellisize_width (int w)
+ArdourButton::set_layout_ellipsize_width (int w)
{
if (_layout_ellipsize_width == w) {
return;
if (!_layout) {
return;
}
- if (_layout_ellipsize_width > 0) {
- _layout->set_width (_layout_ellipsize_width);
+ if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
+ _layout->set_width (_layout_ellipsize_width - 3 * PANGO_SCALE);
+ }
+ if (is_realized ()) {
+ queue_resize ();
}
}
return;
}
_layout->set_ellipsize(_ellipsis);
- if (_layout_ellipsize_width > 0) {
- _layout->set_width (_layout_ellipsize_width);
+ if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
+ _layout->set_width (_layout_ellipsize_width - 3 * PANGO_SCALE);
}
if (is_realized ()) {
queue_resize ();
ensure_style ();
_layout = Pango::Layout::create (get_pango_context());
_layout->set_ellipsize(_ellipsis);
- if (_layout_ellipsize_width > 0) {
- _layout->set_width (_layout_ellipsize_width);
+ if (_layout_ellipsize_width > 3 * PANGO_SCALE) {
+ _layout->set_width (_layout_ellipsize_width - 3* PANGO_SCALE);
}
}
}
_elements = (ArdourButton::Element) (_elements | e);
CairoWidget::set_dirty ();
}
+
+void
+ArdourButton::set_custom_led_color (uint32_t c, bool useit)
+{
+ if (led_custom_color == c && use_custom_led_color == useit) {
+ return;
+ }
+
+ led_custom_color = c;
+ use_custom_led_color = useit;
+ CairoWidget::set_dirty ();
+}