From c99d954f5e2bffa601c599142371cfeb45630f40 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Thu, 01 Aug 2019 00:11:39 -0400
Subject: [PATCH] Hue UI.

---
 ObjEditor.java |   85 ++++++++++++++++++++++-----
 cLabel.java    |   67 ++++++++++++++++++++++
 cMaterial.java |    3 
 icons/hue.png  |    0 
 4 files changed, 137 insertions(+), 18 deletions(-)

diff --git a/ObjEditor.java b/ObjEditor.java
index be8dca3..3b8dd95 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -41,11 +41,25 @@
     JFrame frame;
     
     static ObjEditor theFrame;
+
+    public cGridBag GetSeparator()
+    {
+        cGridBag separator = new cGridBag();
+        separator.add(new JSeparator());
+        separator.preferredHeight = 5;
+        return separator;
+    }
     
     cButton GetButton(String name, boolean border)
     {
         ImageIcon icon = GetIcon(name);
         return new cButton(icon, border);
+    }
+
+    cLabel GetLabel(String name, boolean border)
+    {
+        //ImageIcon icon = GetIcon(name);
+        return new cLabel(GetImage(name), border);
     }
 
     cToggleButton GetToggleButton(String name, boolean border)
@@ -80,6 +94,20 @@
 
             javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
             return icon;
