Merge branch 'main' into beta

This commit is contained in:
David Capello 2022-07-13 18:40:26 -03:00
commit f8f925c634
30 changed files with 82 additions and 50 deletions

View File

@ -73,7 +73,7 @@ might work).
You will need the following dependencies on Ubuntu/Debian:
sudo apt-get install -y g++ clang-10 libc++-10-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev
sudo apt-get install -y g++ clang-10 libc++-10-dev libc++abi-10-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev
On Fedora:

View File

@ -148,5 +148,6 @@ We are using C++17 standard. You can safely use:
* Use `static constexpr T v = ...;`
* You can use `<atomic>`, `<thread>`, `<mutex>`, and `<condition_variable>`
* Prefer `using T = ...;` instead of `typedef ... T`
* Use `[[fallthrough]]` if needed
* We use gcc 9.2 or clang 9.0 on Linux, so check the features available in
https://en.cppreference.com/w/cpp/compiler_support

2
laf

@ -1 +1 @@
Subproject commit a361cb538e8ea7bfa74ad9ce488d3318a3db3bc2
Subproject commit f0bb81ae19517ff8a74cbb00461d3fc5314349f9

View File

@ -8,6 +8,9 @@
if(UNIX)
# All warnings except for switch cases with missing enum items
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-switch")
# Prefer C++17 [[fallthrough]] attribute
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
endif()
if(MSVC)

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -69,7 +69,8 @@ void FlattenLayers::onExecute()
ImageRef image(Image::create(sprite->spec()));
LayerImage* flatLayer; // The layer onto which everything will be flattened.
color_t bgcolor; // The background color to use for flatLayer.
color_t bgcolor; // The background color to use for flatLayer.
bool newFlatLayer = false;
flatLayer = sprite->backgroundLayer();
if (backgroundIsSel && flatLayer && flatLayer->isVisible()) {
@ -80,14 +81,9 @@ void FlattenLayers::onExecute()
// Create a new transparent layer to flatten everything onto it.
flatLayer = new LayerImage(sprite);
ASSERT(flatLayer->isVisible());
executeAndAdd(new cmd::AddLayer(sprite->root(), flatLayer, nullptr));
executeAndAdd(new cmd::SetLayerName(flatLayer, "Flattened"));
flatLayer->setName("Flattened");
newFlatLayer = true;
bgcolor = sprite->transparentColor();
if (list.front())
executeAndAdd(new cmd::MoveLayer(flatLayer,
list.front()->parent(),
list.front()));
}
render::Render render;
@ -135,6 +131,10 @@ void FlattenLayers::onExecute()
}
}
// Add new flatten layer
if (newFlatLayer)
executeAndAdd(new cmd::AddLayer(list.front()->parent(), flatLayer, list.front()));
// Delete flattened layers.
for (Layer* layer : layers) {
// layer can be == flatLayer when we are flattening on the

View File

@ -66,7 +66,10 @@ bool MoveMaskCommand::onEnabled(Context* context)
ContextFlags::HasActiveImage |
ContextFlags::ActiveLayerIsEditable);
else
return (current_editor ? true: false);
return (current_editor != nullptr) &&
context->checkFlags(ContextFlags::HasActiveDocument |
ContextFlags::HasVisibleMask |
ContextFlags::HasActiveImage);
}

View File

