-
Notifications
You must be signed in to change notification settings - Fork 77
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
Improve in-game window positioning #1601
Improve in-game window positioning #1601
Conversation
206ea1f
to
3f89c7a
Compare
3f89c7a
to
6c52c86
Compare
6c52c86
to
c2a7e5d
Compare
c2a7e5d
to
be37675
Compare
Looks good but upon a final look it isn't immediately obvious why we have
So wouldn't we get the same effect by storing the value stored into |
You can resize the observation window as well |
The code evolved quite a bit, so let me think about that a bit. I know there were edge cases that didn't work initially. Edit: Yes. The observation window with its multiple sizes was the issue. |
I removed the Hopefully, there isn't another edge case I'm forgetting. This seemingly trivial feature isn't quite so easy to get right. |
In addition to the map and observation window, every non-modal window can be shaded/minimized, which is also a resize. |
So currently moving a window to a border and minimizing it (I prefer that word as it seems more conventional for windows) would move the minimized window even closer to the border? In any case: The actual behavior change intended here is clipping the window to borders if they were clipped before, correct? I.e. the change in Can't we have it simpler: we get an adjusted position there before the resize which will clip the window correctly again after the resize and not store anything in the config? And/or to persist the clipping over restarts do the modification to Or am I misunderstanding anything? |
Windows® (capital W, registered trademark), sure. Mac and Linux users – depending on the desktop environment – will disagree with you. I have known the function of rolling the window into its title bar as "shade" since the late 90s when I was using MacOS (pre-MacOS X, so, may not be a thing today). It's still available on KDE, though.
I think so. But I concede that this is a less straightforward and more opinionated feature than I assumed.
Not quite. Critically, it's about restoring the position the user last dragged the window to. Which is subtly different for windows with more than two resize states (map and observation window). If a window is placed close to an edge, but not yet in clipping distance, following a resize that puts it in clipping distance
In summary, yes. Even though it's only relevant for one window (the observation window isn't persistent and storing Let's hear some more opinions. Do we want windows to snap to edges – including when "minimized" (ugh) – and do we care about the very subtle difference I've explained? |
Didn't know that, only went by the only name I've read for this and what was used throughout this project before. So thanks for the explanation where this name comes from. Makes sense as "minimized" may mean "smaller" which is more general than the folding into the title bar.
I see. Quite a lot of edge cases here, so thanks for tackling that! |
The static constexpr members are initialized to std::numeric_limits<ElementType>::min/max().
be37675
to
014f0d5
Compare
Alright. I've implemented the "correct" behavior as envisioned and greatly expanded the unit test to cover the edge cases. Bonus: I'll do one more round of manual testing and mark this PR as ready for review if all goes well. *knock on wood* |
1) Remember the window position set by a move and try to restore this position after every resize. 2) If the window is moved to a screen edge save Point::MaxElementValue instead, to make the window "stick" to the edge when resizing.
014f0d5
to
ccc9341
Compare
ccc9341
to
f570847
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job with the tests! I added a few improvement suggestions using contexts instead of unconditional messages which may make the test log harder to read
837e6ea
to
804a988
Compare
I had to add braces for formatting (IfMacros is a clang-format 13 addition). Also, Improved output with
Edit: And clang-format-17 formats differently than v10. :-( |
804a988
to
c6dbb34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add braces for formatting (IfMacros is a clang-format 13 addition). Also,
BOOST_TEST_CONTEXT
expands to anif
. So your initial suggestion didn't quite work, but thanks for pointing me in the right direction. I'm a Catch2/doctest user myself.
A true. I meant to omit the semicolon too: BOOST_TEST_CONTEXT("Before minimize/un-minimize") main();
would also work (best with a newline but that might be confusing), but let's not get too detailed.
Edit: And clang-format-17 formats differently than v10. :-(
Note that there is a build target "clangFormat" which formats modified files (e.g. make clangFormat -j
) which is created if the correct clang-format version is found. Maybe that helps.
What is the BOOST_INFO
in front of the SetMinimized
for? There is no assertion inside the function and the next check is guarded by BOOST_TEST_CONTEXT
. So I'd rather remove that
c6dbb34
to
7879d57
Compare
I'm using that already, thanks! My default is just to format from the editor using clang-format in PATH and it usually produces compatible results.
I think I meant to use Edit: Oh, and CI fails now because |
7879d57
to
f3bd59e
Compare
|
f3bd59e
to
fccbc9e
Compare
Woops, I wanted to enable auto-merge as Appveyor is so slow. Well, I guess/hope it is fine ;-) Thanks for your efforts! |
I'm here to fix things if anything breaks. (Found one bug in a prior PR already.)
You're very welcome! Thanks for reviewing! |
Improve window positioning in two ways:
The images below depict the window position between clicking the resize button.
Before:
After:
To-do:
savedPos
.