Added some icons to edit and delete a node in the shader node editor

experimental
Nehon 10 years ago
parent 629c007cd4
commit ae8474cb57
  1. 3
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Bundle.properties
  2. 3
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/Diagram.java
  3. 52
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodePanel.java
  4. 201
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.form
  5. 147
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/editor/NodeToolBar.java
  6. BIN
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/code.png
  7. BIN
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/codeHover.png
  8. BIN
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNode.png
  9. BIN
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png
  10. BIN
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/icons/previewIcons.psd

@ -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=

@ -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);
}

@ -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<String> filePaths = new ArrayList<String>();
// 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<ShaderNodeVariable>(), 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();
}
}

@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,24,0,0,1,-128"/>
</AuxValues>
<SubComponents>
<Component class="javax.swing.JButton" name="codeButton">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/jme3/gde/materialdefinition/icons/code.png"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/materialdefinition/editor/Bundle.properties" key="NodeToolBar.codeButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="borderPainted" type="boolean" value="false"/>
<Property name="contentAreaFilled" type="boolean" value="false"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Curseur par d&#xe9;faut"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="iconTextGap" type="int" value="0"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[24, 24]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[24, 24]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[16, 16]"/>
</Property>
<Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/jme3/gde/materialdefinition/icons/codeHover.png"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="codeButtonActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="deleteButton">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/jme3/gde/materialdefinition/icons/deleteNode.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/materialdefinition/editor/Bundle.properties" key="NodeToolBar.deleteButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/materialdefinition/editor/Bundle.properties" key="NodeToolBar.deleteButton.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="borderPainted" type="boolean" value="false"/>
<Property name="contentAreaFilled" type="boolean" value="false"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Curseur par d&#xe9;faut"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="iconTextGap" type="int" value="0"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[24, 24]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[24, 24]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[16, 16]"/>
</Property>
<Property name="rolloverIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/jme3/gde/materialdefinition/icons/deleteNodeHover.png"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="deleteButtonActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
</SubComponents>
<LayoutCode>
<CodeStatement>
<CodeExpression id="1_layout">
<CodeVariable name="layout" type="4096" declaredType="java.awt.GridBagLayout"/>
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagLayout" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeExpression">
<CodeExpression id="1_layout"/>
</StatementProvider>
</CodeStatement>
<CodeStatement>
<CodeExpression id="1_layout"/>
<StatementProvider type="CodeField">
<CodeField name="rowHeights" class="java.awt.GridBagLayout"/>
</StatementProvider>
<Parameters>
<CodeExpression id="2">
<ExpressionOrigin>
<Value type="[I" editor="org.netbeans.modules.form.layoutsupport.delegates.GridBagLayoutSupport$IntArrayPropertyEditor">
<PropertyValue value="[16]"/>
</Value>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="3">
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="."/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<StatementProvider type="CodeMethod">
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
</StatementProvider>
<Parameters>
<CodeExpression id="1_layout"/>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="3"/>
<StatementProvider type="CodeMethod">
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
</StatementProvider>
<Parameters>
<CodeExpression id="4_codeButton">
<CodeVariable name="codeButton" type="8194" declaredType="javax.swing.JButton"/>
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="codeButton"/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<CodeExpression id="5">
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
<CodeStatement>
<CodeExpression id="3"/>
<StatementProvider type="CodeMethod">
<CodeMethod name="add" class="java.awt.Container" parameterTypes="java.awt.Component, java.lang.Object"/>
</StatementProvider>
<Parameters>
<CodeExpression id="6_deleteButton">
<CodeVariable name="deleteButton" type="8194" declaredType="javax.swing.JButton"/>
<ExpressionOrigin>
<ExpressionProvider type="ComponentRef">
<ComponentRef name="deleteButton"/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
<CodeExpression id="7">
<ExpressionOrigin>
<ExpressionProvider type="CodeConstructor">
<CodeConstructor class="java.awt.GridBagConstraints" parameterTypes=""/>
</ExpressionProvider>
</ExpressionOrigin>
</CodeExpression>
</Parameters>
</CodeStatement>
</LayoutCode>
</Form>

@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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());
}// </editor-fold>//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) {
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Loading…
Cancel
Save