fix #1394 - The 'narrow strip' option in the mixer does not take extra width into...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Feb 2007 17:22:47 +0000 (17:22 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Feb 2007 17:22:47 +0000 (17:22 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1526 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_mouse.cc
gtk2_ardour/gain_meter.cc
gtk2_ardour/gain_meter.h
gtk2_ardour/mixer_strip.cc
gtk2_ardour/panner2d.cc
gtk2_ardour/panner2d.h
gtk2_ardour/panner_ui.cc
gtk2_ardour/region_view.cc
gtk2_ardour/region_view.h
libs/gtkmm2ext/fastmeter.cc
libs/gtkmm2ext/gtkmm2ext/fastmeter.h

index 7816aa0125bd3d1dc7b6fd494a51483e69db73fb..93b64afb6efaacfaeb1ed7371b44a97d1adb5fac 100644 (file)
@@ -3321,7 +3321,7 @@ Editor::region_drag_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
                                        }
                                }
                        
-                               rv->region()->set_opaque(false);
+                               rv->fake_set_opaque (false);
                        }
                        
                        if (drag_info.brushing) {
@@ -3431,7 +3431,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
                        TimeAxisView* tvp2 = trackview_by_y_position (iy1);
                        AudioTimeAxisView* atv2 = dynamic_cast<AudioTimeAxisView*>(tvp2);
 
-                       (*i)->region()->set_opaque (true);
+                       (*i)->fake_set_opaque (true);
            
                        from_playlist = (*i)->region()->playlist();
                        to_playlist = atv2->playlist();
@@ -3525,7 +3525,7 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
                        /* no need to add an undo here, we did that when we added this playlist to motion_frozen playlists */
                        
                        rv->region()->set_position (where, (void *) this);
-                       rv->region()->set_opaque (true);
+                       rv->fake_set_opaque (true);
                }
        }
 
@@ -4101,7 +4101,7 @@ Editor::trim_motion_callback (ArdourCanvas::Item* item, GdkEvent* event)
                begin_reversible_command (trim_type);
 
                for (list<RegionView*>::const_iterator i = selection->regions.by_layer().begin(); i != selection->regions.by_layer().end(); ++i) {
-                       (*i)->region()->set_opaque(false);
+                       (*i)->fake_set_opaque(false);
                        (*i)->region()->freeze ();
                
                        AudioRegionView* const arv = dynamic_cast<AudioRegionView*>(*i);
@@ -4296,7 +4296,7 @@ Editor::trim_finished_callback (ArdourCanvas::Item* item, GdkEvent* event)
                             i != selection->regions.by_layer().end(); ++i)
                        {
                                thaw_region_after_trim (**i);
-                               (*i)->region()->set_opaque(true);
+                               (*i)->fake_set_opaque (true);
                        }
                }
                
index fbacc6ae1713176530b1eba40f9e9245d895297c..7778430993c2f0e5439dd4536bf72ff358afb495 100644 (file)
@@ -447,6 +447,14 @@ GainMeter::setup_meters ()
        }
 }      
 
+int
+GainMeter::get_gm_width ()
+{
+       Gtk::Requisition sz;
+       hbox.size_request (sz);
+       return sz.width;
+}
+
 bool
 GainMeter::gain_key_press (GdkEventKey* ev)
 {
index 88105ce846afdd99ede76101053e4523c93d52b3..6990c185b8c996d9a7cb1236335d071256ece2a2 100644 (file)
@@ -70,6 +70,8 @@ class GainMeter : public Gtk::VBox
        void set_width (Width);
        void setup_meters ();
 
+       int get_gm_width ();
+
        void set_meter_strip_name (const char * name);
        void set_fader_name (const char * name);
 
index 5c93882c6db31763dba3b775f6e8f4fe188ba109..70e0a6aa1865f31e1e396a5f5cd42b0215a3e600 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include <cmath>
+#include <algorithm>
 
 #include <sigc++/bind.h>
 
@@ -62,6 +63,7 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
+using namespace std;
 
 int MixerStrip::scrollbar_height = 0;
 
@@ -439,7 +441,6 @@ MixerStrip::set_width (Width w)
                break;
 
        case Narrow:
-               set_size_request (50, -1);
                xml_node->add_property ("strip_width", "narrow");
 
                if (rec_enable_button) {
@@ -461,6 +462,7 @@ MixerStrip::set_width (Width w)
                ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (panners.short_astyle_string(_route->panner().automation_style()));
                ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (panners.short_astate_string(_route->panner().automation_state()));
                Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
+               set_size_request (max (50, gpm.get_gm_width()), -1);
                break;
        }
 
index 2756ba4c670963581bd3c8cd83c1492cea7728b6..34f367b25b1ba978f8c8c996142bcc8b66eb7ffe 100644 (file)
@@ -57,8 +57,8 @@ Panner2d::Target::~Target ()
        }
 }
 
