#include <iostream>
+#include "pbd/stacktrace.h"
+
#include "gtkmm2ext/pixfader.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/rgb_macros.h"
float radius = CORNER_RADIUS;
double w = get_width();
+
+ if (w <= 1 || get_height() <= 1) {
+ return;
+ }
if ((pattern = find_pattern (fr, fg, fb, br, bg, bb, get_width(), get_height())) != 0) {
/* found it - use it */
Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context();
cairo_t* cr = context->cobj();
- cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
- cairo_clip (cr);
-
if (!pattern) {
create_patterns();
}
-
+
+ if (!pattern) {
+
+ /* this isn't supposed to be happen, but some wackiness whereby
+ the pixfader ends up with a 1xN or Nx1 size allocation
+ leads to it. the basic wackiness needs fixing but we
+ shouldn't crash. just fill in the expose area with
+ our bg color.
+ */
+
+ Gdk::Color c = get_style()->get_bg (get_state());
+ float br, bg, bb;
+
+ br = c.get_red_p ();
+ bg = c.get_green_p ();
+ bb = c.get_blue_p ();
+ cairo_set_source_rgb (cr, br, bg, bb);
+ cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
+ cairo_fill (cr);
+
+ return true;
+ }
+
+ cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
+ cairo_clip (cr);
+
int ds = display_span ();
float w = get_width();
float h = get_height();
}
}
}
-
- if ( !_text.empty() ) {
- cairo_new_path (cr);
+ if ( !_text.empty() ) {
/* center text */
+ cairo_new_path (cr);
cairo_move_to (cr, (get_width() - _text_width)/2.0, get_height()/2.0 - _text_height/2.0);
cairo_set_source_rgba (cr, text_r, text_g, text_b, 0.9);
pango_cairo_show_layout (cr, _layout->gobj());
PixFader::on_size_request (GtkRequisition* req)
{
if (_orien == VERT) {
- req->width = girth;
- req->height = span;
+ req->width = (girth ? girth : -1);
+ req->height = (span ? span : -1);
} else {
- req->height = girth;
- req->width = span;
+ req->height = (girth ? girth : -1);
+ req->width = (span ? span : -1);
}
}
span = alloc.get_width ();
}
- update_unity_position ();
-
if (is_realized()) {
- create_patterns();
- queue_draw ();
+ /* recreate patterns in case we've changed size */
+ create_patterns ();
}
+
+ update_unity_position ();
}
bool
return ds;
}
-void
-PixFader::set_fader_length (int l)
-{
- span = l;
- update_unity_position ();
- queue_resize ();
-}
-
void
PixFader::update_unity_position ()
{
Widget::on_state_changed (old_state);
create_patterns ();
}
+
+void
+PixFader::on_style_changed (const Glib::RefPtr<Gtk::Style>&)
+{
+ if (_layout) {
+ std::string txt = _layout->get_text();
+ _layout.clear (); // drop reference to existing layout
+ set_text (txt);
+ }
+
+ /* remember that all patterns are cached and not owned by an individual
+ pixfader. we will lazily create a new pattern when needed.
+ */
+
+ pattern = 0;
+}