Skip to content

Commit 72106a4

Browse files
Copilotneph1
andcommitted
Move animation toggle from MaterialPreviewWidget to MaterialEditorTopComponent
Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
1 parent eca1565 commit 72106a4

2 files changed

Lines changed: 20 additions & 29 deletions

File tree

jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private void initComponents() {
176176
jLabel3 = new javax.swing.JLabel();
177177
jTextField1 = new javax.swing.JTextField();
178178
jCheckBox1 = new javax.swing.JCheckBox();
179+
animationCheckBox = new javax.swing.JCheckBox();
179180
materialPreviewWidget1 = new com.jme3.gde.materials.multiview.widgets.MaterialPreviewWidget();
180181
additionalRenderStatePane = new javax.swing.JTabbedPane();
181182
jScrollPane10 = new javax.swing.JScrollPane();
@@ -294,6 +295,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
294295
}
295296
});
296297

298+
animationCheckBox.setSelected(false);
299+
org.openide.awt.Mnemonics.setLocalizedText(animationCheckBox, "Enable Animation");
300+
animationCheckBox.setToolTipText("Enable continuous rendering for animated materials");
301+
animationCheckBox.addActionListener(new java.awt.event.ActionListener() {
302+
public void actionPerformed(java.awt.event.ActionEvent evt) {
303+
animationCheckBoxActionPerformed(evt);
304+
}
305+
});
306+
297307
additionalRenderStatePane.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
298308
additionalRenderStatePane.setMinimumSize(new java.awt.Dimension(100, 100));
299309
additionalRenderStatePane.setPreferredSize(new java.awt.Dimension(380, 355));
@@ -326,6 +336,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
326336
.addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
327337
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
328338
.addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
339+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
340+
.addComponent(animationCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
329341
.addGap(39, 39, 39))))
330342
);
331343
editorPanelLayout.setVerticalGroup(
@@ -336,7 +348,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
336348
.addContainerGap()
337349
.addGroup(editorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
338350
.addComponent(jToolBar3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
339-
.addComponent(jCheckBox1))
351+
.addComponent(jCheckBox1)
352+
.addComponent(animationCheckBox))
340353
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
341354
.addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
342355
.addComponent(materialPreviewWidget1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -382,8 +395,14 @@ private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI
382395
}
383396
}//GEN-LAST:event_jComboBox1ActionPerformed
384397

398+
private void animationCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
399+
boolean enabled = animationCheckBox.isSelected();
400+
materialPreviewWidget1.setAnimationEnabled(enabled);
401+
}
402+
385403
// Variables declaration - do not modify//GEN-BEGIN:variables
386404
private javax.swing.JTabbedPane additionalRenderStatePane;
405+
private javax.swing.JCheckBox animationCheckBox;
387406
private javax.swing.JPanel editorPanel;
388407
private javax.swing.JCheckBox jCheckBox1;
389408
private javax.swing.JComboBox jComboBox1;

jme3-materialeditor/src/com/jme3/gde/materials/multiview/widgets/MaterialPreviewWidget.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ public void cleanUp(){
104104
*/
105105
public void setAnimationEnabled(boolean enabled) {
106106
this.animationEnabled = enabled;
107-
if (animationToggleButton != null) {
108-
animationToggleButton.setSelected(enabled);
109-
}
110107
if (enabled) {
111108
animationTimer.start();
112109
} else {
@@ -139,8 +136,6 @@ private void initComponents() {
139136
teapotButton = new javax.swing.JToggleButton();
140137
jSeparator1 = new javax.swing.JToolBar.Separator();
141138
togglePbrEnvButton = new javax.swing.JToggleButton();
142-
jSeparator2 = new javax.swing.JToolBar.Separator();
143-
animationToggleButton = new javax.swing.JToggleButton();
144139

145140
setMaximumSize(new java.awt.Dimension(244, 200));
146141
setMinimumSize(new java.awt.Dimension(244, 200));
@@ -252,23 +247,6 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
252247
}
253248
});
254249
jToolBar1.add(togglePbrEnvButton);
255-
jToolBar1.add(jSeparator2);
256-
257-
animationToggleButton.setIcon(Icons.animationOff);
258-
animationToggleButton.setToolTipText("Enable animation rendering");
259-
animationToggleButton.setFocusable(false);
260-
animationToggleButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
261-
animationToggleButton.setMaximumSize(new java.awt.Dimension(40, 40));
262-
animationToggleButton.setMinimumSize(new java.awt.Dimension(40, 40));
263-
animationToggleButton.setPreferredSize(new java.awt.Dimension(40, 40));
264-
animationToggleButton.setSelectedIcon(Icons.animationOn);
265-
animationToggleButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
266-
animationToggleButton.addActionListener(new java.awt.event.ActionListener() {
267-
public void actionPerformed(java.awt.event.ActionEvent evt) {
268-
animationToggleButtonActionPerformed(evt);
269-
}
270-
});
271-
jToolBar1.add(animationToggleButton);
272250

273251
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
274252
this.setLayout(layout);
@@ -313,15 +291,9 @@ private void teapotButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-
313291
matRenderer.switchDisplay(MaterialPreviewRenderer.DisplayType.Teapot);
314292
}//GEN-LAST:event_teapotButtonActionPerformed
315293

316-
private void animationToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {
317-
setAnimationEnabled(animationToggleButton.isSelected());
318-
}
319-
320294
// Variables declaration - do not modify//GEN-BEGIN:variables
321-
private javax.swing.JToggleButton animationToggleButton;
322295
private javax.swing.JToggleButton cubeButton;
323296
private javax.swing.JToolBar.Separator jSeparator1;
324-
private javax.swing.JToolBar.Separator jSeparator2;
325297
private javax.swing.JToolBar jToolBar1;
326298
private javax.swing.JToggleButton planeButton;
327299
private javax.swing.JLabel previewLabel;

0 commit comments

Comments
 (0)