Add Trim option in Export Sprite Sheet

This commit is contained in:
David Capello 2017-11-29 16:12:00 -03:00
parent d67b083e42
commit d3d107b0ac
4 changed files with 14 additions and 3 deletions

View File

@ -342,6 +342,7 @@
<option id="border_padding" type="int" default="0" />
<option id="shape_padding" type="int" default="0" />
<option id="inner_padding" type="int" default="0" />
<option id="trim" type="bool" default="false" />
<option id="open_generated" type="bool" default="false" />
<option id="layer" type="std::string" />
<option id="frame_tag" type="std::string" />

View File

@ -234,6 +234,7 @@ padding = Padding
border = Border:
shape = Shape:
inner = Inner:
trim = Trim
width = Width:
height = Height:
best_fit = Best fit for texture

View File

@ -17,6 +17,7 @@
<hbox />
<vbox>
<check id="padding_enabled" text="@.padding" />
<check id="trim_enabled" text="@.trim" />
</vbox>
<grid columns="2" id="padding_container" cell_hspan="2">
<label text="@.border" />

View File

@ -188,6 +188,7 @@ public:
m_sprite, frames(), m_docPref.spriteSheet.frameTag());
openGenerated()->setSelected(m_docPref.spriteSheet.openGenerated());
trimEnabled()->setSelected(m_docPref.spriteSheet.trim());
borderPadding()->setTextf("%d", m_docPref.spriteSheet.borderPadding());
shapePadding()->setTextf("%d", m_docPref.spriteSheet.shapePadding());
@ -356,6 +357,10 @@ public:
return 0;
}
bool trimValue() const {
return trimEnabled()->isSelected();
}
bool openGeneratedValue() const {
return openGenerated()->isSelected();
}
@ -641,6 +646,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
docPref.spriteSheet.borderPadding(window.borderPaddingValue());
docPref.spriteSheet.shapePadding(window.shapePaddingValue());
docPref.spriteSheet.innerPadding(window.innerPaddingValue());
docPref.spriteSheet.trim(window.trimValue());
docPref.spriteSheet.openGenerated(window.openGeneratedValue());
docPref.spriteSheet.layer(window.layerValue());
docPref.spriteSheet.frameTag(window.frameTagValue());
@ -678,9 +684,10 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
borderPadding = MID(0, borderPadding, 100);
shapePadding = MID(0, shapePadding, 100);
innerPadding = MID(0, innerPadding, 100);
bool listLayers = docPref.spriteSheet.listLayers();
bool listFrameTags = docPref.spriteSheet.listFrameTags();
bool listSlices = docPref.spriteSheet.listSlices();
const bool trimCels = docPref.spriteSheet.trim();
const bool listLayers = docPref.spriteSheet.listLayers();
const bool listFrameTags = docPref.spriteSheet.listFrameTags();
const bool listSlices = docPref.spriteSheet.listSlices();
if (context->isUIAvailable() && askOverwrite) {
if (!ask_overwrite(true, filename,
@ -758,6 +765,7 @@ void ExportSpriteSheetCommand::onExecute(Context* context)
exporter.setBorderPadding(borderPadding);
exporter.setShapePadding(shapePadding);
exporter.setInnerPadding(innerPadding);
exporter.setTrimCels(trimCels);
if (listLayers) exporter.setListLayers(true);
if (listFrameTags) exporter.setListFrameTags(true);
if (listSlices) exporter.setListSlices(true);