Skip to content

Commit

Permalink
Don't jump inside "Loop" tag w/next/previous frame within tag when we…
Browse files Browse the repository at this point in the history
… are outside the tag (fix #1756)
  • Loading branch information
dacap committed Jun 19, 2018
1 parent a0c0b1c commit e82404e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/app/commands/cmd_goto_frame.cpp
Expand Up @@ -99,7 +99,7 @@ class GotoNextFrameWithSameTagCommand : public GotoCommand {
FrameTag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(frame);
->getFrameTagByFrame(frame, false);
frame_t first = (tag ? tag->fromFrame(): 0);
frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());

Expand All @@ -118,7 +118,7 @@ class GotoPreviousFrameWithSameTagCommand : public GotoCommand {
FrameTag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(frame);
->getFrameTagByFrame(frame, false);
frame_t first = (tag ? tag->fromFrame(): 0);
frame_t last = (tag ? tag->toFrame(): editor->sprite()->lastFrame());

Expand Down
7 changes: 2 additions & 5 deletions src/app/loop_tag.cpp
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
Expand All @@ -19,10 +19,7 @@ const char* kLoopTagName = "Loop";

doc::FrameTag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame)
{
doc::FrameTag* tag = sprite->frameTags().innerTag(frame);
if (!tag)
tag = get_loop_tag(sprite);
return tag;
return sprite->frameTags().innerTag(frame);
}

doc::FrameTag* get_loop_tag(const doc::Sprite* sprite)
Expand Down
5 changes: 3 additions & 2 deletions src/app/loop_tag.h
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
Expand All @@ -20,7 +20,8 @@ namespace app {
class FrameTagProvider {
public:
virtual ~FrameTagProvider() { }
virtual doc::FrameTag* getFrameTagByFrame(const doc::frame_t frame) = 0;
virtual doc::FrameTag* getFrameTagByFrame(const doc::frame_t frame,
const bool getLoopTagIfNone) = 0;
};

doc::FrameTag* get_animation_tag(const doc::Sprite* sprite, doc::frame_t frame);
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/editor/play_state.cpp
Expand Up @@ -64,7 +64,7 @@ void PlayState::onEnterState(Editor* editor)
m_tag = m_editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(m_refFrame);
->getFrameTagByFrame(m_refFrame, true);

// Go to the first frame of the animation or active frame tag
if (m_playOnce) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/ui/preview_editor.cpp
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
Expand Down Expand Up @@ -384,12 +384,12 @@ void PreviewEditorWindow::updateUsingEditor(Editor* editor)
doc::FrameTag* tag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(editor->frame());
->getFrameTagByFrame(editor->frame(), true);

doc::FrameTag* playingTag = editor
->getCustomizationDelegate()
->getFrameTagProvider()
->getFrameTagByFrame(m_refFrame);
->getFrameTagByFrame(m_refFrame, true);

if (tag == playingTag)
return;
Expand Down
11 changes: 8 additions & 3 deletions src/app/ui/timeline/timeline.cpp
Expand Up @@ -558,13 +558,18 @@ void Timeline::activateClipboardRange()
invalidate();
}

FrameTag* Timeline::getFrameTagByFrame(const frame_t frame)
FrameTag* Timeline::getFrameTagByFrame(const frame_t frame,
const bool getLoopTagIfNone)
{
if (!m_sprite)
return nullptr;

if (m_tagFocusBand < 0)
return get_animation_tag(m_sprite, frame);
if (m_tagFocusBand < 0) {
FrameTag* tag = get_animation_tag(m_sprite, frame);
if (!tag && getLoopTagIfNone)
tag = get_loop_tag(m_sprite);
return tag;
}

for (FrameTag* frameTag : m_sprite->frameTags()) {
if (frame >= frameTag->fromFrame() &&
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/timeline/timeline.h
Expand Up @@ -116,7 +116,8 @@ namespace app {
// Returns the active frame tag depending on the timeline status
// E.g. if other frame tags are collapsed, the focused band has
// priority and tags in other bands are ignored.
FrameTag* getFrameTagByFrame(const frame_t frame) override;
FrameTag* getFrameTagByFrame(const frame_t frame,
const bool getLoopTagIfNone) override;

// ScrollableViewDelegate impl
gfx::Size visibleSize() const override;
Expand Down

0 comments on commit e82404e

Please sign in to comment.