-
Notifications
You must be signed in to change notification settings - Fork 161
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
Save window position and dimensions. Improve Preferences Form. #903
base: master
Are you sure you want to change the base?
Conversation
build with this PR. @cjee21 is the change proposal about how to compute window sizes is fine at high DPIs? PS: @regs01 please rebase, I just merged another PR and now it is conflicting, sorry about that, it is rare. |
I'm new to VCL so I just work on improving the existing codes. If there is a better and more proper way from someone more experienced in VCL then we should use that. I will test it later. We need to test on Windows 7 (to ensure no issues like previously) too and ideally it should be tested by someone with a multi-monitor, multi-DPI system. The existing implementation was not tested on this kind of set-up either so I don't know how it handles that. It seems now the default is to not remember window position and remember window size. We need to consider whether to keep old behaviour as default (set both defaults to not remember) or not. Also remember to use spaces for indents (it looks like tabs now). |
I think it is a good intermediate.
True. @regs01 please use spaces instead of tabs. |
Yes it's blank unless click on one of the items in the tree. Also it is entirely white with no distinction between the left, right and bottom sections. I don't know if that's a good idea. Also is it intended that the main window is re-spawned every time Preferences is closed? The issue reported by Klaus1189 is still there and now is triggered as soon as Preferences is opened. Seems to take very long to open Preferences too. |
With remember window size disabled it is acceptable for me on different DPIs but it is different size/ratio than what MediaInfo has been using for years so I don't know how others will react. With remember window size enabled, if user changes DPI after using MediaInfo at least once, it uses size for old DPI and window is too small (or maybe large). This may also cause issues for people using multi-monitors with different DPIs (I don't know how the behaviour is here since I no longer have multi-monitors). |
I am not shocked by the default and not so different so it is acceptable for me.
@regs01 is it possible to save a kind of DPI independent ratio rather than a pixel size? |
@cjee21 yours is not near from former version, ouch. too much height. Difference due to DPI somewhere? |
@regs01 in practice we have 2 topics, the save window pos/dim on one side and the default size on another side. IMO it would be better to split the PR in 2: the first one keeps the same method for computing the default size. when it is merged, you send a PR with the changes you suggest about the default size. |
Not DPI. that's the default on 100% (96DPI). It is because I'm using higher resolution display with more screen estate (>=1440 height). |
@JeromeMartinez Another major bug. When invoked from explorer context menu produces a window with no file open. This change is causing lots of effects besides remember window size and change Preferences look.
|
At least it does not seem to break Windows 7 compatibility. Note: We can remove delay load from user32 if we no longer need to get DPI manually. |
Took a more detailed look at the changes in this PR. I agree with changing the window size code to use VCL ( I also like that the window size/position saving is planned to be implemented as an option and that window position is disabled by default. I think this should not be added: if (fpUnscaledMonitorHeight>=1440)
Height=900; as it is deemed "too much height" and may cause other users to complain although I can tolerate that
This should not be simply removed from FormShow without sufficient testing and other changes: //Refresh global
FormResize(NULL);
Refresh(); These two functions have been triggered by FormShow long before I started contributing. There is a reason why it is there. @JeromeMartinez these are my opinions since you asked me for a review. As for the other changes, I am not so sure but think they require more testing and changes due to many side-effects/issues mentioned earlier. Of course, you make the decision on what is to be done (I'm just a user/contributor) :) |
Thanks :).
I guess that the best method here is to split this PR is 2 or more PRs with specific changes rather than all in one, too much difficult to review impacts. |
Maybe it is a good idea to make both window size and position saving disabled by default so that users used to existing behaviour will not be affected and especially with the DPI change causing unintended window size. That is why I try to keep the window size the same as before even on high-DPI displays after adding high-DPI support. Then users who want their own size can turn the setting on and resize the window to their liking and deal with resizing it again when changing DPI since the feature will be documented in changelog. If concerned about people not reading changelog and knowing the existence of the feature, maybe can make MediaInfo display changelog on first run after upgrade like what some apps do. |
I moved switching tab visibility before selecting active page.
I commented in the line computing Preferences form height. There is no need as VCL scales it automatically. It's enough to have fine looking height in design time. I see also new commits to chage lables height for Language and Output. There is also no need for that. They just needed to be aligned to baseline of comboboxes, as they were aligned to bottom of comboboxes. VCL take control of scaling.
Yeah, I used C++ Builder 11.3 Community Edition. On VirtualBox, so it wouldn't mess up with old lifetime Delphi 10.2 Starter license. Although i'm using Lazarus now. But I must say how bad C++ Builder code completion is. It's so slow and buggy. Delphi's one is a little better. Even CnPack can't help much of situation. But Lazarus is completely different level - works instantly and only showing items within the scope. It just doesn't have prediction, as Visual Studio, but in everything else Lazarus code completion is even better than VS.
I always use spaces, although RAD Studio seem to default tabs. There could be few, before I changed it. Probably CnPack also does it, i'll look up on it.
I have 4K with 150% myself. It's just uncommon if users want to change scale factor on a daily basis. It is also highly unlikely that a person with high DPI display would use Windows 7. I left Position off by default, as this could be matter of preference. But with dimensions users wouldn't notice difference, as they will keep having default size and location. But those using Text, Tree views and similar will be able to quickly address form height issue without going into Settings.
I'll look up on rebase.
I did for Height, as i didn't do scroll box. I can do for Width. It's 1-second operation.
#203
Cut off little bit less. I'll readd it. Although as I see at FormResize now, there is no need in most of it. All controls just need to be properly aligned. |
One more thing. If MediaInfo is closed while maximized, the next time it will start un-maximized but filling up the entire screen. This is not a problem for me and I have seen other apps behave like this but other users may find it annoying. I suggest if possible and not too difficult, make it remember if it is maximized or not and also the window dimensions saved should be for un-maximized so that user can restore their original un-maximized size. |
We can save the window size at 96DPI and scale it accordingly when we read/write the value. That should work. It may be rare for a user to change DPI but what if there are people who use laptop and dock it on a monitor with a different DPI every day? |
Confirmed that invoking from CLI/context menu is still broken as I expected earlier after a quick look at the codes. @JeromeMartinez I don't feel like reviewing this anymore
|
You mean, when switching tabs? That's because ComboBoxes are filled every time tab is switched. I didn't touch it. It's an old behavior. A better option would be to fill them once at form creation. And when a language is added. |
With the General tab, the one with languages.
There is definitely bad old behaviors but it is not good to make that worse while adding good things. Your work is really appreciated but we need to find a way to avoid regressions when we add features. |
What context menu and where? Any steps to reproduce?
Everything is moved to GUI_Configure, which is called by constructor, as it should be. FormResize event is there. Deprecating it would be a next move.
I didn't see the issue in VirtualBox with 125%, so I removed it. Check on my main system. Now I can see it. ComboBox does not scale properly. LCL has a feature to lock two controls to central lines of each other, as well as to top and or bottom line. Unfortunately VCL doesn't have it. Guess Embarcadero have no wish to develop VCL further. I'll brought it back, so as added to AfterMonitorDpiChanged.
Since Windows 7 dialogs generally using clWindow color. I just made it the way so misalignments wouldn't be noticeable. But as there are no TabSheet borders now and if you don't like clWindow, it's can be easily changed to clBrnFace for TPanel and TForm. However, I might suggest something in between - clWindow for TPanel and clBtnFace for Form.
I literally didn't touch it. TabSheet events are same. Delay is exactly the same. screen2gif-2024-07-03.webm |
Right click file in Windows Explorer > MediaInfo or using CLI
This one is up to @JeromeMartinez but since MediaInfo is working well right now, I think it is very risky to make changes that may break things and that require lots of testing especially since there are other more important issues that time should be spent on (including MediaInfoLib stuff). Also I'm not sure if the plan to replace this VCL version is still on.
Everything should be tested upto 200% DPI scale as there are users using 200% that reported issues previously.
The slowness I noticed and mentioned is when opening the Preferences window it takes longer to appear and I'm using a 5GHz CPU + DDR5 + PCIe 4.0 SSD. I'm also comparing with release version, not development. As for the other things relating to Preferences window design, I suggest to just ask Klaus1189 who originally reported design issues with it instead of asking me. Lastly I agree with splitting the PRs. I suggest the first PR for replacing the native Windows API calls as that can be merged immediately after one more quick test. Second one probably for implementing option to save window size/position since there is a feature request for it on MediaInfo website. |
But I just made a video. It's totally identical. There is nothing in my commits that affect it. But I can fix it anyway by moving reading CSV language files into form creation, so it just fires once. As well as a new language is added.
We can discuss it all first, as it saves time
I moved it down after reading args. Speaking of |
Moving Link, if embeded video doesn't work in Firefox screen2gif-2024-07-04-1955.webm |
New build.
For the moment the only regression I still see is the lack of lines (they are there before this PR) in the light theme, also visible in the video, and it is not expected that theses lines change in a PR about main window position and re-sizable preference windows. |
I still can't get what slowness are you talking about? Is it one in the video? I didn't make a commit yet. But there is a video with partial fix. I'll finish later, when come home. |
If we're still talking about the Preferences window, here are the commits history: https://github.com/MediaArea/MediaInfo/commits/master/Source/GUI/VCL/GUI_Preferences.cpp Time taken to open Preferences window:
I don't see any statistically significant difference regarding Preferences window after my contributions as expected from the commits history. The slightly faster time might be due to 64-bit and considering that a new option was added by your team recently, the results look good. I don't know what happened but 1st version of this PR was bad. Now it can be considered okay. But if the faster speed is just due to now having 64-bit, then it is still no good. Take note that the above test results are likely not accurate to tens of ms (based on 30fps video & only run once) so hundred or so ms difference can be ignored.
I'm not sure which slowness he is talking about (if he is talking about the one in your video, it has been like that for years AFAIK) but the one I talk about in all my comments is time taken for the Preferences window to show up which was bad in 1st build of this PR but can be considered okay now for me. UPDATE: If you want to know the reason why Preferences window now takes longer to show up, the cause is as I had initially suspected and now confirmed with some tests. This takes 0~2ms on both 64-bit and 32-bit to execute: Page->Top=-(Page->TabHeight*1.15);
Page->Height=Page->Height+(Page->TabHeight*1.15);
Cancel->Top=Page->Top+Page->Height+(Cancel->Height*0.15);
OK->Top=Cancel->Top;
ClientHeight=OK->Top+(OK->Height*1.15); This takes ~310ms on 64-bit and ~530ms on 32-bit to execute: for (int cTabIndex = 0; cTabIndex <= Page->PageCount-1; cTabIndex++)
Page->Pages[cTabIndex]->TabVisible = False; I timed this using code so it is accurate. It also agrees with the difference found from the video recording method above. |
Cherry picked to this branch |
Oh this, insignificant. Still it cannot take half a second. Mine isn't 5 GHz. And what's more it's VirtualBox. So it's slow, very slow. But once again - this (whole screen2gif-2024-07-05-0754.webm |
I made a commit here, so you measure it. However, moving |
Added optional ability to save window position and/or dimensions.
Also improved Preferences form a bit. Everything is aligned now. And it's resizeable now, which is more convenient.