Skip to content

Commit 8b07fc8

Browse files
authored
Merge pull request #546 from neph1/Issue#534-SceneComposer_panels_scrolls_with_mouse_movements
Issue#534 scene composer panels scrolls with mouse movements
2 parents 93440a2 + 846ced2 commit 8b07fc8

File tree

5 files changed

+262
-158
lines changed

5 files changed

+262
-158
lines changed

jme3-scenecomposer/src/com/jme3/gde/scenecomposer/Bundle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ SceneComposerTopComponent.jLabel7.text=Near Plane
6262
SceneComposerTopComponent.jLabel8.text=Far Plane
6363
SceneComposerTopComponent.jLabel9.text=Camera Position:
6464
SceneComposerTopComponent.jLabel10.text=Camera Look Direction:
65-
SceneComposerTopComponent.jLabel11.text=(NaN, NaN, NaN)
66-
SceneComposerTopComponent.jLabel12.text=(NaN, NaN, NaN)
65+
SceneComposerTopComponent.cameraPositionLabel.text=(NaN, NaN, NaN)
66+
SceneComposerTopComponent.cameraDirectionLabel.text=(NaN, NaN, NaN)
6767
SceneComposerTopComponent.cursorPositionLabel.text=(NaN, NaN, NaN)
6868
SceneComposerTopComponent.cursorPositionHeader.text=Cursor Position:
6969
SceneComposerTopComponent.cameraPanel.AccessibleContext.accessibleName=Camera

jme3-scenecomposer/src/com/jme3/gde/scenecomposer/CameraPositionTrackerAppState.java

