Merge branch 'main' into beta

This commit is contained in:
David Capello 2025-01-06 17:07:22 -03:00
commit f5bff8ae4b
15 changed files with 80 additions and 23 deletions

View File

@ -28,7 +28,7 @@ jobs:
sudo apt-get update -qq
sudo apt-get install -y \
libpixman-1-dev libfreetype6-dev libharfbuzz-dev zlib1g-dev \
libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev
libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev
- name: Install Skia
if: ${{ matrix.ui == 'gui' }}
shell: bash

2
laf

@ -1 +1 @@
Subproject commit 2647cc0a948176aa85ae3f75f425a4a2554ac15e
Subproject commit d3e6a2c58d37e5e3f249c1f04eded5f80e633c42

View File

@ -578,10 +578,11 @@ private:
fillWheelActionsList();
fillDragActionsList();
// Fill the 'Commands' and 'Action Modifier' lists
for (const KeyPtr& key : m_keys) {
if (key->type() == KeyType::Tool || key->type() == KeyType::Quicktool ||
key->type() == KeyType::WheelAction || key->type() == KeyType::DragAction ||
key->isListed()) {
// If it's not a listed Command or Action key, we go to the next key...
if (!((key->type() == KeyType::Command && key->isCommandListed()) ||
(key->type() == KeyType::Action))) {
continue;
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2023 Igara Studio S.A.
// Copyright (C) 2023-2024 Igara Studio S.A.
// Copyright (C) 2017 David Capello
//
// This program is distributed under the terms of
@ -64,6 +64,7 @@ bool LayerLockCommand::onChecked(Context* context)
void LayerLockCommand::onExecute(Context* context)
{
ContextWriter writer(context);
Doc* doc = writer.document();
SelectedLayers selLayers;
auto range = context->range();
if (range.enabled()) {
@ -77,9 +78,8 @@ void LayerLockCommand::onExecute(Context* context)
if (!layer->isEditable())
anyLock = true;
}
for (auto layer : selLayers) {
layer->setEditable(anyLock);
}
for (auto* layer : selLayers)
doc->setLayerEditableWithNotifications(layer, anyLock);
update_screen_for_document(writer.document());
}

View File

@ -201,6 +201,12 @@ void Doc::setLayerVisibilityWithNotifications(Layer* layer, const bool visible)
notifyAfterLayerVisibilityChange(layer);
}
void Doc::setLayerEditableWithNotifications(Layer* layer, const bool editable)
{
notifyBeforeLayerEditableChange(layer, editable);
layer->setEditable(editable);
}
//////////////////////////////////////////////////////////////////////
// Notifications
@ -266,6 +272,13 @@ void Doc::notifyAfterLayerVisibilityChange(Layer* layer)
notify_observers<DocEvent&>(&DocObserver::onAfterLayerVisibilityChange, ev);
}
void Doc::notifyBeforeLayerEditableChange(Layer* layer, bool newState)
{
DocEvent ev(this);
ev.layer(layer);
notify_observers<DocEvent&, bool>(&DocObserver::onBeforeLayerEditableChange, ev, newState);
}
void Doc::notifyCelMoved(Layer* fromLayer, frame_t fromFrame, Layer* toLayer, frame_t toFrame)
{
DocEvent ev(this);

View File

@ -116,6 +116,12 @@ public:
// invalidated/redrawn, MovingPixelsState can drop pixels, etc.)
void setLayerVisibilityWithNotifications(Layer* layer, const bool visible);
// Use this function to change the layer editable flag and
// notify all DocObservers about this change (e.g. so the Editor
// can be invalidated/redrawn, MovingPixelsState can drop pixels,
// etc.)
void setLayerEditableWithNotifications(Layer* layer, const bool editable);
//////////////////////////////////////////////////////////////////////
// Notifications
@ -127,6 +133,7 @@ public:
void notifyLayerMergedDown(Layer* srcLayer, Layer* targetLayer);
void notifyBeforeLayerVisibilityChange(Layer* layer, bool newState);
void notifyAfterLayerVisibilityChange(Layer* layer);
void notifyBeforeLayerEditableChange(Layer* layer, bool newState);
void notifyCelMoved(Layer* fromLayer, frame_t fromFrame, Layer* toLayer, frame_t toFrame);
void notifyCelCopied(Layer* fromLayer, frame_t fromFrame, Layer* toLayer, frame_t toFrame);
void notifySelectionChanged();

View File

@ -101,6 +101,9 @@ public:
virtual void onBeforeLayerVisibilityChange(DocEvent& ev, bool newState) {}
virtual void onAfterLayerVisibilityChange(DocEvent& ev) {}
// The editable flag of a specific layer is going to change/changed.
virtual void onBeforeLayerEditableChange(DocEvent& ev, bool newState) {}
// The tileset was remapped (e.g. when tiles are re-ordered).
virtual void onRemapTileset(DocEvent& ev, const doc::Remap& remap) {}

View File

@ -2262,7 +2262,7 @@ bool Editor::onProcessMessage(Message* msg)
if (m_brushPreview.onScreen()) {
m_brushPreview.hide();
// Destroy the extra cel explicitly (it could happend
// Destroy the extra cel explicitly (it could happen
// automatically by the m_brushPreview.show()) just in case
// that the brush preview will not use the extra cel
// (e.g. in the case of the Eraser tool).
@ -2523,6 +2523,12 @@ void Editor::onBeforeLayerVisibilityChange(DocEvent& ev, bool newState)
m_state->onBeforeLayerVisibilityChange(this, ev.layer(), newState);
}
void Editor::onBeforeLayerEditableChange(DocEvent& ev, bool newState)
{
if (m_state)
m_state->onBeforeLayerEditableChange(this, ev.layer(), newState);
}
void Editor::setCursor(const gfx::Point& mouseDisplayPos)
{
Rect vp = View::getView(this)->viewportBounds();

View File

@ -342,6 +342,7 @@ protected:
void onRemoveTag(DocEvent& ev) override;
void onRemoveSlice(DocEvent& ev) override;
void onBeforeLayerVisibilityChange(DocEvent& ev, bool newState) override;
void onBeforeLayerEditableChange(DocEvent& ev, bool newState) override;
// ActiveToolObserver impl
void onActiveToolChange(tools::Tool* tool) override;
@ -442,7 +443,7 @@ private:
obs::scoped_connection m_contextBarBrushChangeConn;
obs::scoped_connection m_showExtrasConn;
// Slots listeing document preferences.
// Slots listening document preferences.
obs::scoped_connection m_tiledConnBefore;
obs::scoped_connection m_tiledConn;
obs::scoped_connection m_gridConn;

View File

@ -149,6 +149,9 @@ public:
// Called when the visibility of a specific layer is changed.
virtual void onBeforeLayerVisibilityChange(Editor* editor, doc::Layer* layer, bool newState) {}
// Called when the editable flag of a specific layer is changed.
virtual void onBeforeLayerEditableChange(Editor* editor, doc::Layer* layer, bool newState) {}
private:
DISABLE_COPYING(EditorState);
};

View File

@ -559,16 +559,11 @@ bool MovingPixelsState::acceptQuickTool(tools::Tool* tool)
tool->getInk(0)->isScrollMovement() || tool->getInk(0)->isZoom());
}
void MovingPixelsState::onBeforeLayerVisibilityChange(Editor* editor,
doc::Layer* layer,
bool newState)
void MovingPixelsState::dropPixelsIfLayerIsSelected(doc::Layer* layer)
{
if (!isActiveDocument())
return;
// If the layer visibility of any selected layer changes, we just
// drop the pixels (it's the easiest way to avoid modifying hidden
// pixels).
if (m_pixelsMovement) {
const Site& site = m_pixelsMovement->site();
if (site.layer() == layer || site.range().contains(layer)) {
@ -577,6 +572,30 @@ void MovingPixelsState::onBeforeLayerVisibilityChange(Editor* editor,
}
}
void MovingPixelsState::onBeforeLayerVisibilityChange(Editor* editor,
doc::Layer* layer,
bool newState)
{
// If the layer visibility of any selected layer changes, we just
// drop the pixels (it's the easiest way to avoid modifying hidden
// pixels).
dropPixelsIfLayerIsSelected(layer);
}
void MovingPixelsState::onBeforeLayerEditableChange(Editor* editor,
doc::Layer* layer,
bool newState)
{
// If the layer 'editable' flag of any selected layer changes,
// we just drop the pixels (it's the easiest way to avoid modifying
// hidden pixels and it's the simplest treatment when
// locking the layer)
// TODO: It would be more convenient not to drop the selected
// image if the 'lock' then 'unlock' actions are performed without
// any transformation taking place.
dropPixelsIfLayerIsSelected(layer);
}
// Before executing any command, we drop the pixels (go back to standby).
void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev)
{

View File

@ -65,6 +65,7 @@ public:
bool acceptQuickTool(tools::Tool* tool) override;
bool requireBrushPreview() override { return false; }
void onBeforeLayerVisibilityChange(Editor* editor, doc::Layer* layer, bool newState) override;
void onBeforeLayerEditableChange(Editor* editor, doc::Layer* layer, bool newState) override;
// EditorObserver
void onDestroyEditor(Editor* editor) override;
@ -103,6 +104,9 @@ private:
KeyAction getCurrentKeyAction() const;
// Used on 'onBeforeLayerVisibilityChange' and 'onBeforeLayerEditableChange' functions.
void dropPixelsIfLayerIsSelected(doc::Layer* layer);
// Helper member to move/translate selection and pixels.
PixelsMovementPtr m_pixelsMovement;
DelayedMouseMove m_delayedMouseMove;

View File

@ -131,7 +131,7 @@ public:
const KeyboardShortcuts& globalKeys) const;
bool isPressed() const;
bool isLooselyPressed() const;
bool isListed() const;
bool isCommandListed() const;
bool hasAccel(const ui::Accelerator& accel) const;
bool hasUserDefinedAccels() const;

View File

@ -536,9 +536,9 @@ bool Key::isLooselyPressed() const
return false;
}
bool Key::isListed() const
bool Key::isCommandListed() const
{
return type() != KeyType::Command || !command()->isListed(params());
return type() == KeyType::Command && command()->isListed(params());
}
bool Key::hasAccel(const ui::Accelerator& accel) const

View File

@ -4345,7 +4345,7 @@ int Timeline::topHeight() const
void Timeline::onNewInputPriority(InputChainElement* element, const ui::Message* msg)
{
// It looks like the user wants to execute commands targetting the
// It looks like the user wants to execute commands targeting the
// ColorBar instead of the Timeline. Here we disable the selected
// range, so commands like Clear, Copy, Cut, etc. don't target the
// Timeline and they are sent to the active sprite editor.
@ -4656,7 +4656,7 @@ void Timeline::setLayerEditableFlag(const layer_t l, const bool state)
bool regenRows = false;
if (layer->isEditable() != state) {
layer->setEditable(state);
m_document->setLayerEditableWithNotifications(layer, state);
if (layer->isGroup() && layer->isExpanded())
regenRows = true;
@ -4666,7 +4666,7 @@ void Timeline::setLayerEditableFlag(const layer_t l, const bool state)
layer = layer->parent();
while (layer) {
if (!layer->isEditable()) {
layer->setEditable(true);
m_document->setLayerEditableWithNotifications(layer, true);
regenRows = true;
}
layer = layer->parent();