mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.26k stars 1.76k forks source link

User-defined zoom levels #4081

Open eishiya opened 1 month ago

eishiya commented 1 month ago

For different tile sizes and art styles, as well as different screen resolutions, different zoom levels are more appropriate. Someone working with large tiles may want to have smaller zoom levels available as well as more steps in the low %s, and may not want the ability to zoom in beyond 200% or so, while someone working with pixel art may never want 150% blurring their art and may often want 500 or 600% (currently only possible in Tiled by typing those values in), while yet another user may want some zoom steps that correspond to the specific camera zooms in their game. Currently, Tiled has the same set of zoom steps for everyone, so useful zoom levels might not be easily available to users, while scrolling their mouse wheel to zoom takes through through a bunch of extra steps they never want.

I think a flexible way to address these differences in needs would be to allow users to specify the zoom steps Tiled will use while zooming. Here's a screenshot from ImageGlass, showing their zoom settings. They have a drop-down for the interpolation method and, more relevant to this issue, a text box where users can enter a list of zoom steps (in percent) that the program will step through. They use semicolons as the separator, presumably to avoid ambiguity with the comma potentially used as a decimal separator. It's not beautiful, but it works well. image The initial value of this list could correspond to Tiled's current zoom steps, 1; 3; 6; 12; 25; 33; 50; 75; 100; 150; 200; 300; 400; 550; 800; 1100; 1600; 2300; 3200; 4500; 6400; 9000;12800; 18000; 25600 (does anyone actually use the upper third of this list? It feels like it must've been taken from a vector program). For my own needs (pixel art, mostly), I'd probably replace it with 6.25; 12.5; 25; 50; 100; 200; 300; 400; 500; 600; 700; 800, while someone working with 256px tiles might instead go for 0.78125; 1.5625; 3.125; 6.25; 12.5; 25; 50; 100; 200; 300 (1/128x, 1/64x... 1/2x, 1x, 2x, 3x) This box should display a warning if its contents cannot be parsed into a valid list of zoom steps. If Tiled allows saving such an invalid list, then it should use the default steps while the user-provided list is invalid.

In Tiled, the smallest allowed zoom level is 1% and the zoom drop-downs only allow entering integer values. For smaller and more flexible zooms to be possible, Tiled would need to allow non-integer percentages, e.g. 0.2%, 33.3333%. Such values should be allowed in the text box where the steps are defined, as well as in the drop-downs. I imagine Qt would handle the decimal point (. or ,) based on the current locale, but if not, both should be considered valid.

Typing in zoom values in the zoom dropdown should continue to allow values that aren't listed in the steps. So if someone has a max zoom step of 200%, they should still be able to zoom to 1600% by typing it in. By allowing decimal values, it should also be possible to zoom to values below 1% even if one keeps the default step list.

A related problem is that people with mouse wheels that scroll in finer increments than 15 degrees cannot even use the pre-defined steps in Tiled (except through the zoom drop-down) because Tiled instead calculates the zoom based on the scroll amount and the current zoom level. While that may be appropriate for vector artwork, Tiled does everything in raster mode, and being able to easily get to step values like 100% is usually important. Tiled should provide the option to use the steps even when the scroll wheel events are fine-grained, perhaps by zooming only when the total scroll amount since the last zoom reaches 15 degrees. This option should perhaps be enabled by default, so everyone has the same starter zooming experience regardless of their hardware.