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

creating hidden window #29

Closed
dcnieho opened this issue Jan 24, 2023 · 10 comments
Closed

creating hidden window #29

dcnieho opened this issue Jan 24, 2023 · 10 comments

Comments

@dcnieho
Copy link

dcnieho commented Jan 24, 2023

I'd like to create a window that is initially hidden, i will only show it later. right now it flashes up before i get a chance to call glfw.hide_window(self._glfw_window) in the post_init callback.
I tried:

glfw.window_hint(glfw.VISIBLE, False)
immapp.run(params)

but it makes sense that wouldn't work since glfw isn't even initialized at this point, correct?

Is it possible to make a window that is initially hidden?

@pthom
Copy link
Owner

pthom commented Jan 24, 2023

Is it possible to make a window that is initially hidden?

... No. But you may want to look at internal/backend_impls/backend_window_helper/glfw_window_helper.cpp and see if you can make an adaptation :-)

@dcnieho
Copy link
Author

dcnieho commented Jan 24, 2023

something like this, with corresponding changes to the app parameters, should do the trick:

diff --git a/src/hello_imgui/internal/backend_impls/backend_window_helper/glfw_window_helper.cpp b/src/hello_imgui/internal/backend_impls/backend_window_helper/glfw_window_helper.cpp
index 09590aa..4ecaa2c 100644
--- a/src/hello_imgui/internal/backend_impls/backend_window_helper/glfw_window_helper.cpp
+++ b/src/hello_imgui/internal/backend_impls/backend_window_helper/glfw_window_helper.cpp
@@ -81,6 +81,11 @@ namespace HelloImGui { namespace BackendApi
         else
             glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);

+        if (appWindowParams.hidden)
+            glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
+        else
+            glfwWindowHint(GLFW_VISIBLE, GLFW_TRUE);
+

         // GLFW_SCALE_TO_MONITOR is set to false: we set manually the window size in screen coordinates,
         // then AbstractRunner::MakeWindowSizeRelativeTo96Ppi_IfRequired() may resize the window at the second frame

Does that look ok to you? Should i explore that further?

@dcnieho
Copy link
Author

dcnieho commented Jan 24, 2023

That or an extra entry Hidden in enum class WindowSizeState. maybe thats more logical actually

@dcnieho
Copy link
Author

dcnieho commented Jan 24, 2023

tell me what you prefer and i'll try an implementation

@pthom
Copy link
Owner

pthom commented Jan 24, 2023

I do not know yet what is the best possible location, between WindowSizeState or a hidden flag.

I will need to think about it in more details, but of course your help would be appreciated. Any change needs to be validated with glfw &sdl, on the different OS (windows, mac, linux, etc.); which makes this a bit complex (but I would handle the porting part ;-)

By the way: would using WindowSizeState.minimized be sufficient for you? Beware, it might be broken; this is yet another corner case that I did not explore intensively.

@dcnieho
Copy link
Author

dcnieho commented Jan 24, 2023 via email

@pthom
Copy link
Owner

pthom commented Feb 2, 2023

After studying this, I think that WindowSizeState is not the appropriate place, and that a better solution would be either to add AppWindowParams::initiallyHidden (if taken into account only at startup), or AppWindowParams::hidden (if this is taken into account dynamically).

@pthom
Copy link
Owner

pthom commented Feb 9, 2023

Hi,

Since this was also asked in #41, I implemented a solution in d6af807

@dcnieho
Copy link
Author

dcnieho commented Feb 13, 2023

Super, that should do the trick for me! Will test in the next week or so (let me know if you make a pypi release, that makes testing much quicker ;) )

@dcnieho
Copy link
Author

dcnieho commented Feb 17, 2023

Tested with 0.8.5: works!

@dcnieho dcnieho closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants