13
0

scalable panners

This commit is contained in:
Robin Gareus 2015-04-20 20:45:14 +02:00
parent 494009a6e2
commit 451450d3f8
5 changed files with 40 additions and 30 deletions

View File

@ -705,8 +705,12 @@ MixerStrip::set_width_enum (Width w, void* owner)
panners.astate_string(_route->panner()->automation_state()));
}
set_size_request (max (110 * scale, gpm.get_gm_width() + 5 * scale), -1);
{
// panners expect an even number of horiz. pixels
int width = rint(max (110 * scale, gpm.get_gm_width() + 10 * scale)) + 1;
width &= ~1;
set_size_request (width, -1);
}
break;
case Narrow:
@ -728,7 +732,12 @@ MixerStrip::set_width_enum (Width w, void* owner)
panners.short_astate_string(_route->panner()->automation_state()));
}
set_size_request (max (60 * scale, gpm.get_gm_width() + 10 * scale), -1);
{
// panners expect an even number of horiz. pixels
int width = rint(max (60 * scale, gpm.get_gm_width() + 10 * scale)) + 1;
width &= ~1;
set_size_request (width, -1);
}
break;
}

View File

@ -52,11 +52,6 @@ using namespace Gtk;
using namespace Gtkmm2ext;
using namespace ARDOUR_UI_UTILS;
static const int pos_box_size = 9;
static const int lr_box_size = 15;
static const int step_down = 10;
static const int top_step = 2;
MonoPanner::ColorScheme MonoPanner::colors;
bool MonoPanner::have_colors = false;
@ -136,11 +131,17 @@ MonoPanner::on_expose_event (GdkEventExpose*)
int width, height;
double pos = position_control->get_value (); /* 0..1 */
uint32_t o, f, t, b, pf, po;
const double corner_radius = 5;
width = get_width();
height = get_height ();
const double scale = ARDOUR_UI::config()->get_font_scale() / 102400.;
const int step_down = rint(height / 3.5);
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;
const double corner_radius = 5 * scale;
o = colors.outline;
f = colors.fill;
t = colors.text;
@ -165,7 +166,6 @@ MonoPanner::on_expose_event (GdkEventExpose*)
context->rectangle (0, 0, width, height);
context->fill ();
double usable_width = width - pos_box_size;
/* compute the centers of the L/R boxes based on the current stereo width */
@ -173,8 +173,8 @@ MonoPanner::on_expose_event (GdkEventExpose*)
usable_width -= 1.0;
}
const double half_lr_box = lr_box_size/2.0;
const double left = 4 + half_lr_box; // center of left box
const double right = width - 4 - half_lr_box; // center of right box
const double left = pos_box_size * .5 + half_lr_box; // center of left box
const double right = width - pos_box_size * .5 - half_lr_box; // center of right box
/* center line */
context->set_source_rgba (UINT_RGBA_R_FLT(o), UINT_RGBA_G_FLT(o), UINT_RGBA_B_FLT(o), UINT_RGBA_A_FLT(o));
@ -255,8 +255,8 @@ MonoPanner::on_expose_event (GdkEventExpose*)
context->set_line_width (2.0);
context->move_to (spos + (pos_box_size/2.0), top_step); /* top right */
context->rel_line_to (0.0, pos_box_size); /* lower right */
context->rel_line_to (-pos_box_size/2.0, 4.0); /* bottom point */
context->rel_line_to (-pos_box_size/2.0, -4.0); /* lower left */
context->rel_line_to (-pos_box_size/2.0, 4.0 * scale); /* bottom point */
context->rel_line_to (-pos_box_size/2.0, -4.0 * scale); /* lower left */
context->rel_line_to (0.0, -pos_box_size); /* upper left */
context->close_path ();
@ -268,8 +268,8 @@ MonoPanner::on_expose_event (GdkEventExpose*)
/* marker line */
context->set_line_width (1.0);
context->move_to (spos, pos_box_size + 5);
context->rel_line_to (0, half_lr_box+step_down);
context->move_to (spos, 1 + top_step + pos_box_size + 4.0 * scale);
context->line_to (spos, half_lr_box + step_down + lr_box_size - 1);
context->set_source_rgba (UINT_RGBA_R_FLT(po), UINT_RGBA_G_FLT(po), UINT_RGBA_B_FLT(po), UINT_RGBA_A_FLT(po));
context->stroke ();

View File

@ -43,8 +43,6 @@ using namespace PBD;
using namespace Gtkmm2ext;
using namespace Gtk;
const int PannerUI::pan_bar_height = 35;
PannerUI::PannerUI (Session* s)
: _current_nouts (-1)
, _current_nins (-1)
@ -242,6 +240,8 @@ PannerUI::setup_pan ()
return;
}
const double scale = std::max(1.0, ARDOUR_UI::config()->get_font_scale() / 102400.);
if (_current_uri == "http://ardour.org/plugin/panner_2in2out#ui")
{
delete big_window;
@ -250,7 +250,7 @@ PannerUI::setup_pan ()
boost::shared_ptr<Pannable> pannable = _panner->pannable();
_stereo_panner = new StereoPanner (_panshell);
_stereo_panner->set_size_request (-1, pan_bar_height);
_stereo_panner->set_size_request (-1, 5 * ceil(7. * scale));
_stereo_panner->set_send_drawing_mode (_send_mode);
pan_vbox.pack_start (*_stereo_panner, false, false);
@ -286,7 +286,7 @@ PannerUI::setup_pan ()
_mono_panner->signal_button_release_event().connect (sigc::mem_fun(*this, &PannerUI::pan_button_event));
_mono_panner->set_size_request (-1, pan_bar_height);
_mono_panner->set_size_request (-1, 5 * ceil(7. * scale));
_mono_panner->set_send_drawing_mode (_send_mode);
update_pan_sensitive ();
@ -295,7 +295,7 @@ PannerUI::setup_pan ()
else if (_current_uri == "http://ardour.org/plugin/panner_vbap#ui")
{
if (!twod_panner) {
twod_panner = new Panner2d (_panshell, 61);
twod_panner = new Panner2d (_panshell, 61 * scale);
twod_panner->set_name ("MixerPanZone");
twod_panner->show ();
twod_panner->signal_button_press_event().connect (sigc::mem_fun(*this, &PannerUI::pan_button_event), false);
@ -306,7 +306,7 @@ PannerUI::setup_pan ()
if (big_window) {
big_window->reset (nins);
}
twod_panner->set_size_request (-1, 61);
twod_panner->set_size_request (-1, 61 * scale);
twod_panner->set_send_drawing_mode (_send_mode);
/* and finally, add it to the panner frame */

View File

@ -100,8 +100,6 @@ class PannerUI : public Gtk::HBox, public ARDOUR::SessionHandlePtr
std::string _current_uri;
bool _send_mode;
static const int pan_bar_height;
Panner2d* twod_panner; ///< 2D panner, or 0
Panner2dWindow* big_window;

View File

@ -53,11 +53,6 @@ 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;
StereoPanner::ColorScheme StereoPanner::colors[3];
bool StereoPanner::have_colors = false;
@ -150,13 +145,19 @@ 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 double scale = ARDOUR_UI::config()->get_font_scale() / 102400.;
const int step_down = rint(height / 3.5);
const double corner_radius = 5.0 * 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) {
@ -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
@ -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 ();