Put images on the fade in/out menus. Fixes #3411.
authorCarl Hetherington <carl@carlh.net>
Sun, 19 Sep 2010 03:31:03 +0000 (03:31 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 19 Sep 2010 03:31:03 +0000 (03:31 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7805 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_ops.cc
libs/ardour/ardour/audioregion.h
libs/ardour/ardour/types.h
libs/ardour/audioregion.cc
libs/ardour/enums.cc
libs/ardour/strip_silence.cc

index a91a0572e442ebd2512baa5d75ff911a901eee38..4d3ecb80c8926d21e0f9a4142ee769f92f525c33 100644 (file)
@@ -737,6 +737,8 @@ Editor::Editor ()
 
        constructed = true;
        instant_save ();
+
+       setup_fade_images ();
 }
 
 Editor::~Editor()
@@ -1312,14 +1314,57 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i
                items.push_back (SeparatorElem());
 
                if (Profile->get_sae()) {
-                       items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
-                       items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
+                       
+                       items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeLinear)));
+                       items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeFast)));
+                       
                } else {
-                       items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Linear)));
-                       items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Fast)));
-                       items.push_back (MenuElem (_("Slow"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogB)));
-                       items.push_back (MenuElem (_("Fast"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::LogA)));
-                       items.push_back (MenuElem (_("Fastest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), AudioRegion::Slow)));
+
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Linear"),
+                                       *_fade_in_images[FadeLinear],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeLinear)
+                                       )
+                               );
+
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Slowest"),
+                                       *_fade_in_images[FadeFast],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeFast)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+                       
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Slow"),
+                                       *_fade_in_images[FadeLogB],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeLogB)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+                       
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Fast"),
+                                       *_fade_in_images[FadeLogA],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeLogA)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+                       
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Fastest"),
+                                       *_fade_in_images[FadeSlow],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_in_shape), FadeSlow)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
                }
 
                break;
@@ -1335,14 +1380,55 @@ Editor::popup_fade_context_menu (int button, int32_t time, ArdourCanvas::Item* i
                items.push_back (SeparatorElem());
 
                if (Profile->get_sae()) {
-                       items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
-                       items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
+                       items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeLinear)));
+                       items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeSlow)));
                } else {
-                       items.push_back (MenuElem (_("Linear"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Linear)));
-                       items.push_back (MenuElem (_("Slowest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Slow)));
-                       items.push_back (MenuElem (_("Slow"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogA)));
-                       items.push_back (MenuElem (_("Fast"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::LogB)));
-                       items.push_back (MenuElem (_("Fastest"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), AudioRegion::Fast)));
+
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Linear"),
+                                       *_fade_out_images[FadeLinear],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeLinear)
+                                       )
+                               );
+
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Slowest"),
+                                       *_fade_out_images[FadeFast],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeSlow)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+                       
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Slow"),
+                                       *_fade_out_images[FadeLogB],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeLogA)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+                       
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Fast"),
+                                       *_fade_out_images[FadeLogA],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeLogB)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
+                       
+                       items.push_back (
+                               ImageMenuElem (
+                                       _("Fastest"),
+                                       *_fade_out_images[FadeSlow],
+                                       sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_out_shape), FadeFast)
+                                       ));
+                       
+                       dynamic_cast<ImageMenuItem*>(&items.back())->set_always_show_image ();
                }
 
                break;
@@ -5614,3 +5700,20 @@ Editor::update_region_layering_order_editor (framepos_t frame)
                change_region_layering_order (frame);
        }
 }
+
+void
+Editor::setup_fade_images ()
+{
+       _fade_in_images[FadeLinear] = new Gtk::Image (get_icon_path (X_("crossfade-in-linear")));
+       _fade_in_images[FadeFast] = new Gtk::Image (get_icon_path (X_("crossfade-in-short-cut")));
+       _fade_in_images[FadeLogB] = new Gtk::Image (get_icon_path (X_("crossfade-in-slow-cut")));
+       _fade_in_images[FadeLogA] = new Gtk::Image (get_icon_path (X_("crossfade-in-fast-cut")));
+       _fade_in_images[FadeSlow] = new Gtk::Image (get_icon_path (X_("crossfade-in-long-cut")));
+
+       _fade_out_images[FadeLinear] = new Gtk::Image (get_icon_path (X_("crossfade-out-linear")));
+       _fade_out_images[FadeFast] = new Gtk::Image (get_icon_path (X_("crossfade-out-short-cut")));
+       _fade_out_images[FadeLogB] = new Gtk::Image (get_icon_path (X_("crossfade-out-slow-cut")));
+       _fade_out_images[FadeLogA] = new Gtk::Image (get_icon_path (X_("crossfade-out-fast-cut")));
+       _fade_out_images[FadeSlow] = new Gtk::Image (get_icon_path (X_("crossfade-out-long-cut")));
+}
+
index e47946499df1ab97d30a2e06f471e612a2af31cf..9063599e236f293f059078a6c4c8656c1f685a3b 100644 (file)
@@ -1308,8 +1308,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::Menu fade_context_menu;
        void popup_fade_context_menu (int, int, ArdourCanvas::Item*, ItemType);
 
