mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 03:39:51 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
91c687b1e3
@ -52,10 +52,6 @@ enable_testing()
|
||||
# Options (these can be specified in cmake command line or modifying
|
||||
# CMakeCache.txt)
|
||||
|
||||
option(WITH_WEBP_SUPPORT "Enable support to load/save .webp files" on)
|
||||
option(WITH_DESKTOP_INTEGRATION "Enable desktop integration modules" off)
|
||||
option(WITH_QT_THUMBNAILER "Enable kde5/qt5 thumnailer" off)
|
||||
|
||||
option(USE_SHARED_CMARK "Use your installed copy of cmark" off)
|
||||
option(USE_SHARED_CURL "Use your installed copy of curl" off)
|
||||
option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off)
|
||||
@ -82,7 +78,10 @@ option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
|
||||
option(ENABLE_CLANG_TIDY "Enable static analysis" off)
|
||||
option(ENABLE_CCACHE "Use CCache to improve recompilation speed (optional)" on)
|
||||
option(ENABLE_SENTRY "Use Sentry SDK to report crashes" off)
|
||||
option(ENABLE_WEBP "Enable support to load/save .webp files" on)
|
||||
option(ENABLE_PSD "Enable experimental support for .psd files" off)
|
||||
option(ENABLE_DESKTOP_INTEGRATION "Enable desktop integration modules" off)
|
||||
option(ENABLE_QT_THUMBNAILER "Enable kde5/qt5 thumnailer" off)
|
||||
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
|
||||
|
||||
if(ENABLE_SENTRY)
|
||||
@ -236,7 +235,7 @@ include_directories(${PNG_INCLUDE_DIRS})
|
||||
add_definitions(-DPNG_NO_MMX_CODE) # Do not use MMX optimizations in PNG code
|
||||
|
||||
# libwebp
|
||||
if(WITH_WEBP_SUPPORT)
|
||||
if(ENABLE_WEBP)
|
||||
set(WEBP_LIBRARIES webp webpdemux libwebpmux)
|
||||
set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)
|
||||
include_directories(${WEBP_INCLUDE_DIR})
|
||||
|
@ -133,7 +133,7 @@ if(ENABLE_STEAM)
|
||||
add_subdirectory(steam)
|
||||
endif()
|
||||
|
||||
if(WITH_DESKTOP_INTEGRATION)
|
||||
if(ENABLE_DESKTOP_INTEGRATION)
|
||||
add_subdirectory(desktop)
|
||||
endif()
|
||||
|
||||
|
@ -87,8 +87,8 @@ add_custom_command(
|
||||
DEPENDS ${GEN_DEP} ${widget_files} ${string_files} "${SOURCE_DATA_DIR}/gui.xml")
|
||||
list(APPEND generated_files ${output_fn})
|
||||
|
||||
if(WITH_WEBP_SUPPORT)
|
||||
add_definitions(-DASEPRITE_WITH_WEBP_SUPPORT)
|
||||
if(ENABLE_WEBP)
|
||||
add_definitions(-DENABLE_WEBP)
|
||||
endif()
|
||||
|
||||
if(ENABLE_PSD)
|
||||
@ -138,7 +138,7 @@ set(file_formats
|
||||
file/png_format.cpp
|
||||
file/svg_format.cpp
|
||||
file/tga_format.cpp)
|
||||
if(WITH_WEBP_SUPPORT)
|
||||
if(ENABLE_WEBP)
|
||||
list(APPEND file_formats file/webp_format.cpp)
|
||||
endif()
|
||||
if(ENABLE_PSD)
|
||||
|
@ -37,7 +37,7 @@ extern FileFormat* CreateTgaFormat();
|
||||
extern FileFormat* CreatePsdFormat();
|
||||
#endif
|
||||
|
||||
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
||||
#ifdef ENABLE_WEBP
|
||||
extern FileFormat* CreateWebPFormat();
|
||||
#endif
|
||||
|
||||
@ -78,7 +78,7 @@ FileFormatsManager::FileFormatsManager()
|
||||
registerFormat(CreateSvgFormat());
|
||||
registerFormat(CreateTgaFormat());
|
||||
|
||||
#ifdef ASEPRITE_WITH_WEBP_SUPPORT
|
||||
#ifdef ENABLE_WEBP
|
||||
registerFormat(CreateWebPFormat());
|
||||
#endif
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ namespace app {
|
||||
int push_image_iterator_function(lua_State* L, const doc::Image* image, int extraArgIndex);
|
||||
void push_brush(lua_State* L, const doc::BrushRef& brush);
|
||||
void push_cel_image(lua_State* L, doc::Cel* cel);
|
||||
void push_cel_images(lua_State* L, const doc::ObjectIds& cels);
|
||||
void push_cels(lua_State* L, const doc::ObjectIds& cels);
|
||||
void push_cels(lua_State* L, doc::Layer* layer);
|
||||
void push_cels(lua_State* L, doc::Sprite* sprite);
|
||||
@ -143,7 +144,6 @@ namespace app {
|
||||
void push_doc_range(lua_State* L, Site& site);
|
||||
void push_group_layers(lua_State* L, doc::LayerGroup* group);
|
||||
void push_image(lua_State* L, doc::Image* image);
|
||||
void push_images(lua_State* L, const doc::ObjectIds& images);
|
||||
void push_layers(lua_State* L, const doc::ObjectIds& layers);
|
||||
void push_palette(lua_State* L, doc::Palette* palette);
|
||||
void push_plugin(lua_State* L, Extension* ext);
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,8 +9,9 @@
|
||||
#endif
|
||||
|
||||
#include "app/script/docobj.h"
|
||||
#include "app/script/engine.h"
|
||||
#include "app/script/luacpp.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/object_ids.h"
|
||||
|
||||
namespace app {
|
||||
@ -21,10 +22,10 @@ using namespace doc;
|
||||
namespace {
|
||||
|
||||
struct ImagesObj {
|
||||
ObjectIds images;
|
||||
ObjectIds cels;
|
||||
|
||||
ImagesObj(const ObjectIds& images)
|
||||
: images(images) {
|
||||
ImagesObj(const ObjectIds& cels)
|
||||
: cels(cels) {
|
||||
}
|
||||
|
||||
ImagesObj(const ImagesObj&) = delete;
|
||||
@ -40,7 +41,7 @@ int Images_gc(lua_State* L)
|
||||
int Images_len(lua_State* L)
|
||||
{
|
||||
auto obj = get_obj<ImagesObj>(L, 1);
|
||||
lua_pushinteger(L, obj->images.size());
|
||||
lua_pushinteger(L, obj->cels.size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -48,10 +49,13 @@ int Images_index(lua_State* L)
|
||||
{
|
||||
auto obj = get_obj<ImagesObj>(L, 1);
|
||||
const int i = lua_tointeger(L, 2);
|
||||
if (i >= 1 && i <= obj->images.size())
|
||||
push_docobj<Image>(L, obj->images[i-1]);
|
||||
else
|
||||
lua_pushnil(L);
|
||||
if (i >= 1 && i <= obj->cels.size()) {
|
||||
if (auto cel = doc::get<doc::Cel>(obj->cels[i-1])) {
|
||||
push_cel_image(L, cel);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -72,9 +76,9 @@ void register_images_class(lua_State* L)
|
||||
REG_CLASS(L, Images);
|
||||
}
|
||||
|
||||
void push_images(lua_State* L, const ObjectIds& images)
|
||||
void push_cel_images(lua_State* L, const ObjectIds& cels)
|
||||
{
|
||||
push_new<ImagesObj>(L, images);
|
||||
push_new<ImagesObj>(L, cels);
|
||||
}
|
||||
|
||||
} // namespace script
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2021 Igara Studio S.A.
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -219,31 +219,35 @@ int Range_get_cels(lua_State* L)
|
||||
int Range_get_images(lua_State* L)
|
||||
{
|
||||
auto obj = get_obj<RangeObj>(L, 1);
|
||||
std::set<ObjectId> imagesSet;
|
||||
std::set<ObjectId> set;
|
||||
for (auto celId : obj->cels) {
|
||||
Cel* cel = check_docobj(L, doc::get<Cel>(celId));
|
||||
imagesSet.insert(cel->image()->id());
|
||||
if (Cel* link = cel->link())
|
||||
cel = link;
|
||||
set.insert(cel->id());
|
||||
}
|
||||
ObjectIds images;
|
||||
for (auto imageId : imagesSet)
|
||||
images.push_back(imageId);
|
||||
push_images(L, images);
|
||||
ObjectIds cels;
|
||||
for (auto celId : set)
|
||||
cels.push_back(celId);
|
||||
push_cel_images(L, cels);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Range_get_editableImages(lua_State* L)
|
||||
{
|
||||
auto obj = get_obj<RangeObj>(L, 1);
|
||||
std::set<ObjectId> imagesSet;
|
||||
std::set<ObjectId> set;
|
||||
for (auto celId : obj->cels) {
|
||||
Cel* cel = check_docobj(L, doc::get<Cel>(celId));
|
||||
if (Cel* link = cel->link())
|
||||
cel = link;
|
||||
if (cel->layer()->isEditable())
|
||||
imagesSet.insert(cel->image()->id());
|
||||
set.insert(cel->id());
|
||||
}
|
||||
ObjectIds images;
|
||||
for (auto imageId : imagesSet)
|
||||
images.push_back(imageId);
|
||||
push_images(L, images);
|
||||
ObjectIds cels;
|
||||
for (auto celId : set)
|
||||
cels.push_back(celId);
|
||||
push_cel_images(L, cels);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,32 @@ namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
namespace {
|
||||
|
||||
// Used to show a view temporarily (the one with the file to be
|
||||
// closed) and restore the previous view. E.g. When we close the
|
||||
// non-active sprite pressing the cross button in a sprite tab.
|
||||
class SetRestoreDocView {
|
||||
public:
|
||||
SetRestoreDocView(UIContext* ctx, DocView* newView)
|
||||
: m_ctx(ctx)
|
||||
, m_oldView(ctx->activeView()) {
|
||||
if (newView != m_oldView)
|
||||
m_ctx->setActiveView(newView);
|
||||
else
|
||||
m_oldView = nullptr;
|
||||
}
|
||||
|
||||
~SetRestoreDocView() {
|
||||
if (m_oldView)
|
||||
m_ctx->setActiveView(m_oldView);
|
||||
}
|
||||
|
||||
private:
|
||||
UIContext* m_ctx;
|
||||
DocView* m_oldView;
|
||||
};
|
||||
|
||||
class AppEditor : public Editor,
|
||||
public EditorObserver,
|
||||
public EditorCustomizationDelegate {
|
||||
@ -193,6 +219,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
DocView::DocView(Doc* document, Type type,
|
||||
DocViewPreviewDelegate* previewDelegate)
|
||||
: Box(VERTICAL)
|
||||
@ -282,42 +310,41 @@ bool DocView::onCloseView(Workspace* workspace, bool quitting)
|
||||
}
|
||||
|
||||
UIContext* ctx = UIContext::instance();
|
||||
SetRestoreDocView restoreView(ctx, this);
|
||||
bool save_it;
|
||||
bool try_again = true;
|
||||
|
||||
while (try_again) {
|
||||
// This flag indicates if we have to sabe the sprite before to destroy it
|
||||
save_it = false;
|
||||
{
|
||||
// see if the sprite has changes
|
||||
while (m_document->isModified()) {
|
||||
// ask what want to do the user with the changes in the sprite
|
||||
int ret = Alert::show(
|
||||
fmt::format(
|
||||
Strings::alerts_save_sprite_changes(),
|
||||
m_document->name(),
|
||||
(quitting ? Strings::alerts_save_sprite_changes_quitting():
|
||||
Strings::alerts_save_sprite_changes_closing())));
|
||||
|
||||
if (ret == 1) {
|
||||
// "save": save the changes
|
||||
save_it = true;
|
||||
break;
|
||||
}
|
||||
else if (ret != 2) {
|
||||
// "cancel" or "ESC" */
|
||||
return false; // we back doing nothing
|
||||
}
|
||||
else {
|
||||
// "discard"
|
||||
break;
|
||||
}
|
||||
// See if the sprite has changes
|
||||
while (m_document->isModified()) {
|
||||
// ask what want to do the user with the changes in the sprite
|
||||
int ret = Alert::show(
|
||||
fmt::format(
|
||||
Strings::alerts_save_sprite_changes(),
|
||||
m_document->name(),
|
||||
(quitting ? Strings::alerts_save_sprite_changes_quitting():
|
||||
Strings::alerts_save_sprite_changes_closing())));
|
||||
|
||||
if (ret == 1) {
|
||||
// "save": save the changes
|
||||
save_it = true;
|
||||
break;
|
||||
}
|
||||
else if (ret != 2) {
|
||||
// "cancel" or "ESC" */
|
||||
return false; // we back doing nothing
|
||||
}
|
||||
else {
|
||||
// "discard"
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Does we need to save the sprite?
|
||||
if (save_it) {
|
||||
ctx->setActiveView(this);
|
||||
ctx->updateFlags();
|
||||
|
||||
Command* save_command =
|
||||
|
@ -10,6 +10,6 @@ install(PROGRAMS aseprite-thumbnailer DESTINATION bin)
|
||||
install(FILES gnome/aseprite.thumbnailer DESTINATION share/thumbnailers)
|
||||
|
||||
# Qt Thumbnailer
|
||||
if(WITH_QT_THUMBNAILER)
|
||||
if(ENABLE_QT_THUMBNAILER)
|
||||
add_subdirectory(kde)
|
||||
endif()
|
||||
|
@ -329,8 +329,13 @@ Image* convert_pixel_format(
|
||||
|
||||
if (!is_background && c == image->maskColor())
|
||||
*dst_it = rgba(0, 0, 0, 0);
|
||||
else
|
||||
*dst_it = palette->getEntry(c);
|
||||
else {
|
||||
const uint32_t p = palette->getEntry(c);
|
||||
if (is_background)
|
||||
*dst_it = rgba(rgba_getr(p), rgba_getg(p), rgba_getb(p), 255);
|
||||
else
|
||||
*dst_it = p;
|
||||
}
|
||||
}
|
||||
ASSERT(dst_it == dst_end);
|
||||
break;
|
||||
|
2
third_party/CMakeLists.txt
vendored
2
third_party/CMakeLists.txt
vendored
@ -33,7 +33,7 @@ if(NOT USE_SHARED_GIFLIB)
|
||||
add_subdirectory(giflib)
|
||||
endif()
|
||||
|
||||
if(WITH_WEBP_SUPPORT)
|
||||
if(ENABLE_WEBP)
|
||||
set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "Build extras.")
|
||||
set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "Build animation utilities.")
|
||||
set(WEBP_BUILD_CWEBP OFF CACHE BOOL "Build the cwebp command line tool.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user