mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 21:33:12 +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"/>
|
||||
|
||||
<check text="@.with_vars" id="with_vars" cell_hspan="2" />
|
||||
|
||||
|
||||
<check text="@.generate_html" id="generate_html" cell_hspan="2" />
|
||||
|
||||
<separator horizontal="true" cell_hspan="2" />
|
||||
|
@ -440,11 +440,11 @@
|
||||
pref="scripts.show_run_script_alert" />
|
||||
<hbox>
|
||||
<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="jpeg_options_alert" text="!jpeg" pref="jpeg.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="css_options_alert" text="!css" pref="css.show_alert" />
|
||||
</hbox>
|
||||
<separator horizontal="true" />
|
||||
<hbox>
|
||||
|
@ -125,6 +125,7 @@ endif()
|
||||
set(file_formats
|
||||
file/ase_format.cpp
|
||||
file/bmp_format.cpp
|
||||
file/css_format.cpp
|
||||
file/fli_format.cpp
|
||||
file/gif_format.cpp
|
||||
file/ico_format.cpp
|
||||
@ -132,7 +133,6 @@ set(file_formats
|
||||
file/pcx_format.cpp
|
||||
file/png_format.cpp
|
||||
file/svg_format.cpp
|
||||
file/css_format.cpp
|
||||
file/tga_format.cpp)
|
||||
if(WITH_WEBP_SUPPORT)
|
||||
list(APPEND file_formats file/webp_format.cpp)
|
||||
|
@ -987,10 +987,10 @@ private:
|
||||
advancedModeAlert()->resetWithDefaultValue();
|
||||
invalidFgBgColorAlert()->resetWithDefaultValue();
|
||||
runScriptAlert()->resetWithDefaultValue();
|
||||
cssOptionsAlert()->resetWithDefaultValue();
|
||||
gifOptionsAlert()->resetWithDefaultValue();
|
||||
jpegOptionsAlert()->resetWithDefaultValue();
|
||||
svgOptionsAlert()->resetWithDefaultValue();
|
||||
cssOptionsAlert()->resetWithDefaultValue();
|
||||
tgaOptionsAlert()->resetWithDefaultValue();
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ using namespace base;
|
||||
class CssFormat : public FileFormat {
|
||||
class CssOptions : public FormatOptions {
|
||||
public:
|
||||
CssOptions(): pixelScale(1), gutterSize(0),
|
||||
generateHtml(false), withVars(true) {}
|
||||
CssOptions() : pixelScale(1), gutterSize(0),
|
||||
generateHtml(false), withVars(true) { }
|
||||
int pixelScale;
|
||||
int gutterSize;
|
||||
bool generateHtml;
|
||||
@ -78,11 +78,14 @@ FileFormat *CreateCssFormat()
|
||||
return new CssFormat;
|
||||
}
|
||||
|
||||
bool CssFormat::onLoad(FileOp *fop) { return false; }
|
||||
bool CssFormat::onLoad(FileOp* fop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SAVE
|
||||
|
||||
bool CssFormat::onSave(FileOp *fop)
|
||||
bool CssFormat::onSave(FileOp* fop)
|
||||
{
|
||||
const Image* image = fop->sequenceImage();
|
||||
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) {
|
||||
if (a == 255) {
|
||||
fprintf(f, "#%02X%02X%02X", r, g, b);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
fprintf(f, "rgba(%d, %d, %d, %d)", r, g, b, a);
|
||||
}
|
||||
};
|
||||
@ -117,8 +121,13 @@ bool CssFormat::onSave(FileOp *fop)
|
||||
x, y, i);
|
||||
};
|
||||
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",
|
||||
css_options->pixelScale, css_options->gutterSize);
|
||||
fprintf(f, ":root {\n"
|
||||
"\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");
|
||||
if (image->pixelFormat() == IMAGE_INDEXED) {
|
||||
for (y = 0; y < 256; y++) {
|
||||
@ -222,7 +231,7 @@ bool CssFormat::onSave(FileOp *fop)
|
||||
}
|
||||
if (css_options->generateHtml) {
|
||||
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();
|
||||
fprintf(h,
|
||||
"<html><head><link rel=\"stylesheet\" media=\"all\" "
|
||||
@ -240,15 +249,13 @@ bool CssFormat::onSave(FileOp *fop)
|
||||
#endif
|
||||
|
||||
// Shows the CSS configuration dialog.
|
||||
FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp *fop)
|
||||
FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp* fop)
|
||||
{
|
||||
auto opts = fop->formatOptionsOfDocument<CssOptions>();
|
||||
|
||||
#ifdef ENABLE_UI
|
||||
if (fop->context() && fop->context()->isUIAvailable())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fop->context() && fop->context()->isUIAvailable()) {
|
||||
try {
|
||||
auto &pref = Preferences::instance();
|
||||
|
||||
if (pref.isSet(pref.css.pixelScale))
|
||||
@ -260,16 +267,14 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp *fop)
|
||||
if (pref.isSet(pref.css.generateHtml))
|
||||
opts->generateHtml = pref.css.generateHtml();
|
||||
|
||||
if (pref.css.showAlert())
|
||||
{
|
||||
if (pref.css.showAlert()) {
|
||||
app::gen::CssOptions win;
|
||||
win.pixelScale()->setTextf("%d", opts->pixelScale);
|
||||
win.withVars()->setSelected(opts->withVars);
|
||||
win.generateHtml()->setSelected(opts->generateHtml);
|
||||
win.openWindowInForeground();
|
||||
|
||||
if (win.closer() == win.ok())
|
||||
{
|
||||
if (win.closer() == win.ok()) {
|
||||
pref.css.showAlert(!win.dontShow()->isSelected());
|
||||
pref.css.pixelScale((int)win.pixelScale()->textInt());
|
||||
pref.css.withVars(win.withVars()->isSelected());
|
||||
@ -279,14 +284,12 @@ FormatOptionsPtr CssFormat::onAskUserForFormatOptions(FileOp *fop)
|
||||
opts->withVars = pref.css.withVars();
|
||||
opts->pixelScale = pref.css.pixelScale();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
opts.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
catch (std::exception &e) {
|
||||
Console::showException(e);
|
||||
return std::shared_ptr<CssOptions>(nullptr);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace app {
|
||||
|
||||
extern FileFormat* CreateAseFormat();
|
||||
extern FileFormat* CreateBmpFormat();
|
||||
extern FileFormat* CreateCssFormat();
|
||||
extern FileFormat* CreateFliFormat();
|
||||
extern FileFormat* CreateGifFormat();
|
||||
extern FileFormat* CreateIcoFormat();
|
||||
@ -30,7 +31,6 @@ extern FileFormat* CreatePcxFormat();
|
||||
extern FileFormat* CreatePngFormat();
|
||||
extern FileFormat* CreateSvgFormat();
|
||||
extern FileFormat* CreateTgaFormat();
|
||||
extern FileFormat* CreateCssFormat();
|
||||
|
||||
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
||||
extern FileFormat* CreateWebPFormat();
|
||||
@ -58,6 +58,7 @@ FileFormatsManager::FileFormatsManager()
|
||||
// The first format is the default image format in FileSelector
|
||||
registerFormat(CreateAseFormat());
|
||||
registerFormat(CreateBmpFormat());
|
||||
registerFormat(CreateCssFormat());
|
||||
registerFormat(CreateFliFormat());
|
||||
registerFormat(CreateGifFormat());
|
||||
registerFormat(CreateIcoFormat());
|
||||
@ -66,7 +67,6 @@ FileFormatsManager::FileFormatsManager()
|
||||
registerFormat(CreatePngFormat());
|
||||
registerFormat(CreateSvgFormat());
|
||||
registerFormat(CreateTgaFormat());
|
||||
registerFormat(CreateCssFormat());
|
||||
|
||||
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
||||
registerFormat(CreateWebPFormat());
|
||||
|
@ -73,7 +73,10 @@ FileFormat* CreateSvgFormat()
|
||||
return new SvgFormat;
|
||||
}
|
||||
|
||||
bool SvgFormat::onLoad(FileOp* fop) { return false;}
|
||||
bool SvgFormat::onLoad(FileOp* fop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SAVE
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user