+        }
+        catch (Exception e)
+        {
+            return null;
+        }
+    }
+    
+    BufferedImage GetImage(String name)
+    {
+        try
+        {
+            BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
+
+            return image;
         }
         catch (Exception e)
         {
@@ -1522,22 +1550,28 @@
         //tmp.setName("Edit");
         objectPanel.add(materialPanel);
         objectPanel.setIconAt(0, GetIcon("icons/material.png"));
+        objectPanel.setToolTipTextAt(0, "Material panel");
+    
 //        JPanel north = new JPanel(new BorderLayout());
 //        north.setName("Edit");
 //        north.add(ctrlPanel, BorderLayout.NORTH);
 //        objectPanel.add(north);
         objectPanel.add(editPanel);
         objectPanel.setIconAt(1, GetIcon("icons/write.png"));
+        objectPanel.setToolTipTextAt(1, "Edit panel");
         
         //if (Globals.ADVANCED)
             objectPanel.add(infoPanel);
         objectPanel.setIconAt(2, GetIcon("icons/info.png"));
+        objectPanel.setToolTipTextAt(2, "Info panel");
         
         objectPanel.add(XYZPanel);
         objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
+        objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
         
         objectPanel.add(toolboxPanel);
         objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
+        objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
 
         /*
         aConstraints.gridx = 0;
@@ -1634,8 +1668,8 @@
         /**/
 
         bigThree = new cGridBag();
-        bigThree.addComponent(centralPanel);
         bigThree.addComponent(scenePanel);
+        bigThree.addComponent(centralPanel);
         //bigThree.addComponent(XYZPanel);
         
 //                // SIDE EFFECT!!!
@@ -1677,7 +1711,6 @@
         frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
         frame.addWindowListener(new WindowAdapter()
         {
-
             public void windowClosing(WindowEvent e)
             {
                 Close();
@@ -1739,27 +1772,48 @@
         //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
 
         cGridBag colorSection = new cGridBag().setVertical(true);
+
+        cGridBag huepanel = new cGridBag();
+            cGridBag huelabel = new cGridBag();
+            huelabel.add(GetLabel("icons/hue.png", false));
+            huelabel.preferredWidth = 20;
+            huepanel.add(new cGridBag()); // Label
+            huepanel.add(huelabel); // Field/slider
+            
+        huepanel.preferredHeight = 7;
+
+        colorSection.add(huepanel);
         
         cGridBag color = new cGridBag();
-                color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
-                colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
-                color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
+        
+            color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
+            colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
+            color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
+
         //colorField.preferredWidth = 200;
         colorSection.add(color);
 
         cGridBag modulation = new cGridBag();
                 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
                 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
-                modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
+                modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
         colorSection.add(modulation);
 
+        cGridBag opacity = new cGridBag();
+                opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
+                opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
+                opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
+        colorSection.add(opacity);
+
+        colorSection.add(GetSeparator());
+        
         cGridBag texture = new cGridBag();
                 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
                 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
                 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
         colorSection.add(texture);
 
-        panel.add(new JSeparator());
+        panel.add(GetSeparator());
         
         panel.add(colorSection);
         
@@ -1815,7 +1869,7 @@
                 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
         diffuseSection.add(shadowbias);
 
-        panel.add(new JSeparator());
+        panel.add(GetSeparator());
         
         panel.add(diffuseSection);
         
@@ -1878,7 +1932,7 @@
         specularSection.add(anisoV);
 
 
-        panel.add(new JSeparator());
+        panel.add(GetSeparator());
         
         panel.add(specularSection);
         
@@ -1903,12 +1957,6 @@
                 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
                 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
         colorSection.add(backlit);
-
-        cGridBag opacity = new cGridBag();
-                opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
-                opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
-                opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
-        colorSection.add(opacity);
 
         //panel.add(new JSeparator());
         
@@ -1954,7 +2002,7 @@
                 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
         textureSection.add(opacityPower);
 
-        panel.add(new JSeparator());
+        panel.add(GetSeparator());
         
         panel.add(textureSection);
         
@@ -3644,7 +3692,7 @@
         
         cRadio tab = GetCurrentTab();
         
-        byte[] compress = CompressCopy();
+        byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
         
         boolean thesame = false;
         
@@ -3711,6 +3759,9 @@
         
         copy.clear();
         
+        copy.skyboxname = obj.skyboxname;
+        copy.skyboxext = obj.skyboxext;
+                
         for (int i=0; i<obj.Size(); i++)
         {
             copy.add(obj.get(i));
diff --git a/cLabel.java b/cLabel.java
new file mode 100644
index 0000000..522e537
--- /dev/null
+++ b/cLabel.java
@@ -0,0 +1,67 @@
+import java.awt.image.BufferedImage;
+
+public class cLabel extends javax.swing.JLabel
+{
+    BufferedImage image;
+        
+    cLabel(String name)
+    {
+        super(name);
+        
+        setBorder(new javax.swing.border.EtchedBorder());
+    }
+    
+    cLabel(String name, boolean border)
+    {
+        super(name);
+        
+        if (border)
+                setBorder(new javax.swing.border.EtchedBorder());
+        else
+        {
+                //setBorder(null); //new javax.swing.border.EmptyBorder(0,0,0,0));
+        }
+    }
+    
+    cLabel(javax.swing.ImageIcon icon, boolean border)
+    {
+        super(icon);
+        
+        if (border)
+                setBorder(new javax.swing.border.EtchedBorder());
+        else
+        {
+                //setBorder(null); //new javax.swing.border.EmptyBorder(0,0,0,0));
+        }
+    }
+    
+    cLabel(BufferedImage image, boolean border)
+    {
+        this.image = image;
+        
+        if (border)
+                setBorder(new javax.swing.border.EtchedBorder());
+        else
+        {
+                //setBorder(null); //new javax.swing.border.EmptyBorder(0,0,0,0));
+        }
+    }
+    
+    public void paint(java.awt.Graphics g)
+    {
+        if (image == null)
+        {
+            super.paint(g);
+        }
+        else
+        {
+            BufferedImage resizedimage = new BufferedImage(getWidth(),getHeight(),java.awt.image.BufferedImage.TYPE_INT_RGB);
+            java.awt.Graphics2D g2 = resizedimage.createGraphics();
+            g2.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION, java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
+            g2.drawImage(image, 0, 0,getWidth(),getHeight(), null);
+            g2.dispose();
+            
+            g.drawImage(resizedimage, 0, 0,getWidth(),getHeight(), null);
+        }
+    }
+}
diff --git a/cMaterial.java b/cMaterial.java
index 14519fe..98e4639 100644
--- a/cMaterial.java
+++ b/cMaterial.java
@@ -79,7 +79,8 @@
 
     void UpdateMaterial(cMaterial anchor, cMaterial current)
     {
-        color *= Factor(anchor.color, current.color);
+        //color *= Factor(anchor.color, current.color);
+        color = current.color;
         //if (anchor.saturation == 0)
         //    anchor.saturation = 0.001f;
         if (anchor.modulation == 0)
diff --git a/icons/hue.png b/icons/hue.png
new file mode 100644
index 0000000..1e334cd
--- /dev/null
+++ b/icons/hue.png
Binary files differ

--
Gitblit v1.6.2