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