Skip to content

Commit

Permalink
Add option to keep the timeline selection when we draw on the canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Apr 12, 2021
1 parent 2df3cd8 commit 8d6f889
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
5 changes: 4 additions & 1 deletion data/pref.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Aseprite -->
<!-- Copyright (C) 2018-2020 Igara Studio S.A. -->
<!-- Copyright (C) 2018-2021 Igara Studio S.A. -->
<!-- Copyright (C) 2014-2018 David Capello -->
<preferences>

Expand Down Expand Up @@ -171,6 +171,9 @@
zoom levels -->
<option id="auto_fit" type="bool" default="false" />
</section>
<section id="timeline">
<option id="keep_selection" type="bool" default="false" />
</section>
<section id="cursor">
<option id="use_native_cursor" type="bool" default="false" />
<option id="cursor_scale" type="int" default="1" />
Expand Down
5 changes: 5 additions & 0 deletions data/strings/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,11 @@ rewind_on_stop_tooltip = <<<END
The 'Stop' button should rewind the animation
where it was started.
END
keep_timeline_selection = Keep selection
keep_timeline_selection_tooltip = <<<END
Keep the selected range of layers/frames/cels
when we edit the canvas.
END
default_first_frame = Default First Frame:
ui_mouse_cursor = UI Mouse Cursor
native_cursor = Use native mouse cursors
Expand Down
4 changes: 3 additions & 1 deletion data/widgets/options.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Aseprite -->
<!-- Copyright (C) 2018-2020 Igara Studio S.A. -->
<!-- Copyright (C) 2018-2021 Igara Studio S.A. -->
<!-- Copyright (C) 2001-2018 David Capello -->
<gui>
<window id="options" text="@.title">
Expand Down Expand Up @@ -258,6 +258,8 @@
pref="general.autoshow_timeline" />
<check text="@.rewind_on_stop" id="rewind_on_stop" tooltip="@.rewind_on_stop_tooltip"
pref="general.rewind_on_stop" />
<check text="@.keep_timeline_selection" id="keep_selection" tooltip="@.keep_timeline_selection_tooltip"
pref="timeline.keep_selection" />
<hbox>
<label text="@.default_first_frame" />
<expr id="first_frame" />
Expand Down
18 changes: 13 additions & 5 deletions src/app/ui/timeline/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,24 @@ void Timeline::updateUsingEditor(Editor* editor)

m_aniControls.updateUsingEditor(editor);

DocRange oldRange;
if (editor != m_editor) {
// Save active m_tagFocusBand into the old focused editor
if (m_editor)
m_editor->setTagFocusBand(m_tagFocusBand);
m_tagFocusBand = -1;
}
else {
oldRange = m_range;
}

detachDocument();

if (m_range.enabled() &&
m_rangeLocks == 0) {
m_range.clearRange();
if (Preferences::instance().timeline.keepSelection())
m_range = oldRange;
else {
// The range is reset in detachDocument()
ASSERT(!m_range.enabled());
}

// We always update the editor. In this way the timeline keeps in
Expand Down Expand Up @@ -3991,8 +3997,10 @@ void Timeline::onNewInputPriority(InputChainElement* element,
return;

if (element != this && m_rangeLocks == 0) {
m_range.clearRange();
invalidate();
if (!Preferences::instance().timeline.keepSelection()) {
m_range.clearRange();
invalidate();
}
}
}
}
Expand Down

0 comments on commit 8d6f889

Please sign in to comment.