diff --git a/data/pref.xml b/data/pref.xml
index e26f33032..4e220b006 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -160,6 +160,10 @@
+
+
diff --git a/data/strings/en.ini b/data/strings/en.ini
index 3a4961ad5..f4f0cae28 100644
--- a/data/strings/en.ini
+++ b/data/strings/en.ini
@@ -1068,6 +1068,7 @@ zoom_from_center_with_keys = Zoom from center with keys
show_scrollbars = Show scroll-bars in sprite editor
show_scrollbars_tooltip = Show scroll-bars in all sprite editors.
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_tooltip = <<
+
diff --git a/src/app/commands/cmd_scroll_center.cpp b/src/app/commands/cmd_scroll_center.cpp
index 11d5556c8..c6acd13fc 100644
--- a/src/app/commands/cmd_scroll_center.cpp
+++ b/src/app/commands/cmd_scroll_center.cpp
@@ -37,7 +37,7 @@ bool ScrollCenterCommand::onEnabled(Context* context)
void ScrollCenterCommand::onExecute(Context* context)
{
- current_editor->setDefaultScroll();
+ current_editor->setScrollToCenter();
}
Command* CommandFactory::createScrollCenterCommand()
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index 37c26d33a..5f251c154 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -417,6 +417,14 @@ void Editor::setZoom(const render::Zoom& zoom)
}
void Editor::setDefaultScroll()
+{
+ if (Preferences::instance().editor.autoFit())
+ setScrollAndZoomToFitScreen();
+ else
+ setScrollToCenter();
+}
+
+void Editor::setScrollToCenter()
{
View* view = View::getView(this);
Rect vp = view->viewportBounds();
diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h
index c0ea363ce..e999319b6 100644
--- a/src/app/ui/editor/editor.h
+++ b/src/app/ui/editor/editor.h
@@ -155,6 +155,7 @@ namespace app {
void setZoom(const render::Zoom& zoom);
void setDefaultScroll();
+ void setScrollToCenter();
void setScrollAndZoomToFitScreen();
void setEditorScroll(const gfx::Point& scroll);
void setEditorZoom(const render::Zoom& zoom);