-Panner2d::Panner2d (Panner& p, int32_t w, int32_t h)
-       : panner (p), width (w), height (h)
+Panner2d::Panner2d (Panner& p, int32_t h)
+       : panner (p), width (0), height (h)
 {
        context_menu = 0;
        bypass_menu_item = 0;
index 1bf8879ba5d40e71d23c183db7a468689483875e..d53e50ae08da88ffad6cbd3f37fa59361bd58b5f 100644 (file)
@@ -47,7 +47,7 @@ namespace Pango {
 class Panner2d : public Gtk::DrawingArea
 {
   public:
-       Panner2d (ARDOUR::Panner&, int32_t width, int32_t height);
+       Panner2d (ARDOUR::Panner&, int32_t height);
        ~Panner2d ();
        
        int puck_position (int which_puck, float& x, float& y);
index 72cd24bccee86f3184692100c5fb907e999ccb9d..d65d02f92ef5fddbbe0932d912e23e660f335471 100644 (file)
@@ -73,8 +73,7 @@ PannerUI::PannerUI (boost::shared_ptr<IO> io, Session& s)
        //set_size_request_to_display_given_text (pan_automation_style_button, X_("0"), 2, 2);
 
        pan_bar_packer.set_size_request (-1, 61);
-       panning_viewport.set_size_request (64, 61);
-
+       panning_viewport.set_size_request (-1, 61);
        panning_viewport.set_name (X_("BaseFrame"));
 
        ARDOUR_UI::instance()->tooltips().set_tip (panning_link_button,
@@ -137,7 +136,7 @@ PannerUI::PannerUI (boost::shared_ptr<IO> io, Session& s)
        pan_vbox.pack_start (panning_viewport, Gtk::PACK_SHRINK);
        pan_vbox.pack_start (panning_link_box, Gtk::PACK_SHRINK);
 
-       pack_start (pan_vbox, true, false);
+       pack_start (pan_vbox, true, true);
 
        panner = 0;
 
@@ -215,23 +214,9 @@ PannerUI::set_width (Width w)
 {
        switch (w) {
        case Wide:
-               panning_viewport.set_size_request (64, 61);
-               if (panner) {
-                       panner->set_size_request (63, 61);
-               }
-               for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
-                       (*i)->set_size_request (63, pan_bar_height);
-               }
                panning_link_button.set_label (_("link"));
                break;
        case Narrow:
-               panning_viewport.set_size_request (34, 61);
-               if (panner) {
-                       panner->set_size_request (33, 61);
-               }
-               for (vector<PannerBar*>::iterator i = pan_bars.begin(); i != pan_bars.end(); ++i) {
-                       (*i)->set_size_request (33, pan_bar_height);
-               }
                panning_link_button.set_label (_("L"));
                break;
        }
@@ -344,16 +329,9 @@ PannerUI::setup_pan ()
                        bc->event_widget().signal_button_release_event().connect
                                (bind (mem_fun(*this, &PannerUI::pan_button_event), (uint32_t) asz));
 
-                       pan_bars.push_back (bc);
-                       switch (_width) {
-                       case Wide:
-                               bc->set_size_request (63, pan_bar_height);
-                               break;
-                       case Narrow:
-                               bc->set_size_request (33, pan_bar_height);
-                               break;
-                       }
+                       bc->set_size_request (-1, pan_bar_height);
 
+                       pan_bars.push_back (bc);
                        pan_bar_packer.pack_start (*bc, false, false);
                }
 
@@ -370,26 +348,15 @@ PannerUI::setup_pan ()
 
        } else {
 
-               int w = 0;
-
-               switch (_width) {
-               case Wide:
-                       w = 63;
-                       break;
-               case Narrow:
-                       w = 33;
-                       break;
-               }
-
                if (panner == 0) {
-                       panner = new Panner2d (_io->panner(), w, 61);
+                       panner = new Panner2d (_io->panner(), 61);
                        panner->set_name ("MixerPanZone");
                        panner->show ();
                }
                
                update_pan_sensitive ();
                panner->reset (_io->n_inputs());
-               panner->set_size_request (w, 61);
+               panner->set_size_request (-1, 61);
 
                /* and finally, add it to the panner frame */
 
index e0b6eddb1ff793173860001fe5260bc48bce9609..5e3a6126546f1afca788dd7c51499700b29fb6b8 100644 (file)
@@ -366,6 +366,18 @@ RegionView::set_frame_color ()
        TimeAxisViewItem::set_frame_color ();
 }
 
+void
+RegionView::fake_set_opaque (bool yn)
+{
+       if (yn) {
+               fill_opacity = 130;
+       } else {
+               fill_opacity = 60;
+       }
+
+       TimeAxisViewItem::set_frame_color ();
+}
+
 void
 RegionView::hide_region_editor()
 {
index 9f1f9679355ccaaf7315985a14047f4b7d39e220..b89011e38d67f0992edff8466e4aa44d3c6965b3 100644 (file)
@@ -68,6 +68,7 @@ class RegionView : public TimeAxisViewItem
     void lower_to_bottom ();
 
     bool set_position(nframes_t pos, void* src, double* delta = 0);
+    void fake_set_opaque (bool yn);
 
     virtual void show_region_editor () = 0;
     virtual void hide_region_editor();
@@ -82,7 +83,7 @@ class RegionView : public TimeAxisViewItem
     virtual void entered () {}
     virtual void exited () {}
     
-       static sigc::signal<void,RegionView*> RegionViewGoingAway;
+    static sigc::signal<void,RegionView*> RegionViewGoingAway;
     sigc::signal<void>                    GoingAway;
 
   protected:
index 3c489e08ffbcbb6f3500555b6103afbe4cc28d36..253dad80a24a6206695aa481e689f183d8b3b91c 100644 (file)
@@ -57,11 +57,10 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o)
        pixrect.x = 0;
        pixrect.y = 0;
 
-
        if (orientation == Vertical) {
-               pixbuf = request_vertical_meter(250);
+               pixbuf = request_vertical_meter(dimen, 250);
        } else {
-               pixbuf = request_horizontal_meter(186);
+               pixbuf = request_horizontal_meter(186, dimen);
        }
 
        pixheight = pixbuf->get_height();
@@ -79,14 +78,14 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o)
        request_height= pixrect.height;
 }
 
-Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_vertical_meter(int length)
+Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_vertical_meter(int width, int height)
 {
-       if (length < min_v_pixbuf_size)
-               length = min_v_pixbuf_size;
-       if (length > max_v_pixbuf_size)
-               length = max_v_pixbuf_size;
+       if (height < min_v_pixbuf_size)
+               height = min_v_pixbuf_size;
+       if (height > max_v_pixbuf_size)
+               height = max_v_pixbuf_size;
        
-       int index = length - 1;
+       int index = height - 1;
 
        if (v_pixbuf_cache == 0) {
                v_pixbuf_cache = (Glib::RefPtr<Gdk::Pixbuf>*) malloc(sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size);
@@ -97,8 +96,6 @@ Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_vertical_meter(int length)
                return ret;
 
        guint8* data;
-       int width = 5;
-       int height = length;
 
        data = (guint8*) malloc(width*height * 3);
        
@@ -155,15 +152,15 @@ Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_vertical_meter(int length)
        return ret;
 }
 
-Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_horizontal_meter(int length)
+Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_horizontal_meter(int width, int height)
 {
-       if (length < min_h_pixbuf_size)
-               length = min_h_pixbuf_size;
-       if (length > max_h_pixbuf_size)
-               length = max_h_pixbuf_size;
+       if (width < min_h_pixbuf_size)
+               width = min_h_pixbuf_size;
+       if (width > max_h_pixbuf_size)
+               width = max_h_pixbuf_size;
+       
+       int index = width - 1;
        
-       int index = length - 1;
-
        if (h_pixbuf_cache == 0) {
                h_pixbuf_cache = (Glib::RefPtr<Gdk::Pixbuf>*) malloc(sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_h_pixbuf_size);
                memset(h_pixbuf_cache,0,sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_h_pixbuf_size);
@@ -173,8 +170,6 @@ Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_horizontal_meter(int length)
                return ret;
 
        guint8* data;
-       int width = length;
-       int height = 5;
 
        data = (guint8*) malloc(width*height * 3);
        
@@ -253,19 +248,20 @@ void
 FastMeter::on_size_request (GtkRequisition* req)
 {
        if (orientation == Vertical) {
+
                req->height = request_height;
-               
                req->height = max(req->height, min_v_pixbuf_size);
                req->height = min(req->height, max_v_pixbuf_size);
 
-               req->width  = 5;
-       } else {
                req->width  = request_width;
 
+       } else {
+
+               req->width  = request_width;
                req->width  = max(req->width,  min_h_pixbuf_size);
                req->width  = min(req->width,  max_h_pixbuf_size);
 
-               req->height = 5;
+               req->height = request_height;
        }
 
 }
@@ -274,8 +270,9 @@ void
 FastMeter::on_size_allocate (Gtk::Allocation &alloc)
 {
        if (orientation == Vertical) {
-               if (alloc.get_width() != 5) {
-                       alloc.set_width(5);
+
+               if (alloc.get_width() != request_width) {
+                       alloc.set_width (request_width);
                }
 
                int h = alloc.get_height();
@@ -286,11 +283,13 @@ FastMeter::on_size_allocate (Gtk::Allocation &alloc)
                        alloc.set_height(h);
 
                if (pixheight != h) {
-                       pixbuf = request_vertical_meter(h);
+                       pixbuf = request_vertical_meter(request_width, h);
                }
+
        } else {
-               if (alloc.get_height() != 5) {
-                       alloc.set_height(5);
+
+               if (alloc.get_height() != request_height) {
+                       alloc.set_height(request_height);
                }
 
                int w = alloc.get_width();
@@ -301,7 +300,7 @@ FastMeter::on_size_allocate (Gtk::Allocation &alloc)
                        alloc.set_width(w);
 
                if (pixwidth != w) {
-                       pixbuf = request_horizontal_meter(w);
+                       pixbuf = request_horizontal_meter(w, request_height);
                }
        }
 
index d624f29afb71f9a6ecef012918f87eac9f8af6c1..4ceb38ee096aac3ddf12d92b2f8d1b8fd278b0db 100644 (file)
@@ -70,13 +70,13 @@ class FastMeter : public Gtk::DrawingArea {
        bool vertical_expose (GdkEventExpose*);
        bool horizontal_expose (GdkEventExpose*);
        
-       static Glib::RefPtr<Gdk::Pixbuf> request_vertical_meter(int);
+       static Glib::RefPtr<Gdk::Pixbuf> request_vertical_meter(int w, int h);
 
        static Glib::RefPtr<Gdk::Pixbuf> *v_pixbuf_cache;
        static int min_v_pixbuf_size;
        static int max_v_pixbuf_size;
 
-       static Glib::RefPtr<Gdk::Pixbuf> request_horizontal_meter(int);
+       static Glib::RefPtr<Gdk::Pixbuf> request_horizontal_meter(int w, int h);
 
        static Glib::RefPtr<Gdk::Pixbuf> *h_pixbuf_cache;
        static int min_h_pixbuf_size;