Skip to content

Commit

Permalink
Fit-to-icon button layouts should look at the preferred icon dimensio…
Browse files Browse the repository at this point in the history
…n from the presentation model

For #447
  • Loading branch information
kirill-grouchnikov committed May 31, 2023
1 parent 077417d commit d6bd896
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,15 @@ public int getBandTitleHeight() {
@Override
@SuppressWarnings("unchecked")
protected JCommandButton createExpandButton() {
final int fontSize = RadianceSizeUtils.getComponentFontSize(null);
int arrowIconWidth = (int) RadianceSizeUtils.getSmallArrowIconWidth(fontSize);
int arrowIconHeight = (int) RadianceSizeUtils.getSmallDoubleArrowIconHeight(fontSize);

CommandButtonProjection<Command> expandCommandProjection =
new CommandButtonProjection<>(this.expandCommand,
CommandButtonPresentationModel.builder()
.setPresentationState(CommandButtonPresentationState.SMALL_FIT_TO_ICON)
.setIconDimension(new Dimension(arrowIconWidth, arrowIconHeight))
.setContentPadding(new Insets(3, 2, 3, 2))
.setSides(RadianceThemingSlices.Sides.CLOSED_RECTANGLE)
.setActionKeyTip(ribbonBand.getExpandButtonKeyTip())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private TaskbarPanel() {
.setTag(TASKBAR_OVERFLOW_BUTTON)
.build().project(CommandButtonPresentationModel.builder()
.setPresentationState(CommandButtonPresentationState.SMALL_FIT_TO_ICON)
.setIconDimension(new Dimension(arrowIconHeight, arrowIconWidth))
.setContentPadding(new Insets(2, 6, 2, 6))
.setSides(RadianceThemingSlices.Sides.CLOSED_RECTANGLE)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void layoutContainer(Container parent) {
// Common scroller command presentation
CommandButtonPresentationModel scrollerActionsPresentation = CommandButtonPresentationModel.builder()
.setPresentationState(CommandButtonPresentationState.SMALL_FIT_TO_ICON)
.setIconDimension(new Dimension(arrowIconHeight, arrowIconWidth))
.setContentPadding(new Insets(2, 2, 2, 2))
.setFocusable(false)
.setToDismissPopupsOnActivation(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,6 @@ public CommandButtonLayoutInfo getLayoutInfo(JCommandButton commandButton) {
public static class FitToIcon extends CommandButtonLayoutManagerBig {
@Override
public Dimension getPreferredIconSize(JCommandButton commandButton) {
RadianceIcon icon = commandButton.getIcon();
if (icon != null) {
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
}
BaseCommandButtonPresentationModel presentationModel =
commandButton.getProjection().getPresentationModel();
Dimension preferredIconDimension = presentationModel.getIconDimension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,6 @@ public CommandButtonLayoutInfo getLayoutInfo(JCommandButton commandButton) {
public static class FitToIcon extends CommandButtonLayoutManagerMedium {
@Override
public Dimension getPreferredIconSize(JCommandButton commandButton) {
RadianceIcon icon = commandButton.getIcon();
if (icon != null) {
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
}
BaseCommandButtonPresentationModel presentationModel =
commandButton.getProjection().getPresentationModel();
Dimension preferredIconDimension = presentationModel.getIconDimension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,6 @@ public CommandButtonLayoutInfo getLayoutInfo(JCommandButton commandButton) {
public static class FitToIcon extends CommandButtonLayoutManagerSmall {
@Override
public Dimension getPreferredIconSize(JCommandButton commandButton) {
RadianceIcon icon = commandButton.getIcon();
if (icon != null) {
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
}
BaseCommandButtonPresentationModel presentationModel =
commandButton.getProjection().getPresentationModel();
Dimension preferredIconDimension = presentationModel.getIconDimension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,6 @@ public CommandButtonLayoutInfo getLayoutInfo(JCommandButton commandButton) {
public static class FitToIcon extends CommandButtonLayoutManagerTile {
@Override
public Dimension getPreferredIconSize(JCommandButton commandButton) {
RadianceIcon icon = commandButton.getIcon();
if (icon != null) {
return new Dimension(icon.getIconWidth(), icon.getIconHeight());
}
BaseCommandButtonPresentationModel presentationModel =
commandButton.getProjection().getPresentationModel();
Dimension preferredIconDimension = presentationModel.getIconDimension();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,23 @@ protected void installComponents() {
new HashMap<>();
galleryScrollerOverlays.put(this.scrollUpCommand,
CommandButtonPresentationModel.overlay()
.setIconDimension(new Dimension(arrowIconWidth, arrowIconHeight))
.setSides(RadianceThemingSlices.Sides.builder()
.setStraightSides(EnumSet.of(RadianceThemingSlices.Side.LEADING))
.build())
.setAutoRepeatAction(true)
.setAutoRepeatActionIntervals(200, 50));
galleryScrollerOverlays.put(this.scrollDownCommand,
CommandButtonPresentationModel.overlay()
.setIconDimension(new Dimension(arrowIconWidth, arrowIconHeight))
.setSides(RadianceThemingSlices.Sides.builder()
.setStraightSides(EnumSet.of(RadianceThemingSlices.Side.LEADING))
.build())
.setAutoRepeatAction(true)
.setAutoRepeatActionIntervals(200, 50));
galleryScrollerOverlays.put(this.expandCommand,
CommandButtonPresentationModel.overlay()
.setIconDimension(new Dimension(arrowIconWidth, arrowDoubleIconHeight))
.setSides(RadianceThemingSlices.Sides.builder()
.setStraightSides(EnumSet.of(RadianceThemingSlices.Side.LEADING))
.build())
Expand Down

0 comments on commit d6bd896

Please sign in to comment.