mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-04 13:59:46 +00:00
Minor formatting changes
This commit is contained in:
parent
e813773445
commit
b1016a419f
@ -7,7 +7,7 @@
|
|||||||
<expr id="pixel_scale" magnet="true" cell_align="horizontal"/>
|
<expr id="pixel_scale" magnet="true" cell_align="horizontal"/>
|
||||||
|
|
||||||
<check text="@.with_vars" id="with_vars" cell_hspan="2" />
|
<check text="@.with_vars" id="with_vars" cell_hspan="2" />
|
||||||
|
|
||||||
<check text="@.generate_html" id="generate_html" cell_hspan="2" />
|
<check text="@.generate_html" id="generate_html" cell_hspan="2" />
|
||||||
|
|
||||||
<separator horizontal="true" cell_hspan="2" />
|
<separator horizontal="true" cell_hspan="2" />
|
||||||
|
@ -440,11 +440,11 @@
|
|||||||
pref="scripts.show_run_script_alert" />
|
pref="scripts.show_run_script_alert" />
|
||||||
<hbox>
|
<hbox>
|
||||||
<label text="@.image_format_alerts" />
|
<label text="@.image_format_alerts" />
|
||||||
|
<check id="css_options_alert" text="!css" pref="css.show_alert" />
|
||||||
<check id="gif_options_alert" text="!gif" pref="gif.show_alert" />
|
<check id="gif_options_alert" text="!gif" pref="gif.show_alert" />
|
||||||
<check id="jpeg_options_alert" text="!jpeg" pref="jpeg.show_alert" />
|
<check id="jpeg_options_alert" text="!jpeg" pref="jpeg.show_alert" />
|
||||||
<check id="svg_options_alert" text="!svg" pref="svg.show_alert" />
|
<check id="svg_options_alert" text="!svg" pref="svg.show_alert" />
|
||||||
<check id="tga_options_alert" text="!tga" pref="tga.show_alert" />
|
<check id="tga_options_alert" text="!tga" pref="tga.show_alert" />
|
||||||
<check id="css_options_alert" text="!css" pref="css.show_alert" />
|
|
||||||
</hbox>
|
</hbox>
|
||||||
<separator horizontal="true" />
|
<separator horizontal="true" />
|
||||||
<hbox>
|
<hbox>
|
||||||
|
@ -125,6 +125,7 @@ endif()
|
|||||||
set(file_formats
|
set(file_formats
|
||||||
file/ase_format.cpp
|
file/ase_format.cpp
|
||||||
file/bmp_format.cpp
|
file/bmp_format.cpp
|
||||||
|
file/css_format.cpp
|
||||||
file/fli_format.cpp
|
file/fli_format.cpp
|
||||||
file/gif_format.cpp
|
file/gif_format.cpp
|
||||||
file/ico_format.cpp
|
file/ico_format.cpp
|
||||||
@ -132,7 +133,6 @@ set(file_formats
|
|||||||
file/pcx_format.cpp
|
file/pcx_format.cpp
|
||||||
file/png_format.cpp
|
file/png_format.cpp
|
||||||
file/svg_format.cpp
|
file/svg_format.cpp
|
||||||
file/css_format.cpp
|
|
||||||
file/tga_format.cpp)
|
file/tga_format.cpp)
|
||||||
if(WITH_WEBP_SUPPORT)
|
if(WITH_WEBP_SUPPORT)
|
||||||
list(APPEND file_formats file/webp_format.cpp)
|
list(APPEND file_formats file/webp_format.cpp)
|
||||||
|
@ -987,10 +987,10 @@ private:
|
|||||||
advancedModeAlert()->resetWithDefaultValue();
|
advancedModeAlert()->resetWithDefaultValue();
|
||||||
invalidFgBgColorAlert()->resetWithDefaultValue();
|
invalidFgBgColorAlert()->resetWithDefaultValue();
|
||||||
runScriptAlert()->resetWithDefaultValue();
|
runScriptAlert()->resetWithDefaultValue();
|
||||||
|
cssOptionsAlert()->resetWithDefaultValue();
|
||||||
gifOptionsAlert()->resetWithDefaultValue();
|
gifOptionsAlert()->resetWithDefaultValue();
|
||||||
jpegOptionsAlert()->resetWithDefaultValue();
|
jpegOptionsAlert()->resetWithDefaultValue();
|
||||||
svgOptionsAlert()->resetWithDefaultValue();
|
svgOptionsAlert()->resetWithDefaultValue();
|
||||||
cssOptionsAlert()->resetWithDefaultValue();
|
|
||||||
tgaOptionsAlert()->resetWithDefaultValue();
|
tgaOptionsAlert()->resetWithDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ using namespace base;
|
|||||||
class CssFormat : public FileFormat {
|
class CssFormat : public FileFormat {
|
||||||
class CssOptions : public FormatOptions {
|
class CssOptions : public FormatOptions {
|
||||||
public:
|
public:
|
||||||
CssOptions(): pixelScale(1), gutterSize(0),
|
CssOptions() : pixelScale(1), gutterSize(0),
|
||||||
generateHtml(false), withVars(true) {}
|
generateHtml(false), withVars(true) { }
|
||||||
int pixelScale;
|
int pixelScale;
|
||||||
int gutterSize;
|
int gutterSize;
|
||||||
bool generateHtml;
|
bool generateHtml;
|
||||||
@ -78,11 +78,14 @@ FileFormat *CreateCssFormat()
|
|||||||
return new CssFormat;
|
return new CssFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CssFormat::onLoad(FileOp *fop) { return false; }
|
bool CssFormat::onLoad(FileOp* fop)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_SAVE
|
#ifdef ENABLE_SAVE
|
||||||
|
|
||||||
bool CssFormat::onSave(FileOp *fop)
|
bool CssFormat::onSave(FileOp* fop)
|
||||||
{
|
{
|
||||||
const Image* image = fop->sequenceImage();
|
const Image* image = fop->sequenceImage();
|
||||||
int x, y, c, r, g, b, a, alpha;
|
int x, y, c, r, g, b, a, alpha;
|
||||||
@ -92,7 +95,8 @@ bool CssFormat::onSave(FileOp *fop)
|
|||||||
auto print_color = [f](int r, int g, int b, int a) {
|
auto print_color = [f](int r, int g, int b, int a) {
|
||||||
if (a == 255) {
|
if (a == 255) {
|
||||||
fprintf(f, "#%02X%02X%02X", r, g, b);
|
fprintf(f, "#%02X%02X%02X", r, g, b);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
fprintf(f, "rgba(%d, %d, %d, %d)", r, g, b, a);
|
fprintf(f, "rgba(%d, %d, %d, %d)", r, g, b, a);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -117,8 +121,13 @@ bool CssFormat::onSave(FileOp *fop)
|
|||||||
x, y, i);
|
x, y, i);
|
||||||
};
|
};
|
||||||
if (css_options->withVars) {
|
if (css_options->withVars) {
|
||||||
fprintf(f, ":root {\n\t--blur: 0px;\n\t--spread: 0px;\n\t--pixel-size: %dpx;\n\t--gutter-size: %dpx;\n",
|
fprintf(f, ":root {\n"
|
||||||
css_options->pixelScale, css_options->gutterSize);
|
"\t--blur: 0px;\n"
|
||||||
|
"\t--spread: 0px;\n"
|
||||||
|
"\t--pixel-size: %dpx;\n"
|
||||||
|
"\t--gutter-size: %dpx;\n",
|
||||||
|
css_options->pixelScale,
|
||||||
|
css_options->gutterSize);
|
||||||
fprintf(f, "\t--shadow-mult: calc(var(--gutter-size) + var(--pixel-size));\n");
|
fprintf(f, "\t--shadow-mult: calc(var(--gutter-size) + var(--pixel-size));\n");
|
||||||
if (image->pixelFormat() == IMAGE_INDEXED) {
|
if (image->pixelFormat() == IMAGE_INDEXED) {
|
||||||
for (y = 0; y < 256; y++) {
|
for (y = 0; y < 256; y++) {
|
||||||
@ -222,7 +231,7 @@ bool CssFormat::onSave(FileOp *fop)
|
|||||||
}
|
}
|
||||||
if (css_options->generateHtml) {
|
if (css_options->generateHtml) {
|
||||||
std::string html_filepath = fop->filename() + ".html";
|
std::string html_filepath = fop->filename() + ".html";
|
||||||
FileHandle handle(open_file_with_exception_sync_on_close(html_filepath, "wb"));
|
FileHandle handle(open_file_with_exception_sync_on_close(html_filepath, "wb"));
|
||||||
FILE* h = handle.get();
|
FILE* h = handle.get();
|
||||||
fprintf(h,
|
fprintf(h,
|
||||||
"<html><head><link rel=\"stylesheet\" media=\"all\" "
|
"<html><head><link rel=\"stylesheet\" media=\"all\" "
|
||||||
@ -240,15 +249,13 @@ bool CssFormat::onSave(FileOp *fop)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Shows the CSS configuration dialog.
|
// Shows the CSS configuration dialog.
|
||||||
FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp *fop)
|
FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp* fop)
|
||||||
{
|
{
|
||||||
auto opts = fop->formatOptionsOfDocument<CssOptions>();
|
auto opts = fop->formatOptionsOfDocument<CssOptions>();
|
||||||
|
|
||||||
#ifdef ENABLE_UI
|
#ifdef ENABLE_UI
|
||||||
if (fop->context() && fop->context()->isUIAvailable())
|
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
auto &pref = Preferences::instance();
|
auto &pref = Preferences::instance();
|
||||||
|
|
||||||
if (pref.isSet(pref.css.pixelScale))
|
if (pref.isSet(pref.css.pixelScale))
|
||||||
@ -260,16 +267,14 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp *fop)
|
|||||||
if (pref.isSet(pref.css.generateHtml))
|
if (pref.isSet(pref.css.generateHtml))
|
||||||
opts->generateHtml = pref.css.generateHtml();
|
opts->generateHtml = pref.css.generateHtml();
|
||||||
|
|
||||||
if (pref.css.showAlert())
|
if (pref.css.showAlert()) {
|
||||||
{
|
|
||||||
app::gen::CssOptions win;
|
app::gen::CssOptions win;
|
||||||
win.pixelScale()->setTextf("%d", opts->pixelScale);
|
win.pixelScale()->setTextf("%d", opts->pixelScale);
|
||||||
win.withVars()->setSelected(opts->withVars);
|
win.withVars()->setSelected(opts->withVars);
|
||||||
win.generateHtml()->setSelected(opts->generateHtml);
|
win.generateHtml()->setSelected(opts->generateHtml);
|
||||||
win.openWindowInForeground();
|
win.openWindowInForeground();
|
||||||
|
|
||||||
if (win.closer() == win.ok())
|
if (win.closer() == win.ok()) {
|
||||||
{
|
|
||||||
pref.css.showAlert(!win.dontShow()->isSelected());
|
pref.css.showAlert(!win.dontShow()->isSelected());
|
||||||
pref.css.pixelScale((int)win.pixelScale()->textInt());
|
pref.css.pixelScale((int)win.pixelScale()->textInt());
|
||||||
pref.css.withVars(win.withVars()->isSelected());
|
pref.css.withVars(win.withVars()->isSelected());
|
||||||
@ -279,14 +284,12 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp *fop)
|
|||||||
opts->withVars = pref.css.withVars();
|
opts->withVars = pref.css.withVars();
|
||||||
opts->pixelScale = pref.css.pixelScale();
|
opts->pixelScale = pref.css.pixelScale();
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
opts.reset();
|
opts.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e) {
|
||||||
{
|
|
||||||
Console::showException(e);
|
Console::showException(e);
|
||||||
return std::shared_ptr<CssOptions>(nullptr);
|
return std::shared_ptr<CssOptions>(nullptr);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace app {
|
|||||||
|
|
||||||
extern FileFormat* CreateAseFormat();
|
extern FileFormat* CreateAseFormat();
|
||||||
extern FileFormat* CreateBmpFormat();
|
extern FileFormat* CreateBmpFormat();
|
||||||
|
extern FileFormat* CreateCssFormat();
|
||||||
extern FileFormat* CreateFliFormat();
|
extern FileFormat* CreateFliFormat();
|
||||||
extern FileFormat* CreateGifFormat();
|
extern FileFormat* CreateGifFormat();
|
||||||
extern FileFormat* CreateIcoFormat();
|
extern FileFormat* CreateIcoFormat();
|
||||||
@ -30,7 +31,6 @@ extern FileFormat* CreatePcxFormat();
|
|||||||
extern FileFormat* CreatePngFormat();
|
extern FileFormat* CreatePngFormat();
|
||||||
extern FileFormat* CreateSvgFormat();
|
extern FileFormat* CreateSvgFormat();
|
||||||
extern FileFormat* CreateTgaFormat();
|
extern FileFormat* CreateTgaFormat();
|
||||||
extern FileFormat* CreateCssFormat();
|
|
||||||
|
|
||||||
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
||||||
extern FileFormat* CreateWebPFormat();
|
extern FileFormat* CreateWebPFormat();
|
||||||
@ -58,6 +58,7 @@ FileFormatsManager::FileFormatsManager()
|
|||||||
// The first format is the default image format in FileSelector
|
// The first format is the default image format in FileSelector
|
||||||
registerFormat(CreateAseFormat());
|
registerFormat(CreateAseFormat());
|
||||||
registerFormat(CreateBmpFormat());
|
registerFormat(CreateBmpFormat());
|
||||||
|
registerFormat(CreateCssFormat());
|
||||||
registerFormat(CreateFliFormat());
|
registerFormat(CreateFliFormat());
|
||||||
registerFormat(CreateGifFormat());
|
registerFormat(CreateGifFormat());
|
||||||
registerFormat(CreateIcoFormat());
|
registerFormat(CreateIcoFormat());
|
||||||
@ -66,7 +67,6 @@ FileFormatsManager::FileFormatsManager()
|
|||||||
registerFormat(CreatePngFormat());
|
registerFormat(CreatePngFormat());
|
||||||
registerFormat(CreateSvgFormat());
|
registerFormat(CreateSvgFormat());
|
||||||
registerFormat(CreateTgaFormat());
|
registerFormat(CreateTgaFormat());
|
||||||
registerFormat(CreateCssFormat());
|
|
||||||
|
|
||||||
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
||||||
registerFormat(CreateWebPFormat());
|
registerFormat(CreateWebPFormat());
|
||||||
|
@ -73,7 +73,10 @@ FileFormat* CreateSvgFormat()
|
|||||||
return new SvgFormat;
|
return new SvgFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SvgFormat::onLoad(FileOp* fop) { return false;}
|
bool SvgFormat::onLoad(FileOp* fop)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_SAVE
|
#ifdef ENABLE_SAVE
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user