mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Merge branch 'master' into beta
This commit is contained in:
commit
bff884b4c8
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@ -77,11 +77,11 @@ private:
|
|||||||
|
|
||||||
## C++11
|
## C++11
|
||||||
|
|
||||||
We are using some C++11 features, mainly:
|
We are using some modern C++ (C++11, C++14, etc.) features, mainly:
|
||||||
|
|
||||||
* Use `nullptr` instead of `NULL` macro
|
* Use `nullptr` instead of `NULL` macro
|
||||||
* Use `auto` for complex types, iterators, or when it's variable type
|
* Use `auto` for complex types, iterators, or when the variable type
|
||||||
obvious (e.g. `auto s = new Sprite;`)
|
is obvious (e.g. `auto s = new Sprite;`)
|
||||||
* Use range-based for loops (`for (const auto& item : values) { ... }`)
|
* Use range-based for loops (`for (const auto& item : values) { ... }`)
|
||||||
* Use template alias (`template<typename T> alias = orig<T>;`)
|
* Use template alias (`template<typename T> alias = orig<T>;`)
|
||||||
* Use non-generic lambda functions
|
* Use non-generic lambda functions
|
||||||
|
@ -252,9 +252,9 @@ std::string FlipCommand::onGetFriendlyName() const
|
|||||||
content = Strings::commands_Flip_Canvas();
|
content = Strings::commands_Flip_Canvas();
|
||||||
|
|
||||||
if (m_flipType == doc::algorithm::FlipHorizontal)
|
if (m_flipType == doc::algorithm::FlipHorizontal)
|
||||||
content = Strings::commands_Flip_Horizontally();
|
orientation = Strings::commands_Flip_Horizontally();
|
||||||
else
|
else
|
||||||
content = Strings::commands_Flip_Vertically();
|
orientation = Strings::commands_Flip_Vertically();
|
||||||
|
|
||||||
return fmt::format(getBaseFriendlyName(), content, orientation);
|
return fmt::format(getBaseFriendlyName(), content, orientation);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,6 @@
|
|||||||
|
|
||||||
// Increment this value if the scripting API is modified between two
|
// Increment this value if the scripting API is modified between two
|
||||||
// released Aseprite versions.
|
// released Aseprite versions.
|
||||||
#define API_VERSION 12
|
#define API_VERSION 13
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019 Igara Studio S.A.
|
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/resource_finder.h"
|
#include "app/resource_finder.h"
|
||||||
#include "app/script/luacpp.h"
|
#include "app/script/luacpp.h"
|
||||||
|
#include "app/script/security.h"
|
||||||
#include "base/fs.h"
|
#include "base/fs.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
@ -117,6 +118,71 @@ int AppFS_listFiles(lua_State* L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AppFS_makeDirectory(lua_State* L)
|
||||||
|
{
|
||||||
|
const char* path = luaL_checkstring(L, 1);
|
||||||
|
if (base::is_directory(path)) {
|
||||||
|
lua_pushboolean(L, true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ask_access(L, path, FileAccessMode::Write, true))
|
||||||
|
return luaL_error(L, "the script doesn't have access to create the directory '%s'", path);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// TODO don't throw exception from base::make_directory() function
|
||||||
|
base::make_directory(path);
|
||||||
|
}
|
||||||
|
catch (const std::exception&) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
lua_pushboolean(L, base::is_directory(path));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppFS_makeAllDirectories(lua_State* L)
|
||||||
|
{
|
||||||
|
const char* path = luaL_checkstring(L, 1);
|
||||||
|
if (base::is_directory(path)) {
|
||||||
|
lua_pushboolean(L, true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ask_access(L, path, FileAccessMode::Write, true))
|
||||||
|
return luaL_error(L, "the script doesn't have access to create all directories '%s'", path);
|
||||||
|
|
||||||
|
try {
|
||||||
|
base::make_all_directories(path);
|
||||||
|
}
|
||||||
|
catch (const std::exception&) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
lua_pushboolean(L, base::is_directory(path));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AppFS_removeDirectory(lua_State* L)
|
||||||
|
{
|
||||||
|
const char* path = luaL_checkstring(L, 1);
|
||||||
|
if (!base::is_directory(path)) {
|
||||||
|
lua_pushboolean(L, (base::is_file(path) ? false: // Cannot remove files
|
||||||
|
true)); // The directory is already removed
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ask_access(L, path, FileAccessMode::Write, true))
|
||||||
|
return luaL_error(L, "the script doesn't have access to remove the directory '%s'", path);
|
||||||
|
|
||||||
|
try {
|
||||||
|
base::remove_directory(path);
|
||||||
|
}
|
||||||
|
catch (const std::exception&) {
|
||||||
|
// do nothing...
|
||||||
|
}
|
||||||
|
lua_pushboolean(L, !base::is_directory(path));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
const Property AppFS_properties[] = {
|
const Property AppFS_properties[] = {
|
||||||
{ "pathSeparator", AppFS_pathSeparator, nullptr },
|
{ "pathSeparator", AppFS_pathSeparator, nullptr },
|
||||||
// Special folder names
|
// Special folder names
|
||||||
@ -142,6 +208,10 @@ const luaL_Reg AppFS_methods[] = {
|
|||||||
{ "isDirectory", AppFS_isDirectory },
|
{ "isDirectory", AppFS_isDirectory },
|
||||||
{ "fileSize", AppFS_fileSize },
|
{ "fileSize", AppFS_fileSize },
|
||||||
{ "listFiles", AppFS_listFiles },
|
{ "listFiles", AppFS_listFiles },
|
||||||
|
// Manipulate directories
|
||||||
|
{ "makeDirectory", AppFS_makeDirectory },
|
||||||
|
{ "makeAllDirectories", AppFS_makeAllDirectories },
|
||||||
|
{ "removeDirectory", AppFS_removeDirectory },
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
2
src/clip
2
src/clip
@ -1 +1 @@
|
|||||||
Subproject commit 0a961d75f4ffbf3bf24d707cfa66d6bcc1c295be
|
Subproject commit 5377679fd32f977b32b51d83e0fdc027adcdfe78
|
@ -1,4 +1,5 @@
|
|||||||
// Aseprite UI Library
|
// Aseprite UI Library
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This file is released under the terms of the MIT license.
|
// This file is released under the terms of the MIT license.
|
||||||
@ -9,6 +10,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "ui/manager.h"
|
#include "ui/manager.h"
|
||||||
|
#include "ui/system.h"
|
||||||
#include "ui/theme.h"
|
#include "ui/theme.h"
|
||||||
#include "ui/widget.h"
|
#include "ui/widget.h"
|
||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
@ -22,21 +24,29 @@ static std::list<Widget*>* widgets;
|
|||||||
|
|
||||||
void initWidgets()
|
void initWidgets()
|
||||||
{
|
{
|
||||||
|
assert_ui_thread();
|
||||||
|
|
||||||
widgets = new std::list<Widget*>;
|
widgets = new std::list<Widget*>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void exitWidgets()
|
void exitWidgets()
|
||||||
{
|
{
|
||||||
|
assert_ui_thread();
|
||||||
|
|
||||||
delete widgets;
|
delete widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addWidget(Widget* widget)
|
void addWidget(Widget* widget)
|
||||||
{
|
{
|
||||||
|
assert_ui_thread();
|
||||||
|
|
||||||
widgets->push_back(widget);
|
widgets->push_back(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeWidget(Widget* widget)
|
void removeWidget(Widget* widget)
|
||||||
{
|
{
|
||||||
|
assert_ui_thread();
|
||||||
|
|
||||||
ASSERT(!Manager::widgetAssociatedToManager(widget));
|
ASSERT(!Manager::widgetAssociatedToManager(widget));
|
||||||
|
|
||||||
auto it = std::find(widgets->begin(), widgets->end(), widget);
|
auto it = std::find(widgets->begin(), widgets->end(), widget);
|
||||||
@ -46,6 +56,8 @@ void removeWidget(Widget* widget)
|
|||||||
|
|
||||||
void reinitThemeForAllWidgets()
|
void reinitThemeForAllWidgets()
|
||||||
{
|
{
|
||||||
|
assert_ui_thread();
|
||||||
|
|
||||||
// Reinitialize the theme of each widget
|
// Reinitialize the theme of each widget
|
||||||
auto theme = get_theme();
|
auto theme = get_theme();
|
||||||
for (auto widget : *widgets)
|
for (auto widget : *widgets)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user