mirror of https://github.com/aseprite/aseprite.git
Improper use of pickColor to get the top layer
PickColor was replaced by pickCels in some places in the code because only the top layer was required; the color was ignored. Additionally, the RenderPlan for those pickColors (and now pickCels) was incorrectly initialized for the AutoSelect Layer. Now is fixed.
This commit is contained in:
parent
f26ce64208
commit
5afa9e6b82
|
@ -1,5 +1,5 @@
|
|||
// Aseprite
|
||||
// Copyright (C) 2019-2024 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2025 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
|
@ -104,7 +104,7 @@ void ColorPicker::pickColor(const Site& site,
|
|||
switch (mode) {
|
||||
// Pick from the composed image
|
||||
case FromComposition: {
|
||||
doc::RenderPlan plan(pref.experimental.composeGroups());
|
||||
doc::RenderPlan plan;
|
||||
plan.addLayer(sprite->root(), site.frame());
|
||||
|
||||
doc::CelList cels;
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "base/scoped_value.h"
|
||||
#include "doc/doc.h"
|
||||
#include "doc/mask_boundaries.h"
|
||||
#include "doc/render_plan.h"
|
||||
#include "doc/slice.h"
|
||||
#include "fmt/format.h"
|
||||
#include "os/color_space.h"
|
||||
|
@ -3097,13 +3098,16 @@ void Editor::updateAutoCelGuides(ui::Message* msg)
|
|||
// tool to show automatic guides.
|
||||
if (m_showAutoCelGuides && m_state->allowLayerEdges()) {
|
||||
auto mouseMsg = dynamic_cast<ui::MouseMessage*>(msg);
|
||||
|
||||
ColorPicker picker;
|
||||
picker.pickColor(getSite(),
|
||||
screenToEditorF(mouseMsg ? mouseMsg->position() : mousePosInDisplay()),
|
||||
m_proj,
|
||||
ColorPicker::FromComposition);
|
||||
m_showGuidesThisCel = (picker.layer() ? picker.layer()->cel(m_frame) : nullptr);
|
||||
doc::RenderPlan plan;
|
||||
Sprite* sprite = getSite().sprite();
|
||||
plan.addLayer(sprite->root(), getSite().frame());
|
||||
doc::CelList cels;
|
||||
sprite->pickCels(screenToEditorF(mouseMsg ? mouseMsg->position() : mousePosInDisplay()),
|
||||
1,
|
||||
plan,
|
||||
cels);
|
||||
m_showGuidesThisCel =
|
||||
((!cels.empty() && cels.front()->layer()) ? cels.front()->layer()->cel(m_frame) : nullptr);
|
||||
}
|
||||
else {
|
||||
m_showGuidesThisCel = nullptr;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "doc/layer.h"
|
||||
#include "doc/layer_tilemap.h"
|
||||
#include "doc/mask.h"
|
||||
#include "doc/render_plan.h"
|
||||
#include "doc/slice.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
|
@ -153,18 +154,17 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
|||
// Handle "Auto Select Layer"
|
||||
if (editor->isAutoSelectLayer()) {
|
||||
gfx::PointF cursor = editor->screenToEditorF(msg->position());
|
||||
ColorPicker picker;
|
||||
picker.pickColor(site, cursor, editor->projection(), ColorPicker::FromComposition);
|
||||
RenderPlan plan;
|
||||
plan.addLayer(site.sprite()->root(), site.frame());
|
||||
doc::CelList cels;
|
||||
site.sprite()->pickCels(cursor, 1, plan, cels);
|
||||
|
||||
const view::RealRange& range = context->range();
|
||||
if (picker.layer() && !range.contains(picker.layer())) {
|
||||
layer = picker.layer();
|
||||
if (layer) {
|
||||
editor->setLayer(layer);
|
||||
if (!cels.empty() && cels.front()->layer() && !range.contains(cels.front()->layer())) {
|
||||
editor->setLayer(cels.front()->layer());
|
||||
editor->flashCurrentLayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (layer) {
|
||||
// TODO we should be able to move the `Background' with tiled mode
|
||||
|
|
Loading…
Reference in New Issue