Sfoglia il codice sorgente

Move animation toggle from MaterialPreviewWidget to MaterialEditorTopComponent

Co-authored-by: neph1 <[email protected]>
copilot-swe-agent[bot] 4 giorni fa
parent
commit
72106a4668

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

@@ -176,6 +176,7 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
         jLabel3 = new javax.swing.JLabel();
         jTextField1 = new javax.swing.JTextField();
         jCheckBox1 = new javax.swing.JCheckBox();
+        animationCheckBox = new javax.swing.JCheckBox();
         materialPreviewWidget1 = new com.jme3.gde.materials.multiview.widgets.MaterialPreviewWidget();
         additionalRenderStatePane = new javax.swing.JTabbedPane();
         jScrollPane10 = new javax.swing.JScrollPane();
@@ -294,6 +295,15 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
             }
         });
 
+        animationCheckBox.setSelected(false);
+        org.openide.awt.Mnemonics.setLocalizedText(animationCheckBox, "Enable Animation");
+        animationCheckBox.setToolTipText("Enable continuous rendering for animated materials");
+        animationCheckBox.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                animationCheckBoxActionPerformed(evt);
+            }
+        });
+
         additionalRenderStatePane.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
         additionalRenderStatePane.setMinimumSize(new java.awt.Dimension(100, 100));
         additionalRenderStatePane.setPreferredSize(new java.awt.Dimension(380, 355));
@@ -326,6 +336,8 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
                             .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                         .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(animationCheckBox, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                         .addGap(39, 39, 39))))
         );
         editorPanelLayout.setVerticalGroup(
@@ -336,7 +348,8 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
                         .addContainerGap()
                         .addGroup(editorPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                             .addComponent(jToolBar3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
-                            .addComponent(jCheckBox1))
+                            .addComponent(jCheckBox1)
+                            .addComponent(animationCheckBox))
                         .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                         .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                     .addComponent(materialPreviewWidget1, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -382,8 +395,14 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl
         }
     }//GEN-LAST:event_jComboBox1ActionPerformed
 
+    private void animationCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {
+        boolean enabled = animationCheckBox.isSelected();
+        materialPreviewWidget1.setAnimationEnabled(enabled);
+    }
+
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JTabbedPane additionalRenderStatePane;
+    private javax.swing.JCheckBox animationCheckBox;
     private javax.swing.JPanel editorPanel;
     private javax.swing.JCheckBox jCheckBox1;
     private javax.swing.JComboBox jComboBox1;

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

@@ -104,9 +104,6 @@ public class MaterialPreviewWidget extends javax.swing.JPanel {
      */
     public void setAnimationEnabled(boolean enabled) {
         this.animationEnabled = enabled;
-        if (animationToggleButton != null) {
-            animationToggleButton.setSelected(enabled);
-        }
         if (enabled) {
             animationTimer.start();
         } else {
@@ -139,8 +136,6 @@ public class MaterialPreviewWidget extends javax.swing.JPanel {
         teapotButton = new javax.swing.JToggleButton();
         jSeparator1 = new javax.swing.JToolBar.Separator();
         togglePbrEnvButton = new javax.swing.JToggleButton();
-        jSeparator2 = new javax.swing.JToolBar.Separator();
-        animationToggleButton = new javax.swing.JToggleButton();
 
         setMaximumSize(new java.awt.Dimension(244, 200));
         setMinimumSize(new java.awt.Dimension(244, 200));
@@ -252,23 +247,6 @@ public class MaterialPreviewWidget extends javax.swing.JPanel {
             }
         });
         jToolBar1.add(togglePbrEnvButton);
-        jToolBar1.add(jSeparator2);
-
-        animationToggleButton.setIcon(Icons.animationOff);
-        animationToggleButton.setToolTipText("Enable animation rendering");
-        animationToggleButton.setFocusable(false);
-        animationToggleButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
-        animationToggleButton.setMaximumSize(new java.awt.Dimension(40, 40));
-        animationToggleButton.setMinimumSize(new java.awt.Dimension(40, 40));
-        animationToggleButton.setPreferredSize(new java.awt.Dimension(40, 40));
-        animationToggleButton.setSelectedIcon(Icons.animationOn);
-        animationToggleButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
-        animationToggleButton.addActionListener(new java.awt.event.ActionListener() {
-            public void actionPerformed(java.awt.event.ActionEvent evt) {
-                animationToggleButtonActionPerformed(evt);
-            }
-        });
-        jToolBar1.add(animationToggleButton);
 
         javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
         this.setLayout(layout);
@@ -313,15 +291,9 @@ private void planeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F
         matRenderer.switchDisplay(MaterialPreviewRenderer.DisplayType.Teapot);
     }//GEN-LAST:event_teapotButtonActionPerformed
 
-    private void animationToggleButtonActionPerformed(java.awt.event.ActionEvent evt) {
-        setAnimationEnabled(animationToggleButton.isSelected());
-    }
-
     // Variables declaration - do not modify//GEN-BEGIN:variables
-    private javax.swing.JToggleButton animationToggleButton;
     private javax.swing.JToggleButton cubeButton;
     private javax.swing.JToolBar.Separator jSeparator1;
-    private javax.swing.JToolBar.Separator jSeparator2;
     private javax.swing.JToolBar jToolBar1;
     private javax.swing.JToggleButton planeButton;
     private javax.swing.JLabel previewLabel;