Add option to keep the timeline selection when we draw on the canvas

This commit is contained in:
David Capello 2021-03-31 19:26:54 -03:00
parent 2df3cd8a80
commit 8d6f889e0e
4 changed files with 25 additions and 7 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Aseprite --> <!-- Aseprite -->
<!-- Copyright (C) 2018-2020 Igara Studio S.A. --> <!-- Copyright (C) 2018-2021 Igara Studio S.A. -->
<!-- Copyright (C) 2014-2018 David Capello --> <!-- Copyright (C) 2014-2018 David Capello -->
<preferences> <preferences>
@ -171,6 +171,9 @@
zoom levels --> zoom levels -->
<option id="auto_fit" type="bool" default="false" /> <option id="auto_fit" type="bool" default="false" />
</section> </section>
<section id="timeline">
<option id="keep_selection" type="bool" default="false" />
</section>
<section id="cursor"> <section id="cursor">
<option id="use_native_cursor" type="bool" default="false" /> <option id="use_native_cursor" type="bool" default="false" />
<option id="cursor_scale" type="int" default="1" /> <option id="cursor_scale" type="int" default="1" />

View File

@ -1170,6 +1170,11 @@ rewind_on_stop_tooltip = <<<END
The 'Stop' button should rewind the animation The 'Stop' button should rewind the animation
where it was started. where it was started.
END 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: default_first_frame = Default First Frame:
ui_mouse_cursor = UI Mouse Cursor ui_mouse_cursor = UI Mouse Cursor
native_cursor = Use native mouse cursors native_cursor = Use native mouse cursors

View File

@ -1,5 +1,5 @@
<!-- Aseprite --> <!-- Aseprite -->
<!-- Copyright (C) 2018-2020 Igara Studio S.A. --> <!-- Copyright (C) 2018-2021 Igara Studio S.A. -->
<!-- Copyright (C) 2001-2018 David Capello --> <!-- Copyright (C) 2001-2018 David Capello -->
<gui> <gui>
<window id="options" text="@.title"> <window id="options" text="@.title">
@ -258,6 +258,8 @@
pref="general.autoshow_timeline" /> pref="general.autoshow_timeline" />
<check text="@.rewind_on_stop" id="rewind_on_stop" tooltip="@.rewind_on_stop_tooltip" <check text="@.rewind_on_stop" id="rewind_on_stop" tooltip="@.rewind_on_stop_tooltip"
pref="general.rewind_on_stop" /> pref="general.rewind_on_stop" />
<check text="@.keep_timeline_selection" id="keep_selection" tooltip="@.keep_timeline_selection_tooltip"
pref="timeline.keep_selection" />
<hbox> <hbox>
<label text="@.default_first_frame" /> <label text="@.default_first_frame" />
<expr id="first_frame" /> <expr id="first_frame" />

View File

@ -320,18 +320,24 @@ void Timeline::updateUsingEditor(Editor* editor)
m_aniControls.updateUsingEditor(editor); m_aniControls.updateUsingEditor(editor);
DocRange oldRange;
if (editor != m_editor) { if (editor != m_editor) {
// Save active m_tagFocusBand into the old focused editor // Save active m_tagFocusBand into the old focused editor
if (m_editor) if (m_editor)
m_editor->setTagFocusBand(m_tagFocusBand); m_editor->setTagFocusBand(m_tagFocusBand);
m_tagFocusBand = -1; m_tagFocusBand = -1;
} }
else {
oldRange = m_range;
}
detachDocument(); detachDocument();
if (m_range.enabled() && if (Preferences::instance().timeline.keepSelection())
m_rangeLocks == 0) { m_range = oldRange;
m_range.clearRange(); else {
// The range is reset in detachDocument()
ASSERT(!m_range.enabled());
} }
// We always update the editor. In this way the timeline keeps in // We always update the editor. In this way the timeline keeps in
@ -3991,8 +3997,10 @@ void Timeline::onNewInputPriority(InputChainElement* element,
return; return;
if (element != this && m_rangeLocks == 0) { if (element != this && m_rangeLocks == 0) {
m_range.clearRange(); if (!Preferences::instance().timeline.keepSelection()) {
invalidate(); m_range.clearRange();
invalidate();
}
} }
} }
} }