@ -110,6 +110,7 @@ public:
case ui::kMouseDownMessage:
captureMouse();
[[fallthrough]];
case ui::kMouseMoveMessage:
if (hasCapture()) {

View File

@ -120,7 +120,8 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
captureMouse();
// continue in motion message...
// Continue in motion message...
[[fallthrough]];
}
case kMouseMoveMessage: {

View File

@ -255,12 +255,14 @@ bool PngFormat::onLoad(FileOp* fop)
case PNG_COLOR_TYPE_RGB_ALPHA:
fop->sequenceSetHasAlpha(true);
[[fallthrough]];
case PNG_COLOR_TYPE_RGB:
pixelFormat = IMAGE_RGB;
break;
case PNG_COLOR_TYPE_GRAY_ALPHA:
fop->sequenceSetHasAlpha(true);
[[fallthrough]];
case PNG_COLOR_TYPE_GRAY:
pixelFormat = IMAGE_GRAYSCALE;
break;
@ -799,6 +801,7 @@ void PngFormat::saveColorSpace(png_structp png_ptr, png_infop info_ptr,
}
// Continue to RGB case...
[[fallthrough]];
case gfx::ColorSpace::RGB: {
if (colorSpace->hasPrimaries()) {

View File

@ -129,7 +129,7 @@ public:
AppEvents() {
}
EventType eventType(const char* eventName) const {
EventType eventType(const char* eventName) const override {
if (std::strcmp(eventName, "sitechange") == 0)
return SiteChange;
else if (std::strcmp(eventName, "fgcolorchange") == 0)
@ -209,7 +209,7 @@ public:
}
}
EventType eventType(const char* eventName) const {
EventType eventType(const char* eventName) const override {
if (std::strcmp(eventName, "change") == 0)
return Change;
else if (std::strcmp(eventName, "filenamechange") == 0)

View File

@ -11,6 +11,7 @@
#include "app/app.h"
#include "app/cmd/add_layer.h"
#include "app/cmd/add_slice.h"
#include "app/cmd/assign_color_profile.h"
#include "app/cmd/clear_cel.h"
#include "app/cmd/convert_color_profile.h"
@ -572,7 +573,10 @@ int Sprite_newSlice(lua_State* L)
if (!bounds.isEmpty())
slice->insert(0, doc::SliceKey(bounds));
sprite->slices().add(slice);
Tx tx;
tx(new cmd::AddSlice(sprite, slice));
tx.commit();
push_docobj(L, slice);
return 1;
}

View File

@ -417,6 +417,7 @@ private:
inImage = true;
else if (ev_type == CMARK_EVENT_EXIT)
inImage = false;
break;
}
case CMARK_NODE_LINK: {
@ -434,6 +435,7 @@ private:
}
inLink = nullptr;
}
break;
}
}

View File

@ -316,8 +316,7 @@ bool ColorSelector::onProcessMessage(ui::Message* msg)
break;
captureMouse();
// Continue...
[[fallthrough]];
case kMouseMoveMessage: {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);

View File

@ -2676,6 +2676,7 @@ void Editor::startSelectionTransformation(const gfx::Point& move, double angle)
movingPixels->rotate(angle);
}
else if (auto standby = dynamic_cast<StandbyState*>(m_state.get())) {
ASSERT(m_document->isMaskVisible());
standby->startSelectionTransformation(this, move, angle);
}
}

View File

@ -178,6 +178,7 @@ bool FileList::onProcessMessage(Message* msg)
case kMouseDownMessage:
captureMouse();
[[fallthrough]];
case kMouseMoveMessage:
if (hasCapture()) {

View File

@ -660,8 +660,7 @@ bool PaletteView::onProcessMessage(Message* msg)
}
captureMouse();
// Continue...
[[fallthrough]];
case kMouseMoveMessage: {
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);

View File

