mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-16 04:13:50 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
2b57fcaa6c
@ -266,7 +266,7 @@ include_directories(${PIXMAN_INCLUDE_DIR})
|
||||
# freetype
|
||||
if(USE_SHARED_FREETYPE)
|
||||
find_package(Freetype REQUIRED)
|
||||
else()
|
||||
elseif(NOT LAF_BACKEND STREQUAL "skia")
|
||||
set(FREETYPE_FOUND ON)
|
||||
set(FREETYPE_LIBRARY freetype)
|
||||
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
|
||||
@ -277,11 +277,9 @@ include_directories(${FREETYPE_INCLUDE_DIRS})
|
||||
# harfbuzz
|
||||
if(USE_SHARED_HARFBUZZ)
|
||||
find_package(HarfBuzz)
|
||||
else()
|
||||
if(NOT LAF_BACKEND STREQUAL "skia")
|
||||
set(HARFBUZZ_LIBRARIES harfbuzz)
|
||||
set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src)
|
||||
endif()
|
||||
elseif(NOT LAF_BACKEND STREQUAL "skia")
|
||||
set(HARFBUZZ_LIBRARIES harfbuzz)
|
||||
set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src)
|
||||
endif()
|
||||
include_directories(${HARFBUZZ_INCLUDE_DIRS})
|
||||
|
||||
@ -341,16 +339,6 @@ set(LAF_WITH_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable LAF tests")
|
||||
set(UNDO_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable undo tests")
|
||||
|
||||
add_subdirectory(laf)
|
||||
|
||||
# Use the Skia harfbuzz (it's a modified version with C++11 mutexes).
|
||||
if(LAF_BACKEND STREQUAL "skia")
|
||||
add_definitions(-DHAVE_CONFIG_OVERRIDE_H=1)
|
||||
set(HARFBUZZ_LIBRARIES ${SKIA_HARFBUZZ_LIBRARY})
|
||||
set(HARFBUZZ_INCLUDE_DIRS
|
||||
${SKIA_DIR}/third_party/harfbuzz
|
||||
${SKIA_DIR}/third_party/externals/harfbuzz/src)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
######################################################################
|
||||
|
2
laf
2
laf
@ -1 +1 @@
|
||||
Subproject commit 31ba3f99f17ba1ce7eeef6ad75b6d12396f34b04
|
||||
Subproject commit e1d2d23413e9028bfa6f0b08b74d9c57b3eed4a6
|
@ -14,6 +14,7 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/context.h"
|
||||
#include "app/doc.h"
|
||||
#include "app/file/palette_file.h"
|
||||
#include "app/file_selector.h"
|
||||
#include "app/i18n/strings.h"
|
||||
@ -82,13 +83,17 @@ void SavePaletteCommand::onExecute(Context* ctx)
|
||||
return;
|
||||
}
|
||||
}
|
||||
gfx::ColorSpaceRef colorSpace = nullptr;
|
||||
auto activeDoc = ctx->activeDocument();
|
||||
if (activeDoc)
|
||||
colorSpace = activeDoc->sprite()->colorSpace();
|
||||
|
||||
if (!save_palette(filename.c_str(), palette, 16)) // TODO 16 should be configurable
|
||||
if (!save_palette(filename.c_str(), palette, 16, colorSpace)) // TODO 16 should be configurable
|
||||
ui::Alert::show(fmt::format(Strings::alerts_error_saving_file(), filename));
|
||||
|
||||
if (m_preset == get_default_palette_preset_name()) {
|
||||
set_default_palette(palette);
|
||||
if (!ctx->activeDocument())
|
||||
if (!activeDoc)
|
||||
set_current_palette(palette, false);
|
||||
}
|
||||
if (m_saveAsPreset) {
|
||||
|
@ -118,7 +118,8 @@ Palette* load_palette(const char* filename,
|
||||
return pal;
|
||||
}
|
||||
|
||||
bool save_palette(const char* filename, const Palette* pal, int columns)
|
||||
bool save_palette(const char* filename, const Palette* pal, int columns,
|
||||
const gfx::ColorSpaceRef& cs)
|
||||
{
|
||||
dio::FileFormat dioFormat = dio::detect_format_by_file_extension(filename);
|
||||
bool success = false;
|
||||
@ -154,11 +155,12 @@ bool save_palette(const char* filename, const Palette* pal, int columns)
|
||||
int h = (pal->size() / w) + (pal->size() % w > 0 ? 1: 0);
|
||||
|
||||
Context tmpContext;
|
||||
gfx::ColorSpaceRef colorSpace = (cs ? cs: gfx::ColorSpace::MakeNone());
|
||||
Doc* doc = tmpContext.documents().add(
|
||||
new Doc(Sprite::MakeStdSprite(
|
||||
ImageSpec((pal->size() <= 256 ? doc::ColorMode::INDEXED:
|
||||
doc::ColorMode::RGB),
|
||||
w, h), pal->size())));
|
||||
w, h, 0, colorSpace), pal->size())));
|
||||
|
||||
Sprite* sprite = doc->sprite();
|
||||
doc->sprite()->setPalette(pal, false);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/paths.h"
|
||||
#include "gfx/color_space.h"
|
||||
|
||||
namespace doc {
|
||||
class Palette;
|
||||
@ -23,8 +24,10 @@ namespace app {
|
||||
|
||||
doc::Palette* load_palette(const char *filename,
|
||||
const FileOpConfig* config = nullptr);
|
||||
bool save_palette(const char *filename, const doc::Palette* pal,
|
||||
int columns);
|
||||
bool save_palette(const char *filename,
|
||||
const doc::Palette* pal,
|
||||
int columns,
|
||||
const gfx::ColorSpaceRef& colorSpace);
|
||||
|
||||
} // namespace app
|
||||
|
||||
|
@ -109,7 +109,7 @@ void load_default_palette()
|
||||
// Save default.ase file
|
||||
if (pal) {
|
||||
palFile = defaultPalName;
|
||||
save_palette(palFile.c_str(), pal.get(), 0);
|
||||
save_palette(palFile.c_str(), pal.get(), 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,6 +975,29 @@ int Dialog_modify(lua_State* L)
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// Handling options before option should support
|
||||
// using both or only one of them at the same time
|
||||
type = lua_getfield(L, 2, "options");
|
||||
if (type != LUA_TNIL) {
|
||||
if (lua_istable(L, -1)) {
|
||||
if (auto combobox = dynamic_cast<ui::ComboBox*>(widget)) {
|
||||
combobox->deleteAllItems();
|
||||
lua_pushnil(L);
|
||||
bool empty = true;
|
||||
while (lua_next(L, -2) != 0) {
|
||||
if (auto p = lua_tostring(L, -1)) {
|
||||
combobox->addItem(p);
|
||||
empty = false;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
if (empty)
|
||||
combobox->getEntryWidget()->setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
type = lua_getfield(L, 2, "option");
|
||||
if (auto p = lua_tostring(L, -1)) {
|
||||
if (auto combobox = dynamic_cast<ui::ComboBox*>(widget)) {
|
||||
@ -1018,7 +1041,7 @@ int Dialog_modify(lua_State* L)
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
// TODO combobox options? shades mode? file title / open / save / filetypes? on* events?
|
||||
// TODO shades mode? file title / open / save / filetypes? on* events?
|
||||
|
||||
if (relayout) {
|
||||
dlg->window.layout();
|
||||
|
@ -238,12 +238,17 @@ int Palette_saveAs(lua_State* L)
|
||||
auto obj = get_obj<PaletteObj>(L, 1);
|
||||
auto pal = obj->palette(L);
|
||||
const char* fn = luaL_checkstring(L, 2);
|
||||
Sprite* sprite = obj->sprite(L);
|
||||
|
||||
if (fn) {
|
||||
std::string absFn = base::get_absolute_path(fn);
|
||||
if (!ask_access(L, absFn.c_str(), FileAccessMode::Write, ResourceType::File))
|
||||
return luaL_error(L, "script doesn't have access to write file %s",
|
||||
absFn.c_str());
|
||||
save_palette(absFn.c_str(), pal, pal->size());
|
||||
save_palette(absFn.c_str(),
|
||||
pal,
|
||||
pal->size(),
|
||||
(sprite ? sprite->colorSpace(): nullptr));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
2
third_party/CMakeLists.txt
vendored
2
third_party/CMakeLists.txt
vendored
@ -79,7 +79,7 @@ if(NOT USE_SHARED_PIXMAN)
|
||||
add_subdirectory(pixman-cmake)
|
||||
endif()
|
||||
|
||||
if(NOT USE_SHARED_FREETYPE)
|
||||
if(NOT USE_SHARED_FREETYPE AND NOT LAF_BACKEND STREQUAL "skia")
|
||||
set(SKIP_INSTALL_ALL on)
|
||||
set(WITH_BZip2 OFF CACHE BOOL "")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user