mirror of https://github.com/aseprite/aseprite.git
Show all frame tags again in some special cases
When we add/remove frame tags or change the active document we have to show all tags again. Related to #920
This commit is contained in:
parent
04a3729c03
commit
9d2e542b53
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
#include "app/cmd/add_frame_tag.h"
|
#include "app/cmd/add_frame_tag.h"
|
||||||
|
|
||||||
|
#include "doc/document.h"
|
||||||
|
#include "doc/document_event.h"
|
||||||
#include "doc/frame_tag.h"
|
#include "doc/frame_tag.h"
|
||||||
#include "doc/frame_tag_io.h"
|
#include "doc/frame_tag_io.h"
|
||||||
#include "doc/sprite.h"
|
#include "doc/sprite.h"
|
||||||
|
|
@ -33,6 +35,13 @@ void AddFrameTag::onExecute()
|
||||||
|
|
||||||
sprite->frameTags().add(frameTag);
|
sprite->frameTags().add(frameTag);
|
||||||
sprite->incrementVersion();
|
sprite->incrementVersion();
|
||||||
|
|
||||||
|
// Notify observers about the new frame.
|
||||||
|
Document* doc = sprite->document();
|
||||||
|
DocumentEvent ev(doc);
|
||||||
|
ev.sprite(sprite);
|
||||||
|
ev.frameTag(frameTag);
|
||||||
|
doc->notify_observers<DocumentEvent&>(&DocumentObserver::onAddFrameTag, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddFrameTag::onUndo()
|
void AddFrameTag::onUndo()
|
||||||
|
|
@ -42,6 +51,15 @@ void AddFrameTag::onUndo()
|
||||||
write_frame_tag(m_stream, frameTag);
|
write_frame_tag(m_stream, frameTag);
|
||||||
m_size = size_t(m_stream.tellp());
|
m_size = size_t(m_stream.tellp());
|
||||||
|
|
||||||
|
// Notify observers about the new frame.
|
||||||
|
{
|
||||||
|
Document* doc = sprite->document();
|
||||||
|
DocumentEvent ev(doc);
|
||||||
|
ev.sprite(sprite);
|
||||||
|
ev.frameTag(frameTag);
|
||||||
|
doc->notify_observers<DocumentEvent&>(&DocumentObserver::onRemoveFrameTag, ev);
|
||||||
|
}
|
||||||
|
|
||||||
sprite->frameTags().remove(frameTag);
|
sprite->frameTags().remove(frameTag);
|
||||||
sprite->incrementVersion();
|
sprite->incrementVersion();
|
||||||
delete frameTag;
|
delete frameTag;
|
||||||
|
|
@ -58,6 +76,13 @@ void AddFrameTag::onRedo()
|
||||||
m_stream.str(std::string());
|
m_stream.str(std::string());
|
||||||
m_stream.clear();
|
m_stream.clear();
|
||||||
m_size = 0;
|
m_size = 0;
|
||||||
|
|
||||||
|
// Notify observers about the new frame.
|
||||||
|
Document* doc = sprite->document();
|
||||||
|
DocumentEvent ev(doc);
|
||||||
|
ev.sprite(sprite);
|
||||||
|
ev.frameTag(frameTag);
|
||||||
|
doc->notify_observers<DocumentEvent&>(&DocumentObserver::onAddFrameTag, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace cmd
|
} // namespace cmd
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,13 @@ void Timeline::onThumbnailsPrefChange()
|
||||||
|
|
||||||
void Timeline::updateUsingEditor(Editor* editor)
|
void Timeline::updateUsingEditor(Editor* editor)
|
||||||
{
|
{
|
||||||
|
// TODO if editor == m_editor, avoid doing a lot of extra work here
|
||||||
|
|
||||||
m_aniControls.updateUsingEditor(editor);
|
m_aniControls.updateUsingEditor(editor);
|
||||||
|
|
||||||
|
if (editor != m_editor)
|
||||||
|
m_tagFocusBand = -1;
|
||||||
|
|
||||||
detachDocument();
|
detachDocument();
|
||||||
|
|
||||||
if (m_range.enabled()) {
|
if (m_range.enabled()) {
|
||||||
|
|
@ -1439,6 +1444,20 @@ void Timeline::onLayerNameChange(doc::DocumentEvent& ev)
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Timeline::onAddFrameTag(DocumentEvent& ev)
|
||||||
|
{
|
||||||
|
if (m_tagFocusBand >= 0) {
|
||||||
|
m_tagFocusBand = -1;
|
||||||
|
regenerateLayers();
|
||||||
|
layout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Timeline::onRemoveFrameTag(DocumentEvent& ev)
|
||||||
|
{
|
||||||
|
onAddFrameTag(ev);
|
||||||
|
}
|
||||||
|
|
||||||
void Timeline::onStateChanged(Editor* editor)
|
void Timeline::onStateChanged(Editor* editor)
|
||||||
{
|
{
|
||||||
m_aniControls.updateUsingEditor(editor);
|
m_aniControls.updateUsingEditor(editor);
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,8 @@ namespace app {
|
||||||
void onRemoveFrame(doc::DocumentEvent& ev) override;
|
void onRemoveFrame(doc::DocumentEvent& ev) override;
|
||||||
void onSelectionChanged(doc::DocumentEvent& ev) override;
|
void onSelectionChanged(doc::DocumentEvent& ev) override;
|
||||||
void onLayerNameChange(doc::DocumentEvent& ev) override;
|
void onLayerNameChange(doc::DocumentEvent& ev) override;
|
||||||
|
void onAddFrameTag(DocumentEvent& ev) override;
|
||||||
|
void onRemoveFrameTag(DocumentEvent& ev) override;
|
||||||
|
|
||||||
// app::Context slots.
|
// app::Context slots.
|
||||||
void onAfterCommandExecution(CommandExecutionEvent& ev);
|
void onAfterCommandExecution(CommandExecutionEvent& ev);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (c) 2001-2014 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.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace doc {
|
namespace doc {
|
||||||
class Cel;
|
class Cel;
|
||||||
|
class FrameTag;
|
||||||
class Image;
|
class Image;
|
||||||
class Layer;
|
class Layer;
|
||||||
class LayerImage;
|
class LayerImage;
|
||||||
|
|
@ -46,6 +47,7 @@ namespace doc {
|
||||||
Image* image() const { return m_image; }
|
Image* image() const { return m_image; }
|
||||||
int imageIndex() const { return m_imageIndex; }
|
int imageIndex() const { return m_imageIndex; }
|
||||||
frame_t frame() const { return m_frame; }
|
frame_t frame() const { return m_frame; }
|
||||||
|
FrameTag* frameTag() const { return m_frameTag; }
|
||||||
const gfx::Region& region() const { return m_region; }
|
const gfx::Region& region() const { return m_region; }
|
||||||
|
|
||||||
void sprite(Sprite* sprite) { m_sprite = sprite; }
|
void sprite(Sprite* sprite) { m_sprite = sprite; }
|
||||||
|
|
@ -54,6 +56,7 @@ namespace doc {
|
||||||
void image(Image* image) { m_image = image; }
|
void image(Image* image) { m_image = image; }
|
||||||
void imageIndex(int imageIndex) { m_imageIndex = imageIndex; }
|
void imageIndex(int imageIndex) { m_imageIndex = imageIndex; }
|
||||||
void frame(frame_t frame) { m_frame = frame; }
|
void frame(frame_t frame) { m_frame = frame; }
|
||||||
|
void frameTag(FrameTag* frameTag) { m_frameTag = frameTag; }
|
||||||
void region(const gfx::Region& rgn) { m_region = rgn; }
|
void region(const gfx::Region& rgn) { m_region = rgn; }
|
||||||
|
|
||||||
// Destination of the operation.
|
// Destination of the operation.
|
||||||
|
|
@ -71,6 +74,7 @@ namespace doc {
|
||||||
Image* m_image;
|
Image* m_image;
|
||||||
int m_imageIndex;
|
int m_imageIndex;
|
||||||
frame_t m_frame;
|
frame_t m_frame;
|
||||||
|
FrameTag* m_frameTag;
|
||||||
gfx::Region m_region;
|
gfx::Region m_region;
|
||||||
|
|
||||||
// For copy/move commands, the m_layer/m_frame are source of the
|
// For copy/move commands, the m_layer/m_frame are source of the
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite Document Library
|
// Aseprite Document Library
|
||||||
// Copyright (c) 2001-2016 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.
|
||||||
// Read LICENSE.txt for more information.
|
// Read LICENSE.txt for more information.
|
||||||
|
|
@ -27,6 +27,7 @@ namespace doc {
|
||||||
virtual void onAddLayer(DocumentEvent& ev) { }
|
virtual void onAddLayer(DocumentEvent& ev) { }
|
||||||
virtual void onAddFrame(DocumentEvent& ev) { }
|
virtual void onAddFrame(DocumentEvent& ev) { }
|
||||||
virtual void onAddCel(DocumentEvent& ev) { }
|
virtual void onAddCel(DocumentEvent& ev) { }
|
||||||
|
virtual void onAddFrameTag(DocumentEvent& ev) { }
|
||||||
|
|
||||||
virtual void onBeforeRemoveLayer(DocumentEvent& ev) { }
|
virtual void onBeforeRemoveLayer(DocumentEvent& ev) { }
|
||||||
virtual void onAfterRemoveLayer(DocumentEvent& ev) { }
|
virtual void onAfterRemoveLayer(DocumentEvent& ev) { }
|
||||||
|
|
@ -34,7 +35,7 @@ namespace doc {
|
||||||
// Called when a frame is removed. It's called after the frame was
|
// Called when a frame is removed. It's called after the frame was
|
||||||
// removed, and the sprite's total number of frames is modified.
|
// removed, and the sprite's total number of frames is modified.
|
||||||
virtual void onRemoveFrame(DocumentEvent& ev) { }
|
virtual void onRemoveFrame(DocumentEvent& ev) { }
|
||||||
|
virtual void onRemoveFrameTag(DocumentEvent& ev) { }
|
||||||
virtual void onRemoveCel(DocumentEvent& ev) { }
|
virtual void onRemoveCel(DocumentEvent& ev) { }
|
||||||
|
|
||||||
virtual void onSpriteSizeChanged(DocumentEvent& ev) { }
|
virtual void onSpriteSizeChanged(DocumentEvent& ev) { }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue