mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-24 03:40:14 +00:00
Avoid using LayerIndex in SpritePosition
We're planning to remove the LayerIndex as it doesn't make too much sense with the new Timeline with groups.
This commit is contained in:
parent
5deabfe365
commit
6bffc9f740
@ -65,7 +65,7 @@ std::string CmdTransaction::onLabel() const
|
||||
doc::SpritePosition CmdTransaction::calcSpritePosition()
|
||||
{
|
||||
doc::Site site = context()->activeSite();
|
||||
return doc::SpritePosition(site.layerIndex(), site.frame());
|
||||
return doc::SpritePosition(site.layer(), site.frame());
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -71,7 +71,7 @@ void UndoCommand::onExecute(Context* context)
|
||||
Preferences::instance().undo.gotoModified();
|
||||
|
||||
if (gotoModified) {
|
||||
SpritePosition currentPosition(writer.site()->layerIndex(),
|
||||
SpritePosition currentPosition(writer.site()->layer(),
|
||||
writer.site()->frame());
|
||||
|
||||
if (m_type == Undo)
|
||||
@ -80,7 +80,9 @@ void UndoCommand::onExecute(Context* context)
|
||||
spritePosition = undo->nextRedoSpritePosition();
|
||||
|
||||
if (spritePosition != currentPosition) {
|
||||
current_editor->setLayer(sprite->indexToLayer(spritePosition.layerIndex()));
|
||||
Layer* selectLayer = spritePosition.layer();
|
||||
if (selectLayer)
|
||||
current_editor->setLayer(selectLayer);
|
||||
current_editor->setFrame(spritePosition.frame());
|
||||
|
||||
// Draw the current layer/frame (which is not undone yet) so the
|
||||
@ -112,11 +114,13 @@ void UndoCommand::onExecute(Context* context)
|
||||
// weren't able to reach before the undo).
|
||||
if (gotoModified) {
|
||||
SpritePosition currentPosition(
|
||||
writer.site()->layerIndex(),
|
||||
writer.site()->layer(),
|
||||
writer.site()->frame());
|
||||
|
||||
if (spritePosition != currentPosition) {
|
||||
current_editor->setLayer(sprite->indexToLayer(spritePosition.layerIndex()));
|
||||
Layer* selectLayer = spritePosition.layer();
|
||||
if (selectLayer)
|
||||
current_editor->setLayer(selectLayer);
|
||||
current_editor->setFrame(spritePosition.frame());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (c) 2001-2015 David Capello
|
||||
// Copyright (c) 2001-2016 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
// Read LICENSE.txt for more information.
|
||||
@ -9,34 +9,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "doc/frame.h"
|
||||
#include "doc/layer_index.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/object.h"
|
||||
#include "doc/object_id.h"
|
||||
|
||||
namespace doc {
|
||||
|
||||
class Sprite;
|
||||
|
||||
class SpritePosition {
|
||||
public:
|
||||
SpritePosition()
|
||||
: m_layerIndex(0)
|
||||
: m_layerId(NullId)
|
||||
, m_frame(0) {
|
||||
}
|
||||
SpritePosition(LayerIndex layerIndex, frame_t frame)
|
||||
: m_layerIndex(layerIndex)
|
||||
|
||||
SpritePosition(const Layer* layer, frame_t frame)
|
||||
: m_layerId(layer ? layer->id(): NullId)
|
||||
, m_frame(frame) {
|
||||
}
|
||||
|
||||
const LayerIndex& layerIndex() const { return m_layerIndex; }
|
||||
const frame_t& frame() const { return m_frame; }
|
||||
Layer* layer() const { return get<Layer>(m_layerId); }
|
||||
ObjectId layerId() const { return m_layerId; }
|
||||
frame_t frame() const { return m_frame; }
|
||||
|
||||
void layerIndex(LayerIndex layerIndex) { m_layerIndex = layerIndex; }
|
||||
void frame(frame_t frame) { m_frame = frame; }
|
||||
void layer(Layer* layer) {
|
||||
m_layerId = (layer ? layer->id(): NullId);
|
||||
}
|
||||
|
||||
bool operator==(const SpritePosition& o) const { return m_layerIndex == o.m_layerIndex && m_frame == o.m_frame; }
|
||||
bool operator!=(const SpritePosition& o) const { return m_layerIndex != o.m_layerIndex || m_frame != o.m_frame; }
|
||||
void layerId(ObjectId layerId) {
|
||||
m_layerId = layerId;
|
||||
}
|
||||
|
||||
void frame(frame_t frame) {
|
||||
m_frame = frame;
|
||||
}
|
||||
|
||||
bool operator==(const SpritePosition& o) const { return m_layerId == o.m_layerId && m_frame == o.m_frame; }
|
||||
bool operator!=(const SpritePosition& o) const { return m_layerId != o.m_layerId || m_frame != o.m_frame; }
|
||||
|
||||
private:
|
||||
LayerIndex m_layerIndex;
|
||||
ObjectId m_layerId;
|
||||
frame_t m_frame;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user