diff --git a/app/src/mainwindow2.cpp b/app/src/mainwindow2.cpp
index ce5e0ba7d8..e443cbed83 100644
--- a/app/src/mainwindow2.cpp
+++ b/app/src/mainwindow2.cpp
@@ -308,7 +308,9 @@ void MainWindow2::createMenus()
connect(ui->actionZoom_Out, &QAction::triggered, mCommands, &ActionCommands::ZoomOut);
connect(ui->actionRotate_Clockwise, &QAction::triggered, mCommands, &ActionCommands::rotateClockwise);
connect(ui->actionRotate_Anticlockwise, &QAction::triggered, mCommands, &ActionCommands::rotateCounterClockwise);
+ connect(ui->actionReset_Rotation, &QAction::triggered, mEditor->view(), &ViewManager::resetRotation);
connect(ui->actionReset_View, &QAction::triggered, mEditor->view(), &ViewManager::resetView);
+ connect(ui->actionCenter_View, &QAction::triggered, mEditor->view(), &ViewManager::centerView);
connect(ui->actionZoom400, &QAction::triggered, mEditor->view(), &ViewManager::scale400);
connect(ui->actionZoom300, &QAction::triggered, mEditor->view(), &ViewManager::scale300);
connect(ui->actionZoom200, &QAction::triggered, mEditor->view(), &ViewManager::scale200);
@@ -1211,6 +1213,7 @@ void MainWindow2::setupKeyboardShortcuts()
// View menu
ui->actionResetWindows->setShortcut(cmdKeySeq(CMD_RESET_WINDOWS));
ui->actionReset_View->setShortcut(cmdKeySeq(CMD_RESET_ZOOM_ROTATE));
+ ui->actionCenter_View->setShortcut(cmdKeySeq(CMD_CENTER_VIEW));
ui->actionZoom_In->setShortcut(cmdKeySeq(CMD_ZOOM_IN));
ui->actionZoom_Out->setShortcut(cmdKeySeq(CMD_ZOOM_OUT));
ui->actionZoom400->setShortcut(cmdKeySeq(CMD_ZOOM_400));
@@ -1222,6 +1225,7 @@ void MainWindow2::setupKeyboardShortcuts()
ui->actionZoom25->setShortcut(cmdKeySeq(CMD_ZOOM_25));
ui->actionRotate_Clockwise->setShortcut(cmdKeySeq(CMD_ROTATE_CLOCK));
ui->actionRotate_Anticlockwise->setShortcut(cmdKeySeq(CMD_ROTATE_ANTI_CLOCK));
+ ui->actionReset_Rotation->setShortcut(cmdKeySeq(CMD_RESET_ROTATION));
ui->actionHorizontal_Flip->setShortcut(cmdKeySeq(CMD_FLIP_HORIZONTAL));
ui->actionVertical_Flip->setShortcut(cmdKeySeq(CMD_FLIP_VERTICAL));
ui->actionPreview->setShortcut(cmdKeySeq(CMD_PREVIEW));
diff --git a/app/src/shortcutspage.cpp b/app/src/shortcutspage.cpp
index 763aa51202..70bc571991 100644
--- a/app/src/shortcutspage.cpp
+++ b/app/src/shortcutspage.cpp
@@ -345,9 +345,11 @@ static QString getHumanReadableShortcutName(const QString& cmdName)
{CMD_REDO, QObject::tr("Redo", "Shortcut")},
{CMD_REMOVE_FRAME, QObject::tr("Remove Frame", "Shortcut")},
{CMD_RESET_WINDOWS, QObject::tr("Reset Windows", "Shortcut")},
- {CMD_RESET_ZOOM_ROTATE, QObject::tr("Reset Zoom/Rotate", "Shortcut")},
+ {CMD_RESET_ZOOM_ROTATE, QObject::tr("Reset View", "Shortcut")},
+ {CMD_CENTER_VIEW, QObject::tr("Center View", "Shortcut")},
{CMD_ROTATE_ANTI_CLOCK, QObject::tr("Rotate Anticlockwise", "Shortcut")},
{CMD_ROTATE_CLOCK, QObject::tr("Rotate Clockwise", "Shortcut")},
+ {CMD_RESET_ROTATION, QObject::tr("Reset Rotation", "Shortcut")},
{CMD_SAVE_AS, QObject::tr("Save File As", "Shortcut")},
{CMD_SAVE_FILE, QObject::tr("Save File", "Shortcut")},
{CMD_SELECT_ALL, QObject::tr("Select All", "Shortcut")},
diff --git a/app/ui/mainwindow2.ui b/app/ui/mainwindow2.ui
index 77235f98b9..19d3d991cf 100644
--- a/app/ui/mainwindow2.ui
+++ b/app/ui/mainwindow2.ui
@@ -157,6 +157,7 @@
+
@@ -164,6 +165,7 @@
+
@@ -487,7 +489,7 @@
- Reset Zoom/Rotate
+ Reset
@@ -1105,6 +1107,16 @@
Lock Windows
+
+
+ Center
+
+
+
+
+ Reset Rotation
+
+
diff --git a/core_lib/data/resources/kb.ini b/core_lib/data/resources/kb.ini
index 40e0ac7e3e..d121e1cdb2 100644
--- a/core_lib/data/resources/kb.ini
+++ b/core_lib/data/resources/kb.ini
@@ -33,7 +33,9 @@ CmdZoom33=Shift+3
CmdZoom25=Shift+4
CmdRotateClockwise=R
CmdRotateAntiClockwise=Z
+CmdResetRotation=Alt+H
CmdResetZoomRotate=Ctrl+H
+CmdCenterView=Ctrl+Shift+H
CmdFlipHorizontal=Shift+H
CmdFlipVertical=Shift+V
CmdPreview=Alt+P
diff --git a/core_lib/src/managers/viewmanager.cpp b/core_lib/src/managers/viewmanager.cpp
index c975ee105d..304faf335a 100644
--- a/core_lib/src/managers/viewmanager.cpp
+++ b/core_lib/src/managers/viewmanager.cpp
@@ -183,6 +183,11 @@ void ViewManager::translate(QPointF offset)
translate(static_cast(offset.x()), static_cast(offset.y()));
}
+void ViewManager::centerView()
+{
+ translate(0, 0);
+}
+
float ViewManager::rotation()
{
if (mCurrentCamera)
@@ -203,6 +208,11 @@ void ViewManager::rotate(float degree)
}
}
+void ViewManager::resetRotation()
+{
+ rotate(0);
+}
+
qreal ViewManager::scaling()
{
if (mCurrentCamera)
diff --git a/core_lib/src/managers/viewmanager.h b/core_lib/src/managers/viewmanager.h
index 8b0f7ad63b..55e9243946 100644
--- a/core_lib/src/managers/viewmanager.h
+++ b/core_lib/src/managers/viewmanager.h
@@ -1,4 +1,4 @@
-/*
+/*
Pencil2D - Traditional Animation Software
Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
@@ -58,9 +58,11 @@ class ViewManager : public BaseManager
QPointF translation() const;
void translate(float dx, float dy);
void translate(QPointF offset);
+ void centerView();
float rotation();
void rotate(float degree);
+ void resetRotation();
qreal scaling();
void scale(qreal scaleValue);
diff --git a/core_lib/src/structure/camera.cpp b/core_lib/src/structure/camera.cpp
index d2813f8c95..88aa173b67 100644
--- a/core_lib/src/structure/camera.cpp
+++ b/core_lib/src/structure/camera.cpp
@@ -131,10 +131,7 @@ void Camera::scale(qreal scaleValue)
void Camera::scaleWithOffset(qreal scaleValue, QPointF offset)
{
mTranslate = (mTranslate + offset) * mScale / scaleValue - offset;
- mScale = scaleValue;
-
- mNeedUpdateView = true;
- modification();
+ scale(scaleValue);
}
bool Camera::operator==(const Camera& rhs) const
diff --git a/core_lib/src/util/pencildef.h b/core_lib/src/util/pencildef.h
index 82bbc59952..a98be19f15 100644
--- a/core_lib/src/util/pencildef.h
+++ b/core_lib/src/util/pencildef.h
@@ -124,7 +124,9 @@ const static int MaxFramesBound = 9999;
#define CMD_ZOOM_OUT "CmdZoomOut"
#define CMD_ROTATE_CLOCK "CmdRotateClockwise"
#define CMD_ROTATE_ANTI_CLOCK "CmdRotateAntiClockwise"
+#define CMD_RESET_ROTATION "CmdResetRotation"
#define CMD_RESET_ZOOM_ROTATE "CmdResetZoomRotate"
+#define CMD_CENTER_VIEW "CmdCenterView"
#define CMD_ZOOM_400 "CmdZoom400"
#define CMD_ZOOM_300 "CmdZoom300"
#define CMD_ZOOM_200 "CmdZoom200"