Skip to content

Commit 569f1ac

Browse files
Refac
1 parent 0ca2833 commit 569f1ac

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

pacman-ui/src/main/java/de/amr/pacmanfx/ui/GameUI_Implementation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public void selectGameVariant(String gameVariant) {
427427
Logger.error("Could not find app icon for current game variant {}", gameVariant);
428428
}
429429

430-
playView().canvasFrame().roundedBorderProperty().set(newConfig.hasGameCanvasRoundedBorder());
430+
playView().canvasFrame().setRoundedBorder(newConfig.hasGameCanvasRoundedBorder());
431431

432432
// this triggers a game event and the event handlers:
433433
gameContext.theGameController().selectGameVariant(gameVariant);

pacman-ui/src/main/java/de/amr/pacmanfx/ui/_2d/CanvasWithFrame.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class CanvasWithFrame extends BorderPane {
2828

2929
private final ObjectProperty<Color> borderColor = new SimpleObjectProperty<>(Color.LIGHTBLUE);
3030

31-
private final BooleanProperty roundedBorderPy = new SimpleBooleanProperty(true) {
31+
private final BooleanProperty roundedBorder = new SimpleBooleanProperty(true) {
3232
@Override
3333
protected void invalidated() {
3434
doLayout(scaling(), true);
@@ -77,7 +77,7 @@ public CanvasWithFrame() {
7777
clipRect.setArcHeight(arcSize);
7878
}
7979
return clipRect;
80-
}, roundedBorderPy, scaling, unscaledCanvasWidth, unscaledCanvasHeight));
80+
}, roundedBorder, scaling, unscaledCanvasWidth, unscaledCanvasHeight));
8181

8282
borderProperty().bind(Bindings.createObjectBinding(() -> {
8383
if (!hasRoundedBorder() || !isBorderVisible()) {
@@ -86,7 +86,7 @@ public CanvasWithFrame() {
8686
double bw = Math.max(5, Math.ceil(computeSize().getHeight() / 55)); // TODO avoid magic numbers
8787
CornerRadii cr = hasRoundedBorder() ? new CornerRadii(Math.ceil(10 * scaling())) : null;
8888
return new Border(new BorderStroke(borderColor(), BorderStrokeStyle.SOLID, cr, new BorderWidths(bw)));
89-
}, roundedBorderPy, borderVisible, scaling, unscaledCanvasWidth, unscaledCanvasHeight));
89+
}, roundedBorder, borderVisible, scaling, unscaledCanvasWidth, unscaledCanvasHeight));
9090
}
9191

9292
private void doLayout(double newScaling, boolean forced) {
@@ -121,10 +121,6 @@ private Dimension2D computeSize() {
121121
);
122122
}
123123

124-
public Canvas canvas() {
125-
return canvas;
126-
}
127-
128124
public void resizeTo(double width, double height) {
129125
if (hasRoundedBorder()) {
130126
double downScaledWidth = width, downScaledHeight = height;
@@ -143,6 +139,10 @@ public void resizeTo(double width, double height) {
143139
Logger.debug("Game canvas container resized to width={} height={}", getWidth(), getHeight());
144140
}
145141

142+
public Canvas canvas() {
143+
return canvas;
144+
}
145+
146146
public DoubleProperty scalingProperty() { return scaling; }
147147
public double scaling() {
148148
return scaling.get();
@@ -167,24 +167,28 @@ public void setUnscaledCanvasSize(double width, double height) {
167167
unscaledCanvasHeight.set(height);
168168
}
169169

170-
public BooleanProperty roundedBorderProperty() { return roundedBorderPy; }
170+
public BooleanProperty roundedBorderProperty() { return roundedBorder; }
171+
171172
public boolean hasRoundedBorder() {
172-
return roundedBorderPy.get();
173+
return roundedBorder.get();
173174
}
175+
174176
public void setRoundedBorder(boolean enabled) {
175-
roundedBorderPy.set(enabled);
177+
roundedBorder.set(enabled);
176178
}
177179

178180
public Color borderColor() {
179181
return borderColor.get();
180182
}
183+
181184
public void setBorderColor(Color color) {
182185
borderColor.set(color);
183186
}
184187

185188
public boolean isBorderVisible() {
186189
return borderVisible.get();
187190
}
191+
188192
public void setBorderVisible(boolean visible) {
189193
borderVisible.set(visible);
190194
}

0 commit comments

Comments
 (0)