+44-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
1+
/*
2+
* Copyright (c) 2009-2023 jMonkeyEngine
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are
7+
* met:
8+
*
9+
* * Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* * Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
*
16+
* * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17+
* may be used to endorse or promote products derived from this software
18+
* without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28+
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
132
package com.jme3.gde.scenecomposer;
233

334
import com.jme3.app.Application;
435
import com.jme3.app.state.BaseAppState;
36+
import com.jme3.math.Vector3f;
537
import com.jme3.renderer.Camera;
38+
import java.text.DecimalFormat;
639
import javax.swing.JLabel;
740
import javax.swing.SwingUtilities;
841

@@ -12,8 +45,11 @@
1245
* @author MeFisto94
1346
*/
1447
public class CameraPositionTrackerAppState extends BaseAppState {
15-
JLabel lblPos;
16-
JLabel lblLookAt;
48+
private final JLabel lblPos;
49+
private final JLabel lblLookAt;
50+
51+
private final Vector3f position = new Vector3f();
52+
private final Vector3f direction = new Vector3f();
1753

1854
public CameraPositionTrackerAppState(JLabel lblPos, JLabel lblLookAt) {
1955
this.lblPos = lblPos;
@@ -37,12 +73,12 @@ public void update(float tpf) {
3773
super.update(tpf);
3874

3975
final Camera cam = getApplication().getCamera();
40-
SwingUtilities.invokeLater(new Runnable() {
41-
@Override
42-
public void run() {
43-
lblPos.setText(cam.getLocation().toString());
44-
lblLookAt.setText(cam.getDirection().toString());
45-
}
76+
SwingUtilities.invokeLater(() -> {
77+
position.set(cam.getLocation());
78+
direction.set(cam.getDirection());
79+
lblPos.setText(SceneComposerUtil.trimDecimals(position));
80+
lblLookAt.setText(SceneComposerUtil.trimDecimals(direction));
4681
});
4782
}
83+
4884
}

jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneComposerTopComponent.form

+41-53
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
<DimensionLayout dim="0">
2525
<Group type="103" groupAlignment="0" attributes="0">
2626
<Group type="102" alignment="0" attributes="0">
27-
<Component id="jPanel4" max="32767" attributes="0"/>
27+
<Component id="jPanel4" min="-2" max="-2" attributes="0"/>
2828
<EmptySpace max="-2" attributes="0"/>
29-
<Component id="sceneInfoPanel" max="32767" attributes="0"/>
29+
<Component id="sceneInfoPanel" min="-2" max="-2" attributes="0"/>
3030
<EmptySpace max="-2" attributes="0"/>
3131
<Component id="cameraPanel" max="32767" attributes="0"/>
32-
<EmptySpace max="32767" attributes="0"/>
32+
<EmptySpace max="-2" attributes="0"/>
3333
</Group>
34-
<Component id="jToolBar1" alignment="0" max="32767" attributes="0"/>
34+
<Component id="jToolBar1" alignment="0" pref="1231" max="32767" attributes="0"/>
3535
</Group>
3636
</DimensionLayout>
3737
<DimensionLayout dim="1">
@@ -74,13 +74,13 @@
7474
<Component id="jLabel10" alignment="0" min="-2" max="-2" attributes="0"/>
7575
<Component id="cursorPositionHeader" alignment="0" min="-2" max="-2" attributes="0"/>
7676
</Group>
77-
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
77+
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
7878
<Group type="103" groupAlignment="0" attributes="0">
7979
<Component id="cursorPositionLabel" min="-2" max="-2" attributes="0"/>
80-
<Component id="jLabel12" alignment="0" min="-2" max="-2" attributes="0"/>
81-
<Component id="jLabel11" alignment="0" min="-2" max="-2" attributes="0"/>
80+
<Component id="cameraDirectionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
81+
<Component id="cameraPositionLabel" alignment="0" min="-2" max="-2" attributes="0"/>
8282
</Group>
83-
<EmptySpace pref="134" max="32767" attributes="0"/>
83+
<EmptySpace max="32767" attributes="0"/>
8484
</Group>
8585
<Group type="102" alignment="0" attributes="0">
8686
<Group type="103" groupAlignment="0" attributes="0">
@@ -139,12 +139,12 @@
139139
<EmptySpace max="-2" attributes="0"/>
140140
<Group type="103" groupAlignment="3" attributes="0">
141141
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
142-
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
142+
<Component id="cameraPositionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
143143
</Group>
144144
<EmptySpace max="32767" attributes="0"/>
145145
<Group type="103" groupAlignment="3" attributes="0">
146146
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
147-
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
147+
<Component id="cameraDirectionLabel" alignment="3" min="-2" max="-2" attributes="0"/>
148148
</Group>
149149
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
150150
<Group type="103" groupAlignment="3" attributes="0">
@@ -184,9 +184,6 @@
184184
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
185185
<SpinnerModel initial="0.1" numberType="java.lang.Float" stepSize="0.01" type="number"/>
186186
</Property>
187-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
188-
<Dimension value="[22, 23]"/>
189-
</Property>
190187
</Properties>
191188
<Events>
192189
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jSpinner1StateChanged"/>
@@ -197,9 +194,6 @@
197194
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
198195
<SpinnerModel initial="500.0" numberType="java.lang.Float" stepSize="1.0" type="number"/>
199196
</Property>
200-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
201-
<Dimension value="[22, 23]"/>
202-
</Property>
203197
</Properties>
204198
<Events>
205199
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jSpinner2StateChanged"/>
@@ -210,19 +204,13 @@
210204
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
211205
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel7.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
212206
</Property>
213-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
214-
<Dimension value="[34, 17]"/>
215-
</Property>
216207
</Properties>
217208
</Component>
218209
<Component class="javax.swing.JLabel" name="jLabel8">
219210
<Properties>
220211
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
221212
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel8.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
222213
</Property>
223-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
224-
<Dimension value="[36, 17]"/>
225-
</Property>
226214
</Properties>
227215
</Component>
228216
<Component class="javax.swing.JLabel" name="jLabel9">
@@ -239,17 +227,35 @@
239227
</Property>
240228
</Properties>
241229
</Component>
242-
<Component class="javax.swing.JLabel" name="jLabel11">
230+
<Component class="javax.swing.JLabel" name="cameraPositionLabel">
243231
<Properties>
244232
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
245-
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel11.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
233+
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.cameraPositionLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
234+
</Property>
235+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
236+
<Dimension value="[170, 17]"/>
237+
</Property>
238+
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
239+
<Dimension value="[170, 17]"/>
240+
</Property>
241+
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
242+
<Dimension value="[170, 17]"/>
246243
</Property>
247244
</Properties>
248245
</Component>
249-
<Component class="javax.swing.JLabel" name="jLabel12">
246+
<Component class="javax.swing.JLabel" name="cameraDirectionLabel">
250247
<Properties>
251248
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
252-
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel12.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
249+
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.cameraDirectionLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
250+
</Property>
251+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
252+
<Dimension value="[170, 17]"/>
253+
</Property>
254+
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
255+
<Dimension value="[170, 17]"/>
256+
</Property>
257+
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
258+
<Dimension value="[170, 17]"/>
253259
</Property>
254260
</Properties>
255261
</Component>
@@ -265,16 +271,22 @@
265271
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
266272
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.cursorPositionLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
267273
</Property>
274+
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
275+
<Dimension value="[170, 17]"/>
276+
</Property>
277+
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
278+
<Dimension value="[170, 17]"/>
279+
</Property>
280+
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
281+
<Dimension value="[170, 17]"/>
282+
</Property>
268283
</Properties>
269284
</Component>
270285
<Component class="javax.swing.JLabel" name="jLabel13">
271286
<Properties>
272287
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
273288
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel13.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
274289
</Property>
275-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
276-
<Dimension value="[34, 17]"/>
277-
</Property>
278290
</Properties>
279291
</Component>
280292
<Component class="javax.swing.JSlider" name="fovSlider">
@@ -292,9 +304,6 @@
292304
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
293305
<SpinnerModel initial="45" numberType="java.lang.Integer" stepSize="1" type="number"/>
294306
</Property>
295-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
296-
<Dimension value="[22, 23]"/>
297-
</Property>
298307
</Properties>
299308
<Events>
300309
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="fovSpinnerStateChanged"/>
@@ -928,19 +937,13 @@
928937
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
929938
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jCheckBox1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
930939
</Property>
931-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
932-
<Dimension value="[0, 21]"/>
933-
</Property>
934940
</Properties>
935941
</Component>
936942
<Component class="javax.swing.JTextField" name="jTextField1">
937943
<Properties>
938944
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
939945
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jTextField1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
940946
</Property>
941-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
942-
<Dimension value="[22, 23]"/>
943-
</Property>
944947
</Properties>
945948
</Component>
946949
<Component class="javax.swing.JLabel" name="jLabel4">
@@ -976,29 +979,20 @@
976979
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.fixedCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
977980
</Property>
978981
<Property name="enabled" type="boolean" value="false"/>
979-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
980-
<Dimension value="[0, 21]"/>
981-
</Property>
982982
</Properties>
983983
</Component>
984984
<Component class="javax.swing.JSpinner" name="radiusSpinner">
985985
<Properties>
986986
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
987987
<SpinnerModel initial="0.5" numberType="java.lang.Float" stepSize="0.1" type="number"/>
988988
</Property>
989-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
990-
<Dimension value="[22, 23]"/>
991-
</Property>
992989
</Properties>
993990
</Component>
994991
<Component class="javax.swing.JSpinner" name="heightSpinner">
995992
<Properties>
996993
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
997994
<SpinnerModel initial="1.8" numberType="java.lang.Float" stepSize="0.1" type="number"/>
998995
</Property>
999-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
1000-
<Dimension value="[22, 23]"/>
1001-
</Property>
1002996
</Properties>
1003997
</Component>
1004998
</SubComponents>
@@ -1010,9 +1004,6 @@
10101004
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
10111005
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel5.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
10121006
</Property>
1013-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
1014-
<Dimension value="[20, 17]"/>
1015-
</Property>
10161007
</Properties>
10171008
</Component>
10181009
<Component class="javax.swing.JButton" name="emitButton">
@@ -1033,9 +1024,6 @@
10331024
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
10341025
<ResourceString bundle="com/jme3/gde/scenecomposer/Bundle.properties" key="SceneComposerTopComponent.jLabel6.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
10351026
</Property>
1036-
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
1037-
<Dimension value="[20, 17]"/>
1038-
</Property>
10391027
</Properties>
10401028
</Component>
10411029
<Component class="javax.swing.JButton" name="jButton2">

0 commit comments

Comments
 (0)