diff widgets/LEDButton.cpp @ 33:651e4e868bcc

* Implement play mute, level and pan controls and a layer visibility control * Handle swapping the buffers in AudioCallbackPlaySource more gracefully, so that in many cases it can be done inaudibly. Still gets it wrong when playing in a noncontiguous selection. * Fix to SV file save for non-2d sparse models * Fixes to LED button drawing and AudioDial mouse functionality * Add progress bar for Ogg file import * Reshuffle PropertyContainer and its subclasses so it can be a QObject * Add layer dormancy (invisible layer permitted to free its cache space) * Optimisations to SpectrogramLayer, removing locks when reading/writing individual pixels in the cache (should be unnecessary there) -- there's still an issue here as we need a lock when reading from the model in case the model is replaced, and we don't currently have one * Several munlock() calls to make it harder to exhaust real memory if running in an RT mode with mlockall() active
author Chris Cannam
date Fri, 17 Feb 2006 18:04:26 +0000
parents c53b949ef142
children c43f2c4f66f2
line wrap: on
line diff
--- a/widgets/LEDButton.cpp	Wed Feb 15 17:58:35 2006 +0000
+++ b/widgets/LEDButton.cpp	Fri Feb 17 18:04:26 2006 +0000
@@ -22,6 +22,7 @@
 #include <QPainter>
 #include <QImage>
 #include <QColor>
+#include <QMouseEvent>
 
 
 class LEDButton::LEDButtonPrivate
@@ -84,6 +85,15 @@
 }
 
 void
+LEDButton::mousePressEvent(QMouseEvent *e)
+{
+    if (e->buttons() & Qt::LeftButton) {
+	toggle();
+	emit stateChanged(state());
+    }
+}
+
+void
 LEDButton::paintEvent(QPaintEvent *)
 {
     QPainter paint;
@@ -125,7 +135,7 @@
 	    }
 	}
 
-	scale = 3;
+	scale = 1;
 	width *= scale;
 
 	tmpMap = new QPixmap(width, width);
@@ -136,7 +146,7 @@
 	paint.begin(this);
     }
 
-    paint.setRenderHint(QPainter::Antialiasing, false);
+    paint.setRenderHint(QPainter::Antialiasing, true);
 
     // Set the color of the LED according to given parameters
     color = (led_state) ? led_color : d->offcolor;
@@ -187,7 +197,8 @@
     // around the LED which resembles a shadow with light coming
     // from the upper left.
 
-    pen.setWidth( 2 * scale + 1 ); // ### shouldn't this value be smaller for smaller LEDs?
+//    pen.setWidth( 2 * scale + 1 ); // ### shouldn't this value be smaller for smaller LEDs?
+    pen.setWidth(2 * scale);
     brush.setStyle(Qt::NoBrush);
     paint.setBrush(brush); // This avoids filling of the ellipse
 
@@ -201,8 +212,8 @@
 	pen.setColor(color);
 	paint.setPen(pen);
 	int w = width - pen.width()/2 - scale + 1;
-	paint.drawArc(pen.width()/2, pen.width()/2, w, w, angle + arc, 240);
-	paint.drawArc(pen.width()/2, pen.width()/2, w, w, angle - arc, 240);
+	paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle + arc, 240);
+	paint.drawArc(pen.width()/2 + 1, pen.width()/2 + 1, w - 2, w - 2, angle - arc, 240);
 	color = color.dark(110); //FIXME: this should somehow use the contrast value
     }	// end for ( angle = 720; angle < 6480; angle += 160 )
 
@@ -213,11 +224,12 @@
     if (smooth) {
 	QPixmap *&dest = led_state ? d->on_map : d->off_map;
 	QImage i = tmpMap->toImage();
-	width /= 3;
-	i = i.scaled(width, width, 
-		     Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+	width /= scale;
 	delete tmpMap;
-	dest = new QPixmap(QPixmap::fromImage(i));
+	dest = new QPixmap(QPixmap::fromImage
+			   (i.scaled(width, width, 
+				     Qt::KeepAspectRatio,
+				     Qt::SmoothTransformation)));
 	paint.begin(this);
 	paint.drawPixmap(0, 0, *dest);
 	paint.end();
@@ -305,12 +317,12 @@
 QSize
 LEDButton::sizeHint() const
 {
-    return QSize(16, 16);
+    return QSize(17, 17);
 }
 
 QSize
 LEDButton::minimumSizeHint() const
 {
-    return QSize(16, 16 );
+    return QSize(17, 17);
 }