tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.85k stars 2.46k forks source link

[feat] WindowConfig: preserve aspect ratio #5332

Open petergeneric opened 1 year ago

petergeneric commented 1 year ago

Describe the problem

Currently, tauri.conf.json allows setting window width/height and maxWidth/maxHeight. It is also possible to disable resize.

It isn't possible to preserve the initial aspect ratio, however. This is important for apps whose main window will scale as the window resizes, but where the app does not wish to support different aspect ratios (e.g. a 3x3 security camera grid)

Describe the solution you'd like

A new key in tauri.config.json's WindowConfig, preserveAspectRatio, a boolean defaulting to false. If set to true, then when the user resizes the window, the aspect ratio of the initial window size (as defined in the width and height keys) would be preserved.

Alternatives considered

No response

Additional context

In Electron, this is achieved with:

 mainWindow.setAspectRatio(800/600)
amrbashir commented 1 year ago

This is not possible unfortunately. It is better for you to preserve the aspect ratio in HTML/CSS.

FabianLars commented 10 months ago

Reopening since this seems to be possible as far as i can see. I'd probably go with a similar setting to electron over a preserveAspectRatio but well see i guess.

petergeneric commented 10 months ago

Good to hear, although I'm going to unsubscribe from this ticket... frankly, with the outright rejection of this (pretty common native windowing feature, we gave up on Tauri as a project.