Fixed some valgrind errors from using uninitialized variables in
[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         set_width(Narrow);
148
149         _io.panner().Changed.connect (mem_fun(*this, &PannerUI::panner_changed));
150         _io.panner().LinkStateChanged.connect (mem_fun(*this, &PannerUI::update_pan_linkage));
151         _io.panner().StateChanged.connect (mem_fun(*this, &PannerUI::update_pan_state));
152
153         pan_changed (0);
154         update_pan_sensitive ();
155         update_pan_linkage ();
156         pan_automation_state_changed ();
157 }
158
159 bool
160 PannerUI::panning_link_button_press (GdkEventButton* ev)
161 {
162         cerr << "link press\n";
163         return true;
164 }
165
166 bool
167 PannerUI::panning_link_button_release (GdkEventButton* ev)
168 {
169         cerr << "link release\n";
170         if (!ignore_toggle) {
171                 _io.panner().set_linked (!_io.panner().linked());
172         }
173         return true;
174 }
175
176 void
177 PannerUI::panning_link_direction_clicked()
178 {
179         switch (_io.panner().link_direction()) {
180         case Panner::SameDirection:
181                 _io.panner().set_link_direction (Panner::OppositeDirection);
182                 break;
183         default:
184                 _io.panner().set_link_direction (Panner::SameDirection);
185                 break;
186         }
187 }
188
189 void
190 PannerUI::update_pan_linkage ()
191 {
192         ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::update_pan_linkage));
193         
194         bool x = _io.panner().linked();
195         bool bx = panning_link_button.get_active();
196         
197         if (x != bx) {
198                 
199                 ignore_toggle = true;
200                 panning_link_button.set_active (x);
201                 ignore_toggle = false;
202         }
203
204         panning_link_direction_button.set_sensitive (x);
205
206         switch (_io.panner().link_direction()) {
207         case Panner::SameDirection:
208                 panning_link_direction_button.set_image (*(manage (new Image (get_xpm ("forwardblarrow.xpm")))));
209                 break;
210         default:
211                 panning_link_direction_button.set_image (*(manage (new Image (get_xpm("revdblarrow.xpm")))));
212                 break;
213         }
214 }
215
216 void
217 PannerUI::set_width (Width w)
218 {
219         switch (w) {
220         case Wide:
221                 panning_viewport.set_size_request (61, 61);
222                 if (panner) {
223                         panner->set_size_request (61, 61);
224                 }
225                 for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
226                                 (*i)->set_size_request (61, 15);
227                 }
228                 panning_link_button.set_label (_("link"));
229                 break;
230         case Narrow:
231                 panning_viewport.set_size_request (31, 61);
232                 if (panner) {
233                         panner->set_size_request (31, 61);
234                 }
235                 for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
236                                 (*i)->set_size_request (31, 15);
237                 }
238                 panning_link_button.set_label (_("L"));
239                 break;
240         }
241
242         _width = w;
243 }
244
245
246 PannerUI::~PannerUI ()
247 {
248         for (vector<Adjustment*>::iterator i = pan_adjustments.begin(); i != pan_adjustments.end(); ++i) {
249                 delete (*i);
250         }
251         
252         for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
253                 delete (*i);
254         }
255
256         if (panner) {
257                 delete panner;
258         }
259
260         if (pan_menu) {
261                 delete pan_menu;
262         }
263
264 }
265
266
267 void
268 PannerUI::panner_changed ()
269 {
270         ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::panner_changed));
271         setup_pan ();
272 }
273
274 void
275 PannerUI::update_pan_state ()
276 {
277         /* currently nothing to do */
278         // ENSURE_GUI_THREAD (mem_fun(*this, &PannerUI::update_panner_state));
279 }
280
281 void
282 PannerUI::setup_pan ()
283 {
284         uint32_t nouts = _io.n_outputs ();
285
286         if (nouts == 0 || nouts == 1) {
287
288                 while (!pan_adjustments.empty()) {
289                         delete pan_bars.back();
290                         pan_bars.pop_back ();
291                         delete pan_adjustments.back();
292                         pan_adjustments.pop_back ();
293                 }
294
295         } else if (nouts == 2) {
296
297                 vector<Adjustment*>::size_type asz;
298                 uint32_t npans = _io.panner().size();
299
300                 while (!pan_adjustments.empty()) {
301                         delete pan_bars.back();
302                         pan_bars.pop_back ();
303                         delete pan_adjustments.back();
304                         pan_adjustments.pop_back ();
305                 }
306
307                 while ((asz = pan_adjustments.size()) < npans) {
308
309                         float x;
310                         BarController* bc;
311
312                         /* initialize adjustment with current value of panner */
313
314                         _io.panner()[asz]->get_position (x);
315
316                         pan_adjustments.push_back (new Adjustment (x, 0, 1.0, 0.05, 0.1));
317                         pan_adjustments.back()->signal_value_changed().connect (bind (mem_fun(*this, &PannerUI::pan_adjustment_changed), (uint32_t) asz));
318
319                         _io.panner()[asz]->Changed.connect (bind (mem_fun(*this, &PannerUI::pan_value_changed), (uint32_t) asz));
320
321                         bc = new BarController (*pan_adjustments[asz], 
322                                                 &_io.panner()[asz]->midi_control(),
323                                                 bind (mem_fun(*this, &PannerUI::pan_printer), pan_adjustments[asz]));
324                         
325                         if (_session.midi_port()) {
326                                 _io.panner()[asz]->reset_midi_control (_session.midi_port(), true);
327                         }
328                         
329                         bc->set_name ("PanSlider");
330                         bc->set_shadow_type (Gtk::SHADOW_NONE);
331                         bc->set_style (BarController::Line);
332
333                         bc->StartGesture.connect (bind (mem_fun (_io, &IO::start_pan_touch), (uint32_t) asz));
334                         bc->StopGesture.connect (bind (mem_fun (_io, &IO::end_pan_touch), (uint32_t) asz));
335
336                         char buf[64];
337 #ifdef __APPLE__
338                         snprintf (buf, sizeof (buf), _("panner for channel %lu"), asz + 1);
339 #else
340                         snprintf (buf, sizeof (buf), _("panner for channel %u"), asz + 1);
341 #endif
342                         ARDOUR_UI::instance()->tooltips().set_tip (bc->event_widget(), buf);
343
344                         bc->event_widget().signal_button_release_event().connect
345                                 (bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz));
346
347                         pan_bars.push_back (bc);
348                         switch (_width) {
349                         case Wide:
350                                 pan_bars.back()->set_size_request (61, 15);
351                                 break;
352                         case Narrow:
353                                 pan_bars.back()->set_size_request (31, 15);
354                                 break;
355                         }
356
357                         pan_bar_packer.pack_start (*pan_bars.back(), false, false);
358                 }
359
360                 /* now that we actually have the pan bars,
361                    set their sensitivity based on current
362                    automation state.
363                 */
364
365                 update_pan_sensitive ();
366
367                 panning_viewport.remove ();
368                 panning_viewport.add (pan_bar_packer);
369                 panning_viewport.show_all ();
370
371         } else {
372
373                 int w = 0;
374
375                 switch (_width) {
376                 case Wide:
377                         w = 61;
378                         break;
379                 case Narrow:
380                         w = 31;
381                         break;
382                 }
383
384                 if (panner == 0) {
385                         panner = new Panner2d (_io.panner(), w, 61);
386                         panner->set_name ("MixerPanZone");
387                         panner->show ();
388                 }
389                 
390                 update_pan_sensitive ();
391                 panner->reset (_io.n_inputs());
392                 panner->set_size_request (w, 61);
393
394                 /* and finally, add it to the panner frame */
395
396                 panning_viewport.remove ();
397                 panning_viewport.add (*panner);
398                 panning_viewport.show_all ();
399         }
400 }
401
402 bool
403 PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which)
404 {
405         switch (ev->button) {
406         case 3:
407                 if (pan_menu == 0) {
408                         pan_menu = manage (new Menu);
409                         pan_menu->set_name ("ArdourContextMenu");
410                 }
411                 build_pan_menu (which);
412                 pan_menu->popup (1, ev->time);
413                 return true;
414                 break;
415         default:
416                 return false;
417         }
418
419         return false; // what's wrong with gcc?
420 }
421
422 void
423 PannerUI::build_pan_menu (uint32_t which)
424 {
425         using namespace Menu_Helpers;
426         MenuList& items (pan_menu->items());
427
428         items.clear ();
429
430         items.push_back (CheckMenuElem (_("Mute")));
431         
432         /* set state first, connect second */
433
434         (dynamic_cast<CheckMenuItem*> (&items.back()))->set_active (_io.panner()[which]->muted());
435         (dynamic_cast<CheckMenuItem*> (&items.back()))->signal_toggled().connect
436                 (bind (mem_fun(*this, &PannerUI::pan_mute), which));
437
438         items.push_back (CheckMenuElem (_("Bypass"), mem_fun(*this, &PannerUI::pan_bypass_toggle)));
439         bypass_menu_item = static_cast<CheckMenuItem*> (&items.back());
440
441         /* set state first, connect second */
442
443         bypass_menu_item->set_active (_io.panner().bypassed());
444         bypass_menu_item->signal_toggled().connect (mem_fun(*this, &PannerUI::pan_bypass_toggle));
445
446         items.push_back (MenuElem (_("Reset"), mem_fun(*this, &PannerUI::pan_reset)));
447         items.push_back (SeparatorElem());
448         items.push_back (MenuElem (_("Reset all")));
449 }
450
451 void
452 PannerUI::pan_mute (uint32_t which)
453 {
454         StreamPanner* sp = _io.panner()[which];
455         sp->set_muted (!sp->muted());
456 }
457
458 void
459 PannerUI::pan_bypass_toggle ()
460 {
461         if (bypass_menu_item && (_io.panner().bypassed() != bypass_menu_item->get_active())) {
462                 _io.panner().set_bypassed (!_io.panner().bypassed());
463         }
464 }
465
466 void
467 PannerUI::pan_reset ()
468 {
469 }
470
471 void
472 PannerUI::effective_pan_display ()
473 {
474         if (_io.panner().empty()) {
475                 return;
476         }
477
478         switch (_io.n_outputs()) {
479         case 0: 
480         case 1:
481                 /* relax */
482                 break;
483
484         case 2:
485                 update_pan_bars (true);
486                 break;
487
488         default:
489                 //panner->move_puck (pan_value (v, right), 0.5);
490                 break;
491         }
492 }
493
494 void
495 PannerUI::pan_changed (void *src)
496 {
497         if (src == this) {
498                 return;
499         }
500
501         switch (_io.panner().size()) {
502         case 0:
503                 panning_link_box.set_sensitive (false);
504                 return;
505         case 1:
506                 panning_link_box.set_sensitive (false);
507                 break;
508         default:
509                 panning_link_box.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 }