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

Fix:gui/internal:Handling resize/rotation #682

Merged
merged 28 commits into from
Jan 30, 2019

Conversation

lains
Copy link
Contributor

@lains lains commented Oct 6, 2018

This change allows dynamically resizing windows using the internal GUI.
Initially, I guess this GUI was targeted for embedded touchscreen devices, but it is also used for Android (probably until the Qt5 GUI is available).
The issue with the internal GUI is that it does not really handle resizing when navigating inside menus and submenus, it merely moves back to the main menu each time there is a resize (and rotation on Android implies resize which is annoying).
Issue #433 has been open to track this.
This PR aims to solve this resize problem, allowing to continue wherever the user is (inside the menus/submenus) in the menu after a resize/rotation.

@lains
Copy link
Contributor Author

lains commented Oct 13, 2018

Resize/rotate is now working on HTML menus and on widget-constructed menus as well (these are handled differently).
It still needs work on virtual keyboard resizing (and this is maybe only due to the fact tables resizing is not implemented yet).

@hoehnp
Copy link
Contributor

hoehnp commented Oct 13, 2018

Will it also be possible to get a signal about the rotation for use in changes of the osd layouts?

@lains
Copy link
Contributor Author

lains commented Oct 14, 2018

@hoehnp: yes, we should be able to get a generic notification about resize (thus also handling rotation for fixed-size displays).
From the test I made, map view resize can also be catched by gui_internal_resize() but I think there should be a better place (not related to internal GUI code).
Do you have another example of a signal that is send to OSD items from other events?
How do you catch such signals in OSD items?

@hoehnp
Copy link
Contributor

hoehnp commented Oct 14, 2018

I think gui_internal_resize is a bit ambiguous. So far to my knowledge it was not possible to catch it and use it for rescaling of osd elements. My idea would be to do it similarly like the click event, which calls a separate function, e.g.

static void osd_odometer_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button,
. Then I guess we had to add an additional callback from osd side. Honestly, I never have gone so deeply in the details. Will figure out next week.

@pgrandin pgrandin added the WIP Work in progress. Do not merge as-is, but please contribute label Oct 20, 2018
@lains
Copy link
Contributor Author

lains commented Oct 22, 2018

Yes, definitely, if there is a hook to implement, it should be outside of internal GUI, because the way the map is displayed (and thus OSD items on top of it), is really separate from the GUI implemented in my opinion.

@lains
Copy link
Contributor Author

lains commented Oct 22, 2018

I still have some work to do on handling table and box resize properly, this is impacting virtual keyboard that is currently not rescaled properly.

@lains lains changed the title [WIP] Fix:gui/internal:Handling resize/rotation Fix:gui/internal:Handling resize/rotation Oct 29, 2018
@lains
Copy link
Contributor Author

lains commented Oct 29, 2018

I'm almost there but the code around widget packing is quite complex.
However, I am getting small deltas between an initially small rendered window resized to fullscreen, and an originally fullscreen rendered one...
Is there any internal GUI expert that could help out?

@pgrandin
Copy link
Contributor

pgrandin commented Nov 2, 2018

I'm not an expert, but if you share code/screenshots maybe we can figure it out.

@lains
Copy link
Contributor Author

lains commented Nov 5, 2018

I had to actually write some code to debug the internal GUI boxes (highlight them in red).
If this is of interest, I can share this very small patch to the code or add a preprocessor define to make this accessible to others.
Once I highlight boxes using a red border, and if I initially display the keyboard, then maximize the window, the last (bottom) line of the virtual keyboard was cut as per the screenshot below:
navit_coord_small_resized_maximized_broken

I wrote "was" because, in the meantime, I have made progress on this, and it now seems solved by my last commit 91e6a05 (now resizing while displaying the virtual keyboard seems to work).

However, I think handling resize properly would actually need to be developped on a per-GUI menu basis. And it seems to me that I could extend the issue with virtual keyboard to all cases where a box is not aligned to the top left (which was the case for the virtual keyboard that is aligned with the bottom of the window).

