Add Area element in the Export window (UI only) (#645)

This commit is contained in:
David Capello 2022-08-12 11:56:52 -03:00
parent 03f9db5121
commit 3c3d2dafe6
7 changed files with 72 additions and 17 deletions

View File

@ -508,6 +508,7 @@
<section id="save_copy" canclear="true">
<option id="filename" type="std::string" />
<option id="resize_scale" type="double" default="1" />
<option id="area" type="std::string" />
<option id="layer" type="std::string" />
<option id="frame_tag" type="std::string" />
<option id="ani_dir" type="doc::AniDir" default="doc::AniDir::FORWARD" />

View File

@ -630,6 +630,7 @@ sensors_tweaks = Sensor Threshold
title = Export File
output_file = Output File:
resize = Resize:
area = Area:
layers = Layers:
frames = Frames:
anidir = Animation Direction:

View File

@ -9,21 +9,24 @@
<button id="output_filename_browse" text="..." style="mini_button" />
<label id="resize_label" text="@.resize" />
<combobox id="resize" editable="true" suffix="%"
cell_align="horizontal" cell_hspan="2">
<listitem text="25" />
<listitem text="50" />
<listitem text="100" />
<listitem text="200" />
<listitem text="300" />
<listitem text="400" />
<listitem text="500" />
<listitem text="600" />
<listitem text="700" />
<listitem text="800" />
<listitem text="900" />
<listitem text="1000" />
</combobox>
<hbox cell_hspan="2" cell_align="horizontal">
<combobox id="resize" editable="true" suffix="%" expansive="true">
<listitem text="25" />
<listitem text="50" />
<listitem text="100" />
<listitem text="200" />
<listitem text="300" />
<listitem text="400" />
<listitem text="500" />
<listitem text="600" />
<listitem text="700" />
<listitem text="800" />
<listitem text="900" />
<listitem text="1000" />
</combobox>
<label id="area_label" text="@.area" />
<combobox id="area" text="" cell_align="horizontal" cell_hspan="2" expansive="true" />
</hbox>
<label id="layers_label" text="@.layers" />
<combobox id="layers" text="" cell_align="horizontal" cell_hspan="2" />

View File

@ -52,6 +52,7 @@ ExportFileWindow::ExportFileWindow(const Doc* doc)
// Default export configuration
setResizeScale(m_docPref.saveCopy.resizeScale());
fill_area_combobox(m_doc->sprite(), area(), m_docPref.saveCopy.area());
fill_layers_combobox(m_doc->sprite(), layers(), m_docPref.saveCopy.layer());
fill_frames_combobox(m_doc->sprite(), frames(), m_docPref.saveCopy.frameTag());
fill_anidir_combobox(anidir(), m_docPref.saveCopy.aniDir());
@ -97,6 +98,7 @@ void ExportFileWindow::savePref()
{
m_docPref.saveCopy.filename(outputFilenameValue());
m_docPref.saveCopy.resizeScale(resizeValue());
m_docPref.saveCopy.area(areaValue());
m_docPref.saveCopy.layer(layersValue());
m_docPref.saveCopy.aniDir(aniDirValue());
m_docPref.saveCopy.frameTag(framesValue());
@ -116,6 +118,11 @@ double ExportFileWindow::resizeValue() const
return std::clamp(value, 0.001, 100000000.0);
}
std::string ExportFileWindow::areaValue() const
{
return area()->getValue();
}
std::string ExportFileWindow::layersValue() const
{
return layers()->getValue();

View File

@ -28,6 +28,7 @@ namespace app {
std::string outputFilenameValue() const;
double resizeValue() const;
std::string areaValue() const;
std::string layersValue() const;
std::string framesValue() const;
doc::AniDir aniDirValue() const;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
@ -17,17 +17,27 @@
#include "doc/layer.h"
#include "doc/selected_frames.h"
#include "doc/selected_layers.h"
#include "doc/slice.h"
#include "doc/sprite.h"
#include "doc/tag.h"
#include "ui/combobox.h"
namespace app {
const char* kWholeCanvas = "";
const char* kAllLayers = "";
const char* kAllFrames = "";
const char* kSelectedCanvas = "**selected-canvas**";
const char* kSelectedLayers = "**selected-layers**";
const char* kSelectedFrames = "**selected-frames**";
SliceListItem::SliceListItem(doc::Slice* slice)
: ListItem("Slice: " + slice->name())
, m_slice(slice)
{
setValue(m_slice->name());
}
LayerListItem::LayerListItem(doc::Layer* layer)
: ListItem(buildName(layer))
, m_layer(layer)
@ -57,6 +67,26 @@ FrameListItem::FrameListItem(doc::Tag* tag)
setValue(m_tag->name());
}
void fill_area_combobox(const doc::Sprite* sprite, ui::ComboBox* area, const std::string& defArea)
{
int i = area->addItem("Canvas");
dynamic_cast<ui::ListItem*>(area->getItem(i))->setValue(kWholeCanvas);
i = area->addItem("Selection");
dynamic_cast<ui::ListItem*>(area->getItem(i))->setValue(kSelectedCanvas);
if (defArea == kSelectedCanvas)
area->setSelectedItemIndex(i);
for (auto slice : sprite->slices()) {
if (slice->name().empty())
continue;
i = area->addItem(new SliceListItem(slice));
if (defArea == slice->name())
area->setSelectedItemIndex(i);
}
}
void fill_layers_combobox(const doc::Sprite* sprite, ui::ComboBox* layers, const std::string& defLayer)
{
int i = layers->addItem("Visible layers");

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
@ -18,6 +18,7 @@ namespace doc {
class Layer;
class SelectedFrames;
class SelectedLayers;
class Slice;
class Sprite;
class Tag;
}
@ -30,11 +31,21 @@ namespace app {
class RestoreVisibleLayers;
class Site;
extern const char* kWholeCanvas;
extern const char* kAllLayers;
extern const char* kAllFrames;
extern const char* kSelectedCanvas;
extern const char* kSelectedLayers;
extern const char* kSelectedFrames;
class SliceListItem : public ui::ListItem {
public:
SliceListItem(doc::Slice* slice);
doc::Slice* slice() const { return m_slice; }
private:
doc::Slice* m_slice;
};
class LayerListItem : public ui::ListItem {
public:
LayerListItem(doc::Layer* layer);
@ -52,6 +63,7 @@ namespace app {
doc::Tag* m_tag;
};
void fill_area_combobox(const doc::Sprite* sprite, ui::ComboBox* area, const std::string& defArea);
void fill_layers_combobox(const doc::Sprite* sprite, ui::ComboBox* layers, const std::string& defLayer);
void fill_frames_combobox(const doc::Sprite* sprite, ui::ComboBox* frames, const std::string& defFrame);
void fill_anidir_combobox(ui::ComboBox* anidir, doc::AniDir defAnidir);