24 #include <gtkmm/window.h>
25 #include <pangomm/layout.h>
40 #include "canvas/colors.h"
67 , position_control (_panner->pannable()->pan_azimuth_control)
68 , width_control (_panner->pannable()->pan_width_control)
69 , dragging_position (false)
70 , dragging_left (false)
71 , dragging_right (false)
74 , accumulated_delta (0)
76 , position_binder (position_control)
77 , width_binder (width_control)
85 Pango::FontDescription font;
86 Pango::AttrFontDesc* font_attr;
87 font = Pango::FontDescription (
ARDOUR_UI::config()->get_SmallBoldMonospaceFont());
88 font_attr =
new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
128 snprintf (buf,
sizeof (buf),
_(
"L:%3d R:%3d Width:%d%%"), (
int) rint (100.0 * (1.0 - pos)),
129 (
int) rint (100.0 * pos),
137 Glib::RefPtr<Gdk::Window> win (get_window());
138 Glib::RefPtr<Gdk::GC> gc (get_style()->get_base_gc (get_state()));
139 Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context();
140 Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(get_pango_context());
147 const double fswidth = fabs (swidth);
148 uint32_t o,
f, t, b, r;
152 height = get_height ();
154 const int step_down = rint(height / 3.5);
156 const int lr_box_size = height - 2 * step_down;
157 const int pos_box_size = (int)(rint(step_down * .8)) | 1;
158 const int top_step = step_down - pos_box_size;
162 }
else if (swidth < 0.0) {
191 cairo_rectangle (context->cobj(), 0, 0, width, height);
192 context->fill_preserve ();
200 double usable_width = width - lr_box_size;
204 if (fmod (usable_width,2.0) == 0) {
209 context->translate (1.0, 0.0);
212 const double half_lr_box = lr_box_size/2.0;
213 const double center = rint(half_lr_box + (usable_width * pos));
214 const double pan_spread = rint((fswidth * (usable_width-1.0))/2.0);
215 const double left = center - pan_spread;
216 const double right = center + pan_spread;
219 context->set_line_width (1.0);
220 context->move_to ((usable_width + lr_box_size)/2.0, 0);
221 context->rel_line_to (0, height);
226 context->set_line_width (2);
228 context->move_to (left, top_step + (pos_box_size/2.0) + step_down + 1.0);
229 context->line_to (left, top_step + (pos_box_size/2.0));
230 context->line_to (right, top_step + (pos_box_size/2.0));
231 context->line_to (right, top_step + (pos_box_size/2.0) + step_down + 1.0);
234 context->set_line_width (1.0);
239 half_lr_box+step_down,
240 lr_box_size, lr_box_size, corner_radius);
242 context->fill_preserve();
249 layout->set_text (
S_(
"Panner|R"));
251 layout->set_text (
S_(
"Panner|L"));
253 layout->get_pixel_size(tw, th);
254 context->move_to (rint(left - tw/2), rint(lr_box_size + step_down - th/2));
255 pango_cairo_show_layout (context->cobj(), layout->gobj());
260 half_lr_box+step_down,
261 lr_box_size, lr_box_size, corner_radius);
263 context->fill_preserve();
271 layout->set_text (
S_(
"Panner|M"));
274 layout->set_text (
S_(
"Panner|L"));
276 layout->set_text (
S_(
"Panner|R"));
279 layout->get_pixel_size(tw, th);
280 context->move_to (rint(right - tw/2), rint(lr_box_size + step_down - th/2));
281 pango_cairo_show_layout (context->cobj(), layout->gobj());
284 context->set_line_width (2.0);
285 context->move_to (center + (pos_box_size/2.0), top_step);
286 context->rel_line_to (0.0, pos_box_size);
287 context->rel_line_to (-pos_box_size/2.0, 4.0);
288 context->rel_line_to (-pos_box_size/2.0, -4.0);
289 context->rel_line_to (0.0, -pos_box_size);
290 context->close_path ();
293 context->stroke_preserve ();
335 if (ev->button != 1) {
339 if (ev->type == GDK_2BUTTON_PRESS) {
340 int width = get_width();
342 if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
352 const double max_pos = 1.0 - (w/2.0);
353 const double min_pos = w/2.0;
355 if (ev->x <= width/3) {
357 if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
364 }
else if (ev->x > 2*width/3) {
365 if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
381 const double max_width = 2.0 * min ((1.0 - p), p);
383 if (ev->x <= width/3) {
386 }
else if (ev->x > 2*width/3) {
398 }
else if (ev->type == GDK_BUTTON_PRESS) {
400 if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
414 double fswidth = fabs (swidth);
415 const int lr_box_size = get_height() - 2 * rint(get_height() / 3.5);
416 int usable_width = get_width() - lr_box_size;
417 double center = (lr_box_size/2.0) + (usable_width * pos);
418 int left = lrint (center - (fswidth * usable_width / 2.0));
419 int right = lrint (center + (fswidth * usable_width / 2.0));
420 const int half_box = lr_box_size/2;
422 if (ev->x >= (left - half_box) && ev->x < (left + half_box)) {
428 }
else if (ev->x >= (right - half_box) && ev->x < (right + half_box)) {
452 if (ev->button != 1) {
470 if (Keyboard::modifier_state_contains (ev->state, Keyboard::TertiaryModifier)) {
486 double one_degree = 1.0/180.0;
495 if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
498 step = one_degree * 5.0;
501 switch (ev->direction) {
502 case GDK_SCROLL_LEFT:
510 case GDK_SCROLL_RIGHT:
514 case GDK_SCROLL_DOWN:
533 const int lr_box_size = get_height() - 2 * rint(get_height() / 3.5);
534 int usable_width = get_width() - lr_box_size;
535 double delta = (ev->x -
last_drag_x) / (
double) usable_width;
544 if (Keyboard::modifier_state_contains (ev->state, Keyboard::SecondaryModifier)) {
580 if (!
detented && fabs (current_width) < 0.02) {
617 double one_degree = 1.0/180.0;
626 if (Keyboard::modifier_state_contains (ev->state, Keyboard::PrimaryModifier)) {
629 step = one_degree * 5.0;
636 switch (ev->keyval) {
638 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
645 if (Keyboard::modifier_state_equals (ev->state, Keyboard::SecondaryModifier)) {
boost::shared_ptr< Pannable > pannable() const
ArdourCanvas::Color color(const std::string &, bool *failed=0) const
bool on_button_release_event(GdkEventButton *)
BindingProxy width_binder
PBD::Signal0< void > PannableChanged
#define UINT_RGBA_A_FLT(x)
static ColorScheme colors[3]
#define UINT_RGBA_G_FLT(x)
bool on_expose_event(GdkEventExpose *)
sigc::signal< void > StopPositionGesture
bool on_motion_notify_event(GdkEventMotion *)
void set_controllable(boost::shared_ptr< PBD::Controllable >)
StereoPanner(boost::shared_ptr< ARDOUR::PannerShell >)
#define UINT_RGBA_B_FLT(x)
PBD::ScopedConnectionList panshell_connections
bool on_scroll_event(GdkEventScroll *)
boost::shared_ptr< ARDOUR::PannerShell > _panner_shell
bool on_key_press_event(GdkEventKey *)
bool on_button_press_event(GdkEventButton *)
virtual double get_value(void) const =0
bool button_press_handler(GdkEventButton *)
static Pango::AttrList panner_font_attributes
boost::shared_ptr< PBD::Controllable > width_control
bool on_button_press_event(GdkEventButton *)
virtual void set_value(double)=0
PBD::Signal0< void > Changed
ArdourCanvas::Color color_mod(std::string const &color, std::string const &modifier) const
static UIConfiguration * config()
PBD::Signal0< void > Changed
sigc::signal< void > StartWidthGesture
sigc::signal< void > ColorsChanged
PBD::ScopedConnectionList panvalue_connections
LIBGTKMM2EXT_API void rounded_rectangle(Cairo::RefPtr< Cairo::Context > context, double x, double y, double w, double h, double r=10)
sigc::signal< void > StopWidthGesture
sigc::signal< void > StartPositionGesture
BindingProxy position_binder
boost::shared_ptr< ARDOUR::Panner > _panner
boost::shared_ptr< PBD::Controllable > position_control
PannerPersistentTooltip _tooltip
bool on_button_release_event(GdkEventButton *)
#define UINT_RGBA_R_FLT(x)