> This change fixes missing graphic in the `TabPane` overflow menu, using a
> different approach. Instead of providing a graphic override property, it now
> uses a "decorator" pattern to allow for wider customization of the overflow
> menu (following @Maran23 's suggestion).
>
>
> ### Summary of Changes
>
> - minor `TabPaneSkin` constructor javadoc clarification
> - added the `overflowMenuDecorator` property
> - changed popup menu to be created on demand
> - avoid adding the popup reference to the `TabHeaderSkin.properties` (I think
> it was done for testing purposes, but I could not find any references to it
> in the platform code)
>
>
> ### Question for the Reviewers
>
> 1. do we want to bind the `MenuItem.text` property if decorator is set?
>
>
>
> # Overflow Menu Decorator Property in the TabPaneSkin
>
> ## Summary
>
> Add the `overflowMenuDecorator` property in the `TabPaneSkin` class to allow
> for customization of
> the `TabPane` overflow menu, including support for custom graphic.
>
>
>
> ## Problem
>
> The original issue described impossibility of supporting custom graphic (such
> as `Path` or `Canvas`)
> in the `TabPane` overflow menu.
> This happens because
> the overflow menu must duplicate the the graphic, and the current
> implementation is limited to duplicating
> either `ImageView` or `Label` with an `ImageView` graphic.
>
> Going beyond the original complaint, it is also impossible to customize the
> overflow menu, when, for example,
> the application requirements call for text-only overflow menu (with tabs that
> include the graphic), or when
> the overflow menu needs to contain different text/graphic, or apply different
> rules to individual menu items.
>
>
>
> ## Solution
>
> The solution is to allow the application to set a "decorator" which would be
> used to customize the menu items
> in the overflow menu (the actual menu item instances are of certain type
> created by the skin).
>
> The `overflowMenuDecorator` property holds the decorator instance. The
> default `null` value makes the `TabPane`
> work exactly as it works now.
>
> Example:
>
>
> public class TabPaneGraphicFactoryExample {
> public void example() {
> Tab tab1 = new Tab("Tab1");
> tab1.setGraphic(...);
>
> Tab tab2 = new Tab("Tab2");
> tab2.setGraphic(...);
>
> TabPane tabPane = new TabPane();
> tabPane.getTabs().addAll(tab1, tab2);
>
> TabPaneSkin skin = new TabPaneSkin(tabPane);
> // set overflow menu decorator
> skin.setOverflowMenuDecorator(this::decorateMenu);
> tabPane.setSkin(skin);
> }
>
> // custom over...
Andy Goryachev has updated the pull request with a new target base due to a
merge or a rebase. The pull request now contains 36 commits:
- Merge branch 'master' into 8353599.menu.factory
- Merge branch 'master' into 8353599.menu.factory
- test
- cleanup
- overflow menu decorator
- Merge remote-tracking branch 'origin/master' into 8353599.menu.factory
- Merge branch 'master' into 8353599.menu.factory
- override
- javadoc
- Revert "factory"
This reverts commit 354a515b364a656f96c52023847c7331befbefd2.
- ... and 26 more: https://git.openjdk.org/jfx/compare/7db4a9dd...aca83a39
-------------
Changes: https://git.openjdk.org/jfx/pull/1773/files
Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1773&range=22
Stats: 183 lines in 2 files changed: 137 ins; 28 del; 18 mod
Patch: https://git.openjdk.org/jfx/pull/1773.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1773/head:pull/1773
PR: https://git.openjdk.org/jfx/pull/1773