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 internal use only GFX_COMPILESTAGE (used to control compilation)
FEATURE: Added support for ChibiOS Kernel V5 FEATURE: Added support for ChibiOS Kernel V5
FEATURE: Added WS29EPD WaveShare E-Paper display FEATURE: Added WS29EPD WaveShare E-Paper display
FIX: Fixing GQUEUE full synchronous function signatures FIX: Fixed GQUEUE full synchronous function signatures
CHANGE: Removing label widget auto-sizing functionality CHANGE: Removed label widget auto-sizing during redraw. It will still auto-size during creation
*** Release 2.8 *** *** Release 2.8 ***

View File

@ -61,6 +61,13 @@ static const gwidgetVMT labelVMT = {
}; };
GHandle gwinGLabelCreate(GDisplay *g, GLabelObject *widget, GWidgetInit *pInit) { 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))) if (!(widget = (GLabelObject *)_gwidgetCreate(g, &widget->w, pInit, &labelVMT)))
return 0; return 0;
@ -79,7 +86,7 @@ void gwinLabelSetBorder(GHandle gh, gBool border) {
// is it a valid handle? // is it a valid handle?
if (gh->vmt != (gwinVMT *)&labelVMT) if (gh->vmt != (gwinVMT *)&labelVMT)
return; return;
if (border) if (border)
gh2obj->w.g.flags |= GLABEL_FLG_BORDER; gh2obj->w.g.flags |= GLABEL_FLG_BORDER;
else else
@ -91,58 +98,54 @@ void gwinLabelSetBorder(GHandle gh, gBool border) {
// is it a valid handle? // is it a valid handle?
if (gh->vmt != (gwinVMT *)&labelVMT) if (gh->vmt != (gwinVMT *)&labelVMT)
return; return;
gh2obj->tab = tab; gh2obj->tab = tab;
gh2obj->attr = attr; gh2obj->attr = attr;
gwinRedraw(gh); gwinRedraw(gh);
} }
#endif // GWIN_LABEL_ATTRIBUTE #endif // GWIN_LABEL_ATTRIBUTE
void gwinLabelDrawJustified(GWidgetObject *gw, void *param) { void gwinLabelDrawJustified(GWidgetObject *gw, void *param) {
gCoord w, h; gColor c;
gColor c; gJustify justify = (gJustify)param;
gJustify justify = (gJustify)param;
// is it a valid handle? // is it a valid handle?
if (gw->g.vmt != (gwinVMT *)&labelVMT) if (gw->g.vmt != (gwinVMT *)&labelVMT)
return; return;
w = gw->g.width;
h = gw->g.height;
c = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text; c = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text;
#if GWIN_LABEL_ATTRIBUTE #if GWIN_LABEL_ATTRIBUTE
if (gw2obj->attr) { 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, 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, w-gw2obj->tab, h, gw->text, 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 } 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 #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 #endif
// render the border (if any) // render the border (if any)
if (gw->g.flags & GLABEL_FLG_BORDER) 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) { void gwinLabelDrawJustifiedLeft(GWidgetObject *gw, void *param) {
(void)param; (void)param;
gwinLabelDrawJustified(gw, (void *)gJustifyLeft); gwinLabelDrawJustified(gw, (void *)gJustifyLeft);
} }
void gwinLabelDrawJustifiedRight(GWidgetObject *gw, void *param) { void gwinLabelDrawJustifiedRight(GWidgetObject *gw, void *param) {
(void)param; (void)param;
gwinLabelDrawJustified(gw, (void *)gJustifyRight); gwinLabelDrawJustified(gw, (void *)gJustifyRight);
} }
void gwinLabelDrawJustifiedCenter(GWidgetObject *gw, void *param) { void gwinLabelDrawJustifiedCenter(GWidgetObject *gw, void *param) {
(void)param; (void)param;
gwinLabelDrawJustified(gw, (void *)gJustifyCenter); gwinLabelDrawJustified(gw, (void *)gJustifyCenter);
} }