File tree Expand file tree Collapse file tree
src/main/java/com/ss/editor
asset/tree/context/menu/action Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1785,6 +1785,20 @@ public void moveCameraTo(@NotNull final Vector3f location) {
17851785 EXECUTOR_MANAGER .addJMETask (() -> getNodeForCamera ().setLocalTranslation (location ));
17861786 }
17871787
1788+ /**
1789+ * Look at the position from the camera.
1790+ *
1791+ * @param location the location.
1792+ */
1793+ @ FromAnyThread
1794+ public void cameraLookAt (@ NotNull final Vector3f location ) {
1795+ EXECUTOR_MANAGER .addJMETask (() -> {
1796+ final EditorCamera editorCamera = notNull (getEditorCamera ());
1797+ editorCamera .setTargetDistance (location .distance (getCamera ().getLocation ()));
1798+ getNodeForCamera ().setLocalTranslation (location );
1799+ });
1800+ }
1801+
17881802 /**
17891803 * Remove a light.
17901804 *
Original file line number Diff line number Diff line change 88import com .ss .editor .ui .Icons ;
99import com .ss .editor .ui .component .asset .tree .resource .ResourceElement ;
1010import com .ss .editor .ui .dialog .ConfirmDialog ;
11- import com .ss .editor .ui .scene .EditorFXScene ;
11+ import com .ss .rlib .util .FileUtils ;
12+ import com .ss .rlib .util .array .Array ;
1213import javafx .scene .control .MenuItem ;
1314import javafx .scene .image .ImageView ;
1415import org .jetbrains .annotations .NotNull ;
15- import com .ss .rlib .util .FileUtils ;
16- import com .ss .rlib .util .array .Array ;
1716
1817import java .nio .file .Path ;
1918
@@ -64,9 +63,8 @@ private void processDelete() {
6463 String question = Messages .ASSET_COMPONENT_RESOURCE_TREE_CONTEXT_MENU_DELETE_FILE_QUESTION ;
6564 question = question .replace ("%file_name%" , file .getFileName ().toString ());
6665
67- final EditorFXScene scene = JFX_APPLICATION .getScene ();
6866 final ConfirmDialog confirmDialog = new ConfirmDialog (result -> handle (file , result ), question );
69- confirmDialog .show (scene . getWindow ());
67+ confirmDialog .show (JFX_APPLICATION . getLastWindow ());
7068 }
7169
7270 /**
Original file line number Diff line number Diff line change @@ -202,10 +202,13 @@ protected void createContent() {
202202 }
203203
204204 root = createRoot ();
205- root .setOnKeyPressed (this ::processKeyPressed );
206- root .setOnKeyReleased (this ::processKeyReleased );
207- root .setOnMouseReleased (this ::processMouseReleased );
208- root .setOnMousePressed (this ::processMousePressed );
205+
206+ if (needListenEventsFromPage ()) {
207+ root .setOnKeyPressed (this ::processKeyPressed );
208+ root .setOnKeyReleased (this ::processKeyReleased );
209+ root .setOnMouseReleased (this ::processMouseReleased );
210+ root .setOnMousePressed (this ::processMousePressed );
211+ }
209212
210213 createContent (root );
211214
@@ -220,6 +223,13 @@ protected void createContent() {
220223 root .prefWidthProperty ().bind (container .widthProperty ());
221224 }
222225
226+ /**
227+ * @return true if need to listen to events from root page of this editor.
228+ */
229+ protected boolean needListenEventsFromPage () {
230+ return true ;
231+ }
232+
223233 /**
224234 * Handle the mouse released event.
225235 */
Original file line number Diff line number Diff line change @@ -663,6 +663,11 @@ protected boolean needToolbar() {
663663 return true ;
664664 }
665665
666+ @ Override
667+ protected boolean needListenEventsFromPage () {
668+ return false ;
669+ }
670+
666671 @ Override
667672 @ FXThread
668673 protected void createToolbar (@ NotNull final HBox container ) {
Original file line number Diff line number Diff line change @@ -319,6 +319,11 @@ protected StackPane createRoot() {
319319 return new StackPane ();
320320 }
321321
322+ @ Override
323+ protected boolean needListenEventsFromPage () {
324+ return false ;
325+ }
326+
322327 /**
323328 * Gets editor app state.
324329 *
@@ -906,7 +911,7 @@ public void selectNodeFromTree(@Nullable final Object object) {
906911 updateSelection (spatial );
907912
908913 if (spatial != null && !isIgnoreCameraMove () && !isVisibleOnEditor (spatial )) {
909- editor3DState .moveCameraTo (spatial .getWorldTranslation ());
914+ editor3DState .cameraLookAt (spatial .getWorldTranslation ());
910915 }
911916
912917 final ModelPropertyEditor modelPropertyEditor = getModelPropertyEditor ();
@@ -925,7 +930,7 @@ private boolean isVisibleOnEditor(@NotNull final Spatial spatial) {
925930 final Vector3f position = spatial .getWorldTranslation ();
926931 final Vector3f coordinates = camera .getScreenCoordinates (position , new Vector3f ());
927932
928- boolean invisible = coordinates .getZ () < 0 ;
933+ boolean invisible = coordinates .getZ () < 0F || coordinates . getZ () > 1F ;
929934 invisible = invisible || !isInside (coordinates .getX (), camera .getHeight () - coordinates .getY (), Event .class );
930935
931936 return !invisible ;
Original file line number Diff line number Diff line change 33import com .ss .editor .config .Config ;
44import com .ss .editor .ui .component .editor .FileEditor ;
55import com .ss .editor .ui .component .editor .area .EditorAreaComponent ;
6+ import com .ss .editor .ui .util .UIUtils ;
67import com .ss .rlib .logging .Logger ;
78import com .ss .rlib .logging .LoggerManager ;
89import javafx .event .Event ;
@@ -170,10 +171,12 @@ private void redirect(@NotNull final InputEvent event) {
170171 if (target == destination ) {
171172 return ;
172173 } 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 );
174+ if (event instanceof KeyEvent && UIUtils .isNotHotKey ((KeyEvent ) event )) {
175+ if (Config .DEV_DEBUG_JFX_KEY_INPUT && LOGGER .isEnabledDebug ()) {
176+ LOGGER .debug ("Key event was skipped because it was from " + target );
177+ }
178+ return ;
175179 }
176- return ;
177180 }
178181
179182 final EventType <? extends InputEvent > eventType = event .getEventType ();
Original file line number Diff line number Diff line change @@ -481,31 +481,42 @@ public static Color from(@Nullable final ColorRGBA color) {
481481 }
482482
483483 /**
484- * Consume an event if the event is not hotkey.
485- *
486484 * @param event the event.
485+ * @return true if the event is not hotkey.
487486 */
488487 @ FXThread
489- public static void consumeIfIsNotHotKey (@ Nullable final KeyEvent event ) {
490- if (event == null ) return ;
488+ public static boolean isNotHotKey (@ Nullable final KeyEvent event ) {
489+ if (event == null ) return false ;
491490
492491 final String text = event .getText ();
493- if (text .isEmpty ()) return ;
492+ if (text .isEmpty ()) return false ;
494493
495494 final KeyCode code = event .getCode ();
496495 final EventTarget target = event .getTarget ();
497496
498497 if (code == KeyCode .TAB && !(target instanceof TextInputControl )) {
499- return ;
498+ return false ;
500499 }
501500
502501 if (event .isControlDown ()) {
503- return ;
502+ return false ;
504503 } else if (event .isShiftDown ()) {
505- return ;
504+ return false ;
506505 }
507506
508- event .consume ();
507+ return true ;
508+ }
509+
510+ /**
511+ * Consume an event if the event is not hotkey.
512+ *
513+ * @param event the event.
514+ */
515+ @ FXThread
516+ public static void consumeIfIsNotHotKey (@ Nullable final KeyEvent event ) {
517+ if (isNotHotKey (event )) {
518+ event .consume ();
519+ }
509520 }
510521
511522 /**
You can’t perform that action at this time.
0 commit comments