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