id_t becomes a fully-fledged object, UUID's used for IDs, generic MIDI now owns bindi...
[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]->control(),
320                                                 bind (mem_fun(*this, &PannerUI::pan_printer), pan_adjustments[asz]));
321                         
322                         bc->set_name ("PanSlider");
323                         bc->set_shadow_type (Gtk::SHADOW_NONE);
324                         bc->set_style (BarController::Line);
325
326                         bc->StartGesture.connect (bind (mem_fun (_io, &IO::start_pan_touch), (uint32_t) asz));
327                         bc->StopGesture.connect (bind (mem_fun (_io, &IO::end_pan_touch), (uint32_t) asz));
328
329                         char buf[64];
330 #ifdef __APPLE__
331                         snprintf (buf, sizeof (buf), _("panner for channel %lu"), asz + 1);
332 #else
333                         snprintf (buf, sizeof (buf), _("panner for channel %u"), asz + 1);
334 #endif
335                         ARDOUR_UI::instance()->tooltips().set_tip (bc->event_widget(), buf);
336
337                         bc->event_widget().signal_button_release_event().connect
338                                 (bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz));
339
340                         pan_bars.push_back (bc);
341                         switch (_width) {
342                         case Wide:
343                                 pan_bars.back()->set_size_request (61, 15);
344                                 break;
345                         case Narrow:
346                                 pan_bars.back()->set_size_request (31, 15);
347                                 break;
348                         }
349
350                         pan_bar_packer.pack_start (*pan_bars.back(), false, false);
351                 }
352
353                 /* now that we actually have the pan bars,
354                    set their sensitivity based on current
355                    automation state.
356                 */
357
358                 update_pan_sensitive ();
359
360                 panning_viewport.remove ();
361                 panning_viewport.add (pan_bar_packer);
362                 panning_viewport.show_all ();
363
364         } else {
365
366                 int w = 0;
367
368                 switch (_width) {
369                 case Wide:
370                         w = 61;
371                         break;
372                 case Narrow:
373                         w = 31;
374                         break;
375                 }
376
377                 if (panner == 0) {
378                         panner = new Panner2d (_io.panner(), w, 61);
379                         panner->set_name ("MixerPanZone");
380                         panner->show ();
381                 }
382                 
383                 update_pan_sensitive ();
384                 panner->reset (_io.n_inputs());
385                 panner->set_size_request (w, 61);
386
387                 /* and finally, add it to the panner frame */
388
389                 panning_viewport.remove ();
390                 panning_viewport.add (*panner);
391                 panning_viewport.show_all ();
392         }
393 }
394
395 bool
396 PannerUI::pan_button_event (GdkEventButton* ev, uint32_t which)
397 {
398         switch (ev->button) {
399         case 3:
400                 if (pan_menu == 0) {
401                         pan_menu = manage (new Menu);
402                         pan_menu->set_name ("ArdourContextMenu");
403                 }
404                 build_pan_menu (which);
405                 pan_menu->popup (1, ev->time);
406                 return true;
407                 break;
408         default:
409                 return false;
410         }
411
412         return false; // what's wrong with gcc?
413 }
414
415 void
416 PannerUI::build_pan_menu (uint32_t which)
417 {
418         using namespace Menu_Helpers;
419         MenuList& items (pan_menu->items());
420
421         items.clear ();
422
423         items.push_back (CheckMenuElem (_("Mute")));
424         
425         /* set state first, connect second */
426
427         (dynamic_cast<CheckMenuItem*> (&items.back()))->set_active (_io.panner()[which]->muted());
428         (dynamic_cast<CheckMenuItem*> (&items.back()))->signal_toggled().connect
429                 (bind (mem_fun(*this, &PannerUI::pan_mute), which));
430
431         items.push_back (CheckMenuElem (_("Bypass"), mem_fun(*this, &PannerUI::pan_bypass_toggle)));
432         bypass_menu_item = static_cast<CheckMenuItem*> (&items.back());
433
434         /* set state first, connect second */
435
436         bypass_menu_item->set_active (_io.panner().bypassed());
437         bypass_menu_item->signal_toggled().connect (mem_fun(*this, &PannerUI::pan_bypass_toggle));
438
439         items.push_back (MenuElem (_("Reset"), mem_fun(*this, &PannerUI::pan_reset)));
440         items.push_back (SeparatorElem());
441         items.push_back (MenuElem (_("Reset all")));
442 }
443
444 void
445 PannerUI::pan_mute (uint32_t which)
446 {
447         StreamPanner* sp = _io.panner()[which];
448         sp->set_muted (!sp->muted());
449 }
450
451 void
452 PannerUI::pan_bypass_toggle ()
453 {
454         if (bypass_menu_item && (_io.panner().bypassed() != bypass_menu_item->get_active())) {
455                 _io.panner().set_bypassed (!_io.panner().bypassed());
456         }
457 }
458
459 void
460 PannerUI::pan_reset ()
461 {
462 }
463
464 void
465 PannerUI::effective_pan_display ()
466 {
467         if (_io.panner().empty()) {
468                 return;
469         }
470
471         switch (_io.n_outputs()) {
472         case 0: 
473         case 1:
474                 /* relax */
475                 break;
476
477         case 2:
478                 update_pan_bars (true);
479                 break;
480
481         default:
482                 //panner->move_puck (pan_value (v, right), 0.5);
483                 break;
484         }
485 }
486
487 void
488 PannerUI::pan_changed (void *src)
489 {
490         if (src == this) {
491                 return;
492         }
493
494         switch (_io.panner().size()) {
495         case 0:
496                 panning_link_direction_button.set_sensitive (false);
497                 panning_link_button.set_sensitive (false);
498                 return;
499         case 1:
500                 panning_link_direction_button.set_sensitive (false);
501                 panning_link_button.set_sensitive (false);
502                 break;
503         default:
504                 panning_link_direction_button.set_sensitive (true);
505                 panning_link_button.set_sensitive (true);
506         }
507
508         uint32_t nouts = _io.n_outputs();
509
510         switch (nouts) {
511         case 0:
512         case 1:
513                 /* relax */
514                 break;
515
516         case 2:
517                 update_pan_bars (false);
518                 break;
519
520         default:
521                 // panner->move_puck (pan_value (pans[0], pans[1]), 0.5);
522                 break;
523         }
524 }
525
526 void
527 PannerUI::pan_adjustment_changed (uint32_t which)
528 {
529         if (!in_pan_update && which < _io.panner().size()) {
530
531                 float xpos;
532                 float val = pan_adjustments[which]->get_value ();
533                 _io.panner()[which]->get_position (xpos);
534
535                 /* add a kinda-sorta detent for the middle */
536                 
537                 if (val != 0.5 && Panner::equivalent (val, 0.5)) {
538                         /* this is going to be reentrant, so just 
539                            return after it.
540                         */
541
542                         in_pan_update = true;
543                         pan_adjustments[which]->set_value (0.5);
544                         in_pan_update = false;
545                         return;
546                 }
547                 
548                 if (!Panner::equivalent (val, xpos)) {
549
550                         _io.panner()[which]->set_position (val);
551                         /* XXX 
552                            the panner objects have no access to the session,
553                            so do this here. ick.
554                         */
555                         _session.set_dirty();
556                 }
557         }
558 }
559
560 void
561 PannerUI::pan_value_changed (uint32_t which)
562 {
563         ENSURE_GUI_THREAD (bind (mem_fun(*this, &PannerUI::pan_value_changed), which));
564                                                            
565         if (_io.n_outputs() > 1 && which < _io.panner().size()) {
566                 float xpos;
567                 float val = pan_adjustments[which]->get_value ();
568
569                 _io.panner()[which]->get_position (xpos);
570
571                 if (!Panner::equivalent (val, xpos)) {
572                         in_pan_update = true;
573                         pan_adjustments[which]->set_value (xpos);
574                         in_pan_update = false;
575                 }
576         }
577 }       
578
579 void
580 PannerUI::update_pan_bars (bool only_if_aplay)
581 {
582         uint32_t n;
583         vector<Adjustment*>::iterator i;
584
585         in_pan_update = true;
586
587         /* this runs during automation playback, and moves the bar controllers
588            and/or pucks around.
589         */
590
591         for (i = pan_adjustments.begin(), n = 0; i != pan_adjustments.end(); ++i, ++n) {
592                 float xpos, val;
593
594                 if (only_if_aplay) {
595                         AutomationList& alist (_io.panner()[n]->automation());
596                         
597                         if (!alist.automation_playback()) {
598                                 continue;
599                         }
600                 }
601
602                 _io.panner()[n]->get_effective_position (xpos);
603                 val = (*i)->get_value ();
604                 
605                 if (!Panner::equivalent (val, xpos)) {
606                         (*i)->set_value (xpos);
607                 }
608         }
609
610         in_pan_update = false;
611 }
612
613 void
614 PannerUI::pan_printer (char *buf, uint32_t len, Adjustment* adj)
615 {
616         float val = adj->get_value();
617
618         if (val == 0.0f) {
619                 snprintf (buf, len, X_("L"));
620         } else if (val == 1.0f) {
621                 snprintf (buf, len, X_("R"));
622         } else if (Panner::equivalent (val, 0.5f)) {
623                 snprintf (buf, len, X_("C"));
624         } else {
625                 /* don't print anything */
626                 buf[0] = '\0';
627         }
628 }
629
630 void
631 PannerUI::update_pan_sensitive ()
632 {
633         bool sensitive = !(_io.panner().automation_state() & Play);
634
635         switch (_io.n_outputs()) {
636         case 0:
637         case 1:
638                 break;
639         case 2:
640                 for (vector<BarController*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
641                         (*i)->set_sensitive (sensitive);
642                 }
643                 break;
644         default:
645                 if (panner) {
646                         panner->set_sensitive (sensitive);
647                 }
648                 break;
649         }
650 }
651
652 gint
653 PannerUI::pan_automation_state_button_event (GdkEventButton *ev)
654 {
655         using namespace Menu_Helpers;
656
657         if (ev->type == GDK_BUTTON_RELEASE) {
658                 return TRUE;
659         }
660
661         switch (ev->button) {
662         case 1:
663                 pan_astate_menu.popup (1, ev->time);
664                 break;
665         default:
666                 break;
667         }
668
669         return TRUE;
670 }
671
672 gint
673 PannerUI::pan_automation_style_button_event (GdkEventButton *ev)
674 {
675         if (ev->type == GDK_BUTTON_RELEASE) {
676                 return TRUE;
677         }
678
679         switch (ev->button) {
680         case 1:
681                 pan_astyle_menu.popup (1, ev->time);
682                 break;
683         default:
684                 break;
685         }
686         return TRUE;
687 }
688
689 void
690 PannerUI::pan_automation_style_changed ()
691 {
692         ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_style_changed));
693         
694         switch (_width) {
695         case Wide:
696                 pan_automation_style_button.set_label (astyle_string(_io.panner().automation_style()));
697                 break;
698         case Narrow:
699                 pan_automation_style_button.set_label (short_astyle_string(_io.panner().automation_style()));
700                 break;
701         }
702 }
703
704 void
705 PannerUI::pan_automation_state_changed ()
706 {
707         ENSURE_GUI_THREAD(mem_fun(*this, &PannerUI::pan_automation_state_changed));
708         
709         bool x;
710
711         switch (_width) {
712         case Wide:
713           pan_automation_state_button.set_label (astate_string(_io.panner().automation_state()));
714                 break;
715         case Narrow:
716           pan_automation_state_button.set_label (short_astate_string(_io.panner().automation_state()));
717                 break;
718         }
719
720         /* when creating a new session, we get to create busses (and
721            sometimes tracks) with no outputs by the time they get
722            here.
723         */
724
725         if (_io.panner().empty()) {
726                 return;
727         }
728
729         x = (_io.panner().front()->automation().automation_state() != Off);
730
731         if (pan_automation_state_button.get_active() != x) {
732         ignore_toggle = true;
733                 pan_automation_state_button.set_active (x);
734                 ignore_toggle = false;
735         }
736
737         update_pan_sensitive ();
738
739         /* start watching automation so that things move */
740
741         pan_watching.disconnect();
742
743         if (x) {
744           pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (*this, &PannerUI::effective_pan_display));
745         }
746 }
747
748 string
749 PannerUI::astate_string (AutoState state)
750 {
751         return _astate_string (state, false);
752 }
753
754 string
755 PannerUI::short_astate_string (AutoState state)
756 {
757         return _astate_string (state, true);
758 }
759
760 string
761 PannerUI::_astate_string (AutoState state, bool shrt)
762 {
763         string sstr;
764
765         switch (state) {
766         case Off:
767                 sstr = (shrt ? "O" : _("O"));
768                 break;
769         case Play:
770                 sstr = (shrt ? "P" : _("P"));
771                 break;
772         case Touch:
773                 sstr = (shrt ? "T" : _("T"));
774                 break;
775         case Write:
776                 sstr = (shrt ? "W" : _("W"));
777                 break;
778         }
779
780         return sstr;
781 }
782
783 string
784 PannerUI::astyle_string (AutoStyle style)
785 {
786         return _astyle_string (style, false);
787 }
788
789 string
790 PannerUI::short_astyle_string (AutoStyle style)
791 {
792         return _astyle_string (style, true);
793 }
794
795 string
796 PannerUI::_astyle_string (AutoStyle style, bool shrt)
797 {
798         if (style & Trim) {
799                 return _("Trim");
800         } else {
801                 /* XXX it might different in different languages */
802
803                 return (shrt ? _("Abs") : _("Abs"));
804         }
805 }