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 {
....@@ -383,6 +391,32 @@
383391 closeItem.addActionListener(this);
384392
385393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
386420 toolbarPanel = new JPanel();
387421 toolbarPanel.setName("Toolbar");
388422 treePanel = new cGridBag();
....@@ -415,7 +449,7 @@
415449 // TEXTAREA infoarea.setLineWrap(true);
416450 // TEXTAREA infoarea.setWrapStyleWord(true);
417451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
418
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
419453 infoPanel.setName("Info");
420454 //infoPanel.setLayout(new BorderLayout());
421455 //infoPanel.add(createTextPane());
....@@ -427,7 +461,14 @@
427461 mainPanel.setDividerSize(9);
428462 mainPanel.setDividerLocation(0.5); //1.0);
429463 mainPanel.setResizeWeight(0.5);
430
-
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
+
431472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
432473 //mainPanel.setLayout(new GridBagLayout());
433474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -658,8 +699,8 @@
658699 }
659700 }
660701
661
-static GraphicsDevice device = GraphicsEnvironment
662
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
663704
664705 Rectangle keeprect;
665706 cRadio radio;
....@@ -680,10 +721,19 @@
680721 void Minimize()
681722 {
682723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
683725 }
684726
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={}
685730 void Maximize()
686731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
687737 if (maximized)
688738 {
689739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -691,20 +741,36 @@
691741 else
692742 {
693743 keeprect = frame.getBounds();
694
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
695
- Dimension rect2 = frame.getToolkit().getScreenSize();
696
- 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);
697747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
698749 }
699750
700751 maximized ^= true;
752
+
753
+ frame.validate();
701754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
702759
703760 void ToggleFullScreen()
704761 {
705
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
706767 {
707768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
708774 //frame.setVisible(false);
709775 // frame.removeNotify();
710776 // frame.setUndecorated(false);
....@@ -729,7 +795,12 @@
729795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
730796 // frame.getToolkit().getScreenSize().height);
731797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
732801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
733804 // frame.removeNotify();
734805 // frame.setUndecorated(true);
735806 // frame.addNotify();
....@@ -742,8 +813,7 @@
742813 radio.layout.doClick();
743814 //frame.setVisible(true);
744815 }
745
-
746
- cameraView.ToggleFullScreen();
816
+ frame.validate();
747817 }
748818
749819 private JTextPane createTextPane()
....@@ -884,7 +954,12 @@
884954 JCheckBox speedupCB;
885955 JCheckBox rewindCB;
886956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
887961 JComboBox texresMenu;
962
+
888963 JButton resetButton;
889964 JButton stepButton;
890965 JButton stepAllButton;
....@@ -1071,12 +1146,12 @@
10711146 namePanel = new cGridBag();
10721147
10731148 nameField = AddText(namePanel, copy.GetName());
1074
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10751150 oe.ctrlPanel.add(namePanel);
10761151
10771152 oe.ctrlPanel.Return();
10781153
1079
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
10801155 return;
10811156
10821157 setupPanel = new cGridBag().setVertical(false);
....@@ -1089,15 +1164,15 @@
10891164 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10901165 hideCB.setToolTipText("Hide object");
10911166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1092
- markCB.setToolTipText("Set the animation target transform");
1167
+ markCB.setToolTipText("As animation target transform");
10931168
10941169 setupPanel2 = new cGridBag().setVertical(false);
10951170
10961171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10971172 rewindCB.setToolTipText("Rewind animation");
10981173
1099
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1100
- 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)");
11011176
11021177 if (Globals.ADVANCED)
11031178 {
....@@ -1412,7 +1487,6 @@
14121487
14131488 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14141489 //tmp.setName("Edit");
1415
- objectPanel.add(toolboxPanel);
14161490 objectPanel.add(materialPanel);
14171491 // JPanel north = new JPanel(new BorderLayout());
14181492 // north.setName("Edit");
....@@ -1420,6 +1494,7 @@
14201494 // objectPanel.add(north);
14211495 objectPanel.add(editPanel);
14221496 objectPanel.add(infoPanel);
1497
+ objectPanel.add(toolboxPanel);
14231498
14241499 /*
14251500 aConstraints.gridx = 0;
....@@ -1428,7 +1503,7 @@
14281503 aConstraints.gridy += 1;
14291504 aConstraints.gridwidth = 1;
14301505 mainPanel.add(objectPanel, aConstraints);
1431
- */
1506
+ */
14321507
14331508 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14341509 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1445,9 +1520,7 @@
14451520 JTabbedPane tabbedPane = new JTabbedPane();
14461521 tabbedPane.add(scrollpane);
14471522
1448
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1449
-
1450
- optionsPanel = new cGridBag().setVertical(true);
1523
+ optionsPanel = new cGridBag().setVertical(false);
14511524
14521525 optionsPanel.setName("Options");
14531526
....@@ -1455,6 +1528,8 @@
14551528
14561529 tabbedPane.add(optionsPanel);
14571530
1531
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1532
+
14581533 scenePanel.add(tabbedPane);
14591534
14601535 /*
....@@ -1547,11 +1622,14 @@
15471622 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15481623
15491624 frame.setSize(1280, 860);
1550
- frame.setVisible(true);
1551
-
1625
+
15521626 cameraView.requestFocusInWindow();
15531627
15541628 gridPanel.setDividerLocation(1.0);
1629
+
1630
+ frame.validate();
1631
+
1632
+ frame.setVisible(true);
15551633
15561634 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15571635 frame.addWindowListener(new WindowAdapter()
....@@ -1638,24 +1716,6 @@
16381716 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16391717 colorSection.add(texture);
16401718
1641
- cGridBag anisoU = new cGridBag();
1642
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1643
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1644
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1645
- colorSection.add(anisoU);
1646
-
1647
- cGridBag anisoV = new cGridBag();
1648
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1649
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1650
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1651
- colorSection.add(anisoV);
1652
-
1653
- cGridBag shadowbias = new cGridBag();
1654
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1655
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1656
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1657
- colorSection.add(shadowbias);
1658
-
16591719 panel.add(new JSeparator());
16601720
16611721 panel.add(colorSection);
....@@ -1705,6 +1765,12 @@
17051765 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17061766 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17071767 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);
17081774
17091775 panel.add(new JSeparator());
17101776
....@@ -1756,6 +1822,18 @@
17561822 // aConstraints.gridy += 1;
17571823 // aConstraints.gridwidth = 1;
17581824
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
+
17591837
17601838 panel.add(new JSeparator());
17611839
....@@ -1763,35 +1841,35 @@
17631841
17641842 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17651843
1766
- cGridBag globalSection = new cGridBag().setVertical(true);
1844
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17671845
17681846 cGridBag camera = new cGridBag();
17691847 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17701848 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17711849 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1772
- globalSection.add(camera);
1850
+ colorSection.add(camera);
17731851
17741852 cGridBag ambient = new cGridBag();
17751853 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17761854 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17771855 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1778
- globalSection.add(ambient);
1856
+ colorSection.add(ambient);
17791857
17801858 cGridBag backlit = new cGridBag();
17811859 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17821860 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17831861 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1784
- globalSection.add(backlit);
1862
+ colorSection.add(backlit);
17851863
17861864 cGridBag opacity = new cGridBag();
17871865 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17881866 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17891867 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1790
- globalSection.add(opacity);
1868
+ colorSection.add(opacity);
17911869
1792
- panel.add(new JSeparator());
1870
+ //panel.add(new JSeparator());
17931871
1794
- panel.add(globalSection);
1872
+ //panel.add(globalSection);
17951873
17961874 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17971875
....@@ -2866,6 +2944,8 @@
28662944
28672945 void SetMaterial(Object3D object)
28682946 {
2947
+ latestObject = object;
2948
+
28692949 cMaterial mat = object.material;
28702950
28712951 if (mat == null)
....@@ -2977,12 +3057,17 @@
29773057 // }
29783058
29793059 /**/
2980
- if (deselect)
3060
+ if (deselect || child == null)
29813061 {
29823062 //group.deselectAll();
29833063 //freeze = true;
29843064 GetTree().clearSelection();
29853065 //freeze = false;
3066
+
3067
+ if (child == null)
3068
+ {
3069
+ return;
3070
+ }
29863071 }
29873072
29883073 //group.addSelectee(child);
....@@ -3051,7 +3136,7 @@
30513136 cameraView.ToggleDL();
30523137 cameraView.repaint();
30533138 return;
3054
- } else if (event.getSource() == toggleTextureItem)
3139
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30553140 {
30563141 cameraView.ToggleTexture();
30573142 // june 2013 copy.HardTouch();
....@@ -3090,7 +3175,7 @@
30903175 frame.validate();
30913176
30923177 return;
3093
- } else if (event.getSource() == toggleSwitchItem)
3178
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30943179 {
30953180 cameraView.ToggleSwitch();
30963181 cameraView.repaint();
....@@ -3483,8 +3568,10 @@
34833568
34843569 copy.ExtractBigData(hashtable);
34853570
3571
+ byte[] compress = Compress(copy);
3572
+
34863573 //EditorFrame.m_MainFrame.requestFocusInWindow();
3487
- tab.graphs[tab.undoindex++] = Compress(copy);
3574
+ tab.graphs[tab.undoindex++] = compress;
34883575
34893576 copy.RestoreBigData(hashtable);
34903577
....@@ -3497,6 +3584,8 @@
34973584 tab.graphs[i] = null;
34983585 }
34993586
3587
+ SetUndoStates();
3588
+
35003589 // test save
35013590 if (false)
35023591 {
....@@ -3519,6 +3608,8 @@
35193608
35203609 void CopyChanged(Object3D obj)
35213610 {
3611
+ SetUndoStates();
3612
+
35223613 boolean temp = CameraPane.SWITCH;
35233614 CameraPane.SWITCH = false;
35243615
....@@ -3556,6 +3647,17 @@
35563647 }
35573648
35583649 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);
35593661 }
35603662
35613663 public void Undo()
....@@ -4735,6 +4837,8 @@
47354837 String filename = browser.getFile();
47364838 if (filename != null && filename.length() > 0)
47374839 {
4840
+ if (!filename.endsWith(".gfd"))
4841
+ filename += ".gfd";
47384842 lastname = browser.getDirectory() + filename;
47394843 save();
47404844 }
....@@ -4945,6 +5049,8 @@
49455049 cGridBag optionsPanel;
49465050
49475051 JTabbedPane objectPanel;
5052
+ boolean materialFlushed;
5053
+ Object3D latestObject;
49485054
49495055 cGridBag XYZPanel;
49505056