Fortunately, this may be caught properly by the resize handler I wrote (for box widgets), because this handler actually recursively repacks all children of a widget.
I have written no handler for tables though, so the result is uncertain.
... and to be honest, I have no good control about the side effects of the code I have added so testers are welcome...

@lains
Copy link
Contributor Author

lains commented Nov 5, 2018

In any case, it seems that the code in this PR is actually working as expected and solves the issue initially targetted (resize/rotation).
I will give it a try on Android to check how well it performs...
Please let me know what you think about this fix.

@hoehnp
Copy link
Contributor

hoehnp commented Nov 5, 2018

nice work. I think for OSD designers the code with the red lines is for sure a useful patch.

@lains
Copy link
Contributor Author

lains commented Nov 10, 2018

I'll submit the debugging patch (red lines) in a separate request but this is only active on menus (drawn by the internal GUI), not for OSD items on the map.

@lains
Copy link
Contributor Author

lains commented Nov 10, 2018

I have tested on Android, and it is actually fixing the rotation also (you don't return to the main menu, or loose anything that you might start typing).
There is one bug that I have identified: if you start in a menu with a given size or orientation, then enter a submenu, then change size or orientation, and finally go back to the previous menu, it is not drawn properly (it has not completely applied the orientation change itself).
I know where it comes from, I will submit a patch when I have some spare time.

@pgrandin
Copy link
Contributor

Nice work @lains ! This rotation issue was quite annoying. I also agree with @hoehnp the patch to highlight items would definitely be useful.

@lains
Copy link
Contributor Author

lains commented Nov 19, 2018

@hoehnp and @pgrandin, no problem, I will submit another PR to allow for visually debugging the internal GUI.

@lains
Copy link
Contributor Author

lains commented Nov 19, 2018

I still need to do some testing on table widget resizing and this PR should then be ready.
Now going back menus is working even after a rotation (has been fixed in 081fa13)

@lains lains removed the WIP Work in progress. Do not merge as-is, but please contribute label Nov 26, 2018
@lains
Copy link
Contributor Author

lains commented Nov 26, 2018

Development is finsihed for this PR. Please test and tell me if there are corner cases of menus in the internal GUI.
Virtual keyboard, top menu bar and standard HTML-like menus should resize/rotate without issues.
The risky parts are the content zone of other menus, for example layout lists, GPS coords input.
Testing can be done directly under Linux by using the internal GUI and resizing the window while on a menu.

I also agree with @hoehnp the patch to highlight items would definitely be useful.

I have submitted the visual debugging in PR #715

@lains
Copy link
Contributor Author

lains commented Nov 28, 2018

This patch should handle the issue covered by trac ticket 1149:
http://trac.navit-project.org/ticket/1149

@jkoan jkoan changed the title Fix:gui/internal:Handling resize/rotation [WIP] Fix:gui/internal:Handling resize/rotation Jan 7, 2019
@lains lains changed the title [WIP] Fix:gui/internal:Handling resize/rotation Fix:gui/internal:Handling resize/rotation Jan 8, 2019
@metalstrolch
Copy link
Contributor

Is this ready to be merged? Would be cool if so, because this fixes something really annoying.

@lains
Copy link
Contributor Author

lains commented Jan 30, 2019

@metalstrolch, tes, it should be ready, I have tested this on Android and Linux builds.
You can already build this code and test it either on the desktop version (resizing the window will show you the result), or by installing it on android which uses the internal GUI. You should get rotation and resize working even while typing some search text for countries, towns or streets.

Please let me know if this works correctly for you.

@metalstrolch
Copy link
Contributor

It's OK for me, tested this under sailfish/et5 on desktop as well. Unfortunately it triggers an old bug in graphics_qt5 that sometimes does not redraw the screen after rotation. But that's clearly NOT an issue of this task. So I think we can merge this.

@metalstrolch metalstrolch merged commit 94fccd7 into navit-gps:trunk Jan 30, 2019
@metalstrolch
Copy link
Contributor

Thank you, good work.

@metalstrolch
Copy link
Contributor

Unfortunately I cannot close the trac ticket, as I don't know how and don't have credentials.

@lains lains deleted the fixing_resize branch February 1, 2019 07:19
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

Successfully merging this pull request may close these issues.

5 participants