mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-12 11:47:47 -04:00
Add font scale support to meter panel
This commit is contained in:
parent
3d5757d8d8
commit
95fd357c72
@ -148,32 +148,28 @@ void MeterPanel::drawPanelContents() {
|
|||||||
|
|
||||||
glGetIntegerv( GL_VIEWPORT, vp);
|
glGetIntegerv( GL_VIEWPORT, vp);
|
||||||
|
|
||||||
float viewHeight = (float) vp[3];
|
double viewHeight = vp[3];
|
||||||
|
|
||||||
CubicVR::vec4 t = CubicVR::mat4::vec4_multiply(CubicVR::vec4(0,0.5,0,1), transform);
|
CubicVR::vec4 t = CubicVR::mat4::vec4_multiply(CubicVR::vec4(0,0.5,0,1), transform);
|
||||||
CubicVR::vec4 b = CubicVR::mat4::vec4_multiply(CubicVR::vec4(0,-0.5,0,1), transform);
|
CubicVR::vec4 b = CubicVR::mat4::vec4_multiply(CubicVR::vec4(0,-0.5,0,1), transform);
|
||||||
|
|
||||||
float hScale = t.y-b.y;
|
double hScale = t.y-b.y;
|
||||||
|
|
||||||
viewHeight = round(viewHeight * hScale);
|
viewHeight = viewHeight * hScale;
|
||||||
|
|
||||||
float labelHeight = 24.0f;
|
double labelHeight = GLFont::getScaledPx(18, GLFont::getScaleFactor());
|
||||||
float labelPad = 8.0f;
|
double labelPad = 8.0;
|
||||||
|
|
||||||
if (viewHeight > 400.0f) {
|
double pScale = (1.0/viewHeight);
|
||||||
labelHeight = 32.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float pScale = (1.0f/viewHeight);
|
|
||||||
RGBA4f c1, c2;
|
RGBA4f c1, c2;
|
||||||
|
|
||||||
bgPanel.setSize(1.0f, 1.0f - pScale * (labelHeight + labelPad * 2.0f));
|
bgPanel.setSize(1.0f, 1.0 - pScale * (labelHeight + labelPad * 2.0));
|
||||||
|
|
||||||
valuePanel.setPosition(0.0f, (pScale * (labelHeight / 2.0f + labelPad) ) - 1.0f);
|
valuePanel.setPosition(0.0, (pScale * (labelHeight / 2.0 + labelPad) ) - 1.0);
|
||||||
valuePanel.setSize(1.0f, pScale*labelHeight);
|
valuePanel.setSize(1.0, pScale*labelHeight);
|
||||||
|
|
||||||
labelPanel.setPosition(0.0f, 1.0f - (pScale * (labelHeight / 2.0f + labelPad)));
|
labelPanel.setPosition(0.0, 1.0 - (pScale * (labelHeight / 2.0 + labelPad)));
|
||||||
labelPanel.setSize(1.0f, pScale*labelHeight);
|
labelPanel.setSize(1.0, pScale*labelHeight);
|
||||||
|
|
||||||
c1 = ThemeMgr::mgr.currentTheme->generalBackground;
|
c1 = ThemeMgr::mgr.currentTheme->generalBackground;
|
||||||
c2 = ThemeMgr::mgr.currentTheme->generalBackground * 0.5;
|
c2 = ThemeMgr::mgr.currentTheme->generalBackground * 0.5;
|
||||||
|
@ -857,6 +857,30 @@ double GLFont::getScaleFactor() {
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GLFont::getScaledPx(int basicFontSize, double scaleFactor) {
|
||||||
|
//try to align on an integer pixel size if the targetSize font is available
|
||||||
|
int targetSize = round(basicFontSize * scaleFactor);
|
||||||
|
int resultIndex = 0;
|
||||||
|
|
||||||
|
fonts[0].loadFontOnce();
|
||||||
|
|
||||||
|
for (int i = 0; i < GLFONT_SIZE_MAX - 1; i++) {
|
||||||
|
|
||||||
|
fonts[i + 1].loadFontOnce();
|
||||||
|
|
||||||
|
if (fonts[i + 1].pixHeight <= targetSize) {
|
||||||
|
resultIndex = i + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} //end for
|
||||||
|
|
||||||
|
// return font height px
|
||||||
|
return fonts[resultIndex].pixHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GLFont::Drawer::Drawer(int basicFontSize, double scaleFactor) {
|
GLFont::Drawer::Drawer(int basicFontSize, double scaleFactor) {
|
||||||
|
|
||||||
//Selection of the final font: scan GLFont::fonts to find the biggest font such as
|
//Selection of the final font: scan GLFont::fonts to find the biggest font such as
|
||||||
|
@ -112,6 +112,9 @@ public:
|
|||||||
|
|
||||||
//Mean current scale factor: 1.0 in normal, 1.5 medium, 2.0 for large
|
//Mean current scale factor: 1.0 in normal, 1.5 medium, 2.0 for large
|
||||||
static double getScaleFactor();
|
static double getScaleFactor();
|
||||||
|
|
||||||
|
//Return a valid font px height given the font size and scale factor
|
||||||
|
static int getScaledPx(int basicFontSize, double scaleFactor);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user