diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties index f2fb15a9f..c3c41f44a 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties @@ -9,3 +9,6 @@ BackdropPanel.quadButton.toolTipText=Quad BackdropPanel.reloadButton.toolTipText=Refresh BackdropPanel.boxButton.toolTipText=Cube BackdropPanel.bringToFrontButton.toolTipText=Toggle back/front +NodeToolBar.codeButton.toolTipText=Display code +NodeToolBar.deleteButton.toolTipText=Delete node +NodeToolBar.deleteButton.text= diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java index e1ca87657..a6ff5a6d7 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java @@ -294,6 +294,7 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene } } + selectedNode.cleanup(); remove(selectedNode); selectedItem = null; repaint(); @@ -418,6 +419,8 @@ public class Diagram extends JPanel implements MouseListener, MouseMotionListene return doSelect(outBusPanel); } } + + return doSelect(null); } diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java index 62b54428b..1ee7ffced 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java @@ -52,6 +52,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha private Color color; private String name; private String techName; + private NodeToolBar toolBar; protected List filePaths = new ArrayList(); // private List listeners = Collections.synchronizedList(new LinkedList()); @@ -112,6 +113,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha this.filePaths.addAll(def.getShadersPath()); String defPath = ((DefinitionBlock) node.getContents().get(0)).getPath(); this.filePaths.add(defPath); + toolBar = new NodeToolBar(this); } /** @@ -125,6 +127,7 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha this.type = type; init(new ArrayList(), outputs); addKeyListener(this); + toolBar = new NodeToolBar(this); } public final void refresh(ShaderNodeBlock node) { @@ -201,14 +204,18 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha } g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias! RenderingHints.VALUE_ANTIALIAS_ON); - // Color[] colors = {new Color(0, 0, 0, 0.7f), new Color(0, 0, 0, 0.15f)}; + // Color[] colors = {new Color(0, 0, 0, 0.7f), new Color(0, 0, 0, 0.15f)}; if (diagram.selectedItem == this) { Color[] colors = new Color[]{new Color(0.6f, 0.6f, 1.0f, 0.8f), new Color(0.6f, 0.6f, 1.0f, 0.5f)}; float[] factors = {0f, 1f}; g.setPaint(new RadialGradientPaint(getWidth() / 2, getHeight() / 2, getWidth() / 2, factors, colors)); g.fillRoundRect(8, 3, getWidth() - 10, getHeight() - 6, 15, 15); - } - + }else{ + if(toolBar.isVisible()){ + toolBar.setVisible(false); + } + } + g.setColor(new Color(170, 170, 170, 120)); g.fillRoundRect(5, 1, getWidth() - 9, getHeight() - 6, 15, 15); g.setColor(boderColor); @@ -253,6 +260,11 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha public void mousePressed(MouseEvent e) { super.mousePressed(e); diagram.select(this); + showToolBar(); + } + + private void showToolBar(){ + toolBar.display(); } public NodeType getType() { @@ -299,6 +311,16 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha color = type.getColor(); } + public void edit() { + if (type == NodeType.Fragment || type == NodeType.Vertex) { + diagram.showEdit(NodePanel.this); + } + } + + public void cleanup(){ + toolBar.getParent().remove(toolBar); + } + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -318,18 +340,6 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha header.addMouseMotionListener(labelMouseMotionListener); header.setHorizontalAlignment(SwingConstants.LEFT); header.setFont(new Font("Tahoma", Font.BOLD, 11)); - header.addMouseListener(new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - //if(e.getClickCount()==2){ - if (type == NodeType.Fragment || type == NodeType.Vertex) { - diagram.showEdit(NodePanel.this); - } - //} - } - - }); content = new JPanel(); content.setOpaque(false); @@ -423,10 +433,14 @@ public class NodePanel extends DraggablePanel implements Selectable, PropertyCha public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { - Diagram diag = getDiagram(); - if (diag.selectedItem == this) { - diag.removeSelectedNode(); - } + delete(); + } + } + + public void delete() { + Diagram diag = getDiagram(); + if (diag.selectedItem == this) { + diag.removeSelectedNode(); } } diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.form b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.form new file mode 100644 index 000000000..593a23893 --- /dev/null +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.form @@ -0,0 +1,201 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.java new file mode 100644 index 000000000..4ed8228b9 --- /dev/null +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.java @@ -0,0 +1,147 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.materialdefinition.editor; + +import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +/** + * + * @author Nehon + */ +public class NodeToolBar extends javax.swing.JPanel implements ComponentListener, MouseListener { + + private final NodePanel node; + + /** + * Creates new form NodeToolBar + */ + @SuppressWarnings("LeakingThisInConstructor") + public NodeToolBar(NodePanel node) { + initComponents(); + this.node = node; + node.addComponentListener(this); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + codeButton = new javax.swing.JButton(); + deleteButton = new javax.swing.JButton(); + + setOpaque(false); + java.awt.GridBagLayout layout = new java.awt.GridBagLayout(); + layout.rowHeights = new int[] {16}; + setLayout(layout); + + codeButton.setBackground(new java.awt.Color(255, 255, 255)); + codeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/code.png"))); // NOI18N + codeButton.setToolTipText(org.openide.util.NbBundle.getMessage(NodeToolBar.class, "NodeToolBar.codeButton.toolTipText")); // NOI18N + codeButton.setBorder(null); + codeButton.setBorderPainted(false); + codeButton.setContentAreaFilled(false); + codeButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + codeButton.setFocusable(false); + codeButton.setIconTextGap(0); + codeButton.setMaximumSize(new java.awt.Dimension(24, 24)); + codeButton.setMinimumSize(new java.awt.Dimension(24, 24)); + codeButton.setPreferredSize(new java.awt.Dimension(16, 16)); + codeButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/codeHover.png"))); // NOI18N + codeButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + codeButtonActionPerformed(evt); + } + }); + add(codeButton, new java.awt.GridBagConstraints()); + + deleteButton.setBackground(new java.awt.Color(255, 255, 255)); + deleteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/deleteNode.png"))); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(deleteButton, org.openide.util.NbBundle.getMessage(NodeToolBar.class, "NodeToolBar.deleteButton.text")); // NOI18N + deleteButton.setToolTipText(org.openide.util.NbBundle.getMessage(NodeToolBar.class, "NodeToolBar.deleteButton.toolTipText")); // NOI18N + deleteButton.setBorder(null); + deleteButton.setBorderPainted(false); + deleteButton.setContentAreaFilled(false); + deleteButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + deleteButton.setFocusable(false); + deleteButton.setIconTextGap(0); + deleteButton.setMaximumSize(new java.awt.Dimension(24, 24)); + deleteButton.setMinimumSize(new java.awt.Dimension(24, 24)); + deleteButton.setPreferredSize(new java.awt.Dimension(16, 16)); + deleteButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png"))); // NOI18N + deleteButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + deleteButtonActionPerformed(evt); + } + }); + add(deleteButton, new java.awt.GridBagConstraints()); + }// //GEN-END:initComponents + + private void codeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codeButtonActionPerformed + node.edit(); + }//GEN-LAST:event_codeButtonActionPerformed + + private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed + node.delete(); + }//GEN-LAST:event_deleteButtonActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton codeButton; + private javax.swing.JButton deleteButton; + // End of variables declaration//GEN-END:variables + + public void display() { + if (getParent() == null) { + node.getParent().add(this); + } + setBounds(node.getLocation().x + 5, node.getLocation().y - 18, node.getWidth() - 10, 16); + node.getParent().setComponentZOrder(this, 0); + setVisible(true); + + } + + public void componentResized(ComponentEvent e) { + } + + public void componentMoved(ComponentEvent e) { + setLocation(node.getLocation().x + 5, node.getLocation().y - 18); + } + + public void componentShown(ComponentEvent e) { + } + + public void componentHidden(ComponentEvent e) { + } + + public void mouseClicked(MouseEvent e) { + e.consume(); + } + + public void mousePressed(MouseEvent e) { + e.consume(); + } + + public void mouseReleased(MouseEvent e) { + e.consume(); + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + +} diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/code.png b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/code.png new file mode 100644 index 000000000..fe0e9cc18 Binary files /dev/null and b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/code.png differ diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/codeHover.png b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/codeHover.png new file mode 100644 index 000000000..7ea559039 Binary files /dev/null and b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/codeHover.png differ diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNode.png b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNode.png new file mode 100644 index 000000000..e413274c1 Binary files /dev/null and b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNode.png differ diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png new file mode 100644 index 000000000..778b12422 Binary files /dev/null and b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png differ diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/previewIcons.psd b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/previewIcons.psd index 4c64777c0..a65243271 100644 Binary files a/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/previewIcons.psd and b/sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/previewIcons.psd differ