Skip to content

Commit d648013

Browse files
committed
some changes to improve usability
1 parent b63ce07 commit d648013

11 files changed

Lines changed: 75 additions & 38 deletions

File tree

src/main/java/com/ss/editor/config/Config.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ public abstract class Config {
7878
* Flag is for showing debug of the JavaFX.
7979
*/
8080
public static final boolean DEV_DEBUG_JFX;
81+
/**
82+
* The flag to enable debug of mouse input from javaFX to jME.
83+
*/
84+
public static final boolean DEV_DEBUG_JFX_MOUSE_INPUT;
8185
/**
8286
* The flag to enable debug of key input from javaFX to jME.
8387
*/
@@ -97,6 +101,7 @@ public abstract class Config {
97101
DEV_DEBUG = vars.getBoolean("Dev.debug", false);
98102
DEV_CAMERA_DEBUG = vars.getBoolean("Dev.cameraDebug", false);
99103
DEV_TRANSFORMS_DEBUG = vars.getBoolean("Dev.transformsDebug", false);
104+
DEV_DEBUG_JFX_MOUSE_INPUT = vars.getBoolean("Dev.jfxMouseInput", false);
100105
DEV_DEBUG_JFX_KEY_INPUT = vars.getBoolean("Dev.jfxKeyInput", false);
101106
DEV_DEBUG_JFX = vars.getBoolean("Dev.debugJFX", false);
102107
ENABLE_PBR = vars.getBoolean("Graphics.enablePBR", true);

src/main/java/com/ss/editor/state/editor/impl/AdvancedAbstractEditor3DState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ protected boolean isShiftDown() {
744744
*/
745745
protected void setShiftDown(final boolean shiftDown) {
746746
this.shiftDown = shiftDown;
747+
new Exception("Shift down" + shiftDown).printStackTrace();
747748
}
748749

749750
/**

src/main/java/com/ss/editor/state/editor/impl/scene/AbstractSceneEditor3DState.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ protected Node getPresentableNode() {
439439
return presentableNode;
440440
}
441441

442+
@Override
443+
protected void redo() {
444+
getFileEditor().redo();
445+
}
446+
447+
@Override
448+
protected void undo() {
449+
getFileEditor().undo();
450+
}
451+
442452
/**
443453
* Create collision plane.
444454
*/

src/main/java/com/ss/editor/state/editor/impl/scene/SceneEditor3DState.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,6 @@ protected int getGridSize() {
5353
return 1000;
5454
}
5555

56-
@Override
57-
protected void undo() {
58-
final SceneFileEditor fileEditor = getFileEditor();
59-
fileEditor.undo();
60-
}
61-
62-
@Override
63-
protected void redo() {
64-
final SceneFileEditor fileEditor = getFileEditor();
65-
fileEditor.redo();
66-
}
67-
6856
@Override
6957
protected void attachModel(@NotNull final SceneNode model, @NotNull final Node modelNode) {
7058
}

src/main/java/com/ss/editor/ui/component/editor/FileEditor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.ss.rlib.util.array.Array;
77
import com.ss.rlib.util.array.ArrayFactory;
88
import javafx.beans.property.BooleanProperty;
9+
import javafx.event.Event;
910
import javafx.scene.Parent;
1011
import javafx.scene.layout.BorderPane;
1112
import org.jetbrains.annotations.NotNull;
@@ -159,12 +160,13 @@ default void notifyHided() {
159160
/**
160161
* Check the coords that it's inside in the editing area of this editor.
161162
*
162-
* @param sceneX the scene x
163-
* @param sceneY the scene y
163+
* @param sceneX the scene x
164+
* @param sceneY the scene y
165+
* @param eventType the event type.
164166
* @return true if the point is inside in the editing area.
165167
*/
166168
@FXThread
167-
default boolean isInside(double sceneX, double sceneY) {
169+
default boolean isInside(double sceneX, double sceneY, @NotNull Class<? extends Event> eventType) {
168170
return false;
169171
}
170172
}

src/main/java/com/ss/editor/ui/component/editor/impl/material/MaterialFileEditor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import com.ss.editor.ui.util.UIUtils;
4343
import com.ss.editor.util.MaterialUtils;
4444
import com.ss.rlib.ui.util.FXUtils;
45-
import com.ss.rlib.util.FileUtils;
4645
import javafx.collections.ObservableList;
4746
import javafx.event.Event;
4847
import javafx.geometry.Point2D;
@@ -448,7 +447,7 @@ private void dragDropped(@NotNull final DragEvent dragEvent) {
448447
private void applyTexture(@NotNull final MaterialFileEditor editor, @NotNull final DragEvent dragEvent,
449448
@NotNull final Path path) {
450449

451-
final String textureName = FileUtils.getNameWithoutExtension(path);
450+
final String textureName = path.getFileName().toString();
452451
final int textureType = MaterialUtils.getPossibleTextureType(textureName);
453452

454453
if (textureType == 0) {
@@ -487,7 +486,7 @@ private Pane getEditorAreaPane() {
487486

488487
@Override
489488
@FXThread
490-
public boolean isInside(final double sceneX, final double sceneY) {
489+
public boolean isInside(final double sceneX, final double sceneY, @NotNull final Class<? extends Event> eventType) {
491490
final Pane editorAreaPane = getEditorAreaPane();
492491
final Point2D point2D = editorAreaPane.sceneToLocal(sceneX, sceneY);
493492
return editorAreaPane.contains(point2D);

src/main/java/com/ss/editor/ui/component/editor/impl/scene/AbstractSceneFileEditor.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
import javafx.scene.image.ImageView;
8888
import javafx.scene.input.DragEvent;
8989
import javafx.scene.input.KeyCode;
90+
import javafx.scene.input.KeyEvent;
91+
import javafx.scene.input.MouseEvent;
9092
import javafx.scene.layout.*;
9193
import org.jetbrains.annotations.NotNull;
9294
import org.jetbrains.annotations.Nullable;
@@ -920,13 +922,14 @@ public void selectNodeFromTree(@Nullable final Object object) {
920922
@FXThread
921923
private boolean isVisibleOnEditor(@NotNull final Spatial spatial) {
922924

923-
final Camera camera = EDITOR.getCamera();
925+
final MA editor3DState = getEditor3DState();
926+
final Camera camera = editor3DState.getCamera();
924927

925928
final Vector3f position = spatial.getWorldTranslation();
926929
final Vector3f coordinates = camera.getScreenCoordinates(position, new Vector3f());
927930

928931
boolean invisible = coordinates.getZ() < 0;
929-
invisible = invisible || !isInside(coordinates.getX(), camera.getHeight() - coordinates.getY());
932+
invisible = invisible || !isInside(coordinates.getX(), camera.getHeight() - coordinates.getY(), Event.class);
930933

931934
return !invisible;
932935
}
@@ -957,15 +960,20 @@ private Pane getEditorAreaPane() {
957960

958961
@Override
959962
@FXThread
960-
public boolean isInside(final double sceneX, final double sceneY) {
963+
public boolean isInside(final double sceneX, final double sceneY, @NotNull final Class<? extends Event> eventType) {
961964

962965
final Pane editorAreaPane = getEditorAreaPane();
963966
final Point2D point2D = editorAreaPane.sceneToLocal(sceneX, sceneY);
964967
final boolean result = editorAreaPane.contains(point2D);
965968

966-
if (Config.DEV_DEBUG_JFX_KEY_INPUT && LOGGER.isEnabledDebug()) {
967-
LOGGER.debug("Coords sceneX = " + sceneX + ", sceneY = " + sceneY + ", localX = " + point2D.getX() +
968-
", localY = " + point2D.getY() + " is inside " + result);
969+
if (LOGGER.isEnabledDebug()) {
970+
if (Config.DEV_DEBUG_JFX_KEY_INPUT && eventType.isAssignableFrom(KeyEvent.class)) {
971+
LOGGER.debug("Coords sceneX = " + sceneX + ", sceneY = " + sceneY + ", localX = " + point2D.getX() +
972+
", localY = " + point2D.getY() + " is inside " + result);
973+
} else if (Config.DEV_DEBUG_JFX_MOUSE_INPUT && eventType.isAssignableFrom(MouseEvent.class)) {
974+
LOGGER.debug("Coords sceneX = " + sceneX + ", sceneY = " + sceneY + ", localX = " + point2D.getX() +
975+
", localY = " + point2D.getY() + " is inside " + result);
976+
}
969977
}
970978

971979
return result;

src/main/java/com/ss/editor/ui/control/model/tree/dialog/GenerateTangentsDialog.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ protected void createContent(@NotNull final GridPane root) {
122122
super.createContent(root);
123123

124124
final Label algorithmTypeLabel = new Label(Messages.GENERATE_TANGENTS_DIALOG_ALGORITHM_LABEL + ":");
125-
algorithmTypeLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));
125+
algorithmTypeLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT3));
126126

127127
algorithmTypeComboBox = new ComboBox<>(GenerateTangentsDialog.ALGORITHM_TYPES);
128-
algorithmTypeComboBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));
128+
algorithmTypeComboBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT3));
129129

130130
final SingleSelectionModel<AlgorithmType> selectionModel = algorithmTypeComboBox.getSelectionModel();
131-
selectionModel.select(AlgorithmType.STANDARD);
131+
selectionModel.select(AlgorithmType.MIKKTSPACE);
132132

133133
final Label splitMirroredLabel = new Label(Messages.GENERATE_TANGENTS_DIALOG_SPLIT_MIRRORED + ":");
134-
splitMirroredLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT2));
134+
splitMirroredLabel.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_LABEL_W_PERCENT3));
135135

136136
splitMirroredCheckBox = new CheckBox();
137137
splitMirroredCheckBox.disableProperty().bind(selectionModel.selectedItemProperty().isNotEqualTo(AlgorithmType.STANDARD));
138-
splitMirroredCheckBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT2));
138+
splitMirroredCheckBox.prefWidthProperty().bind(root.widthProperty().multiply(DEFAULT_FIELD_W_PERCENT3));
139139

140140
root.add(algorithmTypeLabel, 0, 0);
141141
root.add(algorithmTypeComboBox, 1, 0);

src/main/java/com/ss/editor/ui/event/EventRedirector.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import javafx.event.EventTarget;
1010
import javafx.event.EventType;
1111
import javafx.scene.Node;
12-
import javafx.scene.control.Control;
12+
import javafx.scene.control.TextInputControl;
1313
import javafx.scene.input.*;
1414
import javafx.stage.Stage;
1515
import org.jetbrains.annotations.NotNull;
@@ -101,7 +101,7 @@ private void init() {
101101
if (target == destination) return;
102102

103103
final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();
104-
if (currentEditor == null || !currentEditor.isInside(event.getSceneX(), event.getSceneY())) {
104+
if (currentEditor == null || !currentEditor.isInside(event.getSceneX(), event.getSceneY(), event.getClass())) {
105105
return;
106106
}
107107

@@ -118,7 +118,7 @@ private void init() {
118118
updateCoords(event);
119119

120120
final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();
121-
if (currentEditor == null || !currentEditor.isInside(event.getSceneX(), event.getSceneY())) {
121+
if (currentEditor == null || !currentEditor.isInside(event.getSceneX(), event.getSceneY(), event.getClass())) {
122122
return;
123123
}
124124

@@ -127,6 +127,10 @@ private void init() {
127127

128128
stage.addEventFilter(MouseEvent.MOUSE_DRAGGED, event -> {
129129

130+
if (Config.DEV_DEBUG_JFX_MOUSE_INPUT) {
131+
LOGGER.debug("Mouse dragged " + event);
132+
}
133+
130134
final EventTarget target = event.getTarget();
131135
if (target == destination) return;
132136

@@ -135,7 +139,7 @@ private void init() {
135139
final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();
136140
if (currentEditor == null) return;
137141

138-
if (!isMousePressed(event.getButton()) && !currentEditor.isInside(event.getSceneX(), event.getSceneY())) {
142+
if (!isMousePressed(event.getButton()) && !currentEditor.isInside(event.getSceneX(), event.getSceneY(), event.getClass())) {
139143
return;
140144
}
141145

@@ -153,7 +157,7 @@ private void redirect(@NotNull final GestureEvent event) {
153157
if (target == destination) return;
154158

155159
final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();
156-
if (currentEditor == null || !currentEditor.isInside(event.getSceneX(), event.getSceneY())) {
160+
if (currentEditor == null || !currentEditor.isInside(event.getSceneX(), event.getSceneY(), event.getClass())) {
157161
return;
158162
}
159163

@@ -163,17 +167,24 @@ private void redirect(@NotNull final GestureEvent event) {
163167
private void redirect(@NotNull final InputEvent event) {
164168

165169
final EventTarget target = event.getTarget();
166-
if (target == destination || target instanceof Control) return;
170+
if (target == destination) {
171+
return;
172+
} else if (target instanceof TextInputControl) {
173+
if (Config.DEV_DEBUG_JFX_KEY_INPUT && LOGGER.isEnabledDebug()) {
174+
LOGGER.debug("Key event was skipped because it was from " + target);
175+
}
176+
return;
177+
}
167178

168179
final EventType<? extends InputEvent> eventType = event.getEventType();
169180
final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();
170181

171182
if (Config.DEV_DEBUG_JFX_KEY_INPUT && LOGGER.isEnabledDebug()) {
172183
LOGGER.debug("Key event " + event.getEventType() + " is inside " +
173-
currentEditor.isInside(getSceneX(), getSceneY()));
184+
currentEditor.isInside(getSceneX(), getSceneY(), event.getClass()));
174185
}
175186

176-
if (currentEditor == null || eventType != KeyEvent.KEY_RELEASED && !currentEditor.isInside(getSceneX(), getSceneY())) {
187+
if (currentEditor == null || eventType != KeyEvent.KEY_RELEASED && !currentEditor.isInside(getSceneX(), getSceneY(), event.getClass())) {
177188
return;
178189
}
179190

src/main/java/com/ss/editor/util/MaterialUtils.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,26 @@ public class MaterialUtils {
6868
*/
6969
public static int getPossibleTextureType(@NotNull final String textureName) {
7070

71-
if (textureName.contains("NORMAL") || textureName.contains("normal")) {
71+
if (textureName.contains("NORMAL") || textureName.contains("Normal") || textureName.contains("normal")) {
7272
return TEXTURE_NORMAL;
7373
} else if (textureName.contains("_NRM") || textureName.contains("_nrm")) {
7474
return TEXTURE_NORMAL;
75+
} else if (textureName.contains("_NM") || textureName.contains("_nm")) {
76+
return TEXTURE_NORMAL;
77+
} else if (textureName.contains("_N.") || textureName.contains("_n.")) {
78+
return TEXTURE_NORMAL;
7579
} else if (textureName.contains("ALBEDO") || textureName.contains("albedo")) {
7680
return TEXTURE_DIFFUSE;
7781
} else if (textureName.contains("_CLR") || textureName.contains("_clr")) {
7882
return TEXTURE_DIFFUSE;
7983
} else if (textureName.contains("DIFFUSE") || textureName.contains("diffuse")) {
8084
return TEXTURE_DIFFUSE;
85+
} else if (textureName.contains("_DIFF") || textureName.contains("_diff")) {
86+
return TEXTURE_DIFFUSE;
87+
} else if (textureName.contains("_D.") || textureName.contains("_d.")) {
88+
return TEXTURE_DIFFUSE;
89+
} else if (textureName.contains("_C.") || textureName.contains("_c.")) {
90+
return TEXTURE_DIFFUSE;
8191
} else if (textureName.contains("EMISSION") || textureName.contains("emission")) {
8292
return TEXTURE_EMISSIVE;
8393
} else if (textureName.contains("GLOW") || textureName.contains("glow")) {
@@ -88,6 +98,8 @@ public static int getPossibleTextureType(@NotNull final String textureName) {
8898
return TEXTURE_SPECULAR;
8999
} else if (textureName.contains("_SPC") || textureName.contains("_spc")) {
90100
return TEXTURE_SPECULAR;
101+
} else if (textureName.contains("_S.") || textureName.contains("_s.")) {
102+
return TEXTURE_SPECULAR;
91103
}
92104

93105
return 0;

0 commit comments

Comments
 (0)