From cfa061e014fe5dd63740ca387e2bd2c30a3b67f0 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 2 May 2014 20:19:43 -0300 Subject: [PATCH] Fix sprite properties dialog size when jguiscale() = 1 (problem referenced in issue #197) --- src/app/widget_loader.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/app/widget_loader.cpp b/src/app/widget_loader.cpp index d5ed8dd7b..1de9809ac 100644 --- a/src/app/widget_loader.cpp +++ b/src/app/widget_loader.cpp @@ -406,6 +406,15 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget const char* maxheight = elem->Attribute("maxheight"); const char* childspacing = elem->Attribute("childspacing"); + if (width) { + if (!minwidth) minwidth = width; + if (!maxwidth) maxwidth = width; + } + if (height) { + if (!minheight) minheight = height; + if (!maxheight) maxheight = height; + } + if (id != NULL) widget->setId(id); @@ -433,20 +442,20 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget widget->noBorderNoChildSpacing(); if (childspacing) - widget->child_spacing = ustrtol(childspacing, NULL, 10); + widget->child_spacing = strtol(childspacing, NULL, 10); - if (width || minwidth || - height || minheight) { - int w = (width || minwidth) ? ustrtol(width ? width: minwidth, NULL, 10): 0; - int h = (height || minheight) ? ustrtol(height ? height: minheight, NULL, 10): 0; - widget->setMinSize(gfx::Size(w*jguiscale(), h*jguiscale())); + gfx::Size reqSize = widget->getPreferredSize(); + + if (minwidth || minheight) { + int w = (minwidth ? jguiscale()*strtol(minwidth, NULL, 10): reqSize.w); + int h = (minheight ? jguiscale()*strtol(minheight, NULL, 10): reqSize.h); + widget->setMinSize(gfx::Size(w, h)); } - if (width || maxwidth || - height || maxheight) { - int w = (width || maxwidth) ? strtol(width ? width: maxwidth, NULL, 10): INT_MAX; - int h = (height || maxheight) ? strtol(height ? height: maxheight, NULL, 10): INT_MAX; - widget->setMaxSize(gfx::Size(w*jguiscale(), h*jguiscale())); + if (maxwidth || maxheight) { + int w = (maxwidth ? jguiscale()*strtol(maxwidth, NULL, 10): INT_MAX); + int h = (maxheight ? jguiscale()*strtol(maxheight, NULL, 10): INT_MAX); + widget->setMaxSize(gfx::Size(w, h)); } if (!root)