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

disable maximize/resize #17

Open
LaureLazard opened this issue Feb 21, 2022 · 1 comment
Open

disable maximize/resize #17

LaureLazard opened this issue Feb 21, 2022 · 1 comment
Labels
question Further information is requested

Comments

@LaureLazard
Copy link

Hi, amazing tool to work with, thank you a lot.
I was wondering if it there was a way to disable resizing/maximizing of the stage.
I tried to use setResizeable() but I suppose you are overriding this function since you rewrote the whole resizing process yourself.

I also tried to listen for attempts to maximize then set maximize to false but your codes set it back to true.

Custom Stage itself is a private class so I cannot extend/override it.

Any idea ?

@Oshan96
Copy link
Owner

Oshan96 commented Feb 21, 2022

Hi @LaureLazard good to hear you found CustomStage to be useful for your work!
And to answer your question(s),

  1. You can't change it using setResizable() since the functionality is not supported by default for undecorated windows (thus, the separate implementation).
  2. If you try to remove the listeners on resize events, you probably won't be able to perform that since the event is set for each and every Node in your UI recursively once it is called (since there is an issue in resizing an undecorated window so you have to manually resize every node with their child nodes once a resize occurs)
  3. No. CustomStage is a public class and you can directly use it (which has no resize listener set on it) and can override it. CustomStage itself is not responsible of resizing events.

The resize listener is set at the constructor of the CustomStageBuilder class which acts as an interface to easily build CustomStages with minimal effort, correctly. If you check the code there, I have used the ResizeHelper class to set the resize listeners. So, if you study the code in the builder class, and create your own CustomStage (without setting the ResizeListener) you should have an undecorated stage with all the functionality of CustomStage except for resize. Furthermore, you can then write your own resize listener class (follow the current ResizeListener to get an idea?) and then pass your CustomStage instance to it (if you followed the same pattern as ResizeHelper class) you can integrate it into your instance as well.

And, if you want the ability to maximize the stage gone, just take out the maximize button when you set the three (minimize, maximize, close) buttons, and it should be solved.

Hope this helps and solves your issue :)

PS: I just realized the current implementation of ResizeHelper and the ResizeListener does a recursive call to resize all the nodes and their children which can be quite ineffective at runtime and can even cause stackoverflaw errors. Should come up with a better way to handle it so that users will have smooth transitions when resizing (if you come up with a better implementation feel free to do a PR here. I'll study the code and merge it to the code).

@Oshan96 Oshan96 added the question Further information is requested label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants