mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
It's better if mouse wheel doesn't center the scroll on zoom-in/out
This commit is contained in:
parent
223988d7ff
commit
2c0642d1f1
@ -1120,14 +1120,26 @@ bool Editor::isInsideSelection()
|
|||||||
m_document->getMask()->containsPoint(x, y);
|
m_document->getMask()->containsPoint(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setZoomAndCenterInMouse(int zoom, int mouse_x, int mouse_y)
|
void Editor::setZoomAndCenterInMouse(int zoom, int mouse_x, int mouse_y, ZoomBehavior zoomBehavior)
|
||||||
{
|
{
|
||||||
View* view = View::getView(this);
|
View* view = View::getView(this);
|
||||||
Rect vp = view->getViewportBounds();
|
Rect vp = view->getViewportBounds();
|
||||||
int x, y;
|
int x, y;
|
||||||
bool centerMouse = get_config_bool("Editor", "CenterMouseInZoom", true);
|
bool centerMouse;
|
||||||
int mx, my;
|
int mx, my;
|
||||||
|
|
||||||
|
switch (zoomBehavior) {
|
||||||
|
case kCofiguredZoomBehavior:
|
||||||
|
centerMouse = get_config_bool("Editor", "CenterMouseInZoom", true);
|
||||||
|
break;
|
||||||
|
case kCenterOnZoom:
|
||||||
|
centerMouse = true;
|
||||||
|
break;
|
||||||
|
case kDontCenterOnZoom:
|
||||||
|
centerMouse = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
hideDrawingCursor();
|
hideDrawingCursor();
|
||||||
screenToEditor(mouse_x, mouse_y, &x, &y);
|
screenToEditor(mouse_x, mouse_y, &x, &y);
|
||||||
|
|
||||||
|
@ -70,6 +70,12 @@ namespace app {
|
|||||||
kDefaultEditorFlags = kShowGridFlag | kShowMaskFlag,
|
kDefaultEditorFlags = kShowGridFlag | kShowMaskFlag,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ZoomBehavior {
|
||||||
|
kCofiguredZoomBehavior,
|
||||||
|
kCenterOnZoom,
|
||||||
|
kDontCenterOnZoom,
|
||||||
|
};
|
||||||
|
|
||||||
Editor(Document* document, EditorFlags flags = kDefaultEditorFlags);
|
Editor(Document* document, EditorFlags flags = kDefaultEditorFlags);
|
||||||
~Editor();
|
~Editor();
|
||||||
|
|
||||||
@ -157,7 +163,7 @@ namespace app {
|
|||||||
// Returns true if the cursor is inside the active mask/selection.
|
// Returns true if the cursor is inside the active mask/selection.
|
||||||
bool isInsideSelection();
|
bool isInsideSelection();
|
||||||
|
|
||||||
void setZoomAndCenterInMouse(int zoom, int mouse_x, int mouse_y);
|
void setZoomAndCenterInMouse(int zoom, int mouse_x, int mouse_y, ZoomBehavior zoomBehavior);
|
||||||
|
|
||||||
bool processKeysToSetZoom(ui::KeyMessage* msg);
|
bool processKeysToSetZoom(ui::KeyMessage* msg);
|
||||||
|
|
||||||
|
@ -62,7 +62,8 @@ bool Editor::processKeysToSetZoom(KeyMessage* msg)
|
|||||||
|
|
||||||
// Change zoom
|
// Change zoom
|
||||||
if (zoom >= 0) {
|
if (zoom >= 0) {
|
||||||
setZoomAndCenterInMouse(zoom, jmouse_x(0), jmouse_y(0));
|
setZoomAndCenterInMouse(zoom, jmouse_x(0), jmouse_y(0),
|
||||||
|
Editor::kCofiguredZoomBehavior);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,9 @@ bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
|
|||||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||||
int zoom = MID(MIN_ZOOM, editor->getZoom()-dz, MAX_ZOOM);
|
int zoom = MID(MIN_ZOOM, editor->getZoom()-dz, MAX_ZOOM);
|
||||||
if (editor->getZoom() != zoom)
|
if (editor->getZoom() != zoom)
|
||||||
editor->setZoomAndCenterInMouse(zoom, mouseMsg->position().x, mouseMsg->position().y);
|
editor->setZoomAndCenterInMouse(zoom,
|
||||||
|
mouseMsg->position().x, mouseMsg->position().y,
|
||||||
|
Editor::kDontCenterOnZoom);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,8 @@ bool ZoomingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
|||||||
else if (msg->right() && zoom > 0)
|
else if (msg->right() && zoom > 0)
|
||||||
--zoom;
|
--zoom;
|
||||||
|
|
||||||
editor->setZoomAndCenterInMouse(zoom, msg->position().x, msg->position().y);
|
editor->setZoomAndCenterInMouse(zoom, msg->position().x, msg->position().y,
|
||||||
|
Editor::kCofiguredZoomBehavior);
|
||||||
|
|
||||||
editor->backToPreviousState();
|
editor->backToPreviousState();
|
||||||
editor->releaseMouse();
|
editor->releaseMouse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user