From 2b0a2822a7a7869d331f8a0e8beba87cc03d47a2 Mon Sep 17 00:00:00 2001 From: vsonnier Date: Sun, 12 Feb 2017 22:26:40 +0100 Subject: [PATCH] MISC: Position labels better according to font scale --- src/visual/PrimaryGLContext.cpp | 14 ++++++++++++-- src/visual/ScopeContext.cpp | 14 +++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/visual/PrimaryGLContext.cpp b/src/visual/PrimaryGLContext.cpp index cc58c77..50e1fdf 100644 --- a/src/visual/PrimaryGLContext.cpp +++ b/src/visual/PrimaryGLContext.cpp @@ -391,16 +391,26 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBA4f color, long // demodStr = demodStr + " UnLock"; // } + //Shift the user label from the modem label more for the bigger + //font sizes so they do not step on each other... + double heightShiftFactor = 1.3; + + if (GLFont::getScale() == GLFont::GLFONT_SCALE_MEDIUM) { + heightShiftFactor = 1.7; + } else if (GLFont::getScale() == GLFont::GLFONT_SCALE_LARGE) { + heightShiftFactor = 2.3; + } + //demodulator user label if present: type is displayed above the label, which is at the bottom of the screen. if (!demod->getDemodulatorUserLabel().empty()) { - hPos += 1.3 * labelHeight; + hPos += heightShiftFactor * labelHeight; } drawSingleDemodLabel(demodStr.ToStdWstring(), uxPos, hPos, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER); //revert... if (!demod->getDemodulatorUserLabel().empty()) { - hPos -= 1.3 * labelHeight; + hPos -= heightShiftFactor * labelHeight; drawSingleDemodLabel(demod->getDemodulatorUserLabel(), uxPos, hPos, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER); } diff --git a/src/visual/ScopeContext.cpp b/src/visual/ScopeContext.cpp index 0e86d9b..98a1707 100644 --- a/src/visual/ScopeContext.cpp +++ b/src/visual/ScopeContext.cpp @@ -40,9 +40,17 @@ void ScopeContext::DrawTunerTitles(bool ppmMode) { GLFont::Drawer refDrawingFont = GLFont::getFont(12, GLFont::getScaleFactor()); - refDrawingFont.drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); - refDrawingFont.drawString("Bandwidth", 0.0, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); - refDrawingFont.drawString("Center Frequency", 0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); + //better position frequency/bandwith labels according to font scale + double shiftFactor = 1.0; + if (GLFont::getScaleFactor() == GLFont::GLFONT_SCALE_MEDIUM) { + shiftFactor = 1.5; + } else if (GLFont::getScaleFactor() == GLFont::GLFONT_SCALE_LARGE) { + shiftFactor = 2.0; + } + + refDrawingFont.drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); + refDrawingFont.drawString("Bandwidth", 0.0, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); + refDrawingFont.drawString("Center Frequency", 0.66f, -1.0 +hPos*shiftFactor, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true); } void ScopeContext::DrawDeviceName(std::string deviceName) {