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