Fade out the obscuring demodulator overlay when mouse out of view

This commit is contained in:
Charles J. Cliffe 2015-03-06 21:11:14 -05:00
parent b8fd786c47
commit 92870c2957
4 changed files with 21 additions and 3 deletions

View File

@ -50,7 +50,7 @@ void PrimaryGLContext::CheckGLError() {
} }
PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContext) : PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContext) :
wxGLContext(canvas, sharedContext) { wxGLContext(canvas, sharedContext), hoverAlpha(1.0) {
//#ifndef __linux__ //#ifndef __linux__
// SetCurrent(*canvas); // SetCurrent(*canvas);
// // Pre-load fonts // // Pre-load fonts
@ -214,7 +214,7 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
glEnd(); glEnd();
glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f(color.r, color.g, color.b, 0.2); glColor4f(color.r, color.g, color.b, 0.2*hoverAlpha);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex3f((uxPos - 0.5) * 2.0 - ofsLeft, 1.0, 0.0); glVertex3f((uxPos - 0.5) * 2.0 - ofsLeft, 1.0, 0.0);
glVertex3f((uxPos - 0.5) * 2.0 - ofsLeft, -1.0, 0.0); glVertex3f((uxPos - 0.5) * 2.0 - ofsLeft, -1.0, 0.0);
@ -374,3 +374,6 @@ void PrimaryGLContext::EndDraw() {
CheckGLError(); CheckGLError();
} }
void PrimaryGLContext::setHoverAlpha(float hoverAlpha) {
this->hoverAlpha = hoverAlpha;
}

View File

@ -31,7 +31,10 @@ public:
static GLFont &getFont(GLFontSize esize); static GLFont &getFont(GLFontSize esize);
void setHoverAlpha(float hoverAlpha);
private: private:
static GLFont fonts[GLFONT_MAX]; static GLFont fonts[GLFONT_MAX];
DemodulatorThreadParameters defaultDemodParams; DemodulatorThreadParameters defaultDemodParams;
float hoverAlpha;
}; };

View File

@ -36,7 +36,7 @@ wxEND_EVENT_TABLE()
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) : WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines( InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(
0), plan( 0), plan(
NULL), in(NULL), out(NULL), resampler(NULL), resamplerRatio(0), lastInputBandwidth(0), zoom(1), mouseZoom(1), otherWaterfallCanvas(NULL), polling(true), last_data_size(0), fft_in_data(NULL), fft_last_data(NULL) { NULL), in(NULL), out(NULL), resampler(NULL), resamplerRatio(0), lastInputBandwidth(0), zoom(1), mouseZoom(1), otherWaterfallCanvas(NULL), polling(true), last_data_size(0), fft_in_data(NULL), fft_last_data(NULL), hoverAlpha(1.0) {
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this)); glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
@ -142,6 +142,11 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();
if (mouseTracker.mouseInView()) { if (mouseTracker.mouseInView()) {
hoverAlpha += (1.0f-hoverAlpha)*0.1f;
if (hoverAlpha > 1.5f) {
hoverAlpha = 1.5f;
}
glContext->setHoverAlpha(hoverAlpha);
if (nextDragState == WF_DRAG_RANGE) { if (nextDragState == WF_DRAG_RANGE) {
float width = (1.0 / (float) ClientSize.x); float width = (1.0 / (float) ClientSize.x);
float rangeWidth = mouseTracker.getOriginDeltaMouseX(); float rangeWidth = mouseTracker.getOriginDeltaMouseX();
@ -175,6 +180,11 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} }
} }
} else { } else {
hoverAlpha += (0.0f-hoverAlpha)*0.05f;
if (hoverAlpha < 1.0e-5f) {
hoverAlpha = 0;
}
glContext->setHoverAlpha(hoverAlpha);
if (activeDemodulator) { if (activeDemodulator) {
glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
} }
@ -182,6 +192,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->DrawDemod(lastActiveDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth); glContext->DrawDemod(lastActiveDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
} }
} }
std::cout<<hoverAlpha<<std::endl;
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (int i = 0, iMax = demods.size(); i < iMax; i++) {
if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) { if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) {

View File

@ -82,6 +82,7 @@ private:
int lastInputBandwidth; int lastInputBandwidth;
float mouseZoom, zoom; float mouseZoom, zoom;
float hoverAlpha;
std::vector<liquid_float_complex> shiftBuffer; std::vector<liquid_float_complex> shiftBuffer;
std::vector<liquid_float_complex> resampleBuffer; std::vector<liquid_float_complex> resampleBuffer;