Skip to content

Commit

Permalink
Cleaned up button and label dimension definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
bwRavencl committed Aug 18, 2024
1 parent bbe72d7 commit f8f052e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Binary file modified example_screenshot_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private void init() {

actionButtonsPanel.add(Box.createVerticalGlue());
final var addButton = addActionButton(new AddActionAction(), actionButtonsPanel, Main.BUTTON_DIMENSION);
actionButtonsPanel.add(Box.createVerticalStrut(Main.BUTTON_DIMENSION.height));
actionButtonsPanel.add(Box.createVerticalStrut(Main.BUTTON_DIMENSION_HEIGHT));
final var removeButton = addActionButton(new RemoveActionAction(), actionButtonsPanel, Main.BUTTON_DIMENSION);
actionButtonsPanel.add(Box.createVerticalGlue());

Expand All @@ -419,13 +419,11 @@ private void init() {
final var insideBorderInsets = emptyBorder.getBorderInsets();
addComponentToPanelFixedSize(copyPastePanel, actionButtonsPanel,
new Dimension(Main.BUTTON_DIMENSION.width,
Main.BUTTON_DIMENSION.height + titledBorder.getMinimumSize(copyPastePanel).height
Main.BUTTON_DIMENSION_HEIGHT + titledBorder.getMinimumSize(copyPastePanel).height
+ insideBorderInsets.top + insideBorderInsets.bottom));

@SuppressWarnings("SuspiciousNameCombination")
final var squareButtonDimension = new Dimension(Main.BUTTON_DIMENSION.height, Main.BUTTON_DIMENSION.height);
final var copyButton = addActionButton(new CopyActionAction(), copyPastePanel, squareButtonDimension);
pasteButton = addActionButton(new PasteActionAction(), copyPastePanel, squareButtonDimension);
final var copyButton = addActionButton(new CopyActionAction(), copyPastePanel, Main.SQUARE_BUTTON_DIMENSION);
pasteButton = addActionButton(new PasteActionAction(), copyPastePanel, Main.SQUARE_BUTTON_DIMENSION);

availableActionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
availableActionsList.addListSelectionListener(_ -> {
Expand Down
17 changes: 12 additions & 5 deletions src/main/java/de/bwravencl/controllerbuddy/gui/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,15 @@ public final class Main {
public static final int DEFAULT_HGAP = 10;
public static final int DEFAULT_VGAP = 10;
@SuppressWarnings("exports")
public static final Dimension BUTTON_DIMENSION = new Dimension(120, 25);
@SuppressWarnings("exports")
public static final Color TRANSPARENT = new Color(255, 255, 255, 0);
public static final String SWAPPED_SYMBOL = "⇆";
static final int DEFAULT_OVERLAY_SCALING = 1;
static final int BUTTON_DIMENSION_HEIGHT = 25;
@SuppressWarnings("exports")
public static final Dimension BUTTON_DIMENSION = new Dimension(120, BUTTON_DIMENSION_HEIGHT);
@SuppressWarnings({ "exports", "SuspiciousNameCombination" })
public static final Dimension SQUARE_BUTTON_DIMENSION = new Dimension(BUTTON_DIMENSION_HEIGHT,
BUTTON_DIMENSION_HEIGHT);
private static final Options options = new Options();
private static final Logger log = Logger.getLogger(Main.class.getName());
private static final String PROFILE_FILE_EXTENSION = "json";
Expand Down Expand Up @@ -264,6 +268,8 @@ public final class Main {
private static final String SVG_ID_Y = "y";
private static final int SETTINGS_LABEL_DIMENSION_HEIGHT = 15;
private static final Dimension SETTINGS_LABEL_DIMENSION = new Dimension(160, SETTINGS_LABEL_DIMENSION_HEIGHT);
private static final Dimension OVERLAY_SETTINGS_LABEL_DIMENSION = new Dimension(100,
SETTINGS_LABEL_DIMENSION_HEIGHT);
private static final Dimension CONNECTION_SETTINGS_LABEL_DIMENSION = new Dimension(80,
SETTINGS_LABEL_DIMENSION_HEIGHT);
private static final FlowLayout DEFAULT_FLOW_LAYOUT = new FlowLayout(FlowLayout.LEFT, DEFAULT_HGAP, DEFAULT_VGAP);
Expand Down Expand Up @@ -2903,7 +2909,7 @@ void updateModesPanel(final boolean newModeAdded) {
GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL, GRID_BAG_ITEM_INSETS, 0, 0));

final var modeNoLabel = new JLabel(MessageFormat.format(strings.getString("MODE_LABEL_NO"), i + 1));
modeNoLabel.setPreferredSize(new Dimension(100, 15));
modeNoLabel.setPreferredSize(OVERLAY_SETTINGS_LABEL_DIMENSION);
modePanel.add(modeNoLabel, new GridBagConstraints(0, 0, 1, 1, 0d, 0d, GridBagConstraints.CENTER,
GridBagConstraints.NONE, LIST_ITEM_INNER_INSETS, 0, 0));

Expand Down Expand Up @@ -3023,7 +3029,7 @@ private void updateOverlayPanel() {

final var virtualAxisLabel = new JLabel(
MessageFormat.format(strings.getString("AXIS_LABEL"), virtualAxis.toString()));
virtualAxisLabel.setPreferredSize(new Dimension(100, 15));
virtualAxisLabel.setPreferredSize(OVERLAY_SETTINGS_LABEL_DIMENSION);
indicatorPanel.add(virtualAxisLabel, new GridBagConstraints(0, 0, 1, 1, 0d, 0d, GridBagConstraints.CENTER,
GridBagConstraints.NONE, LIST_ITEM_INNER_INSETS, 0, 0));

Expand All @@ -3040,12 +3046,13 @@ private void updateOverlayPanel() {
}
colorLabel.setHorizontalAlignment(SwingConstants.CENTER);

colorLabel.setPreferredSize(new Dimension(100, 15));
colorLabel.setPreferredSize(OVERLAY_SETTINGS_LABEL_DIMENSION);
colorLabel.setBorder(BorderFactory.createLineBorder(borderColor));
indicatorPanel.add(colorLabel, new GridBagConstraints(1, 0, 1, 1, 0.2d, 0d, GridBagConstraints.CENTER,
GridBagConstraints.NONE, LIST_ITEM_INNER_INSETS, 0, 0));

final var colorButton = new JButton(new SelectIndicatorColorAction(virtualAxis));
colorButton.setPreferredSize(SQUARE_BUTTON_DIMENSION);
colorButton.setEnabled(enabled);
indicatorPanel.add(colorButton, new GridBagConstraints(2, 0, 1, 1, 0d, 0d, GridBagConstraints.CENTER,
GridBagConstraints.NONE, LIST_ITEM_INNER_INSETS, 0, 0));
Expand Down

0 comments on commit f8f052e

Please sign in to comment.