> 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 incrementally with one additional 
commit since the last revision:

  cleanup

-------------

Changes:
  - all: https://git.openjdk.org/jfx/pull/1773/files
  - new: https://git.openjdk.org/jfx/pull/1773/files/38abae8f..82c2fe65

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jfx&pr=1773&range=25
 - incr: https://webrevs.openjdk.org/?repo=jfx&pr=1773&range=24-25

  Stats: 4 lines in 1 file changed: 0 ins; 4 del; 0 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

Reply via email to