Normand Briere
2019-06-30 cfd7a643cb5a445016ddb15595158ecc59b184fd
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -207,7 +210,7 @@
207210
208211 objEditor.ctrlPanel.remove(namePanel);
209212
210
- if (!GroupEditor.allparams)
213
+ if (!allparams)
211214 return;
212215
213216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -306,7 +309,7 @@
306309 //localCopy.parent = null;
307310
308311 frame = new JFrame();
309
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
310313 objEditor = this;
311314 this.callee = callee;
312315
....@@ -336,6 +339,11 @@
336339 {
337340 return frame.action(event, obj);
338341 }
342
+
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
339347
340348 void SetupMenu()
341349 {
....@@ -398,6 +406,11 @@
398406 //
399407 // materialFlushed = true;
400408 // }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
401414
402415 refreshContents(false); // To refresh Info tab
403416 }
....@@ -436,7 +449,7 @@
436449 // TEXTAREA infoarea.setLineWrap(true);
437450 // TEXTAREA infoarea.setWrapStyleWord(true);
438451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
439
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
440453 infoPanel.setName("Info");
441454 //infoPanel.setLayout(new BorderLayout());
442455 //infoPanel.add(createTextPane());
....@@ -448,7 +461,14 @@
448461 mainPanel.setDividerSize(9);
449462 mainPanel.setDividerLocation(0.5); //1.0);
450463 mainPanel.setResizeWeight(0.5);
451
-
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
452472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
453473 //mainPanel.setLayout(new GridBagLayout());
454474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -679,8 +699,8 @@
679699 }
680700 }
681701
682
-static GraphicsDevice device = GraphicsEnvironment
683
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
684704
685705 Rectangle keeprect;
686706 cRadio radio;
....@@ -701,10 +721,19 @@
701721 void Minimize()
702722 {
703723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
704725 }
705726
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
706730 void Maximize()
707731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
708737 if (maximized)
709738 {
710739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -712,20 +741,36 @@
712741 else
713742 {
714743 keeprect = frame.getBounds();
715
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
- Dimension rect2 = frame.getToolkit().getScreenSize();
717
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
718747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
719749 }
720750
721751 maximized ^= true;
752
+
753
+ frame.validate();
722754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
723759
724760 void ToggleFullScreen()
725761 {
726
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
727767 {
728768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
729774 //frame.setVisible(false);
730775 // frame.removeNotify();
731776 // frame.setUndecorated(false);
....@@ -750,7 +795,12 @@
750795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
751796 // frame.getToolkit().getScreenSize().height);
752797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
753801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
754804 // frame.removeNotify();
755805 // frame.setUndecorated(true);
756806 // frame.addNotify();
....@@ -763,8 +813,7 @@
763813 radio.layout.doClick();
764814 //frame.setVisible(true);
765815 }
766
-
767
- cameraView.ToggleFullScreen();
816
+ frame.validate();
768817 }
769818
770819 private JTextPane createTextPane()
....@@ -1097,12 +1146,12 @@
10971146 namePanel = new cGridBag();
10981147
10991148 nameField = AddText(namePanel, copy.GetName());
1100
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11011150 oe.ctrlPanel.add(namePanel);
11021151
11031152 oe.ctrlPanel.Return();
11041153
1105
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
11061155 return;
11071156
11081157 setupPanel = new cGridBag().setVertical(false);
....@@ -1115,15 +1164,15 @@
11151164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11161165 hideCB.setToolTipText("Hide object");
11171166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
11191168
11201169 setupPanel2 = new cGridBag().setVertical(false);
11211170
11221171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11231172 rewindCB.setToolTipText("Rewind animation");
11241173
1125
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11271176
11281177 if (Globals.ADVANCED)
11291178 {
....@@ -1439,13 +1488,13 @@
14391488 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14401489 //tmp.setName("Edit");
14411490 objectPanel.add(materialPanel);
1442
- objectPanel.add(toolboxPanel);
14431491 // JPanel north = new JPanel(new BorderLayout());
14441492 // north.setName("Edit");
14451493 // north.add(ctrlPanel, BorderLayout.NORTH);
14461494 // objectPanel.add(north);
14471495 objectPanel.add(editPanel);
14481496 objectPanel.add(infoPanel);
1497
+ objectPanel.add(toolboxPanel);
14491498
14501499 /*
14511500 aConstraints.gridx = 0;
....@@ -1454,7 +1503,7 @@
14541503 aConstraints.gridy += 1;
14551504 aConstraints.gridwidth = 1;
14561505 mainPanel.add(objectPanel, aConstraints);
1457
- */
1506
+ */
14581507
14591508 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14601509 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1574,12 +1623,13 @@
15741623
15751624 frame.setSize(1280, 860);
15761625
1577
- frame.validate();
1578
- frame.setVisible(true);
1579
-
15801626 cameraView.requestFocusInWindow();
15811627
15821628 gridPanel.setDividerLocation(1.0);
1629
+
1630
+ frame.validate();
1631
+
1632
+ frame.setVisible(true);
15831633
15841634 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15851635 frame.addWindowListener(new WindowAdapter()
....@@ -1666,24 +1716,6 @@
16661716 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16671717 colorSection.add(texture);
16681718
1669
- cGridBag anisoU = new cGridBag();
1670
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1671
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1673
- colorSection.add(anisoU);
1674
-
1675
- cGridBag anisoV = new cGridBag();
1676
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1677
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1678
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1679
- colorSection.add(anisoV);
1680
-
1681
- cGridBag shadowbias = new cGridBag();
1682
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1683
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1684
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1685
- colorSection.add(shadowbias);
1686
-
16871719 panel.add(new JSeparator());
16881720
16891721 panel.add(colorSection);
....@@ -1733,6 +1765,12 @@
17331765 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17341766 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17351767 diffuseSection.add(fakedepth);
1768
+
1769
+ cGridBag shadowbias = new cGridBag();
1770
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1771
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1772
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1773
+ diffuseSection.add(shadowbias);
17361774
17371775 panel.add(new JSeparator());
17381776
....@@ -1784,6 +1822,18 @@
17841822 // aConstraints.gridy += 1;
17851823 // aConstraints.gridwidth = 1;
17861824
1825
+ cGridBag anisoU = new cGridBag();
1826
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1827
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1828
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1829
+ specularSection.add(anisoU);
1830
+
1831
+ cGridBag anisoV = new cGridBag();
1832
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1833
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1834
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1835
+ specularSection.add(anisoV);
1836
+
17871837
17881838 panel.add(new JSeparator());
17891839
....@@ -1791,35 +1841,35 @@
17911841
17921842 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17931843
1794
- cGridBag globalSection = new cGridBag().setVertical(true);
1844
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17951845
17961846 cGridBag camera = new cGridBag();
17971847 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17981848 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17991849 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1800
- globalSection.add(camera);
1850
+ colorSection.add(camera);
18011851
18021852 cGridBag ambient = new cGridBag();
18031853 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18041854 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18051855 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1806
- globalSection.add(ambient);
1856
+ colorSection.add(ambient);
18071857
18081858 cGridBag backlit = new cGridBag();
18091859 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18101860 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18111861 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1812
- globalSection.add(backlit);
1862
+ colorSection.add(backlit);
18131863
18141864 cGridBag opacity = new cGridBag();
18151865 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18161866 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18171867 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
- globalSection.add(opacity);
1868
+ colorSection.add(opacity);
18191869
1820
- panel.add(new JSeparator());
1870
+ //panel.add(new JSeparator());
18211871
1822
- panel.add(globalSection);
1872
+ //panel.add(globalSection);
18231873
18241874 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18251875
....@@ -3007,12 +3057,17 @@
30073057 // }
30083058
30093059 /**/
3010
- if (deselect)
3060
+ if (deselect || child == null)
30113061 {
30123062 //group.deselectAll();
30133063 //freeze = true;
30143064 GetTree().clearSelection();
30153065 //freeze = false;
3066
+
3067
+ if (child == null)
3068
+ {
3069
+ return;
3070
+ }
30163071 }
30173072
30183073 //group.addSelectee(child);
....@@ -3513,8 +3568,10 @@
35133568
35143569 copy.ExtractBigData(hashtable);
35153570
3571
+ byte[] compress = Compress(copy);
3572
+
35163573 //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
- tab.graphs[tab.undoindex++] = Compress(copy);
3574
+ tab.graphs[tab.undoindex++] = compress;
35183575
35193576 copy.RestoreBigData(hashtable);
35203577
....@@ -3527,6 +3584,8 @@
35273584 tab.graphs[i] = null;
35283585 }
35293586
3587
+ SetUndoStates();
3588
+
35303589 // test save
35313590 if (false)
35323591 {
....@@ -3549,6 +3608,8 @@
35493608
35503609 void CopyChanged(Object3D obj)
35513610 {
3611
+ SetUndoStates();
3612
+
35523613 boolean temp = CameraPane.SWITCH;
35533614 CameraPane.SWITCH = false;
35543615
....@@ -3586,6 +3647,17 @@
35863647 }
35873648
35883649 refreshContents();
3650
+ }
3651
+
3652
+ cButton undoButton;
3653
+ cButton redoButton;
3654
+
3655
+ void SetUndoStates()
3656
+ {
3657
+ cRadio tab = GetCurrentTab();
3658
+
3659
+ undoButton.setEnabled(tab.undoindex > 0);
3660
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
35893661 }
35903662
35913663 public void Undo()
....@@ -4765,6 +4837,8 @@
47654837 String filename = browser.getFile();
47664838 if (filename != null && filename.length() > 0)
47674839 {
4840
+ if (!filename.endsWith(".gfd"))
4841
+ filename += ".gfd";
47684842 lastname = browser.getDirectory() + filename;
47694843 save();
47704844 }