diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2007-02-27 17:22:47 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2007-02-27 17:22:47 +0000 |
commit | e1957a31666ad1a23fa0df3f32e2d6910a3abe64 (patch) | |
tree | d63acb69d3f91a8e9896670976e3a7890ceb81e9 /libs/gtkmm2ext | |
parent | ad55d36c560ddb48b50343e334802b9e051d9992 (diff) |
fix #1394 - The 'narrow strip' option in the mixer does not take extra width into account; involved some nice cleanup of width handling in mixer strips etc.
git-svn-id: svn://localhost/ardour2/trunk@1526 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/fastmeter.cc | 59 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/fastmeter.h | 4 |
2 files changed, 31 insertions, 32 deletions
diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc index 3c489e08ff..253dad80a2 100644 --- a/libs/gtkmm2ext/fastmeter.cc +++ b/libs/gtkmm2ext/fastmeter.cc @@ -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); } } diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index d624f29afb..4ceb38ee09 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -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; |