Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus map zooming on the cursor #316

Merged
merged 8 commits into from
Oct 23, 2020
Merged

Conversation

BigBahss
Copy link
Collaborator

@BigBahss BigBahss commented Oct 14, 2020

Closes #256.
Zooming the map will now zoom into the location of the cursor rather than the top left corner. If the cursor is not on the map then the map will zoom into the center.

@@ -1481,6 +1506,31 @@ void Editor::createConnectionItem(MapConnection* connection, bool hide) {
connection_edit_items.append(connection_edit_item);
}

// Hides connected map tiles that cannot be seen from the current map (beyond BORDER_DISTANCE).
void Editor::maskNonVisibleConnectionTiles() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain this please

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so to enable this functionality I had to expand the graphicsView to fill the entire frame, which caused outer parts of connected maps to be displayed (tiles extending further than BORDER_DISTANCE from the current map). These outer tiles were previously hidden by resizing the graphicsView. This resize was reseting the scroll bars and preventing the zoom from anchoring on the mouse cursor. So to keep the displayed tiles the same I draw over them with the background color of the graphicsView, this is the 'mask'.

@huderlem
Copy link
Owner

On initial load, there is a funny gray area around the map:
image

When I switch tabs, the gray area disappears. Any idea why? Otherwise seems to work well enough. Certainly better than before!

@BigBahss
Copy link
Collaborator Author

This one perplexes me, I can't recreate the gray area (and have no idea why it would disappear when switching tabs). Does the gray area come back when switching back to the map tab, or does it stay gone? And do you still get an off-colored area when using other porymap themes?

@garakmon
Copy link
Collaborator

It is drawing the widget while the window is disabled so it is using the widget's disabled color palette. The window is disabled when porymap is loading the project in case it encounters an error. In the MainWindow constructor you could probably add setWindowDisabled(!isProjectOpen()); and remove setWindowDisabled(false); from initWindow().

@huderlem huderlem merged commit 530ff4c into huderlem:master Oct 23, 2020
@BigBahss BigBahss deleted the better-map-zoom branch February 14, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion: Keep focus on the currently selected tile when zooming in the map view
3 participants