Skip to content

Commit aa368e0

Browse files
committed
fixed a bug with asset dialog, updated property controls API.
1 parent 47e5fcc commit aa368e0

File tree

10 files changed

+350
-12
lines changed

10 files changed

+350
-12
lines changed

src/main/java/com/ss/editor/ui/control/property/PropertyControl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,22 @@ protected void createComponents() {
332332
FXUtils.addToPane(container, this);
333333
}
334334

335+
/**
336+
* Change control width percent.
337+
*
338+
* @param controlWidthPercent the control width percent.
339+
*/
340+
@FXThread
341+
public void changeControlWidthPercent(final double controlWidthPercent) {
342+
343+
if (!isSingleRow()) {
344+
return;
345+
}
346+
347+
propertyNameLabel.maxWidthProperty().unbind();
348+
propertyNameLabel.maxWidthProperty().bind(widthProperty().multiply(1D - controlWidthPercent));
349+
}
350+
335351
/**
336352
* Is single row boolean.
337353
*

src/main/java/com/ss/editor/ui/control/property/impl/BooleanPropertyControl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.ss.rlib.ui.util.FXUtils;
1111
import javafx.scene.control.CheckBox;
1212
import javafx.scene.layout.HBox;
13+
import javafx.scene.layout.Region;
1314
import org.jetbrains.annotations.NotNull;
1415
import org.jetbrains.annotations.Nullable;
1516

@@ -54,6 +55,16 @@ protected void createComponents(@NotNull final HBox container) {
5455
FXUtils.addClassTo(checkBox, CSSClasses.ABSTRACT_PARAM_CONTROL_CHECK_BOX);
5556
}
5657

58+
/**
59+
* Disable the offset of checkbox control.
60+
*/
61+
@FXThread
62+
public void disableCheckboxOffset() {
63+
final CheckBox checkBox = getCheckBox();
64+
checkBox.prefWidthProperty().unbind();
65+
checkBox.setPrefWidth(Region.USE_COMPUTED_SIZE);
66+
}
67+
5768
@Override
5869
@FromAnyThread
5970
protected boolean isSingleRow() {

src/main/java/com/ss/editor/ui/control/property/impl/ColorPropertyControl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ protected void createComponents(@NotNull final HBox container) {
4747
FXUtils.addClassTo(colorPicker, CSSClasses.ABSTRACT_PARAM_CONTROL_COLOR_PICKER);
4848
}
4949

50+
@Override
51+
@FXThread
52+
public void changeControlWidthPercent(final double controlWidthPercent) {
53+
super.changeControlWidthPercent(controlWidthPercent);
54+
55+
final ColorPicker colorPicker = getColorPicker();
56+
colorPicker.prefWidthProperty().unbind();
57+
colorPicker.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent));
58+
}
59+
5060
@Override
5161
@FXThread
5262
protected void setPropertyValue(@Nullable final ColorRGBA color) {

src/main/java/com/ss/editor/ui/control/property/impl/FloatPropertyControl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ public FloatPropertyControl(@Nullable final Float propertyValue, @NotNull final
4141
super(propertyValue, propertyName, changeConsumer, changeHandler);
4242
}
4343

44+
@Override
45+
@FXThread
46+
public void changeControlWidthPercent(final double controlWidthPercent) {
47+
super.changeControlWidthPercent(controlWidthPercent);
48+
49+
final FloatTextField valueField = getValueField();
50+
valueField.prefWidthProperty().unbind();
51+
valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent));
52+
}
53+
4454
@Override
4555
@FXThread
4656
protected void createComponents(@NotNull final HBox container) {

src/main/java/com/ss/editor/ui/control/property/impl/IntegerPropertyControl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ public IntegerPropertyControl(@Nullable final Integer propertyValue, @NotNull fi
3232
super(propertyValue, propertyName, changeConsumer);
3333
}
3434

35+
@Override
36+
@FXThread
37+
public void changeControlWidthPercent(final double controlWidthPercent) {
38+
super.changeControlWidthPercent(controlWidthPercent);
39+
40+
final IntegerTextField valueField = getValueField();
41+
valueField.prefWidthProperty().unbind();
42+
valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent));
43+
}
44+
3545
@Override
3646
@FXThread
3747
protected void createComponents(@NotNull final HBox container) {

src/main/java/com/ss/editor/ui/control/property/impl/Texture2DPropertyControl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public Texture2DPropertyControl(@Nullable final Texture2D propertyValue, @NotNul
9797
setOnDragDropped(this::handleDragDroppedEvent);
9898
}
9999

100+
@Override
101+
@FXThread
102+
public void changeControlWidthPercent(final double controlWidthPercent) {
103+
}
104+
100105
/**
101106
* Handle drag dropped events.
102107
*

src/main/java/com/ss/editor/ui/control/property/impl/Vector2FPropertyControl.java

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,66 @@ public class Vector2FPropertyControl<C extends ChangeConsumer, T> extends Proper
3737
@Nullable
3838
private FloatTextField yField;
3939

40+
/**
41+
* The field container.
42+
*/
43+
@Nullable
44+
private HBox fieldContainer;
45+
4046
public Vector2FPropertyControl(@Nullable final Vector2f propertyValue, @NotNull final String propertyName,
4147
@NotNull final C changeConsumer) {
4248
super(propertyValue, propertyName, changeConsumer);
4349
}
4450

51+
@Override
52+
@FXThread
53+
public void changeControlWidthPercent(final double controlWidthPercent) {
54+
super.changeControlWidthPercent(controlWidthPercent);
55+
56+
final HBox valueField = getFieldContainer();
57+
valueField.prefWidthProperty().unbind();
58+
valueField.prefWidthProperty().bind(widthProperty().multiply(controlWidthPercent));
59+
}
60+
4561
@Override
4662
@FXThread
4763
protected void createComponents(@NotNull final HBox container) {
4864
super.createComponents(container);
4965

50-
final HBox field = new HBox();
51-
field.prefWidthProperty()
66+
fieldContainer = new HBox();
67+
fieldContainer.prefWidthProperty()
5268
.bind(widthProperty().multiply(CONTROL_WIDTH_PERCENT));
5369

5470
xField = new FloatTextField();
5571
xField.setOnKeyReleased(this::updateVector);
5672
xField.addChangeListener((observable, oldValue, newValue) -> updateVector(null));
57-
xField.prefWidthProperty().bind(field.widthProperty().multiply(0.5));
73+
xField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5));
5874
xField.setScrollPower(10F);
5975

