mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-06 07:07:48 -04:00
Make GLFont its own pixHeight, so don't provide it in drawString() anymore
This commit is contained in:
parent
26bf1d9927
commit
f52bad6196
@ -214,11 +214,10 @@ void SpectrumPanel::drawPanelContents() {
|
||||
double hPos = 1.0 - (16.0 / viewHeight);
|
||||
double lMhzPos = 1.0 - (5.0 / viewHeight);
|
||||
|
||||
int fontSize = 12;
|
||||
GLFont::GLFontSize fontEnumSize = GLFont::GLFONT_SIZE12;
|
||||
|
||||
if (viewHeight > 135) {
|
||||
fontSize = 16;
|
||||
|
||||
fontEnumSize = GLFont::GLFONT_SIZE16;
|
||||
hPos = 1.0 - (18.0 / viewHeight);
|
||||
}
|
||||
@ -254,7 +253,7 @@ void SpectrumPanel::drawPanelContents() {
|
||||
|
||||
glColor4f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b,1.0);
|
||||
|
||||
GLFont::getFont(fontEnumSize).drawString(label.str(), m, hPos, fontSize, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(fontEnumSize).drawString(label.str(), m, hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
|
||||
label.str(std::string());
|
||||
|
||||
|
@ -391,31 +391,30 @@ void GLTextPanel::drawPanelContents() {
|
||||
glColor4f(1, 1, 1, 1.0);
|
||||
|
||||
GLFont::GLFontSize sz;
|
||||
float size;
|
||||
|
||||
|
||||
if (pdim.y <= 16) {
|
||||
sz = GLFont::GLFONT_SIZE12;
|
||||
size = 12;
|
||||
|
||||
} else if (pdim.y <= 18) {
|
||||
sz = GLFont::GLFONT_SIZE16;
|
||||
size = 16;
|
||||
|
||||
} else if(pdim.y <= 24) {
|
||||
sz = GLFont::GLFONT_SIZE18;
|
||||
size = 18;
|
||||
|
||||
} else if(pdim.y <= 32) {
|
||||
sz = GLFont::GLFONT_SIZE24;
|
||||
size = 24;
|
||||
|
||||
} else if(pdim.y <= 48) {
|
||||
sz = GLFont::GLFONT_SIZE32;
|
||||
size = 32;
|
||||
|
||||
} else {
|
||||
sz = GLFont::GLFONT_SIZE48;
|
||||
size = 48;
|
||||
|
||||
}
|
||||
|
||||
|
||||
GLFont::getFont(sz).drawString(textVal, mid, mid, size, horizAlign, vertAlign, (int)pdim.x, (int)pdim.y);
|
||||
GLFont::getFont(sz).drawString(textVal, mid, mid, horizAlign, vertAlign, (int)pdim.x, (int)pdim.y);
|
||||
}
|
||||
|
||||
void GLTextPanel::setText(std::string text, GLFont::Align hAlign, GLFont::Align vAlign) {
|
||||
|
@ -268,10 +268,16 @@ void GLFont::loadFontOnce() {
|
||||
std::wstring param = nextParam(info_param);
|
||||
|
||||
std::wstring paramKey = getParamKey(param);
|
||||
std::wstring paramValue = getParamValue(param);
|
||||
|
||||
if (paramKey == L"face") {
|
||||
fontName = paramValue;
|
||||
fontName = getParamValue(param);
|
||||
}
|
||||
|
||||
param = nextParam(info_param);
|
||||
paramKey = getParamKey(param);
|
||||
if (paramKey == L"size") {
|
||||
|
||||
std::wistringstream paramValue(getParamValue(param));
|
||||
paramValue >> pixHeight;
|
||||
}
|
||||
|
||||
// std::cout << "[" << paramKey << "] = '" << paramValue << "'" << std::endl;
|
||||
@ -495,14 +501,13 @@ float GLFont::getStringWidth(const std::wstring& str, float size, float viewAspe
|
||||
}
|
||||
|
||||
// Draw string, immediate
|
||||
void GLFont::drawString(const std::wstring& str, float xpos, float ypos, int pxHeight, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
void GLFont::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
|
||||
//load pxHeight from the font itself, but because it is an "internal font", the scaling has already been applied.
|
||||
int pxHeight = pixHeight;
|
||||
|
||||
// Why another scale ?
|
||||
pxHeight *= 2;
|
||||
|
||||
//Rise the pixel hight by the scale factor
|
||||
pxHeight *= getScaleFactor();
|
||||
|
||||
if (!vpx || !vpy) {
|
||||
GLint vp[4];
|
||||
glGetIntegerv( GL_VIEWPORT, vp);
|
||||
@ -625,7 +630,7 @@ void GLFont::drawString(const std::wstring& str, float xpos, float ypos, int pxH
|
||||
}
|
||||
|
||||
// Draw string, immediate, 8 bit version
|
||||
void GLFont::drawString(const std::string& str, float xpos, float ypos, int pxHeight, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
void GLFont::drawString(const std::string& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
|
||||
//Displayed string is wstring, so use wxString to do the heavy lifting of converting str...
|
||||
#ifdef WIN32
|
||||
@ -637,7 +642,7 @@ void GLFont::drawString(const std::string& str, float xpos, float ypos, int pxHe
|
||||
|
||||
wsTmp.assign(str);
|
||||
|
||||
drawString(wsTmp.ToStdWstring(), xpos, ypos, pxHeight, hAlign, vAlign, vpx, vpy, cacheable);
|
||||
drawString(wsTmp.ToStdWstring(), xpos, ypos, hAlign, vAlign, vpx, vpy, cacheable);
|
||||
}
|
||||
|
||||
// Draw cached GLFontCacheString
|
||||
@ -873,7 +878,6 @@ void GLFont::setScale(GLFontScale scale) {
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE32] = GLFont::GLFONT_SIZE64;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE72;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE96;
|
||||
|
||||
}
|
||||
|
||||
//Not overridden mapping stays normal, like the biggest fonts.
|
||||
@ -882,22 +886,6 @@ void GLFont::setScale(GLFontScale scale) {
|
||||
//and the new fonts will show up.
|
||||
}
|
||||
|
||||
double GLFont::getScaleFactor() {
|
||||
|
||||
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
|
||||
|
||||
if (currentScaleFactor == GLFONT_SCALE_MEDIUM) {
|
||||
|
||||
return 1.5;
|
||||
}
|
||||
else if (currentScaleFactor == GLFONT_SCALE_LARGE) {
|
||||
|
||||
return 2.0;
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
GLFont::GLFontScale GLFont::getScale() {
|
||||
|
||||
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
|
||||
|
@ -107,14 +107,11 @@ public:
|
||||
|
||||
static GLFontScale getScale();
|
||||
|
||||
//Return the current scale factor in use (1.0 for normal, 1.5 for medium, 2.0 for large for ex.)
|
||||
static double getScaleFactor();
|
||||
|
||||
//Public drawing font, 16 bit char version.
|
||||
void drawString(const std::wstring& str, float xpos, float ypos, int pxHeight, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx=0, int vpy=0, bool cacheable = false);
|
||||
void drawString(const std::wstring& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx=0, int vpy=0, bool cacheable = false);
|
||||
|
||||
//Public drawing font, 8 bit char version.
|
||||
void drawString(const std::string& str, float xpos, float ypos, int pxHeight, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
void drawString(const std::string& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
private:
|
||||
|
||||
@ -149,7 +146,7 @@ private:
|
||||
|
||||
int lineHeight;
|
||||
int base;
|
||||
int imageWidth, imageHeight;
|
||||
int imageWidth, imageHeight, pixHeight;
|
||||
bool loaded;
|
||||
GLFontSize fontSizeClass;
|
||||
|
||||
|
@ -31,11 +31,8 @@ void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool
|
||||
|
||||
GLFont::GLFontSize fontSize = GLFont::GLFONT_SIZE16;
|
||||
|
||||
int fontHeight = 16;
|
||||
|
||||
if (viewWidth < 30 || viewHeight < 200) {
|
||||
fontSize = GLFont::GLFONT_SIZE12;
|
||||
fontHeight = 12;
|
||||
}
|
||||
|
||||
glColor4f(r, g, b, a);
|
||||
@ -62,7 +59,7 @@ void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool
|
||||
glColor4f(0, 0, 0, a);
|
||||
}
|
||||
|
||||
GLFont::getFont(fontSize).drawString(label, 0.0, y + height / 2.0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(fontSize).drawString(label, 0.0, y + height / 2.0, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
void ModeSelectorContext::DrawEnd() {
|
||||
|
@ -166,11 +166,11 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l
|
||||
}
|
||||
|
||||
if (demod->getDemodulatorType() == "USB") {
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
} else if (demod->getDemodulatorType() == "LSB") {
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
} else {
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -256,27 +256,27 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
|
||||
if (lastType == "USB") {
|
||||
glColor4f(0,0,0, 1.0);
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos+shadowOfsY, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos-shadowOfsX, hPos-shadowOfsY, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos+shadowOfsY, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos-shadowOfsX, hPos-shadowOfsY, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor4f(color.r, color.g, color.b, 1.0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
} else if (lastType == "LSB") {
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glColor4f(0,0,0, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos+shadowOfsY, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos-shadowOfsX, hPos-shadowOfsY, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos+shadowOfsY, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos-shadowOfsX, hPos-shadowOfsY, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor4f(color.r, color.g, color.b, 1.0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||
} else {
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
glColor4f(0,0,0, 1.0);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos+shadowOfsY, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos-shadowOfsX, hPos-shadowOfsY, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos+shadowOfsX, hPos+shadowOfsY, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos-shadowOfsX, hPos-shadowOfsY, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
glColor4f(color.r, color.g, color.b, 1.0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, 16, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
@ -407,12 +407,12 @@ void PrimaryGLContext::drawSingleDemodLabel(const std::wstring& demodStr, float
|
||||
|
||||
glColor3f(0, 0, 0);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs,
|
||||
-1.0 + hPos - yOfs, 16, demodAlign,
|
||||
-1.0 + hPos - yOfs, demodAlign,
|
||||
GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
|
||||
glColor3f(1, 1, 1);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodStr, 2.0 * (uxPos - 0.5),
|
||||
-1.0 + hPos, 16, demodAlign,
|
||||
-1.0 + hPos, demodAlign,
|
||||
GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,9 @@ void ScopeContext::DrawTunerTitles(bool ppmMode) {
|
||||
|
||||
glColor3f(0.65f, 0.65f, 0.65f);
|
||||
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0+hPos, 12, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString("Bandwidth", 0.0, -1.0+hPos, 12, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString("Center Frequency", 0.66f, -1.0+hPos, 12, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString("Bandwidth", 0.0, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString("Center Frequency", 0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
}
|
||||
|
||||
void ScopeContext::DrawDeviceName(std::string deviceName) {
|
||||
@ -47,7 +47,7 @@ void ScopeContext::DrawDeviceName(std::string deviceName) {
|
||||
float hPos = (float) (viewHeight - 20) / viewHeight;
|
||||
|
||||
glColor3f(0.65f, 0.65f, 0.65f);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString(deviceName.c_str(), 1.0, hPos, 12, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString(deviceName.c_str(), 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
|
||||
}
|
||||
|
||||
void ScopeContext::DrawEnd() {
|
||||
|
@ -75,19 +75,19 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float
|
||||
std::string freqChars = freqStr.str();
|
||||
|
||||
GLFont::GLFontSize fontSize = GLFont::GLFONT_SIZE24;
|
||||
int fontHeight = 24;
|
||||
|
||||
|
||||
if (viewHeight < 28) {
|
||||
fontSize = GLFont::GLFONT_SIZE18;
|
||||
fontHeight = 18;
|
||||
|
||||
}
|
||||
if (viewHeight < 24) {
|
||||
fontSize = GLFont::GLFONT_SIZE16;
|
||||
fontHeight = 16;
|
||||
|
||||
}
|
||||
if (viewHeight < 18) {
|
||||
fontSize = GLFont::GLFONT_SIZE12;
|
||||
fontHeight = 12;
|
||||
|
||||
}
|
||||
|
||||
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
|
||||
@ -95,7 +95,7 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float
|
||||
int ofs = count - numChars;
|
||||
for (int i = ofs; i < count; i++) {
|
||||
float xpos = displayPos + (displayWidth / (float) count) * (float) i + ((displayWidth / 2.0) / (float) count);
|
||||
GLFont::getFont(fontSize).drawString(freqStr.str().substr(i - ofs, 1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
GLFont::getFont(fontSize).drawString(freqStr.str().substr(i - ofs, 1), xpos, 0, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
glColor4f(0.65f, 0.65f, 0.65f, 0.25f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user