-       void set_fade_in_shape (ARDOUR::AudioRegion::FadeShape);
-       void set_fade_out_shape (ARDOUR::AudioRegion::FadeShape);
+       void set_fade_in_shape (ARDOUR::FadeShape);
+       void set_fade_out_shape (ARDOUR::FadeShape);
 
        void set_fade_length (bool in);
        void toggle_fade_active (bool in);
@@ -2052,6 +2052,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        */
        bool _block_region_list_update_if_empty;
 
+       void setup_fade_images ();
+       std::map<ARDOUR::FadeShape, Gtk::Image*> _fade_in_images;
+       std::map<ARDOUR::FadeShape, Gtk::Image*> _fade_out_images;
+
        friend class Drag;
        friend class RegionDrag;
        friend class RegionMoveDrag;
index ce9aafb3fb0be6bf50645c774bc43d19710ab6f7..10d8410dad5bf9722eb68f987af71ca747052a48 100644 (file)
@@ -5272,7 +5272,7 @@ Editor::toggle_fade_active (bool in)
 }
 
 void
-Editor::set_fade_in_shape (AudioRegion::FadeShape shape)
+Editor::set_fade_in_shape (FadeShape shape)
 {
        RegionSelection rs;
 
@@ -5305,7 +5305,7 @@ Editor::set_fade_in_shape (AudioRegion::FadeShape shape)
 }
 
 void
-Editor::set_fade_out_shape (AudioRegion::FadeShape shape)
+Editor::set_fade_out_shape (FadeShape shape)
 {
        RegionSelection rs;
 
index b2940822738bfede99086aad9aea1816f2e4bbc2..b919b6572c847ac9964ca7afa70f7cff46887bc7 100644 (file)
@@ -129,14 +129,6 @@ class AudioRegion : public Region
        bool fade_in_is_default () const;
        bool fade_out_is_default () const;
 
-       enum FadeShape {
-               Linear,
-               Fast,
-               Slow,
-               LogA,
-               LogB
-       };
-
        void set_fade_in_active (bool yn);
        void set_fade_in_shape (FadeShape);
        void set_fade_in_length (framecnt_t);
index cc36941ba80c115a2ed466a920f7f0883868f97f..d452cd6b541e2cc8fcc77a9f3b7d1391fc6e09ad 100644 (file)
@@ -495,6 +495,14 @@ namespace ARDOUR {
             uint32_t requested_physical_out; /* now many of the available physical inputs to consider usable */
         };
 
+       enum FadeShape {
+               FadeLinear,
+               FadeFast,
+               FadeSlow,
+               FadeLogA,
+               FadeLogB
+       };
+
 } // namespace ARDOUR
 
 
