mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-05 15:35:01 -04:00
Add mute button and 'M' to toggle mute on waterfall hover
This commit is contained in:
@@ -25,7 +25,7 @@ EVT_ENTER_WINDOW(ModeSelectorCanvas::OnMouseEnterWindow)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
ModeSelectorCanvas::ModeSelectorCanvas(wxWindow *parent, int *attribList) :
|
||||
InteractiveCanvas(parent, attribList), numChoices(0), currentSelection(-1) {
|
||||
InteractiveCanvas(parent, attribList), numChoices(0), currentSelection(-1), toggleMode(false), inputChanged(false) {
|
||||
|
||||
glContext = new ModeSelectorContext(this, &wxGetApp().GetContext(this));
|
||||
}
|
||||
@@ -97,10 +97,21 @@ void ModeSelectorCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
|
||||
const wxSize ClientSize = GetClientSize();
|
||||
|
||||
int selectedButton = currentSelection;
|
||||
if (mouseTracker.getOriginDeltaMouseX() < 2.0 / ClientSize.y) {
|
||||
currentSelection = getHoveredSelection();
|
||||
selectedButton = getHoveredSelection();
|
||||
}
|
||||
|
||||
if (toggleMode && (currentSelection == selectedButton)) {
|
||||
selectedButton = -1;
|
||||
}
|
||||
|
||||
if (currentSelection != selectedButton) {
|
||||
inputChanged = true;
|
||||
}
|
||||
|
||||
currentSelection = selectedButton;
|
||||
|
||||
SetCursor (wxCURSOR_ARROW);
|
||||
}
|
||||
|
||||
@@ -148,4 +159,15 @@ int ModeSelectorCanvas::getSelection() {
|
||||
return selections[currentSelection].value;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::setToggleMode(bool toggleMode) {
|
||||
this->toggleMode = toggleMode;
|
||||
}
|
||||
|
||||
bool ModeSelectorCanvas::modeChanged() {
|
||||
return inputChanged;
|
||||
}
|
||||
|
||||
void ModeSelectorCanvas::clearModeChanged() {
|
||||
inputChanged = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,11 @@ public:
|
||||
void setSelection(int value);
|
||||
int getSelection();
|
||||
|
||||
void setToggleMode(bool toggleMode);
|
||||
|
||||
bool modeChanged();
|
||||
void clearModeChanged();
|
||||
|
||||
private:
|
||||
void setNumChoices(int numChoices_in);
|
||||
|
||||
@@ -53,6 +58,8 @@ private:
|
||||
std::string helpTip;
|
||||
int numChoices;
|
||||
int currentSelection;
|
||||
bool toggleMode;
|
||||
bool inputChanged;
|
||||
std::vector<ModeSelectorMode> selections;
|
||||
//
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
||||
@@ -94,7 +94,12 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGB3f color, lo
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glColor4f(0, 0, 0, 0.35);
|
||||
if (demod->isMuted()) {
|
||||
glColor4f(0.8, 0, 0, 0.35);
|
||||
} else {
|
||||
glColor4f(0, 0, 0, 0.35);
|
||||
}
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glVertex3f(uxPos - ofsLeft, hPos + labelHeight, 0.0);
|
||||
glVertex3f(uxPos - ofsLeft, -1.0, 0.0);
|
||||
@@ -128,12 +133,18 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGB3f color, lo
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 0.8);
|
||||
|
||||
std::string demodLabel = demod->getLabel();
|
||||
|
||||
if (demod->isMuted()) {
|
||||
demodLabel.append("[M]");
|
||||
}
|
||||
|
||||
if (demod->getDemodulatorType() == DEMOD_TYPE_USB) {
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demod->getLabel(), uxPos, hPos, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
} else if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) {
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demod->getLabel(), uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
} else {
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demod->getLabel(), uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@@ -230,7 +241,11 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGB3f color, long l
|
||||
glColor3f(0, 0, 0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs, -1.0 + hPos - yOfs, 16, demodAlign,
|
||||
GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor3f(0.8, 0.8, 0.8);
|
||||
if (demod->isMuted()) {
|
||||
glColor3f(0.8, 0.2, 0.2);
|
||||
} else {
|
||||
glColor3f(0.8, 0.2, 0.2);
|
||||
}
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5), -1.0 + hPos, 16, demodAlign, GLFont::GLFONT_ALIGN_CENTER);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
@@ -322,6 +322,12 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
|
||||
wxGetApp().removeDemodulator(activeDemod);
|
||||
wxGetApp().getDemodMgr().deleteThread(activeDemod);
|
||||
break;
|
||||
case 'M':
|
||||
if (!activeDemod) {
|
||||
break;
|
||||
}
|
||||
activeDemod->setMuted(!activeDemod->isMuted());
|
||||
break;
|
||||
case 'S':
|
||||
if (!activeDemod) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user