MISC2: Position labels better according to font scale (working this time)

This commit is contained in:
vsonnier 2017-02-13 18:37:40 +01:00
parent 2b0a2822a7
commit 977ffa3e3d
2 changed files with 9 additions and 29 deletions

View File

@ -393,29 +393,18 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBA4f color, long
//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;
}
double heightShift = GLFont::getScaleFactor();
//demodulator user label if present: type is displayed above the label, which is at the bottom of the screen.
if (!demod->getDemodulatorUserLabel().empty()) {
hPos += heightShiftFactor * labelHeight;
drawSingleDemodLabel(demodStr.ToStdWstring(), uxPos, hPos * 1.2 + hPos * 1.2 * heightShift, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER);
drawSingleDemodLabel(demod->getDemodulatorUserLabel(), uxPos, hPos * 1.2, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER);
}
drawSingleDemodLabel(demodStr.ToStdWstring(), uxPos, hPos, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER);
//revert...
if (!demod->getDemodulatorUserLabel().empty()) {
hPos -= heightShiftFactor * labelHeight;
drawSingleDemodLabel(demod->getDemodulatorUserLabel(), uxPos, hPos, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER);
else {
drawSingleDemodLabel(demodStr.ToStdWstring(), uxPos, hPos * 1.2, xOfs, yOfs, GLFont::GLFONT_ALIGN_CENTER);
}
glDisable(GL_BLEND);
}
void PrimaryGLContext::drawSingleDemodLabel(const std::wstring& demodStr, float uxPos, float hPos, float xOfs, float yOfs, GLFont::Align demodAlign) {
@ -423,14 +412,10 @@ void PrimaryGLContext::drawSingleDemodLabel(const std::wstring& demodStr, float
GLFont::Drawer refDrawingFont = GLFont::getFont(16, GLFont::getScaleFactor());
glColor3f(0, 0, 0);
refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs,
-1.0 + hPos - yOfs, demodAlign,
GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs, -1.0 + hPos - yOfs, demodAlign, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
glColor3f(1, 1, 1);
refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5),
-1.0 + hPos, demodAlign,
GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5), -1.0 + hPos, demodAlign, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
}
void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long long /* center_freq */, long long srate) {

View File

@ -41,13 +41,8 @@ void ScopeContext::DrawTunerTitles(bool ppmMode) {
GLFont::Drawer refDrawingFont = GLFont::getFont(12, GLFont::getScaleFactor());
//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;
}
double shiftFactor = GLFont::getScaleFactor();
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);