Add auto-fit screen option (fix #789, fix #2267)

This commit is contained in:
David Capello 2020-03-27 16:53:17 -03:00
parent 70afe4195e
commit d358e6055f
6 changed files with 17 additions and 1 deletions

View File

@ -160,6 +160,10 @@
<option id="straight_line_preview" type="bool" default="true" /> <option id="straight_line_preview" type="bool" default="true" />
<option id="play_once" type="bool" default="false" /> <option id="play_once" type="bool" default="false" />
<option id="play_all" type="bool" default="false" /> <option id="play_all" type="bool" default="false" />
<!-- TODO this would be nice to be "true" but we have to fix
some performance issue rendering huge sprites with small
zoom levels -->
<option id="auto_fit" type="bool" default="false" />
</section> </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" />

View File

@ -1068,6 +1068,7 @@ zoom_from_center_with_keys = Zoom from center with keys
show_scrollbars = Show scroll-bars in sprite editor show_scrollbars = Show scroll-bars in sprite editor
show_scrollbars_tooltip = Show scroll-bars in all sprite editors. show_scrollbars_tooltip = Show scroll-bars in all sprite editors.
auto_scroll = Auto-scroll on editor edges auto_scroll = Auto-scroll on editor edges
auto_fit = Auto-fit screen when a sprite is open
straight_line_preview = Preview straight line immediately on Pencil tool straight_line_preview = Preview straight line immediately on Pencil tool
straight_line_preview_tooltip = <<<END straight_line_preview_tooltip = <<<END
On Pencil tool you can draw straight lines On Pencil tool you can draw straight lines

View File

@ -203,6 +203,8 @@
<check text="@.zoom_from_center_with_keys" id="zoom_from_center_with_keys" /> <check text="@.zoom_from_center_with_keys" id="zoom_from_center_with_keys" />
<check text="@.show_scrollbars" id="show_scrollbars" tooltip="@.show_scrollbars_tooltip" /> <check text="@.show_scrollbars" id="show_scrollbars" tooltip="@.show_scrollbars_tooltip" />
<check text="@.auto_scroll" id="auto_scroll" /> <check text="@.auto_scroll" id="auto_scroll" />
<check text="@.auto_fit" id="auto_fit"
pref="editor.auto_fit" />
<check text="@.straight_line_preview" id="straight_line_preview" tooltip="@.straight_line_preview_tooltip" /> <check text="@.straight_line_preview" id="straight_line_preview" tooltip="@.straight_line_preview_tooltip" />
<check text="@.discard_brush" id="discard_brush" /> <check text="@.discard_brush" id="discard_brush" />
<hbox> <hbox>

View File

@ -37,7 +37,7 @@ bool ScrollCenterCommand::onEnabled(Context* context)
void ScrollCenterCommand::onExecute(Context* context) void ScrollCenterCommand::onExecute(Context* context)
{ {
current_editor->setDefaultScroll(); current_editor->setScrollToCenter();
} }
Command* CommandFactory::createScrollCenterCommand() Command* CommandFactory::createScrollCenterCommand()

View File

@ -417,6 +417,14 @@ void Editor::setZoom(const render::Zoom& zoom)
} }
void Editor::setDefaultScroll() void Editor::setDefaultScroll()
{
if (Preferences::instance().editor.autoFit())
setScrollAndZoomToFitScreen();
else
setScrollToCenter();
}
void Editor::setScrollToCenter()
{ {
View* view = View::getView(this); View* view = View::getView(this);
Rect vp = view->viewportBounds(); Rect vp = view->viewportBounds();

View File

@ -155,6 +155,7 @@ namespace app {
void setZoom(const render::Zoom& zoom); void setZoom(const render::Zoom& zoom);
void setDefaultScroll(); void setDefaultScroll();
void setScrollToCenter();
void setScrollAndZoomToFitScreen(); void setScrollAndZoomToFitScreen();
void setEditorScroll(const gfx::Point& scroll); void setEditorScroll(const gfx::Point& scroll);
void setEditorZoom(const render::Zoom& zoom); void setEditorZoom(const render::Zoom& zoom);