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