Use new Entry suffixes in SpriteSizeCommand

This commit is contained in:
David Capello 2013-03-30 20:10:54 -03:00
parent 527c85e26e
commit 7c15aee0a5
3 changed files with 13 additions and 7 deletions

View File

@ -12,8 +12,8 @@
<label text="Height:" />
</box>
<box vertical="true" homogeneous="true" expansive="true">
<entry expansive="true" id="width_px" maxsize="8" magnet="true" tooltip="New width for the sprite (in pixels)" />
<entry expansive="true" id="height_px" maxsize="8" tooltip="New height for the sprite (in pixels)" />
<entry expansive="true" id="width_px" suffix="px" maxsize="8" magnet="true" tooltip="New width for the sprite (in pixels)" />
<entry expansive="true" id="height_px" suffix="px" maxsize="8" tooltip="New height for the sprite (in pixels)" />
</box>
<check text="Lock Ratio" id="lock_ratio" selected="true" />
</box>
@ -26,8 +26,8 @@
<label text="Height:" />
</box>
<box vertical="true" homogeneous="true" expansive="true">
<entry expansive="true" text="100%%" id="width_perc" maxsize="8" magnet="true" tooltip="New width for the sprite&#10;Percentage of current width." />
<entry expansive="true" text="100%%" id="height_perc" maxsize="8" tooltip="New height for the sprite&#10;Percentage of current height." />
<entry expansive="true" text="100" suffix="%" id="width_perc" maxsize="8" magnet="true" tooltip="New width for the sprite&#10;Percentage of current width." />
<entry expansive="true" text="100" suffix="%" id="height_perc" maxsize="8" tooltip="New height for the sprite&#10;Percentage of current height." />
</box>
<box horizontal="true" width="64" />
</box>

View File

@ -239,8 +239,9 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
}
/* entry */
else if (ustrcmp(elem_name, "entry") == 0) {
const char *maxsize = elem->Attribute("maxsize");
const char *text = elem->Attribute("text");
const char* maxsize = elem->Attribute("maxsize");
const char* text = elem->Attribute("text");
const char* suffix = elem->Attribute("suffix");
if (maxsize != NULL) {
bool readonly = bool_attr_is_true(elem, "readonly");
@ -250,7 +251,12 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
if (readonly)
((Entry*)widget)->setReadOnly(true);
if (suffix)
((Entry*)widget)->setSuffix(suffix);
}
else
throw std::runtime_error("<entry> element found without 'maxsize' attribute");
}
/* grid */
else if (ustrcmp(elem_name, "grid") == 0) {

View File

@ -42,7 +42,7 @@
using namespace ui;
#define PERC_FORMAT "%.1f%%"
#define PERC_FORMAT "%.1f"
class SpriteSizeJob : public Job
{