Skip to content

Make Custom menus scrollable - #11425

Merged
cmaglie merged 2 commits into
arduino:masterfrom
facchinm:scrollable_custommenus
Apr 30, 2021
Merged

cmaglie merged 2 commits into
arduino:masterfrom
facchinm:scrollable_custommenus

Conversation

@facchinm

@facchinm facchinm commented Apr 12, 2021 •

Copy link
Copy Markdown
Member

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).

@matthijskooijman matthijskooijman left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
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

cmaglie commented Apr 26, 2021 •

Copy link
Copy Markdown
Member

@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?

@matthijskooijman matthijskooijman left a comment

Copy link
Copy Markdown
Collaborator

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

fpistm commented Apr 30, 2021

Copy link
Copy Markdown

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