basic automatic font size
This commit is contained in:
parent
237a7ad06f
commit
27aacb001e
|
@ -135,12 +135,20 @@ void GLPanel::setSize(float w, float h) {
|
||||||
size[1] = h;
|
size[1] = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GLPanel::getWidth() {
|
||||||
|
return size[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
float GLPanel::getHeight() {
|
||||||
|
return size[1];
|
||||||
|
}
|
||||||
|
|
||||||
float GLPanel::getWidthPx() {
|
float GLPanel::getWidthPx() {
|
||||||
return size[0]*view[0];
|
return pdim.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLPanel::getHeightPx() {
|
float GLPanel::getHeightPx() {
|
||||||
return size[1]*view[0];
|
return pdim.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -329,7 +337,33 @@ GLTextPanel::GLTextPanel() : GLPanel() {
|
||||||
|
|
||||||
void GLTextPanel::drawPanelContents() {
|
void GLTextPanel::drawPanelContents() {
|
||||||
glColor4f(1, 1, 1, 1.0);
|
glColor4f(1, 1, 1, 1.0);
|
||||||
GLFont::getFont(GLFont::GLFONT_SIZE48).drawString(textVal, mid, mid, 48, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, (int)pdim.x, (int)pdim.y);
|
|
||||||
|
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, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, (int)pdim.x, (int)pdim.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLTextPanel::setText(std::string text) {
|
void GLTextPanel::setText(std::string text) {
|
||||||
|
|
|
@ -61,6 +61,8 @@ public:
|
||||||
|
|
||||||
void setPosition(float x, float y);
|
void setPosition(float x, float y);
|
||||||
void setSize(float w, float h);
|
void setSize(float w, float h);
|
||||||
|
float getWidth();
|
||||||
|
float getHeight();
|
||||||
float getWidthPx();
|
float getWidthPx();
|
||||||
float getHeightPx();
|
float getHeightPx();
|
||||||
void setCoordinateSystem(GLPanelCoordinateSystem coord);
|
void setCoordinateSystem(GLPanelCoordinateSystem coord);
|
||||||
|
|
Loading…
Reference in New Issue