summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Daniel <cd@maintech.de>2013-09-27 21:40:01 +0200
committerChristian Daniel <cd@maintech.de>2013-09-27 21:40:01 +0200
commitc71160cf9b60f49f3fa382f9674674e3c0bf6aeb (patch)
tree766c765f0a11a17f2dc74558cfc4a1d4514e9cad
parent710be6e71904f311996e5f9167bdf2d0b1f145d7 (diff)
GLSpectrum: only show channels when mouse pointer is inside widget
-rw-r--r--include-gpl/gui/glspectrum.h4
-rw-r--r--sdrbase/gui/glspectrum.cpp97
2 files changed, 62 insertions, 39 deletions
diff --git a/include-gpl/gui/glspectrum.h b/include-gpl/gui/glspectrum.h
index cbe22a9..794780b 100644
--- a/include-gpl/gui/glspectrum.h
+++ b/include-gpl/gui/glspectrum.h
@@ -75,6 +75,7 @@ private:
QTimer m_timer;
QMutex m_mutex;
+ bool m_mouseInside;
bool m_changesPending;
qint64 m_centerFrequency;
@@ -144,6 +145,9 @@ private:
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
+ void enterEvent(QEvent* event);
+ void leaveEvent(QEvent* event);
+
private slots:
void tick();
void channelMarkerChanged();
diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp
index b365bbe..4352c2c 100644
--- a/sdrbase/gui/glspectrum.cpp
+++ b/sdrbase/gui/glspectrum.cpp
@@ -22,6 +22,7 @@
GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent),
m_cursorState(CSNormal),
+ m_mouseInside(false),
m_changesPending(true),
m_centerFrequency(100000000),
m_referenceLevel(0),
@@ -459,23 +460,25 @@ void GLSpectrum::paintGL()
glDisable(GL_TEXTURE_2D);
// paint channels
- for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
- ChannelMarkerState* dv = m_channelMarkerStates[i];
- if(dv->m_channelMarker->getVisible()) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.15f);
- glPushMatrix();
- glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
- glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
- glBegin(GL_QUADS);
- glVertex2f(0, 0);
- glVertex2f(1, 0);
- glVertex2f(1, 1);
- glVertex2f(0, 1);
- glEnd();
- glDisable(GL_BLEND);
- glPopMatrix();
+ if(m_mouseInside) {
+ for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
+ ChannelMarkerState* dv = m_channelMarkerStates[i];
+ if(dv->m_channelMarker->getVisible()) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.15f);
+ glPushMatrix();
+ glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
+ glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
+ glBegin(GL_QUADS);
+ glVertex2f(0, 0);
+ glVertex2f(1, 0);
+ glVertex2f(1, 1);
+ glVertex2f(0, 1);
+ glEnd();
+ glDisable(GL_BLEND);
+ glPopMatrix();
+ }
}
}
@@ -537,28 +540,30 @@ void GLSpectrum::paintGL()
}
// paint channels
- for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
- ChannelMarkerState* dv = m_channelMarkerStates[i];
- if(dv->m_channelMarker->getVisible()) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.15f);
- glPushMatrix();
- glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
- glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
- glBegin(GL_QUADS);
- glVertex2f(0, 0);
- glVertex2f(1, 0);
- glVertex2f(1, 1);
- glVertex2f(0, 1);
- glEnd();
- glDisable(GL_BLEND);
- glColor3f(0.8f, 0.8f, 0.6f);
- glBegin(GL_LINE_LOOP);
- glVertex2f(0.5, 0);
- glVertex2f(0.5, 1);
- glEnd();
- glPopMatrix();
+ if(m_mouseInside) {
+ for(int i = 0; i < m_channelMarkerStates.size(); ++i) {
+ ChannelMarkerState* dv = m_channelMarkerStates[i];
+ if(dv->m_channelMarker->getVisible()) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(dv->m_channelMarker->getColor().redF(), dv->m_channelMarker->getColor().greenF(), dv->m_channelMarker->getColor().blueF(), 0.15f);
+ glPushMatrix();
+ glTranslatef(dv->m_glRect.x(), dv->m_glRect.y(), 0);
+ glScalef(dv->m_glRect.width(), dv->m_glRect.height(), 1);
+ glBegin(GL_QUADS);
+ glVertex2f(0, 0);
+ glVertex2f(1, 0);
+ glVertex2f(1, 1);
+ glVertex2f(0, 1);
+ glEnd();
+ glDisable(GL_BLEND);
+ glColor3f(0.8f, 0.8f, 0.6f);
+ glBegin(GL_LINE_LOOP);
+ glVertex2f(0.5, 0);
+ glVertex2f(0.5, 1);
+ glEnd();
+ glPopMatrix();
+ }
}
}
@@ -1239,6 +1244,20 @@ void GLSpectrum::mouseReleaseEvent(QMouseEvent*)
}
}
+void GLSpectrum::enterEvent(QEvent* event)
+{
+ m_mouseInside = true;
+ update();
+ QGLWidget::enterEvent(event);
+}
+
+void GLSpectrum::leaveEvent(QEvent* event)
+{
+ m_mouseInside = false;
+ update();
+ QGLWidget::enterEvent(event);
+}
+
void GLSpectrum::tick()
{
if(m_displayChanged) {