kirill-grouchnikov / radiance

Building modern, elegant and fast Swing applications
BSD 3-Clause "New" or "Revised" License
807 stars 89 forks source link

[Component] Icon filter strategies are not applied on ribbon application menu commands #477

Closed stik79 closed 3 months ago

stik79 commented 3 months ago

Version of Radiance (latest release is 8.0-SNAPSHOT)

7.5.0

Sub-project (Common, Animation, Theming, Component, ...)

Component/Theming

Version of Java (current minimum is 9)

17/21

Version of OS

Win 11

The issue you're experiencing (expected vs actual, screenshot, stack trace etc)

When using the Application Menu Popup in the ribbon it doesn't appear the icon strategy specified in the popup presentation model is honored. Unsure if this is expect or there's another way to get the icons within the menu to follow the theme? (I couldn't find an obvious way)


public static void main(String[] args) {
        SwingUtilities.invokeLater(()->{
            JFrame.setDefaultLookAndFeelDecorated(true);
            RadianceThemingCortex.GlobalScope.setSkin(new CeruleanSkin());

            JRibbonFrame frame = new JRibbonFrame("Menu Application Test");

            Command start= Command.builder().setIconFactory(skip_previous.factory()).setText("Start").build();
            Command rwd = Command.builder().setIconFactory(fast_rewind.factory()).setText("Rewind").build();
            Command play = Command.builder().setToggle().setIconFactory(play_arrow.factory()).setText("Play").build();
            Command fwd= Command.builder().setIconFactory(fast_foward.factory()).setText("Forward").build();
            Command end = Command.builder().setIconFactory(skip_next.factory()).setText("End").build();

            CommandGroup commandGroup = new CommandGroup(start,rwd,play,fwd,end);
            CommandMenuContentModel popupMenuContentModel = new CommandMenuContentModel(commandGroup);

            CommandPopupMenuPanelPresentationModel popupMenuPanelPresentationModel = CommandPopupMenuPanelPresentationModel.builder().setIconFilterStrategies(RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT).setLayoutSpec(new MenuPopupPanelLayoutSpec(2,5)).setCommandPresentationState(CommandButtonPresentationState.BIG).build();
            CommandPopupMenuPresentationModel popupMenuPresentationModel = CommandPopupMenuPresentationModel.builder().setItemFilterStrategies(RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT).setPanelPresentationModel(popupMenuPanelPresentationModel).build();

            CommandButtonProjection<Command> popupProjection = Command.builder().setText("Popup").setIconFactory(play_arrow.factory()).setSecondaryContentModel(popupMenuContentModel).build().project(CommandButtonPresentationModel.builder().setPresentationState(CommandButtonPresentationState.BIG).setIconFilterStrategies(RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT).setPopupMenuPresentationModel(popupMenuPresentationModel).build());
            JRibbonBand popupTestBand = new JRibbonBand("Pop",play_arrow.factory());
            popupTestBand.addRibbonCommand(popupProjection, JRibbonBand.PresentationPriority.TOP);

            popupTestBand.setResizePolicies(Collections.singletonList(new CoreRibbonResizePolicies.Mirror(popupTestBand)));
            frame.getRibbon().addTask(new RibbonTask("Popup",popupTestBand));

            CommandStripProjection stripProjection = new CommandStripProjection(commandGroup,CommandStripPresentationModel.builder().setIconFilterStrategies(RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT,RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.ORIGINAL).setHorizontalGapScaleFactor(1.3f).setCommandPresentationState(CommandButtonPresentationState.SMALL).build());
            JFlowRibbonBand flowRibbonBand = new JFlowRibbonBand("Commands",play_arrow.factory());
            flowRibbonBand.addFlowComponent(stripProjection);
            frame.getRibbon().addTask(new RibbonTask("Command Strip",flowRibbonBand));

            RibbonApplicationMenu ribbonApplicationMenu = new RibbonApplicationMenu(commandGroup);
            RibbonApplicationMenuCommand menuCommand = RibbonApplicationMenuCommand.builder().setIconFactory(play_arrow.factory()).setText("Play").setSecondaryContentModel(ribbonApplicationMenu).build();

            RibbonApplicationMenuCommandButtonProjection ribbonApplicationMenuCommandButtonProjection = new RibbonApplicationMenuCommandButtonProjection(menuCommand, CommandButtonPresentationModel.builder().setIconFilterStrategies(RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT, RadianceThemingSlices.IconFilterStrategy.THEMED_FOLLOW_TEXT).setPopupMenuPresentationModel(popupMenuPresentationModel).build());
            frame.getRibbon().setApplicationMenuCommand(ribbonApplicationMenuCommandButtonProjection);

            JPanel contentPanel = new JPanel(new BorderLayout());
            contentPanel.add(new JLabel("TESTING"),BorderLayout.CENTER);

            frame.getContentPane().add(getStatusBar(),BorderLayout.SOUTH);
            frame.getContentPane().add(contentPanel);

            frame.setSize(800,600);
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setVisible(true);

        });

Cerulean-ApplicationMenuNotFollowing Cerulean-PopupFollowing CremeCoffee-ApplicationMenuNotFollowing