Skip to content

Commit 895a766

Browse files
(v2) Scene editor: some fixes.
1 parent 574340c commit 895a766

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

source/v2/phasereditor/phasereditor.scene.ui/src/phasereditor/scene/ui/editor/properties/AnimationsSection.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ public Control createContent(Composite parent) {
7070
var comp = new Composite(parent, 0);
7171
comp.setLayout(new GridLayout(2, false));
7272

73+
74+
_animCanvas = new AnimationPreviewComp(comp, 0);
75+
{
76+
var gd = new GridData(GridData.FILL_BOTH);
77+
gd.horizontalSpan = 2;
78+
gd.heightHint = 200;
79+
_animCanvas.setLayoutData(gd);
80+
}
81+
7382
_browseBtn = new Button(comp, 0);
7483
_browseBtn.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
7584
_browseBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
@@ -80,13 +89,6 @@ public Control createContent(Composite parent) {
8089
_clearBtn.setText("Clear");
8190
_clearBtn.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> clearAnimation()));
8291

83-
_animCanvas = new AnimationPreviewComp(comp, 0);
84-
{
85-
var gd = new GridData(GridData.FILL_BOTH);
86-
gd.horizontalSpan = 2;
87-
gd.heightHint = 200;
88-
_animCanvas.setLayoutData(gd);
89-
}
9092

9193
return comp;
9294
}

source/v2/phasereditor/phasereditor.scene.ui/src/phasereditor/scene/ui/editor/properties/BitmapTextSection.java

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,21 @@ public void run() {
8585
getModels().forEach(model -> {
8686
BitmapTextComponent.set_align(model, _align);
8787
});
88-
88+
8989
}, getModels(), true);
9090

9191
getEditor().setDirty(true);
9292
getEditor().getScene().redraw();
93-
93+
94+
updateAlignActionsState();
9495
}
9596
}
9697

9798
@Override
9899
public Control createContent(Composite parent) {
100+
101+
createActions();
102+
99103
var comp = new Composite(parent, SWT.NONE);
100104
comp.setLayout(new GridLayout(2, false));
101105

@@ -136,8 +140,6 @@ public Control createContent(Composite parent) {
136140

137141
}
138142

139-
update_UI_from_Model();
140-
141143
return comp;
142144
}
143145

@@ -206,12 +208,6 @@ public void run() {
206208
@Override
207209
public void fillToolbar(ToolBarManager manager) {
208210

209-
_alignLeftAction = new AlignAction("ALIGN_LEFT", IMG_TEXT_ALIGN_LEFT, BitmapTextComponent.ALIGN_LEFT);
210-
_alignMiddleAction = new AlignAction("ALIGN_MIDDLE", IMG_TEXT_ALIGN_CENTER, BitmapTextComponent.ALIGN_MIDDLE);
211-
_alignRightAction = new AlignAction("ALIGN_RIGHT", IMG_TEXT_ALIGN_RIGHT, BitmapTextComponent.ALIGN_RIGHT);
212-
213-
_fontAction = new FontAction();
214-
215211
manager.add(_alignLeftAction);
216212
manager.add(_alignMiddleAction);
217213
manager.add(_alignRightAction);
@@ -226,13 +222,23 @@ public void fillToolbar(ToolBarManager manager) {
226222
manager.add(new FontSizeAction(false));
227223
}
228224

225+
private void createActions() {
226+
_alignLeftAction = new AlignAction("ALIGN_LEFT", IMG_TEXT_ALIGN_LEFT, BitmapTextComponent.ALIGN_LEFT);
227+
_alignMiddleAction = new AlignAction("ALIGN_MIDDLE", IMG_TEXT_ALIGN_CENTER, BitmapTextComponent.ALIGN_MIDDLE);
228+
_alignRightAction = new AlignAction("ALIGN_RIGHT", IMG_TEXT_ALIGN_RIGHT, BitmapTextComponent.ALIGN_RIGHT);
229+
230+
_fontAction = new FontAction();
231+
}
232+
229233
@SuppressWarnings("boxing")
230234
@Override
231235
public void update_UI_from_Model() {
232236
var models = getModels();
233237

238+
String flatValues_to_String = flatValues_to_String(models.stream().map(model -> BitmapTextComponent.get_fontSize(model)));
239+
234240
_fontSizeText
235-
.setText(flatValues_to_String(models.stream().map(model -> BitmapTextComponent.get_fontSize(model))));
241+
.setText(flatValues_to_String);
236242

237243
_letterSpacingText.setText(
238244
flatValues_to_String(models.stream().map(model -> BitmapTextComponent.get_letterSpacing(model))));
@@ -242,10 +248,7 @@ public void update_UI_from_Model() {
242248
return asset == null ? "<null>" : asset.getKey();
243249
})));
244250

245-
for (var action : new AlignAction[] { _alignLeftAction, _alignMiddleAction, _alignRightAction }) {
246-
action.setChecked(flatValues_to_boolean(
247-
models.stream().map(model -> BitmapTextComponent.get_align(model) == action.getAlign())));
248-
}
251+
updateAlignActionsState();
249252

250253
listenInt(_fontSizeText, value -> {
251254

@@ -266,12 +269,20 @@ public void update_UI_from_Model() {
266269
getModels().stream().forEach(model -> {
267270
BitmapTextComponent.set_letterSpacing(model, value);
268271
});
269-
}, getModels());
272+
}, getModels(), true);
270273

271274
getEditor().setDirty(true);
272275

273276
});
274277

275278
}
276279

280+
@SuppressWarnings("boxing")
281+
void updateAlignActionsState() {
282+
for (var action : new AlignAction[] { _alignLeftAction, _alignMiddleAction, _alignRightAction }) {
283+
action.setChecked(flatValues_to_boolean(
284+
getModels().stream().map(model -> BitmapTextComponent.get_align(model) == action.getAlign())));
285+
}
286+
}
287+
277288
}

0 commit comments

Comments
 (0)