index 214d31165bc5ccfbd39f7e08a02cc8acf65d94d5..afd4456cdd8124e55e2f6dbdf276fe9aa793780e 100644 (file)
@@ -736,12 +736,12 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
        _fade_in->clear ();
 
        switch (shape) {
-       case Linear:
+       case FadeLinear:
                _fade_in->fast_simple_add (0.0, 0.0);
                _fade_in->fast_simple_add (len, 1.0);
                break;
 
-       case Fast:
+       case FadeFast:
                _fade_in->fast_simple_add (0, 0);
                _fade_in->fast_simple_add (len * 0.389401, 0.0333333);
                _fade_in->fast_simple_add (len * 0.629032, 0.0861111);
@@ -751,7 +751,7 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
                _fade_in->fast_simple_add (len, 1);
                break;
 
-       case Slow:
+       case FadeSlow:
                _fade_in->fast_simple_add (0, 0);
                _fade_in->fast_simple_add (len * 0.0207373, 0.197222);
                _fade_in->fast_simple_add (len * 0.0645161, 0.525);
@@ -762,7 +762,7 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
                _fade_in->fast_simple_add (len, 1);
                break;
 
-       case LogA:
+       case FadeLogA:
                _fade_in->fast_simple_add (0, 0);
                _fade_in->fast_simple_add (len * 0.0737327, 0.308333);
                _fade_in->fast_simple_add (len * 0.246544, 0.658333);
@@ -772,7 +772,7 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
                _fade_in->fast_simple_add (len, 1);
                break;
 
-       case LogB:
+       case FadeLogB:
                _fade_in->fast_simple_add (0, 0);
                _fade_in->fast_simple_add (len * 0.304147, 0.0694444);
                _fade_in->fast_simple_add (len * 0.529954, 0.152778);
@@ -804,7 +804,7 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
        _fade_out->clear ();
 
        switch (shape) {
-       case Fast:
+       case FadeFast:
                _fade_out->fast_simple_add (len * 0, 1);
                _fade_out->fast_simple_add (len * 0.023041, 0.697222);
                _fade_out->fast_simple_add (len * 0.0553,   0.483333);
@@ -814,7 +814,7 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
                _fade_out->fast_simple_add (len * 1, 0);
                break;
 
-       case LogA:
+       case FadeLogA:
                _fade_out->fast_simple_add (len * 0, 1);
                _fade_out->fast_simple_add (len * 0.228111, 0.988889);
                _fade_out->fast_simple_add (len * 0.347926, 0.972222);
@@ -824,7 +824,7 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
                _fade_out->fast_simple_add (len * 1, 0);
                break;
 
-       case Slow:
+       case FadeSlow:
                _fade_out->fast_simple_add (len * 0, 1);
                _fade_out->fast_simple_add (len * 0.305556, 1);
                _fade_out->fast_simple_add (len * 0.548611, 0.991736);
@@ -834,7 +834,7 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
                _fade_out->fast_simple_add (len * 1, 0);
                break;
 
-       case LogB:
+       case FadeLogB:
                _fade_out->fast_simple_add (len * 0, 1);
                _fade_out->fast_simple_add (len * 0.080645, 0.730556);
                _fade_out->fast_simple_add (len * 0.277778, 0.289256);
@@ -843,7 +843,7 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
                _fade_out->fast_simple_add (len * 1, 0);
                break;
 
-       case Linear:
+       case FadeLinear:
                _fade_out->fast_simple_add (len * 0, 1);
                _fade_out->fast_simple_add (len * 1, 0);
                break;
@@ -920,14 +920,14 @@ void
 AudioRegion::set_default_fade_in ()
 {
        _fade_in_suspended = 0;
-       set_fade_in (Linear, 64);
+       set_fade_in (FadeLinear, 64);
 }
 
 void
 AudioRegion::set_default_fade_out ()
 {
        _fade_out_suspended = 0;
-       set_fade_out (Linear, 64);
+       set_fade_out (FadeLinear, 64);
 }
 
 void
index 972ff2efb7ca05d55708f2b801fe87ed8dbc3f48..bde6d7a7fe8b8d6c4908ae6a463fea17b7580051 100644 (file)
@@ -82,7 +82,7 @@ setup_enum_writer ()
        SessionEvent::Type _SessionEvent_Type;
        TimecodeFormat _Session_TimecodeFormat;
        Session::PullupFormat _Session_PullupFormat;
-       AudioRegion::FadeShape _AudioRegion_FadeShape;
+       FadeShape _FadeShape;
        Panner::LinkDirection _Panner_LinkDirection;
        IOChange _IOChange;
        AutomationType _AutomationType;
@@ -387,12 +387,12 @@ setup_enum_writer ()
        REGISTER_CLASS_ENUM (Source, Destructive);
        REGISTER_BITS (_Source_Flag);
 
-       REGISTER_CLASS_ENUM (AudioRegion, Linear);
-       REGISTER_CLASS_ENUM (AudioRegion, Fast);
-       REGISTER_CLASS_ENUM (AudioRegion, Slow);
-       REGISTER_CLASS_ENUM (AudioRegion, LogA);
-       REGISTER_CLASS_ENUM (AudioRegion, LogB);
-       REGISTER (_AudioRegion_FadeShape);
+       REGISTER_ENUM (FadeLinear);
+       REGISTER_ENUM (FadeFast);
+       REGISTER_ENUM (FadeSlow);
+       REGISTER_ENUM (FadeLogA);
+       REGISTER_ENUM (FadeLogB);
+       REGISTER (_FadeShape);
 
        REGISTER_CLASS_ENUM (Diskstream, Recordable);
        REGISTER_CLASS_ENUM (Diskstream, Hidden);
index 21faeded6840e16e3b79efc7f2eaaadd8934f00f..a7d7ab073f5d2ad75a2d7b9447ae74e7d4b1e8b0 100644 (file)
@@ -111,7 +111,7 @@ StripSilence::run (boost::shared_ptr<Region> r)
                                 copy->position() << std::endl;
 
                         copy->set_fade_in_active (true);
-                        copy->set_fade_in (AudioRegion::Linear, _fade_length);
+                        copy->set_fade_in (FadeLinear, _fade_length);
                         results.push_back (copy);
                 }