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

Make Custom menus scrollable #11425

Merged
merged 2 commits into from
Apr 30, 2021
Merged

Conversation

facchinm
Copy link
Member

@facchinm facchinm commented Apr 12, 2021

Fixes #11416

The patch on MenuScroller.java is needed to avoid a clash between custom menus with the same label.
This behaviour artificially increases the amount of objects that the scroller will calculate.
Eg. if two boards share the same custom menu, that menu will contain the properties for both the boards (since it's parsed twice).

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you lint your code locally prior to submission?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes

Fixes arduino#11416

The patch on MenuScroller.java is needed to avoid a clash between custom menus with the same label.
This behaviour artificially increases the amount of objects that the scroller will calculate.
Eg. if two boards share the same custom menu, that menu will contain the properties for both the boards (since it's parsed twice).
Copy link
Collaborator

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so the problem is indeed the invisible items. I haven't tested, but I wonder if the filter you added is in the right place? AFAICS this now ensures that menuItems omits the invisible items, but restoreItems clears all items, including invisible ones and then restores all items in menuItems, so that restores only the visible ones? If this is indeed the case, I suspect that switching between boards might prevent showing items for the second board that did not exist for the first board?

Shouldn't setMenuItems still backup the full list and then have refreshMenu operate on the visible list? In practice, that could be done by modifying the loops in refreshMenu to skip invisible items (or use streaming functions to simplify that, mabye), or a lot simpler, by letting setMenuItems create two lists: One list with all items for restoration and one list with visible items for use in refreshMenu?

@facchinm
Copy link
Member Author

@matthijskooijman you are indeed (as always 🙂 ) right, but for some unknown reason I'm unable to trigger the expected wrong behaviour.
May it depend on the destruction of the menu entries when it gets minimised (the putClientProperty("removeOnWindowDeactivation", true); line) ?

@facchinm facchinm added this to the Release 1.8.14 milestone Apr 19, 2021
@matthijskooijman
Copy link
Collaborator

Hm, I haven't tried reproducing it (and no time to dig in, I'm afraid). Maybe just apply a fix and not worry about reproducing the problem, though? :-)

@cmaglie
Copy link
Member

cmaglie commented Apr 26, 2021

@matthijskooijman I've pushed a fix for the issue you described, the only way I managed to reproduce is this way:

  1. Install stm32 platform
  2. Select Generic STM32F0 series board
  3. Open the Board part number submenu: it shows a lot of entries
  4. Select Generic STM32F1 series board
  5. The Board part number submenu is gone -> bug

All the other platforms (avr, samd, esp32...) seem to be unaffected.
may you test it on some of your configurations to see if everything is behaving correctly?

Copy link
Collaborator

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to me. I played around with the latest STM32 core a bit and it seems to work as expected.

@cmaglie cmaglie merged commit 488f0d7 into arduino:master Apr 30, 2021
@cmaglie cmaglie deleted the scrollable_custommenus branch April 30, 2021 15:11
@fpistm
Copy link

fpistm commented Apr 30, 2021

Thanks a lot @facchinm, @cmaglie and @matthijskooijman

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.

list are longer than screen height, and impossible to scroll down
4 participants