Merge branch 'main' into beta

This commit is contained in:
David Capello 2021-08-19 10:34:32 -03:00
commit a5b41d2630
9 changed files with 42 additions and 14 deletions

View File

@ -19,7 +19,7 @@
You should be able to compile Aseprite successfully on the following
platforms:
* Windows 10 + [Visual Studio Community 2019 + Windows 10.0.18362.0 SDK](https://imgur.com/a/7zs51IT) (we don't support [MinGW](#mingw))
* Windows 10 + [Visual Studio Community 2019 + Windows 10.0 SDK (the latest version available)](https://imgur.com/a/7zs51IT) (we don't support [MinGW](#mingw))
* macOS 10.15.3 Catalina + Xcode 11.2.1 + macOS 10.15 SDK (older version might work)
* Linux + gcc 9.2 or clang 9.0

View File

@ -53,6 +53,7 @@ Import Sprite Sheet
END
error_loading_file = Error<<Error loading file: {0}||&OK
error_saving_file = Error<<Error saving file: {0}||&OK
file_format_doesnt_support_palette = Error<<Cannot save a color palette in {0} format||&OK
export_animation_in_sequence = <<<END
Notice
<<Do you want to export the animation in {0} files?

View File

@ -303,7 +303,8 @@ int App::initialize(const AppOptions& options)
ui::set_mouse_cursor_scale(preferences().cursor.cursorScale());
ui::set_mouse_cursor(kArrowCursor);
ui::Manager::getDefault()->invalidate();
auto manager = ui::Manager::getDefault();
manager->invalidate();
// Create the main window.
m_mainWindow.reset(new MainWindow);
@ -322,7 +323,16 @@ int App::initialize(const AppOptions& options)
m_mainWindow->openWindow();
// Redraw the whole screen.
ui::Manager::getDefault()->invalidate();
manager->invalidate();
// Pump some messages so we receive the first
// Manager::onNewDisplayConfiguration() and we known the manager
// initial size. This is required so if the OpenFileCommand
// (called when we're processing the CLI with OpenBatchOfFiles)
// shows a dialog to open a sequence of files, the dialog is
// centered correctly to the manager bounds.
ui::MessageLoop loop(manager);
loop.pumpMessages();
}
#endif // ENABLE_UI

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -50,7 +51,7 @@ void SavePaletteCommand::onLoadParams(const Params& params)
m_saveAsPreset = (params.get("saveAsPreset") == "true");
}
void SavePaletteCommand::onExecute(Context* context)
void SavePaletteCommand::onExecute(Context* ctx)
{
const doc::Palette* palette = get_current_palette();
std::string filename;
@ -68,6 +69,18 @@ void SavePaletteCommand::onExecute(Context* context)
return;
filename = selFilename.front();
// Check that the file format supports saving indexed images/color
// palettes (e.g. if the user specified .jpg we should show that
// that file format is not supported to save color palettes)
if (!base::has_file_extension(filename, exts)) {
if (ctx->isUIAvailable()) {
ui::Alert::show(
fmt::format(Strings::alerts_file_format_doesnt_support_palette(),
base::get_file_extension(filename)));
}
return;
}
}
if (!save_palette(filename.c_str(), palette, 16)) // TODO 16 should be configurable
@ -75,7 +88,7 @@ void SavePaletteCommand::onExecute(Context* context)
if (m_preset == get_default_palette_preset_name()) {
set_default_palette(palette);
if (!context->activeDocument())
if (!ctx->activeDocument())
set_current_palette(palette, false);
}
if (m_saveAsPreset) {

View File

@ -63,11 +63,13 @@ base::paths get_readable_extensions()
return paths;
}
base::paths get_writable_extensions()
base::paths get_writable_extensions(const int requiredFormatFlag)
{
base::paths paths;
for (const FileFormat* format : *FileFormatsManager::instance()) {
if (format->support(FILE_SUPPORT_SAVE))
if (format->support(FILE_SUPPORT_SAVE) &&
(requiredFormatFlag == 0 ||
format->support(requiredFormatFlag)))
format->getExtensions(paths);
}
return paths;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -281,7 +281,7 @@ namespace app {
// Available extensions for each load/save operation.
base::paths get_readable_extensions();
base::paths get_writable_extensions();
base::paths get_writable_extensions(const int requiredFormatFlag = 0);
// High-level routines to load/save documents.
Doc* load_document(Context* context, const std::string& filename);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2020 Igara Studio S.A.
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -357,7 +357,9 @@ bool JpegFormat::onSave(FileOp* fop)
JSAMPARRAY buffer;
JDIMENSION buffer_height;
const auto jpeg_options = std::static_pointer_cast<JpegOptions>(fop->formatOptions());
const int qualityValue = (int)base::clamp(100.0f * jpeg_options->quality, 0.f, 100.f);
const int qualityValue =
(jpeg_options ? (int)base::clamp(100.0f * jpeg_options->quality, 0.f, 100.f):
100);
int c;

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2019 Igara Studio S.A.
// Copyright (C) 2018-2021 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -47,7 +47,7 @@ base::paths get_readable_palette_extensions()
base::paths get_writable_palette_extensions()
{
base::paths paths = get_writable_extensions();
base::paths paths = get_writable_extensions(FILE_SUPPORT_INDEXED);
for (const char* s : palExts)
paths.push_back(s);
return paths;

View File

@ -284,7 +284,7 @@ void Manager::run()
if (first_time) {
first_time = false;
Manager::getDefault()->invalidate();
invalidate();
set_mouse_cursor(kArrowCursor);
}