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