Add tweak rule to hide MenuButton dropdown arrow

This commit is contained in:
mkpaz 2022-09-02 21:08:28 +04:00
parent 21858a3ace
commit dd1a8f6452
3 changed files with 44 additions and 1 deletions

@ -0,0 +1,7 @@
package atlantafx.base.theme;
/** Contains extra style class names introduced to tweak some controls view. */
public final class Tweaks {
public static final String NO_ARROW = "no-arrow";
}

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: MIT */
package atlantafx.sampler.page.components;
import atlantafx.base.theme.Tweaks;
import atlantafx.sampler.page.AbstractPage;
import atlantafx.sampler.page.SampleBlock;
import javafx.geometry.Side;
@ -35,7 +36,8 @@ public class MenuButtonPage extends AbstractPage {
popupSideSample().getRoot(),
iconOnlySample().getRoot(),
outlinedSample().getRoot(),
disabledSample().getRoot()
disabledSample().getRoot(),
noArrowSample().getRoot()
);
}
@ -234,6 +236,26 @@ public class MenuButtonPage extends AbstractPage {
return new SampleBlock("Disabled", sample);
}
private SampleBlock noArrowSample() {
var basicMenuBtn = new MenuButton("_Menu Button");
basicMenuBtn.getItems().setAll(menuItems(5));
basicMenuBtn.getStyleClass().addAll(Tweaks.NO_ARROW);
var flatMenuBtn = new MenuButton("Flat");
flatMenuBtn.getItems().setAll(menuItems(5));
flatMenuBtn.getStyleClass().addAll(FLAT, Tweaks.NO_ARROW);
var iconMenuBtn = new MenuButton();
iconMenuBtn.setGraphic(new FontIcon(Feather.MORE_HORIZONTAL));
iconMenuBtn.getItems().setAll(menuItems(5));
iconMenuBtn.getStyleClass().addAll(BUTTON_ICON, Tweaks.NO_ARROW);
var content = new HBox(10);
content.getChildren().addAll(basicMenuBtn, flatMenuBtn, iconMenuBtn);
return new SampleBlock("No Arrow", content);
}
@SuppressWarnings("SameParameterValue")
private MenuItem[] menuItems(int count) {
return IntStream.range(0, count)

@ -121,6 +121,20 @@ $separator-width: 0.75px !default;
}
}
.menu-button {
&.no-arrow {
>.arrow-button {
-fx-padding: 0;
>.arrow {
-fx-shape: none;
-fx-scale-shape: false;
-fx-min-width: -1;
}
}
}
}
.split-menu-button {
>.label {