Worldmap Window: Zoom to Mouse: update Pivot offset

Hi there .
I’m currently making Progress in my Game UI.
During the past 5 Days i’m dealing with my Worldmap Window.

This should have the following Features:
• Can be scrolled with Sliders
• Can have markers
• zoom onto a specific position
• Zoom with mousewheel to mouse position

The problem i now get is targeting the last two features… cause to zoom onto a position on the map (like a marker or the mouse hovered spot), i need to update the RenderPivot of the Worldmap Image, so changing the RenderScale has a target.

To avoid the Map to offset when a new Pivot is set (including updating the pivot OnMouseMove), i need to calculate a Counter-Offset.

This works flawelessly for a Map scale of 1.0! But break at any other scale…

A video of the Problem:

The Pivot set and translation is done in 3 Events:



Some Variable explanations:
CurrentMapSize is the current absolute Size of the Images Scaled Cached Geometry.
CanvasSize is the absolute size of thr Canvas cached Geometry.
PivOff is the CounterOffset
Translate is the FinalTranslation set to the Image.
MaxScroll is the calculated maximum amount of scrolling allowed, scaled… so the Map always stays in the Canvas.
CurrentScroll is the negative Translation, defined by the Scroll-Sliders.
MapCursor is the Relative location of the Mouse, inside the Canvas.

Does one know a solution, to make the pivot offset counter work for unspecified Scales of the Image?

You could have a look at how it was accomplished here:

And if you scroll down, there is an attached project you could take apart - it received a couple updates over time. Perhaps it will inspire you.

1 Like

This really seems to help.
Thank you very much :heart:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.