6076
yField = new FloatTextField();
6177
yField.setOnKeyReleased(this::updateVector);
6278
yField.addChangeListener((observable, oldValue, newValue) -> updateVector(null));
63-
yField.prefWidthProperty().bind(field.widthProperty().multiply(0.5));
79+
yField.prefWidthProperty().bind(fieldContainer.widthProperty().multiply(0.5));
6480
yField.setScrollPower(10F);
6581

66-
FXUtils.addToPane(xField, field);
67-
FXUtils.addToPane(yField, field);
68-
FXUtils.addToPane(field, container);
82+
FXUtils.addToPane(xField, fieldContainer);
83+
FXUtils.addToPane(yField, fieldContainer);
84+
FXUtils.addToPane(fieldContainer, container);
6985

70-
FXUtils.addClassesTo(field, CSSClasses.DEF_HBOX, CSSClasses.TEXT_INPUT_CONTAINER,
86+
FXUtils.addClassesTo(fieldContainer, CSSClasses.DEF_HBOX, CSSClasses.TEXT_INPUT_CONTAINER,
7187
CSSClasses.ABSTRACT_PARAM_CONTROL_SHORT_INPUT_CONTAINER);
7288

7389
FXUtils.addClassesTo(xField, yField, CSSClasses.TRANSPARENT_TEXT_FIELD);
7490

75-
UIUtils.addFocusBinding(field, xField, yField);
91+
UIUtils.addFocusBinding(fieldContainer, xField, yField);
92+
}
93+
94+
/**
95+
* @return the field container.
96+
*/
97+
@FXThread
98+
private @NotNull HBox getFieldContainer() {
99+
return notNull(fieldContainer);
76100
}
77101

78102
@Override
@@ -143,7 +167,7 @@ protected void reload() {
143167

144168
final FloatTextField yField = getYField();
145169
yField.setValue(vector.getY());
146-
yField.positionCaret(xField.getText().length());
170+
yField.positionCaret(yField.getText().length());
147171
}
148172

149173
/**

0 commit comments

Comments
 (0)