X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fstereo_panner.cc;h=304300fcdbb38912967301c3cb70a9a1c4e3943f;hb=234b06a18cf3e8c07bc44fb4f8c1218e17fb65f1;hp=37fa5a6b4b967fca7a12ef6e56b006f0b547f6b4;hpb=56ca52651e910496084b992486ac7b8e3bbc88cf;p=ardour.git diff --git a/gtk2_ardour/stereo_panner.cc b/gtk2_ardour/stereo_panner.cc index 37fa5a6b4b..304300fcdb 100644 --- a/gtk2_ardour/stereo_panner.cc +++ b/gtk2_ardour/stereo_panner.cc @@ -39,12 +39,11 @@ #include "canvas/colors.h" -#include "ardour_ui.h" -#include "global_signals.h" #include "stereo_panner.h" #include "stereo_panner_editor.h" #include "rgb_macros.h" #include "utils.h" +#include "ui_config.h" #include "i18n.h" @@ -53,10 +52,7 @@ using namespace Gtk; using namespace Gtkmm2ext; using namespace ARDOUR_UI_UTILS; -static const int pos_box_size = 8; -static const int lr_box_size = 15; -static const int step_down = 10; -static const int top_step = 2; +using PBD::Controllable; StereoPanner::ColorScheme StereoPanner::colors[3]; bool StereoPanner::have_colors = false; @@ -89,7 +85,7 @@ StereoPanner::StereoPanner (boost::shared_ptr p) if (!have_font) { Pango::FontDescription font; Pango::AttrFontDesc* font_attr; - font = Pango::FontDescription (ARDOUR_UI::config()->get_SmallBoldMonospaceFont()); + font = Pango::FontDescription (UIConfiguration::instance().get_SmallBoldMonospaceFont()); font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font)); panner_font_attributes.change(*font_attr); delete font_attr; @@ -102,7 +98,7 @@ StereoPanner::StereoPanner (boost::shared_ptr p) _panner_shell->Changed.connect (panshell_connections, invalidator (*this), boost::bind (&StereoPanner::bypass_handler, this), gui_context()); _panner_shell->PannableChanged.connect (panshell_connections, invalidator (*this), boost::bind (&StereoPanner::pannable_handler, this), gui_context()); - ColorsChanged.connect (sigc::mem_fun (*this, &StereoPanner::color_handler)); + UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &StereoPanner::color_handler)); set_tooltip (); } @@ -150,13 +146,18 @@ StereoPanner::on_expose_event (GdkEventExpose*) const double pos = position_control->get_value (); /* 0..1 */ const double swidth = width_control->get_value (); /* -1..+1 */ const double fswidth = fabs (swidth); - const double corner_radius = 5.0; uint32_t o, f, t, b, r; State state; width = get_width(); height = get_height (); + const int step_down = rint(height / 3.5); + const double corner_radius = 5.0 * UIConfiguration::instance().get_ui_scale(); + const int lr_box_size = height - 2 * step_down; + const int pos_box_size = (int)(rint(step_down * .8)) | 1; + const int top_step = step_down - pos_box_size; + if (swidth == 0.0) { state = Mono; } else if (swidth < 0.0) { @@ -180,7 +181,7 @@ StereoPanner::on_expose_event (GdkEventExpose*) } if (_send_mode) { - b = ARDOUR_UI::config()->color ("send strip base"); + b = UIConfiguration::instance().color ("send bg"); // b = rgba_from_style("SendStripBase", // UINT_RGBA_R(b), UINT_RGBA_G(b), UINT_RGBA_B(b), 255, // "fg"); @@ -246,9 +247,9 @@ StereoPanner::on_expose_event (GdkEventExpose*) /* add text */ context->set_source_rgba (UINT_RGBA_R_FLT(t), UINT_RGBA_G_FLT(t), UINT_RGBA_B_FLT(t), UINT_RGBA_A_FLT(t)); if (swidth < 0.0) { - layout->set_text (_("R")); + layout->set_text (S_("Panner|R")); } else { - layout->set_text (_("L")); + layout->set_text (S_("Panner|L")); } layout->get_pixel_size(tw, th); context->move_to (rint(left - tw/2), rint(lr_box_size + step_down - th/2)); @@ -268,12 +269,12 @@ StereoPanner::on_expose_event (GdkEventExpose*) context->set_source_rgba (UINT_RGBA_R_FLT(t), UINT_RGBA_G_FLT(t), UINT_RGBA_B_FLT(t), UINT_RGBA_A_FLT(t)); if (state == Mono) { - layout->set_text (_("M")); + layout->set_text (S_("Panner|M")); } else { if (swidth < 0.0) { - layout->set_text (_("L")); + layout->set_text (S_("Panner|L")); } else { - layout->set_text (_("R")); + layout->set_text (S_("Panner|R")); } } layout->get_pixel_size(tw, th); @@ -307,7 +308,7 @@ StereoPanner::on_button_press_event (GdkEventButton* ev) if (_panner_shell->bypassed()) { return true; } - + drag_start_x = ev->x; last_drag_x = ev->x; @@ -356,21 +357,21 @@ StereoPanner::on_button_press_event (GdkEventButton* ev) /* left side dbl click */ if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) { /* 2ndary-double click on left, collapse to hard left */ - width_control->set_value (0); - position_control->set_value (0); + width_control->set_value (0, Controllable::NoGroup); + position_control->set_value (0, Controllable::NoGroup); } else { - position_control->set_value (min_pos); + position_control->set_value (min_pos, Controllable::NoGroup); } } else if (ev->x > 2*width/3) { if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) { /* 2ndary-double click on right, collapse to hard right */ - width_control->set_value (0); - position_control->set_value (1.0); + width_control->set_value (0, Controllable::NoGroup); + position_control->set_value (1.0, Controllable::NoGroup); } else { - position_control->set_value (max_pos); + position_control->set_value (max_pos, Controllable::NoGroup); } } else { - position_control->set_value (0.5); + position_control->set_value (0.5, Controllable::NoGroup); } } else { @@ -382,13 +383,13 @@ StereoPanner::on_button_press_event (GdkEventButton* ev) if (ev->x <= width/3) { /* left side dbl click */ - width_control->set_value (max_width); // reset width to 100% + width_control->set_value (max_width, Controllable::NoGroup); // reset width to 100% } else if (ev->x > 2*width/3) { /* right side dbl click */ - width_control->set_value (-max_width); // reset width to inverted 100% + width_control->set_value (-max_width, Controllable::NoGroup); // reset width to inverted 100% } else { /* center dbl click */ - width_control->set_value (0); // collapse width to 0% + width_control->set_value (0, Controllable::NoGroup); // collapse width to 0% } } @@ -412,6 +413,7 @@ StereoPanner::on_button_press_event (GdkEventButton* ev) double pos = position_control->get_value (); /* 0..1 */ double swidth = width_control->get_value (); /* -1..+1 */ double fswidth = fabs (swidth); + const int lr_box_size = get_height() - 2 * rint(get_height() / 3.5); int usable_width = get_width() - lr_box_size; double center = (lr_box_size/2.0) + (usable_width * pos); int left = lrint (center - (fswidth * usable_width / 2.0)); // center of leftmost box @@ -447,7 +449,7 @@ StereoPanner::on_button_release_event (GdkEventButton* ev) if (PannerInterface::on_button_release_event (ev)) { return true; } - + if (ev->button != 1) { return false; } @@ -500,19 +502,19 @@ StereoPanner::on_scroll_event (GdkEventScroll* ev) switch (ev->direction) { case GDK_SCROLL_LEFT: wv += step; - width_control->set_value (wv); + width_control->set_value (wv, Controllable::NoGroup); break; case GDK_SCROLL_UP: pv -= step; - position_control->set_value (pv); + position_control->set_value (pv, Controllable::NoGroup); break; case GDK_SCROLL_RIGHT: wv -= step; - width_control->set_value (wv); + width_control->set_value (wv, Controllable::NoGroup); break; case GDK_SCROLL_DOWN: pv += step; - position_control->set_value (pv); + position_control->set_value (pv, Controllable::NoGroup); break; } @@ -529,6 +531,7 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev) return false; } + const int lr_box_size = get_height() - 2 * rint(get_height() / 3.5); int usable_width = get_width() - lr_box_size; double delta = (ev->x - last_drag_x) / (double) usable_width; double current_width = width_control->get_value (); @@ -536,7 +539,7 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev) if (dragging_left) { delta = -delta; } - + if (dragging_left || dragging_right) { if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) { @@ -546,13 +549,13 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev) */ _panner->freeze (); - + double pv = position_control->get_value(); if (dragging_left) { - position_control->set_value (pv - delta); + position_control->set_value (pv - delta, Controllable::NoGroup); } else { - position_control->set_value (pv + delta); + position_control->set_value (pv + delta, Controllable::NoGroup); } if (delta > 0.0) { @@ -562,9 +565,9 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev) other side remains in place when we set the position as well. */ - width_control->set_value (current_width + (delta * 2.0)); + width_control->set_value (current_width + (delta * 2.0), Controllable::NoGroup); } else { - width_control->set_value (current_width + delta); + width_control->set_value (current_width + delta, Controllable::NoGroup); } _panner->thaw (); @@ -572,37 +575,37 @@ StereoPanner::on_motion_notify_event (GdkEventMotion* ev) } else { /* maintain position as invariant as we change the width */ - + /* create a detent close to the center */ - + if (!detented && fabs (current_width) < 0.02) { detented = true; /* snap to zero */ - width_control->set_value (0); + width_control->set_value (0, Controllable::NoGroup); } - + if (detented) { - + accumulated_delta += delta; - + /* have we pulled far enough to escape ? */ - + if (fabs (accumulated_delta) >= 0.025) { - width_control->set_value (current_width + accumulated_delta); + width_control->set_value (current_width + accumulated_delta, Controllable::NoGroup); detented = false; accumulated_delta = false; } - + } else { /* width needs to change by 2 * delta because both L & R move */ - width_control->set_value (current_width + (delta * 2.0)); + width_control->set_value (current_width + (delta * 2.0), Controllable::NoGroup); } } } else if (dragging_position) { double pv = position_control->get_value(); // 0..1.0 ; 0 = left - position_control->set_value (pv + delta); + position_control->set_value (pv + delta, Controllable::NoGroup); } last_drag_x = ev->x; @@ -634,30 +637,30 @@ StereoPanner::on_key_press_event (GdkEventKey* ev) switch (ev->keyval) { case GDK_Up: if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) { - width_control->set_value (1.0); + width_control->set_value (1.0, Controllable::NoGroup); } else { - width_control->set_value (wv + step); + width_control->set_value (wv + step, Controllable::NoGroup); } break; case GDK_Down: if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) { - width_control->set_value (-1.0); + width_control->set_value (-1.0, Controllable::NoGroup); } else { - width_control->set_value (wv - step); + width_control->set_value (wv - step, Controllable::NoGroup); } break; case GDK_Left: pv -= step; - position_control->set_value (pv); + position_control->set_value (pv, Controllable::NoGroup); break; case GDK_Right: pv += step; - position_control->set_value (pv); + position_control->set_value (pv, Controllable::NoGroup); break; case GDK_0: case GDK_KP_0: - width_control->set_value (0.0); + width_control->set_value (0.0, Controllable::NoGroup); break; default: @@ -670,24 +673,24 @@ StereoPanner::on_key_press_event (GdkEventKey* ev) void StereoPanner::set_colors () { - colors[Normal].fill = ARDOUR_UI::config()->color ("stereo panner fill"); - // colors[Normal].outline = ARDOUR_UI::config()->color ("stereo panner outline"); + colors[Normal].fill = UIConfiguration::instance().color_mod ("stereo panner fill", "panner fill"); + // colors[Normal].outline = UIConfiguration::instance().color ("stereo panner outline"); colors[Normal].outline = ArdourCanvas::HSV (colors[Normal].fill).outline().color (); - colors[Normal].text = ARDOUR_UI::config()->color ("stereo panner text"); - colors[Normal].background = ARDOUR_UI::config()->color ("stereo panner bg"); - colors[Normal].rule = ARDOUR_UI::config()->color ("stereo panner rule"); - - colors[Mono].fill = ARDOUR_UI::config()->color ("stereo panner mono fill"); - colors[Mono].outline = ARDOUR_UI::config()->color ("stereo panner mono outline"); - colors[Mono].text = ARDOUR_UI::config()->color ("stereo panner mono text"); - colors[Mono].background = ARDOUR_UI::config()->color ("stereo panner mono bg"); - colors[Mono].rule = ARDOUR_UI::config()->color ("stereo panner rule"); - - colors[Inverted].fill = ARDOUR_UI::config()->color ("stereo panner inverted fill"); - colors[Inverted].outline = ARDOUR_UI::config()->color ("stereo panner inverted outline"); - colors[Inverted].text = ARDOUR_UI::config()->color ("stereo panner inverted text"); - colors[Inverted].background = ARDOUR_UI::config()->color ("stereo panner inverted bg"); - colors[Inverted].rule = ARDOUR_UI::config()->color ("stereo panner rule"); + colors[Normal].text = UIConfiguration::instance().color ("stereo panner text"); + colors[Normal].background = UIConfiguration::instance().color ("stereo panner bg"); + colors[Normal].rule = UIConfiguration::instance().color ("stereo panner rule"); + + colors[Mono].fill = UIConfiguration::instance().color ("stereo panner mono fill"); + colors[Mono].outline = UIConfiguration::instance().color ("stereo panner mono outline"); + colors[Mono].text = UIConfiguration::instance().color ("stereo panner mono text"); + colors[Mono].background = UIConfiguration::instance().color ("stereo panner mono bg"); + colors[Mono].rule = UIConfiguration::instance().color ("stereo panner rule"); + + colors[Inverted].fill = UIConfiguration::instance().color_mod ("stereo panner inverted fill", "stereo panner inverted"); + colors[Inverted].outline = UIConfiguration::instance().color ("stereo panner inverted outline"); + colors[Inverted].text = UIConfiguration::instance().color ("stereo panner inverted text"); + colors[Inverted].background = UIConfiguration::instance().color_mod ("stereo panner inverted bg", "stereo panner inverted bg"); + colors[Inverted].rule = UIConfiguration::instance().color ("stereo panner rule"); } void