Open kulkesk opened 1 year ago
At the moment all windows are resizable. Why do you want to forbid the user to do this?
It's just nice to have, in example tiling window managers are generally don't tile windows with fixed sizes or ratios. They usually stretch the window across the screen and that could break the look and/or layout of the window.
Also having an option to limit the minimum size of the window would be nice.
OK. I will have a look into an implementation, I think it's easy.
I have implemented it in commit https://github.com/simonkrauter/NiGui/commit/e4b6749a1b9c5377b9d966cb05be18385049979e . Tell me in case you find any issues with it. You need to use the the master branch to use it, no the latest release.
I tested out the fixed size windows in my windows 7 vm and this is the result. borders of the window just don't update even if i turn off the padding around the container. The same doesn't happen without resizable flag being turned off
in linux everything works as intended
the bit of code from https://github.com/simonkrauter/NiGui/blob/master/examples/example_05_handle_window_close.nim doesn't work with windows.alwaysOnTop
window just becomes inaccessible and unmovable in windows 7 vm
window.minWidth
and window.minHeight
work without a problem on both systems
I tested out the fixed size windows in my windows 7 vm and this is the result.
I wouldn't base conclusions on results from a three generations old Windows version in a VM. If you would like to provide valid results, it should be done in a native Windows 10 or Windows 11 system.
I wouldn't base conclusions on results from a three generations old Windows version in a VM.
fair point, but i don't have any other Windows installations at the moment. If you can, you could test it.
import nigui
import nigui/msgBox
app.init()
var window = newWindow("NiGui example")
# window.width = 600.scaleToDpi
# window.height = 400.scaleToDpi
window.minWidth = 600.scaleToDpi
window.minHeight = 400.scaleToDpi
# window.resizable = false
# window.alwaysOnTop = true
window.centerOnScreen()
# window.onResize = proc (e: ResizeEvent) =
# var w = e.window
# w.width = 600.scaleToDpi
# w.height = 400.scaleToDpi
var container = newLayoutContainer(Layout_Vertical)
# container.padding = 10
window.add(container)
var button = newButton("Button 1")
container.add(button)
var textArea = newTextArea()
textArea.editable = false
container.add(textArea)
button.onClick = proc(event: ClickEvent) =
textArea.addLine("Button1 clicked, message box opened.")
window.alert("This is simple message box.", "simple message box")
textArea.addLine("Message box closed.")
window.onCloseClick = proc(event: CloseClickEvent) =
case window.msgBox("Do you want to quit?", "Quit?", "Quit", "Minimize", "Cancel")
of 1: window.dispose()
of 2: window.minimize()
else: discard
window.show()
app.run()
Running on Windows 10.
the bit of code from https://github.com/simonkrauter/NiGui/blob/master/examples/example_05_handle_window_close.nim doesn't work with
windows.alwaysOnTop
window just becomes inaccessible and unmovable in windows 7 vm
I can confirm this.
I wouldn't base conclusions on results from a three generations old Windows version in a VM.
fair point, but i don't have any other Windows installations at the moment. If you can, you could test it.
import nigui import nigui/msgBox app.init() var window = newWindow("NiGui example") # window.width = 600.scaleToDpi # window.height = 400.scaleToDpi window.minWidth = 600.scaleToDpi window.minHeight = 400.scaleToDpi # window.resizable = false # window.alwaysOnTop = true window.centerOnScreen() # window.onResize = proc (e: ResizeEvent) = # var w = e.window # w.width = 600.scaleToDpi # w.height = 400.scaleToDpi var container = newLayoutContainer(Layout_Vertical) # container.padding = 10 window.add(container) var button = newButton("Button 1") container.add(button) var textArea = newTextArea() textArea.editable = false container.add(textArea) button.onClick = proc(event: ClickEvent) = textArea.addLine("Button1 clicked, message box opened.") window.alert("This is simple message box.", "simple message box") textArea.addLine("Message box closed.") window.onCloseClick = proc(event: CloseClickEvent) = case window.msgBox("Do you want to quit?", "Quit?", "Quit", "Minimize", "Cancel") of 1: window.dispose() of 2: window.minimize() else: discard window.show() app.run()
I tested this example with window.resizable = false
and it works as intended.
Is there a way to make windows with fixed sizes or ratios?