@ -248,7 +248,7 @@ bool ToolBar::onProcessMessage(Message* msg)
m_openedRecently = false;
releaseMouse();
// fallthrough
[[fallthrough]];
case kMouseLeaveMessage:
if (hasCapture())
@ -612,7 +612,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
case kMouseDownMessage:
captureMouse();
// fallthrough
[[fallthrough]];
case kMouseMoveMessage: {
auto mouseMsg = static_cast<const MouseMessage*>(msg);

@ -1 +1 @@
Subproject commit 246e60fd569993f8a756d548c130602919eec6c0
Subproject commit 31f8f34048dcde35c8a4b1b1df01b1c230c14452

View File

@ -1,5 +1,5 @@
// Aseprite Document Library
// Copyright (c) 2019 Igara Studio S.A.
// Copyright (c) 2019-2022 Igara Studio S.A.
// Copyright (c) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
@ -36,14 +36,13 @@ CelData::CelData(const CelData& celData)
, m_image(celData.m_image)
, m_opacity(celData.m_opacity)
, m_bounds(celData.m_bounds)
, m_boundsF(celData.m_boundsF ? new gfx::RectF(*celData.m_boundsF):
, m_boundsF(celData.m_boundsF ? std::make_unique<gfx::RectF>(*celData.m_boundsF):
nullptr)
{
}
CelData::~CelData()
{
delete m_boundsF;
}
void CelData::setImage(const ImageRef& image, Layer* layer)
@ -57,6 +56,8 @@ void CelData::setImage(const ImageRef& image, Layer* layer)
void CelData::setPosition(const gfx::Point& pos)
{
m_bounds.setOrigin(pos);
if (m_boundsF)
m_boundsF->setOrigin(gfx::PointF(pos));
}
void CelData::adjustBounds(Layer* layer)

View File

@ -46,7 +46,10 @@ namespace doc {
void setImage(const ImageRef& image, Layer* layer);
void setPosition(const gfx::Point& pos);
void setOpacity(int opacity) { m_opacity = opacity; }
void setOpacity(int opacity) {
m_opacity = opacity;
}
void setBounds(const gfx::Rect& bounds) {
m_bounds = bounds;
@ -58,14 +61,14 @@ namespace doc {
if (m_boundsF)
*m_boundsF = boundsF;
else
m_boundsF = new gfx::RectF(boundsF);
m_boundsF = std::make_unique<gfx::RectF>(boundsF);
m_bounds = gfx::Rect(boundsF);
}
const gfx::RectF& boundsF() const {
if (!m_boundsF)
m_boundsF = new gfx::RectF(m_bounds);
m_boundsF = std::make_unique<gfx::RectF>(m_bounds);
return *m_boundsF;
}
@ -87,7 +90,7 @@ namespace doc {
// Special bounds for reference layers that can have subpixel
// position.
mutable gfx::RectF* m_boundsF;
mutable std::unique_ptr<gfx::RectF> m_boundsF;
};
typedef std::shared_ptr<CelData> CelDataRef;

View File

@ -50,6 +50,7 @@ frame_t calculate_next_frame(
case AniDir::REVERSE:
frameDelta = -frameDelta;
[[fallthrough]];
case AniDir::FORWARD:
frame += frameDelta;

View File

@ -60,7 +60,7 @@ void write_layer(std::ostream& os, const Layer* layer)
int images = 0;
int celdatas = 0;
for (it=begin; it != end; ++it) {
Cel* cel = *it;
const Cel* cel = *it;
if (!cel->link()) {
++images;
++celdatas;
@ -69,14 +69,14 @@ void write_layer(std::ostream& os, const Layer* layer)
write16(os, images);
for (it=begin; it != end; ++it) {
Cel* cel = *it;
const Cel* cel = *it;
if (!cel->link())
write_image(os, cel->image());
}
write16(os, celdatas);
for (it=begin; it != end; ++it) {
Cel* cel = *it;
const Cel* cel = *it;
if (!cel->link())
write_celdata(os, cel->dataRef().get());
}

View File

@ -395,6 +395,8 @@ bool Entry::onProcessMessage(Message* msg)
if (!m_selecting_words.isEmpty())
m_selecting_words.reset();
[[fallthrough]];
case kMouseMoveMessage:
if (hasCapture()) {
bool is_dirty = false;

View File

@ -207,6 +207,7 @@ bool ListBox::onProcessMessage(Message* msg)
case kMouseDownMessage:
captureMouse();
[[fallthrough]];
case kMouseMoveMessage:
if (hasCapture()) {

View File

@ -2241,11 +2241,10 @@ bool Manager::processFocusMovementMessage(Message* msg)
break;
// Arrow keys
case kKeyLeft: if (!cmp) cmp = cmp_left;
case kKeyRight: if (!cmp) cmp = cmp_right;
case kKeyUp: if (!cmp) cmp = cmp_up;
case kKeyLeft: if (!cmp) cmp = cmp_left; [[fallthrough]];
case kKeyRight: if (!cmp) cmp = cmp_right; [[fallthrough]];
case kKeyUp: if (!cmp) cmp = cmp_up; [[fallthrough]];
case kKeyDown: if (!cmp) cmp = cmp_down;
// More than one widget
if (count > 1) {
// Position where the focus come

View File

@ -113,9 +113,9 @@ static void choose_side(gfx::Rect& bounds,
Rect r1(0, 0, bounds.w, bounds.h);
Rect r2(0, 0, bounds.w, bounds.h);
r1.x = x_left = std::clamp(x_left, workarea.x, workarea.x2()-bounds.w);
r2.x = x_right = std::clamp(x_right, workarea.x, workarea.x2()-bounds.w);
r1.y = r2.y = y = std::clamp(y, workarea.y, workarea.y2()-bounds.h);
r1.x = x_left = std::clamp(x_left, workarea.x, std::max(workarea.x, workarea.x2()-bounds.w));
r2.x = x_right = std::clamp(x_right, workarea.x, std::max(workarea.x, workarea.x2()-bounds.w));
r1.y = r2.y = y = std::clamp(y, workarea.y, std::max(workarea.y, workarea.y2()-bounds.h));
// Calculate both intersections
const gfx::Rect s1 = r1.createIntersection(parentBounds);
@ -490,7 +490,7 @@ bool MenuBox::onProcessMessage(Message* msg)
if (!base->was_clicked)
break;
//[[fallthrough]];
[[fallthrough]];
}
case kMouseDownMessage:
@ -509,12 +509,17 @@ bool MenuBox::onProcessMessage(Message* msg)
const gfx::Point mousePos = static_cast<MouseMessage*>(msg)->position();
const gfx::Point screenPos = msg->display()->nativeWindow()->pointToScreen(mousePos);
// Get the widget below the mouse cursor
auto mgr = manager();
if (!mgr)
break;
Widget* picked = mgr->pickFromScreenPos(screenPos);
// Here we catch the filtered messages (menu-bar or the
// popuped menu-box) to detect if the user press outside of
// the widget
if (msg->type() == kMouseDownMessage && m_base != nullptr) {
Widget* picked = manager()->pickFromScreenPos(screenPos);
// If one of these conditions are accomplished we have to
// close all menus (back to menu-bar or close the popuped
// menubox), this is the place where we control if...
@ -533,8 +538,7 @@ bool MenuBox::onProcessMessage(Message* msg)
}
}
// Get the widget below the mouse cursor
if (Widget* picked = menu->pickFromScreenPos(screenPos)) {
if (picked) {
if ((picked->type() == kMenuItemWidget) &&
!(picked->hasFlags(DISABLED))) {
MenuItem* pickedItem = static_cast<MenuItem*>(picked);
@ -913,7 +917,7 @@ bool MenuItem::onProcessMessage(Message* msg)
std::function<gfx::Rect(Widget*)> getWidgetBounds){
const gfx::Rect itemBounds = getWidgetBounds(this);
if (inBar()) {
bounds.x = std::clamp(itemBounds.x, workarea.x, workarea.x2()-bounds.w);
bounds.x = std::clamp(itemBounds.x, workarea.x, std::max(workarea.x, workarea.x2()-bounds.w));
bounds.y = std::max(workarea.y, itemBounds.y2());
}
else {

View File

@ -101,7 +101,8 @@ void Overlay::captureOverlappedArea()
os::SurfaceLock lock(m_overlap.get());
displaySurface->blitTo(m_overlap.get(), m_pos.x, m_pos.y, 0, 0,
m_overlap->width(), m_overlap->height());
m_overlap->setImmutable();
// TODO uncomment and test this when GPU support is added
//m_overlap->setImmutable();
m_captured = base::AddRef(displaySurface);
}

View File

@ -132,7 +132,8 @@ bool ScrollBar::onProcessMessage(Message* msg)
setSelected(true);
captureMouse();
// continue to kMouseMoveMessage handler...
// Continue to kMouseMoveMessage handler...
[[fallthrough]];
}
case kMouseMoveMessage:
@ -221,7 +222,7 @@ void ScrollBar::getScrollBarInfo(int *_pos, int *_len, int *_bar_size, int *_vie
}
else if (m_size > 0) {
len = bar_size * viewport_size / m_size;
len = std::clamp(len, theme()->getScrollbarSize()*2-border_width, bar_size);
len = std::clamp(len, std::min(theme()->getScrollbarSize()*2-border_width, bar_size), bar_size);
pos = (bar_size-len) * m_pos / (m_size-viewport_size);
pos = std::clamp(pos, 0, bar_size-len);
}

View File

@ -114,7 +114,7 @@ bool Slider::onProcessMessage(Message* msg)
setupSliderCursor();
// Fall through
[[fallthrough]];
case kMouseMoveMessage:
if (hasCapture()) {

View File

@ -100,6 +100,7 @@ bool Splitter::onProcessMessage(Message* msg)
captureMouse();
// Continue with motion message...
[[fallthrough]];
}
else
break;