breakout control protocol code into LGPL library; fix panner buttons even more than...
[ardour.git] / gtk2_ardour / panner_ui.cc
1 /*
2   Copyright (C) 2004 Paul Davis
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; either version 2 of the License, or
7   (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   GNU General Public License for more details.
13
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18   $Id$
19 */
20
21 #include <limits.h>
22
23 #include <ardour/io.h>
24 #include <ardour/dB.h>
25 #include <gtkmm2ext/utils.h>
26 #include <gtkmm2ext/stop_signal.h>
27 #include <gtkmm2ext/barcontroller.h>
28 #include <midi++/manager.h>
29 #include <pbd/fastlog.h>
30
31 #include "ardour_ui.h"
32 #include "panner_ui.h"
33 #include "panner2d.h"
34 #include "utils.h"
35 #include "gui_thread.h"
36
37 #include <ardour/session.h>
38 #include <ardour/panner.h>
39 #include <ardour/route.h>
40
41 #include "i18n.h"
42
43 using namespace ARDOUR;
44 using namespace Gtkmm2ext;
45 using namespace Gtk;
46 using namespace sigc;
47
48
49 PannerUI::PannerUI (IO& io, Session& s)
50         : _io (io),
51           _session (s),
52           hAdjustment(0.0, 0.0, 0.0),
53           vAdjustment(0.0, 0.0, 0.0),
54           panning_viewport(hAdjustment, vAdjustment),
55           panning_up_arrow (Gtk::ARROW_UP, Gtk::SHADOW_OUT),
56           panning_down_arrow (Gtk::ARROW_DOWN, Gtk::SHADOW_OUT),
57           panning_link_button (_("link")),
58           pan_automation_style_button (""),
59           pan_automation_state_button ("")
60 {
61         ignore_toggle = false;
62         pan_menu = 0;
63         in_pan_update = false;
64
65         pan_automation_style_button.set_name ("MixerAutomationModeButton");
66         pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
67
68         ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
69         ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
70
71         set_size_request_to_display_given_text (pan_automation_state_button, X_("M"), 2, 2);
72         set_size_request_to_display_given_text (pan_automation_style_button, X_("M"), 2, 2);
73
74         pan_bar_packer.set_size_request (-1, 61);
75         panning_viewport.set_size_request (61, 61);
76
77         panning_viewport.set_name (X_("BaseFrame"));
78
79         ARDOUR_UI::instance()->tooltips().set_tip (panning_link_button,
80                                                    _("panning link control"));
81         ARDOUR_UI::instance()->tooltips().set_tip (panning_link_direction_button,
82                                                    _("panning link direction"));
83
84         pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
85         pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
86
87         using namespace Menu_Helpers;
88         pan_astate_menu.items().push_back (MenuElem (_("Off"), 
89                                                      bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Off)));
90         pan_astate_menu.items().push_back (MenuElem (_("Play"),
91                                                      bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Play)));
92         pan_astate_menu.items().push_back (MenuElem (_("Write"),
93                                                      bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Write)));
94         pan_astate_menu.items().push_back (MenuElem (_("Touch"),
95                                                      bind (mem_fun (_io.panner(), &Panner::set_automation_state), (AutoState) Touch)));
96
97         pan_astyle_menu.items().push_back (MenuElem (_("Trim")));
98         pan_astyle_menu.items().push_back (MenuElem (_("Abs")));
99
100         pan_astate_menu.set_name ("ArdourContextMenu");
101         pan_astyle_menu.set_name ("ArdourContextMenu");
102
103         pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &PannerUI::pan_automation_style_button_event), false);
104         pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &PannerUI::pan_automation_state_button_event), false);
105
106         panning_link_button.set_name (X_("PanningLinkButton"));
107         panning_link_direction_button.set_name (X_("PanningLinkDirectionButton"));
108
109         /* the pixmap will be reset at some point, but the key thing is that
110            we need a pixmap in the button just to get started.
111         */
112
113         Gtk::HBox* pan_button_hbox = manage (new Gtk::HBox());
114
115         panning_link_box.pack_start (panning_link_button, true, true);
116         panning_link_box.pack_start (panning_link_direction_button, true, true);
117         pan_button_hbox->pack_start (panning_link_box, true, true);
118         pan_button_hbox->pack_start (pan_automation_state_button, true, true);
119
120         panning_link_direction_button.add (*(manage (new Image (get_xpm("forwardblarrow.xpm")))));
121
122         panning_link_direction_button.signal_clicked().connect
123                 (mem_fun(*this, &PannerUI::panning_link_direction_clicked));
124
125         panning_link_button.signal_button_press_event().connect
126                 (mem_fun(*this, &PannerUI::panning_link_button_press), false);
127         panning_link_button.signal_button_release_event().connect
128                 (mem_fun(*this, &PannerUI::panning_link_button_release), false);
129
130         panning_up.set_border_width (3);
131         panning_down.set_border_width (3);
132         panning_up.add (panning_up_arrow);
133         panning_down.add (panning_down_arrow);
134         panning_up.set_name (X_("PanScrollerBase"));
135         panning_down.set_name (X_("PanScrollerBase"));
136         panning_up_arrow.set_name (X_("PanScrollerArrow"));
137         panning_down_arrow.set_name (X_("PanScrollerArrow"));
138
139         pan_vbox.set_spacing (4);
140         pan_vbox.pack_start (panning_viewport, Gtk::PACK_SHRINK);
141         pan_vbox.pack_start (*pan_button_hbox, Gtk::PACK_SHRINK);
142
143         pack_start (pan_vbox, true, false);
144
145         panner = 0;
146
147         _io.panner().Changed.connect (mem_fun(*this, &PannerUI::panner_changed));
148         _io.panner().LinkStateChanged.connect (mem_fun(*this, &PannerUI::update_pan_linkage));
149         _io.panner().StateChanged.connect (mem_fun(*this, &PannerUI::update_pan_state));
150
151         pan_changed (0);
152         update_pan_sensitive ();
153         update_pan_linkage ();
154         pan_automation_state_changed ();
155 }
156
157 bool
158 PannerUI::panning_link_button_press (GdkEventButton* ev)
159 {
160         cerr << "link press\n";
161         return true;
162 }
163
164 bool
165 PannerUI::panning_link_button_release (GdkEventButton* ev)
166 {
167         cerr << "link release\n";
168         if (!ignore_toggle) {
169                 _io.panner().set_linked (!_io.panner().linked());
170         }
171         return true;
172 }
173
174 void
175 PannerUI::panning_link_direction_clicked()
176 {
177         switch (_io.panner().link_direction()) {
178         case Panner::SameDirection:
179                 _io.panner().set_link_direction (Panner::OppositeDirection);
180                 break;
181         default:
182                 _io.panner().set_link_direction (Panner::SameDirection);
183                 break;
184         }
185 }
186
187 void
188 PannerUI::update_pan_linkage ()
189 {
190         ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::update_pan_linkage));
191         
192         bool x = _io.panner().linked();
193         bool bx = panning_link_button.get_active();
194         
195         if (x != bx) {
196                 
197                 ignore_toggle = true;
198                 panning_link_button.set_active (x);
199                 ignore_toggle = false;
200         }
201
202         panning_link_direction_button.set_sensitive (x);
203
204         switch (_io.panner().link_direction()) {
205         case Panner::SameDirection:
206                 panning_link_direction_button.set_image (*(manage (new Image (get_xpm ("forwardblarrow.xpm")))));
207                 break;
208         default:
209                 panning_link_direction_button.set_image (*(manage (new Image (get_xpm("revdblarrow.xpm")))));
210                 break;
211         }
212 }
213
214 void
215 PannerUI::set_width (Width w)
216 {
217         switch (w) {
218         case Wide:
219                 panning_viewport.set_size_request (61, 61);
220                 if (panner) {
221                         panner->set_size_request (61, 61);
222                 }
223                 for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
224                                 (*i)->set_size_request (61, 15);
225                 }
226                 panning_link_button.set_label (_("link"));
227                 break;
228         case Narrow:
229                 panning_viewport.set_size_request (31, 61);
230                 if (panner) {
231                         panner->set_size_request (31, 61);
232                 }
233                 for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
234                                 (*i)->set_size_request (31, 15);
235                 }
236                 panning_link_button.set_label (_("L"));
237                 break;
238         }
239
240         _width = w;
241 }
242
243
244 PannerUI::~PannerUI ()
245 {
246         for (vector<Adjustment*>::iterator i = pan_adjustments.begin(); i != pan_adjustments.end(); ++i) {
247                 delete (*i);
248         }
249         
250         for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
251                 delete (*i);
252         }
253
254         if (panner) {
255                 delete panner;
256         }
257
258         if (pan_menu) {
259                 delete pan_menu;
260         }
261
262 }
263
264
265 void
266 PannerUI::panner_changed ()
267 {
268         ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::panner_changed));
269         setup_pan ();
270 }
271
272 void
273 PannerUI::update_pan_state ()
274 {
275         /* currently nothing to do */
276         // ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::update_panner_state));
277 }
278
279 void
280 PannerUI::setup_pan ()
281 {
282         uint32_t nouts = _io.n_outputs ();
283
284         if (nouts == 0 || nouts == 1) {
285
286                 while (!pan_adjustments.empty()) {
287                         delete pan_bars.back();
288                         pan_bars.pop_back ();
289                         delete pan_adjustments.back();
290                         pan_adjustments.pop_back ();
291                 }
292
293         } else if (nouts == 2) {
294
295                 vector<Adjustment*>::size_type asz;
296                 uint32_t npans = _io.panner().size();
297
298                 while (!pan_adjustments.empty()) {
299                         delete pan_bars.back();
300                         pan_bars.pop_back ();
301                         delete pan_adjustments.back();
302                         pan_adjustments.pop_back ();
303                 }
304
305                 while ((asz = pan_adjustments.size()) < npans) {
306
307                         float x;
308                         BarController* bc;
309
310                         /* initialize adjustment with current value of panner */
311
312                         _io.panner()[asz]->get_position (x);
313
314                         pan_adjustments.push_back (new Adjustment (x, 0, 1.0, 0.05, 0.1));
315                         pan_adjustments.back()->signal_value_changed().connect (bind (mem_fun(*this, &PannerUI::pan_adjustment_changed), (uint32_t) asz));
316
317                         _io.panner()[asz]->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz));
318
319                         bc = new BarController (*pan_adjustments[asz], 
320                                                 &_io.panner()[asz]->midi_control(),
321                                                 bind (mem_fun(*this, &PannerUI::pan_printer), pan_adjustments[asz]));
322                         
323                         if (_session.midi_port()) {
324                                 _io.panner()[asz]->reset_midi_control (_session.midi_port(), true);
325                         }
326                         
327                         bc->set_name ("PanSlider");
328                         bc->set_shadow_type (Gtk::SHADOW_NONE);
329                         bc->set_style (BarController::Line);
330
331                         bc->StartGesture.connect (bind (mem_fun (_io, &IO::start_pan_touch), (uint32_t) asz));
332                         bc->StopGesture.connect (bind (mem_fun (_io, &IO::end_pan_touch), (uint32_t) asz));
333
334                         char buf[64];
335 #ifdef __APPLE__
336                         snprintf (buf, sizeof (buf), _("panner for channel %lu"), asz + 1);
337 #else
338                         snprintf (buf, sizeof (buf), _("panner for channel %u"), asz + 1);
339 #endif
340                         ARDOUR_UI::instance()->tooltips().set_tip (bc->event_widget(), buf);
341
342                         bc->event_widget().signal_button_release_event().connect
343                                 (bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz));
344
345                         pan_bars.push_back (bc);
346                         switch (_width) {
347                         case Wide:
348                                 pan_bars.back()->set_size_request (61, 15);
349                                 break;
350                         case Narrow:
351                                 pan_bars.back()->set_size_request (31, 15);
352                                 break;
353                         }
354
355                         pan_bar_packer.pack_start (*pan_bars.back(), false, false);
356                 }
357
358                 /* now that we actually have the pan bars,
359                    set their sensitivity based on current
360                    automation state.
361                 */
362
363                 update_pan_sensitive ();
364
365                 panning_viewport.remove ();
366                 panning_viewport.add (pan_bar_packer);
367                 panning_viewport.show_all ();
368
369         } else {
370
371                 int w = 0;
372
373                 switch (_width) {
374                 case Wide:
375                         w = 61;
376                         break;
377                 case Narrow:
378                         w = 31;
379                         break;
380                 }
381
382                 if (panner == 0) {
383                         panner = new Panner2d (_io.panner(), w, 61);
384                         panner->set_name ("MixerPanZone");
385                         panner->show ();
386                 }
387                 
388                 update_pan_sensitive ();
389                 panner->reset (_io.n_inputs());
390                 panner->set_size_request (w, 61);
391
392                 /* and finally, add it to the panner frame */
393
394                 panning_viewport.remove ();
395                 panning_viewport.add (*panner);
396                 panning_viewport.show_all ();
397         }
398 }
399
400 bool
401 PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which)
402 {
403         switch (ev->button) {
404         case 3:
405                 if (pan_menu == 0) {
406                         pan_menu = manage (new Menu);
407                         pan_menu->set_name ("ArdourContextMenu");
408                 }
409                 build_pan_menu (which);
410                 pan_menu->popup (1, ev->time);
411                 return true;
412                 break;
413         default:
414                 return false;
415         }
416
417         return false; // what's wrong with gcc?
418 }
419
420 void
421 PannerUI::build_pan_menu (uint32_t which)
422 {
423         using namespace Menu_Helpers;
424         MenuList& items (pan_menu->items());
425
426         items.clear ();
427
428         items.push_back (CheckMenuElem (_("Mute")));
429         
430         /* set state first, connect second */
431
432         (dynamic_cast<CheckMenuItem*> (&items.back()))->set_active (_io.panner()[which]->muted());
433         (dynamic_cast<CheckMenuItem*> (&items.back()))->signal_toggled().connect
434                 (bind (mem_fun(*this, &PannerUI::pan_mute), which));
435
436         items.push_back (CheckMenuElem (_("Bypass"), mem_fun(*this, &PannerUI::pan_bypass_toggle)));
437         bypass_menu_item = static_cast<CheckMenuItem*> (&items.back());
438
439         /* set state first, connect second */
440
441         bypass_menu_item->set_active (_io.panner().bypassed());
442         bypass_menu_item->signal_toggled().connect (mem_fun(*this, &PannerUI::pan_bypass_toggle));
443
444         items.push_back (MenuElem (_("Reset"), mem_fun(*this, &PannerUI::pan_reset)));
445         items.push_back (SeparatorElem());
446         items.push_back (MenuElem (_("Reset all")));
447 }
448
449 void
450 PannerUI::pan_mute (uint32_t which)
451 {
452         StreamPanner* sp = _io.panner()[which];
453         sp->set_muted (!sp->muted());
454 }
455
456 void
457 PannerUI::pan_bypass_toggle ()
458 {
459         if (bypass_menu_item && (_io.panner().bypassed() != bypass_menu_item->get_active())) {
460                 _io.panner().set_bypassed (!_io.panner().bypassed());
461         }
462 }
463
464 void
465 PannerUI::pan_reset ()
466 {
467 }
468
469 void
470 PannerUI::effective_pan_display ()
471 {
472         if (_io.panner().empty()) {
473                 return;
474         }
475
476         switch (_io.n_outputs()) {
477         case 0: 
478         case 1:
479                 /* relax */
480                 break;
481
482         case 2:
483                 update_pan_bars (true);
484                 break;
485
486         default:
487                 //panner->move_puck (pan_value (v, right), 0.5);
488                 break;
489         }
490 }
491
492 void
493 PannerUI::pan_changed (void *src)
494 {
495         if (src == this) {
496                 return;
497         }
498
499         switch (_io.panner().size()) {
500         case 0:
501                 panning_link_box.set_sensitive (false);
502                 return;
503         case 1:
504                 panning_link_box.set_sensitive (false);
505                 break;
506         default:
507                 panning_link_box.set_sensitive (true);
508         }
509
510         uint32_t nouts = _io.n_outputs();
511
512         switch (nouts) {
513         case 0:
514         case 1:
515                 /* relax */
516                 break;
517
518         case 2:
519                 update_pan_bars (false);
520                 break;
521
522         default:
523                 // panner->move_puck (pan_value (pans[0], pans[1]), 0.5);
524                 break;
525         }
526 }
527
528 void
529 PannerUI::pan_adjustment_changed (uint32_t which)
530 {
531         if (!in_pan_update && which < _io.panner().size()) {
532
533                 float xpos;
534                 float val = pan_adjustments[which]->get_value ();
535                 _io.panner()[which]->get_position (xpos);
536
537                 /* add a kinda-sorta detent for the middle */
538                 
539                 if (val != 0.5 && Panner::equivalent (val, 0.5)) {
540                         /* this is going to be reentrant, so just 
541                            return after it.
542                         */
543
544                         in_pan_update = true;
545                         pan_adjustments[which]->set_value (0.5);
546                         in_pan_update = false;
547                         return;
548                 }
549                 
550                 if (!Panner::equivalent (val, xpos)) {
551
552                         _io.panner()[which]->set_position (val);
553                         /* XXX 
554                            the panner objects have no access to the session,
555                            so do this here. ick.
556                         */
557                         _session.set_dirty();
558                 }
559         }
560 }
561
562 void
563 PannerUI::pan_value_changed (uint32_t which)
564 {
565         ENSURE_GUI_THREAD (bind (mem_fun(*this, &PannerUI::pan_value_changed), which));
566                                                            
567         if (_io.n_outputs() > 1 && which < _io.panner().size()) {
568                 float xpos;
569                 float val = pan_adjustments[which]->get_value ();
570
571                 _io.panner()[which]->get_position (xpos);
572
573                 if (!Panner::equivalent (val, xpos)) {
574                         in_pan_update = true;
575                         pan_adjustments[which]->set_value (xpos);
576                         in_pan_update = false;
577                 }
578         }
579 }       
580
581 void
582 PannerUI::update_pan_bars (bool only_if_aplay)
583 {
584         uint32_t n;
585         vector<Adjustment*>::iterator i;
586
587         in_pan_update = true;
588
589         /* this runs during automation playback, and moves the bar controllers
590            and/or pucks around.
591         */
592
593         for (i = pan_adjustments.begin(), n = 0; i != pan_adjustments.end(); ++i, ++n) {
594                 float xpos, val;
595
596                 if (only_if_aplay) {
597                         AutomationList& alist (_io.panner()[n]->automation());
598                         
599                         if (!alist.automation_playback()) {
600                                 continue;
601                         }
602                 }
603
604                 _io.panner()[n]->get_effective_position (xpos);
605                 val = (*i)->get_value ();
606                 
607                 if (!Panner::equivalent (val, xpos)) {
608                         (*i)->set_value (xpos);
609                 }
610         }
611
612         in_pan_update = false;
613 }
614
615 void
616 PannerUI::pan_printer (char *buf, uint32_t len, Adjustment* adj)
617 {
618         float val = adj->get_value();
619
620         if (val == 0.0f) {
621                 snprintf (buf, len, X_("L"));
622         } else if (val == 1.0f) {
623                 snprintf (buf, len, X_("R"));
624         } else if (Panner::equivalent (val, 0.5f)) {
625                 snprintf (buf, len, X_("C"));
626         } else {
627                 /* don't print anything */
628                 buf[0] = '\0';
629         }
630 }
631
632 void
633 PannerUI::update_pan_sensitive ()
634 {
635         bool sensitive = !(_io.panner().automation_state() & Play);
636
637         switch (_io.n_outputs()) {
638         case 0:
639         case 1:
640                 break;
641         case 2:
642                 for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
643                         (*i)->set_sensitive (sensitive);
644                 }
645                 break;
646         default:
647                 if (panner) {
648                         panner->set_sensitive (sensitive);
649                 }
650                 break;
651         }
652 }
653
654 gint
655 PannerUI::pan_automation_state_button_event (GdkEventButton *ev)
656 {
657         using namespace Menu_Helpers;
658
659         if (ev->type == GDK_BUTTON_RELEASE) {
660                 return TRUE;
661         }
662
663         switch (ev->button) {
664         case 1:
665                 pan_astate_menu.popup (1, ev->time);
666                 break;
667         default:
668                 break;
669         }
670
671         return TRUE;
672 }
673
674 gint
675 PannerUI::pan_automation_style_button_event (GdkEventButton *ev)
676 {
677         if (ev->type == GDK_BUTTON_RELEASE) {
678                 return TRUE;
679         }
680
681         switch (ev->button) {
682         case 1:
683                 pan_astyle_menu.popup (1, ev->time);
684                 break;
685         default:
686                 break;
687         }
688         return TRUE;
689 }
690
691 void
692 PannerUI::pan_automation_style_changed ()
693 {
694         ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_style_changed));
695         
696         switch (_width) {
697         case Wide:
698                 pan_automation_style_button.set_label (astyle_string(_io.panner().automation_style()));
699                 break;
700         case Narrow:
701                 pan_automation_style_button.set_label (short_astyle_string(_io.panner().automation_style()));
702                 break;
703         }
704 }
705
706 void
707 PannerUI::pan_automation_state_changed ()
708 {
709         ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_state_changed));
710         
711         bool x;
712
713         switch (_width) {
714         case Wide:
715           pan_automation_state_button.set_label (astate_string(_io.panner().automation_state()));
716                 break;
717         case Narrow:
718           pan_automation_state_button.set_label (short_astate_string(_io.panner().automation_state()));
719                 break;
720         }
721
722         /* when creating a new session, we get to create busses (and
723            sometimes tracks) with no outputs by the time they get
724            here.
725         */
726
727         if (_io.panner().empty()) {
728                 return;
729         }
730
731         x = (_io.panner().front()->automation().automation_state() != Off);
732
733         if (pan_automation_state_button.get_active() != x) {
734         ignore_toggle = true;
735                 pan_automation_state_button.set_active (x);
736                 ignore_toggle = false;
737         }
738
739         update_pan_sensitive ();
740
741         /* start watching automation so that things move */
742
743         pan_watching.disconnect();
744
745         if (x) {
746           pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (*this, &PannerUI::effective_pan_display));
747         }
748 }
749
750 string
751 PannerUI::astate_string (AutoState state)
752 {
753         return _astate_string (state, false);
754 }
755
756 string
757 PannerUI::short_astate_string (AutoState state)
758 {
759         return _astate_string (state, true);
760 }
761
762 string
763 PannerUI::_astate_string (AutoState state, bool shrt)
764 {
765         string sstr;
766
767         switch (state) {
768         case Off:
769                 sstr = (shrt ? "O" : _("O"));
770                 break;
771         case Play:
772                 sstr = (shrt ? "P" : _("P"));
773                 break;
774         case Touch:
775                 sstr = (shrt ? "T" : _("T"));
776                 break;
777         case Write:
778                 sstr = (shrt ? "W" : _("W"));
779                 break;
780         }
781
782         return sstr;
783 }
784
785 string
786 PannerUI::astyle_string (AutoStyle style)
787 {
788         return _astyle_string (style, false);
789 }
790
791 string
792 PannerUI::short_astyle_string (AutoStyle style)
793 {
794         return _astyle_string (style, true);
795 }
796
797 string
798 PannerUI::_astyle_string (AutoStyle style, bool shrt)
799 {
800         if (style & Trim) {
801                 return _("Trim");
802         } else {
803                 /* XXX it might different in different languages */
804
805                 return (shrt ? _("Abs") : _("Abs"));
806         }
807 }