mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-14 12:40:55 +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);
|
||||
}
|
||||
|
||||
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);
|
||||
Rect vp = view->getViewportBounds();
|
||||
int x, y;
|
||||
bool centerMouse = get_config_bool("Editor", "CenterMouseInZoom", true);
|
||||
bool centerMouse;
|
||||
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();
|
||||
screenToEditor(mouse_x, mouse_y, &x, &y);
|
||||
|
||||
|
@ -70,6 +70,12 @@ namespace app {
|
||||
kDefaultEditorFlags = kShowGridFlag | kShowMaskFlag,
|
||||
};
|
||||
|
||||
enum ZoomBehavior {
|
||||
kCofiguredZoomBehavior,
|
||||
kCenterOnZoom,
|
||||
kDontCenterOnZoom,
|
||||
};
|
||||
|
||||
Editor(Document* document, EditorFlags flags = kDefaultEditorFlags);
|
||||
~Editor();
|
||||
|
||||
@ -157,7 +163,7 @@ namespace app {
|
||||
// Returns true if the cursor is inside the active mask/selection.
|
||||
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);
|
||||
|
||||
|
@ -62,7 +62,8 @@ bool Editor::processKeysToSetZoom(KeyMessage* msg)
|
||||
|
||||
// Change zoom
|
||||
if (zoom >= 0) {
|
||||
setZoomAndCenterInMouse(zoom, jmouse_x(0), jmouse_y(0));
|
||||
setZoomAndCenterInMouse(zoom, jmouse_x(0), jmouse_y(0),
|
||||
Editor::kCofiguredZoomBehavior);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +356,9 @@ bool StandbyState::onMouseWheel(Editor* editor, MouseMessage* msg)
|
||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
int zoom = MID(MIN_ZOOM, editor->getZoom()-dz, MAX_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;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,8 @@ bool ZoomingState::onMouseUp(Editor* editor, MouseMessage* msg)
|
||||
else if (msg->right() && zoom > 0)
|
||||
--zoom;
|
||||
|
||||
editor->setZoomAndCenterInMouse(zoom, msg->position().x, msg->position().y);
|
||||
editor->setZoomAndCenterInMouse(zoom, msg->position().x, msg->position().y,
|
||||
Editor::kCofiguredZoomBehavior);
|
||||
|
||||
editor->backToPreviousState();
|
||||
editor->releaseMouse();
|
||||
|
Loading…
Reference in New Issue
Block a user