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

Fixed sized windows #158

Open
kulkesk opened this issue Oct 27, 2022 · 12 comments
Open

Fixed sized windows #158

kulkesk opened this issue Oct 27, 2022 · 12 comments
Labels

Comments

@kulkesk
Copy link

kulkesk commented Oct 27, 2022

Is there a way to make windows with fixed sizes or ratios?

@simonkrauter
Copy link
Owner

At the moment all windows are resizable. Why do you want to forbid the user to do this?

@kulkesk
Copy link
Author

kulkesk commented Oct 27, 2022

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.

@kulkesk
Copy link
Author

kulkesk commented Oct 27, 2022

Also having an option to limit the minimum size of the window would be nice.

@simonkrauter
Copy link
Owner

OK. I will have a look into an implementation, I think it's easy.

simonkrauter added a commit that referenced this issue Oct 27, 2022
This allows to make windows not resizable and to set a minimum size.

Fixes #125 and #158.
@simonkrauter
Copy link
Owner

I have implemented it in commit e4b6749 .
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.

@kulkesk
Copy link
Author

kulkesk commented Oct 28, 2022

I tested out the fixed size windows in my windows 7 vm and this is the result.
image
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
image

@kulkesk
Copy link
Author

kulkesk commented Oct 28, 2022

in linux everything works as intended

@kulkesk
Copy link
Author

kulkesk commented Oct 28, 2022

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

@kulkesk
Copy link
Author

kulkesk commented Oct 28, 2022

window.minWidth and window.minHeight work without a problem on both systems

@theAkito
Copy link

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.

@kulkesk
Copy link
Author

kulkesk commented Oct 28, 2022

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()

@theAkito
Copy link

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.

@simonkrauter simonkrauter reopened this Mar 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants