mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-02-03 09:44:26 -05:00
Fade out the obscuring demodulator overlay when mouse out of view
This commit is contained in:
parent
b8fd786c47
commit
92870c2957
@ -50,7 +50,7 @@ void PrimaryGLContext::CheckGLError() {
|
||||
}
|
||||
|
||||
PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContext) :
|
||||
wxGLContext(canvas, sharedContext) {
|
||||
wxGLContext(canvas, sharedContext), hoverAlpha(1.0) {
|
||||
//#ifndef __linux__
|
||||
// SetCurrent(*canvas);
|
||||
// // Pre-load fonts
|
||||
@ -214,7 +214,7 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBColor color, lon
|
||||
glEnd();
|
||||
|
||||
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);
|
||||
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();
|
||||
}
|
||||
|
||||
void PrimaryGLContext::setHoverAlpha(float hoverAlpha) {
|
||||
this->hoverAlpha = hoverAlpha;
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ public:
|
||||
|
||||
static GLFont &getFont(GLFontSize esize);
|
||||
|
||||
void setHoverAlpha(float hoverAlpha);
|
||||
|
||||
private:
|
||||
static GLFont fonts[GLFONT_MAX];
|
||||
DemodulatorThreadParameters defaultDemodParams;
|
||||
float hoverAlpha;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@ wxEND_EVENT_TABLE()
|
||||
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
|
||||
InteractiveCanvas(parent, attribList), spectrumCanvas(NULL), dragState(WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), fft_size(0), waterfall_lines(
|
||||
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));
|
||||
|
||||
@ -142,6 +142,11 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
int last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();
|
||||
|
||||
if (mouseTracker.mouseInView()) {
|
||||
hoverAlpha += (1.0f-hoverAlpha)*0.1f;
|
||||
if (hoverAlpha > 1.5f) {
|
||||
hoverAlpha = 1.5f;
|
||||
}
|
||||
glContext->setHoverAlpha(hoverAlpha);
|
||||
if (nextDragState == WF_DRAG_RANGE) {
|
||||
float width = (1.0 / (float) ClientSize.x);
|
||||
float rangeWidth = mouseTracker.getOriginDeltaMouseX();
|
||||
@ -175,6 +180,11 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
hoverAlpha += (0.0f-hoverAlpha)*0.05f;
|
||||
if (hoverAlpha < 1.0e-5f) {
|
||||
hoverAlpha = 0;
|
||||
}
|
||||
glContext->setHoverAlpha(hoverAlpha);
|
||||
if (activeDemodulator) {
|
||||
glContext->DrawDemod(activeDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
|
||||
}
|
||||
@ -182,6 +192,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
glContext->DrawDemod(lastActiveDemodulator, currentTheme->waterfallHighlight, currentCenterFreq, currentBandwidth);
|
||||
}
|
||||
}
|
||||
std::cout<<hoverAlpha<<std::endl;
|
||||
|
||||
for (int i = 0, iMax = demods.size(); i < iMax; i++) {
|
||||
if (activeDemodulator == demods[i] || lastActiveDemodulator == demods[i]) {
|
||||
|
@ -82,6 +82,7 @@ private:
|
||||
|
||||
int lastInputBandwidth;
|
||||
float mouseZoom, zoom;
|
||||
float hoverAlpha;
|
||||
|
||||
std::vector<liquid_float_complex> shiftBuffer;
|
||||
std::vector<liquid_float_complex> resampleBuffer;
|
||||
|
Loading…
Reference in New Issue
Block a user