Reverse removal of label auto-sizing during label creation. Retained removal of auto-sizing during draw.

release/v2.9
inmarket 2018-10-14 14:58:53 +10:00
parent 4c4cf51682
commit 0f3310dd34
2 changed files with 22 additions and 19 deletions

View File

@ -42,8 +42,8 @@ FEATURE: Added keyboard support to radio buttons (by Steffan)
FEATURE: Added internal use only GFX_COMPILESTAGE (used to control compilation)
FEATURE: Added support for ChibiOS Kernel V5
FEATURE: Added WS29EPD WaveShare E-Paper display
FIX: Fixing GQUEUE full synchronous function signatures
CHANGE: Removing label widget auto-sizing functionality
FIX: Fixed GQUEUE full synchronous function signatures
CHANGE: Removed label widget auto-sizing during redraw. It will still auto-size during creation
*** Release 2.8 ***

View File

@ -61,6 +61,13 @@ static const gwidgetVMT labelVMT = {
};
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit) {
// auto assign width
if (pInit->g.width <= 0)
pInit->g.width = gdispGetStringWidth(pInit->text, gwinGetDefaultFont())+2; // Allow one pixel of padding on each side
// auto assign height
if (pInit->g.height <= 0)
pInit->g.height = gdispGetFontMetric(gwinGetDefaultFont(), gFontHeight);
if (!(widget = (GLabelObject *)_gwidgetCreate(g, &widget->w, pInit, &labelVMT)))
return 0;
@ -100,32 +107,28 @@ void gwinLabelSetBorder(GHandle gh, gBool border) {
#endif // GWIN_LABEL_ATTRIBUTE
void gwinLabelDrawJustified(GWidgetObject *gw, void *param) {
gCoord w, h;
gColor c;
gJustify justify = (gJustify)param;
// is it a valid handle?
if (gw->g.vmt != (gwinVMT *)&labelVMT)
return;
w = gw->g.width;
h = gw->g.height;
c = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text;
#if GWIN_LABEL_ATTRIBUTE
if (gw2obj->attr) {
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, h, gw2obj->attr, gw->g.font, c, gw->pstyle->background, justify);
gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, w-gw2obj->tab, h, gw->text, gw->g.font, c, gw->pstyle->background, justify);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw2obj->tab, gw->g.height, gw2obj->attr, gw->g.font, c, gw->pstyle->background, justify);
gdispGFillStringBox(gw->g.display, gw->g.x + gw2obj->tab, gw->g.y, gw->g.width-gw2obj->tab, gw->g.height, gw->text, gw->g.font, c, gw->pstyle->background, justify);
} else
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justify);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, c, gw->pstyle->background, justify);
#else
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, w, h, gw->text, gw->g.font, c, gw->pstyle->background, justify);
gdispGFillStringBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font, c, gw->pstyle->background, justify);
#endif
// render the border (if any)
if (gw->g.flags & GLABEL_FLG_BORDER)
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, w, h, (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge);
gdispGDrawBox(gw->g.display, gw->g.x, gw->g.y, gw->g.width, gw->g.height, (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.edge : gw->pstyle->disabled.edge);
}
void gwinLabelDrawJustifiedLeft(GWidgetObject *gw, void *param) {