mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-27 06:08:37 -05:00
Carry / preset mute state; mute button visual tweaks
This commit is contained in:
parent
8b5500fc9b
commit
03c8619c5a
@ -115,6 +115,8 @@ AppFrame::AppFrame() :
|
||||
|
||||
demodMuteButton = new ModeSelectorCanvas(this, attribList);
|
||||
demodMuteButton->addChoice(1, "M");
|
||||
demodMuteButton->setPadding(-1,-1);
|
||||
demodMuteButton->setHighlightColor(RGBA4f(0.8,0.2,0.2));
|
||||
demodMuteButton->setHelpTip("Demodulator Mute Toggle");
|
||||
demodMuteButton->setToggleMode(true);
|
||||
|
||||
@ -492,6 +494,7 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
wxGetApp().setFrequency(100000000);
|
||||
wxGetApp().getDemodMgr().setLastDemodulatorType(DEMOD_TYPE_FM);
|
||||
demodModeSelector->setSelection(1);
|
||||
wxGetApp().getDemodMgr().setLastMuted(false);
|
||||
wxGetApp().getDemodMgr().setLastStereo(false);
|
||||
wxGetApp().getDemodMgr().setLastBandwidth(DEFAULT_DEMOD_BW);
|
||||
wxGetApp().getDemodMgr().setLastGain(1.0);
|
||||
@ -716,12 +719,15 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
} else if (!demod->isMuted() && muteMode == 1) {
|
||||
demod->setMuted(true);
|
||||
}
|
||||
wxGetApp().getDemodMgr().setLastMuted(demod->isMuted());
|
||||
demodMuteButton->clearModeChanged();
|
||||
} else {
|
||||
if (demod->isMuted() && muteMode == -1) {
|
||||
demodMuteButton->setSelection(1);
|
||||
wxGetApp().getDemodMgr().setLastMuted(demod->isMuted());
|
||||
} else if (!demod->isMuted() && muteMode == 1) {
|
||||
demodMuteButton->setSelection(-1);
|
||||
wxGetApp().getDemodMgr().setLastMuted(demod->isMuted());
|
||||
}
|
||||
}
|
||||
|
||||
@ -762,6 +768,15 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||
}
|
||||
if (demodMuteButton->modeChanged()) {
|
||||
int muteMode = demodMuteButton->getSelection();
|
||||
if (muteMode == -1) {
|
||||
wxGetApp().getDemodMgr().setLastMuted(false);
|
||||
} else if (muteMode == 1) {
|
||||
wxGetApp().getDemodMgr().setLastMuted(true);
|
||||
}
|
||||
demodMuteButton->clearModeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
if (demodTuner->getMouseTracker()->mouseInView()) {
|
||||
|
@ -223,3 +223,12 @@ void DemodulatorMgr::setLastStereo(bool lastStereo) {
|
||||
this->lastStereo = lastStereo;
|
||||
}
|
||||
|
||||
|
||||
bool DemodulatorMgr::isLastMuted() const {
|
||||
return lastMuted;
|
||||
}
|
||||
|
||||
void DemodulatorMgr::setLastMuted(bool lastMuted) {
|
||||
this->lastMuted = lastMuted;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,9 @@ public:
|
||||
bool isLastStereo() const;
|
||||
void setLastStereo(bool lastStereo);
|
||||
|
||||
bool isLastMuted() const;
|
||||
void setLastMuted(bool lastMuted);
|
||||
|
||||
private:
|
||||
void garbageCollect();
|
||||
void updateLastState();
|
||||
@ -55,5 +58,5 @@ private:
|
||||
bool lastSquelchEnabled;
|
||||
float lastSquelch;
|
||||
float lastGain;
|
||||
bool lastStereo;
|
||||
bool lastStereo, lastMuted;
|
||||
};
|
||||
|
@ -25,9 +25,11 @@ EVT_ENTER_WINDOW(ModeSelectorCanvas::OnMouseEnterWindow)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
ModeSelectorCanvas::ModeSelectorCanvas(wxWindow *parent, int *attribList) :
|
||||
InteractiveCanvas(parent, attribList), numChoices(0), currentSelection(-1), toggleMode(false), inputChanged(false) {
|
||||
InteractiveCanvas(parent, attribList), numChoices(0), currentSelection(-1), toggleMode(false), inputChanged(false), padX(4.0), padY(4.0), highlightOverride(false) {
|
||||
|
||||
glContext = new ModeSelectorContext(this, &wxGetApp().GetContext(this));
|
||||
|
||||
highlightColor = RGBA4f(1.0,1.0,1.0,1.0);
|
||||
}
|
||||
|
||||
ModeSelectorCanvas::~ModeSelectorCanvas() {
|
||||
@ -59,10 +61,15 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||
int yval = getHoveredSelection();
|
||||
|
||||
for (int i = 0; i < numChoices; i++) {
|
||||
if (yval == i) {
|
||||
glContext->DrawSelector(selections[i].label, i, numChoices, true, ThemeMgr::mgr.currentTheme->buttonHighlight.r, ThemeMgr::mgr.currentTheme->buttonHighlight.g, ThemeMgr::mgr.currentTheme->buttonHighlight.b, 1.0);
|
||||
if (yval == i && !highlightOverride) {
|
||||
RGBA4f hc = ThemeMgr::mgr.currentTheme->buttonHighlight;
|
||||
glContext->DrawSelector(selections[i].label, i, numChoices, true, hc.r, hc.g, hc.b, 1.0, padX, padY);
|
||||
} else {
|
||||
glContext->DrawSelector(selections[i].label, i, numChoices, i == currentSelection, ThemeMgr::mgr.currentTheme->button.r, ThemeMgr::mgr.currentTheme->button.g, ThemeMgr::mgr.currentTheme->button.b, 1.0);
|
||||
RGBA4f hc = ThemeMgr::mgr.currentTheme->button;
|
||||
if (highlightOverride) {
|
||||
hc = highlightColor;
|
||||
}
|
||||
glContext->DrawSelector(selections[i].label, i, numChoices, i == currentSelection, hc.r, hc.g, hc.b, 1.0, padX, padY);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +119,7 @@ void ModeSelectorCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
|
||||
currentSelection = selectedButton;
|
||||
|
||||
SetCursor (wxCURSOR_ARROW);
|
||||
SetCursor (wxCURSOR_HAND);
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
@ -123,7 +130,7 @@ void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
|
||||
void ModeSelectorCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
|
||||
SetCursor (wxCURSOR_ARROW);
|
||||
SetCursor (wxCURSOR_HAND);
|
||||
if (!helpTip.empty()) {
|
||||
setStatusText(helpTip);
|
||||
}
|
||||
@ -171,3 +178,12 @@ void ModeSelectorCanvas::clearModeChanged() {
|
||||
inputChanged = false;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setPadding(float padX, float padY) {
|
||||
this->padX = padX;
|
||||
this->padY = padY;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setHighlightColor(RGBA4f hc) {
|
||||
this->highlightColor = hc;
|
||||
this->highlightOverride = true;
|
||||
}
|
||||
|
@ -40,6 +40,9 @@ public:
|
||||
bool modeChanged();
|
||||
void clearModeChanged();
|
||||
|
||||
void setPadding(float padX, float padY);
|
||||
void setHighlightColor(RGBA4f hc);
|
||||
|
||||
private:
|
||||
void setNumChoices(int numChoices_in);
|
||||
|
||||
@ -61,6 +64,9 @@ private:
|
||||
bool toggleMode;
|
||||
bool inputChanged;
|
||||
std::vector<ModeSelectorMode> selections;
|
||||
float padX, padY;
|
||||
RGBA4f highlightColor;
|
||||
bool highlightOverride;
|
||||
//
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
@ -22,7 +22,7 @@ void ModeSelectorContext::DrawBegin() {
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a) {
|
||||
void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a, float px, float py) {
|
||||
GLint vp[4];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
|
||||
@ -42,15 +42,21 @@ void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool
|
||||
|
||||
float y = 1.0 - ((float) (c+1) / (float) cMax * 2.0);
|
||||
float height = (2.0 / (float) cMax);
|
||||
float padX = (4.0 / viewWidth);
|
||||
float padY = (4.0 / viewHeight);
|
||||
float padX = (px / viewWidth);
|
||||
float padY = (py / viewHeight);
|
||||
|
||||
if (a < 1.0) {
|
||||
glEnable(GL_BLEND);
|
||||
}
|
||||
glBegin(on?GL_QUADS:GL_LINE_LOOP);
|
||||
glVertex2f(-1.0 + padX, y + padY);
|
||||
glVertex2f(1.0 - padX, y + padY);
|
||||
glVertex2f(1.0 - padX, y + height - padY);
|
||||
glVertex2f(-1.0 + padX, y + height - padY);
|
||||
glEnd();
|
||||
if (a < 1.0) {
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
if (on) {
|
||||
glColor4f(0, 0, 0, a);
|
||||
|
@ -12,6 +12,6 @@ public:
|
||||
ModeSelectorContext(ModeSelectorCanvas *canvas, wxGLContext *sharedContext);
|
||||
|
||||
void DrawBegin();
|
||||
void DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a);
|
||||
void DrawSelector(std::string label, int c, int cMax, bool on, float r, float g, float b, float a, float padx, float pady);
|
||||
void DrawEnd();
|
||||
};
|
||||
|
@ -612,6 +612,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
demod->setSquelchEnabled(mgr->isLastSquelchEnabled());
|
||||
demod->setStereo(mgr->isLastStereo());
|
||||
demod->setGain(mgr->getLastGain());
|
||||
demod->setMuted(mgr->isLastMuted());
|
||||
|
||||
demod->run();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user