From: John Hodge Date: Thu, 17 Nov 2011 14:41:06 +0000 (+0800) Subject: Usermode/AxWin3 - Fiddling with text presentation X-Git-Tag: rel0.14~91 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5469fe753efcaccb07e7666c4b7d9b4a8d003808;p=tpg%2Facess2.git Usermode/AxWin3 - Fiddling with text presentation --- diff --git a/Usermode/Applications/axwin3_src/Interface/main.c b/Usermode/Applications/axwin3_src/Interface/main.c index d43845b5..b7c06ca8 100644 --- a/Usermode/Applications/axwin3_src/Interface/main.c +++ b/Usermode/Applications/axwin3_src/Interface/main.c @@ -132,9 +132,9 @@ int run_close(tAxWin3_Widget *unused) tAxWin3_Widget *make_textbutton(tAxWin3_Widget *Parent, const char *Label, tAxWin3_Widget_FireCb handler) { tAxWin3_Widget *ret, *txt; - ret = AxWin3_Widget_AddWidget(Parent, ELETYPE_BUTTON, ELEFLAG_NOSTRETCH, "_btn"); + ret = AxWin3_Widget_AddWidget(Parent, ELETYPE_BUTTON, ELEFLAG_ALIGN_CENTER, "_btn"); AxWin3_Widget_SetFireHandler(ret, handler); - txt = AxWin3_Widget_AddWidget(ret, ELETYPE_TEXT, 0, "_txt"); + txt = AxWin3_Widget_AddWidget(ret, ELETYPE_TEXT, ELEFLAG_NOSTRETCH|ELEFLAG_NOEXPAND, "_txt"); AxWin3_Widget_SetText(txt, Label); return ret; } diff --git a/Usermode/Applications/axwin3_src/WM/renderers/widget.c b/Usermode/Applications/axwin3_src/WM/renderers/widget.c index 1bd437da..d77a67a9 100644 --- a/Usermode/Applications/axwin3_src/WM/renderers/widget.c +++ b/Usermode/Applications/axwin3_src/WM/renderers/widget.c @@ -319,40 +319,50 @@ void Widget_UpdatePosition(tElement *Element) void Widget_UpdateMinDims(tElement *Element) { tElement *child; + int minW, minH; if(!Element) return; - Element->MinCross = 0; - Element->MinWith = 0; + minW = 0; + minH = 0; for(child = Element->FirstChild; child; child = child->NextSibling) { - if( Element->Parent && - (Element->Flags & ELEFLAG_VERTICAL) == (Element->Parent->Flags & ELEFLAG_VERTICAL) - ) + if( (Element->Flags & ELEFLAG_VERTICAL) ) { if(child->FixedCross) - Element->MinCross += child->FixedCross; + minW += child->FixedCross; else - Element->MinCross += child->MinCross; + minW += child->MinCross; if(child->FixedWith) - Element->MinWith += child->FixedWith; + minH += child->FixedWith; else - Element->MinWith += child->MinWith; + minH += child->MinWith; } else { if(child->FixedCross) - Element->MinWith += child->FixedCross; + minH += child->FixedCross; else - Element->MinWith += child->MinCross; + minH += child->MinCross; if(child->FixedWith) - Element->MinCross += child->FixedWith; + minW += child->FixedWith; else - Element->MinCross += child->MinWith; + minW += child->MinWith; } } + if( Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL) ) + { + Element->MinCross = Element->PaddingL + minW + Element->PaddingR; + Element->MinWith = Element->PaddingT + minH + Element->PaddingB; + } + else + { + Element->MinWith = Element->PaddingL + minW + Element->PaddingR; + Element->MinCross = Element->PaddingL + minH + Element->PaddingR; + } + // Recurse upwards Widget_UpdateMinDims(Element->Parent); } diff --git a/Usermode/Applications/axwin3_src/WM/renderers/widget/disptext.c b/Usermode/Applications/axwin3_src/WM/renderers/widget/disptext.c index 4a091def..4ea48331 100644 --- a/Usermode/Applications/axwin3_src/WM/renderers/widget/disptext.c +++ b/Usermode/Applications/axwin3_src/WM/renderers/widget/disptext.c @@ -29,6 +29,10 @@ void Widget_DispText_UpdateText(tElement *Element, const char *Text) Element->Text = strdup(Text); WM_Render_GetTextDims(NULL, Element->Text, &w, &h); + + // Apply edge padding + w += 2; h += 2; + if(Element->Parent && (Element->Parent->Flags & ELEFLAG_VERTICAL)) { Element->MinCross = w; Element->MinWith = h;