Normand Briere
2019-06-29 a69bb4474a3264a9a7a7f8b8d8154ea771f167c8
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.
....@@ -49,6 +52,19 @@
4952 catch (Exception e)
5053 {
5154 return new cButton(name, border);
55
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
60
+ try
61
+ {
62
+ ImageIcon icon = GetIcon(name);
63
+ return new cToggleButton(icon, border);
64
+ }
65
+ catch (Exception e)
66
+ {
67
+ return new cToggleButton(name, border);
5268 }
5369 }
5470
....@@ -194,7 +210,7 @@
194210
195211 objEditor.ctrlPanel.remove(namePanel);
196212
197
- if (!GroupEditor.allparams)
213
+ if (!allparams)
198214 return;
199215
200216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -324,6 +340,11 @@
324340 return frame.action(event, obj);
325341 }
326342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
327348 void SetupMenu()
328349 {
329350 frame.setMenuBar(menuBar = new MenuBar());
....@@ -370,6 +391,32 @@
370391 closeItem.addActionListener(this);
371392
372393 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
+
373420 toolbarPanel = new JPanel();
374421 toolbarPanel.setName("Toolbar");
375422 treePanel = new cGridBag();
....@@ -384,9 +431,12 @@
384431 editPanel.add(editCommandsPanel);
385432 editPanel.add(ctrlPanel);
386433
387
- materialPanel = new cGridBag().setVertical(true);
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
388436
437
+ materialPanel = new cGridBag().setVertical(true);
389438 materialPanel.setName("Material");
439
+
390440 /*JTextPane*/
391441 infoarea = createTextPane();
392442 doc = infoarea.getStyledDocument();
....@@ -399,7 +449,7 @@
399449 // TEXTAREA infoarea.setLineWrap(true);
400450 // TEXTAREA infoarea.setWrapStyleWord(true);
401451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
402
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
403453 infoPanel.setName("Info");
404454 //infoPanel.setLayout(new BorderLayout());
405455 //infoPanel.add(createTextPane());
....@@ -411,7 +461,14 @@
411461 mainPanel.setDividerSize(9);
412462 mainPanel.setDividerLocation(0.5); //1.0);
413463 mainPanel.setResizeWeight(0.5);
414
-
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
+
415472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
416473 //mainPanel.setLayout(new GridBagLayout());
417474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -659,13 +716,24 @@
659716
660717 boolean maximized;
661718
719
+ cButton fullscreenLayout;
720
+
662721 void Minimize()
663722 {
664723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
665725 }
666726
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={}
667730 void Maximize()
668731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
669737 if (maximized)
670738 {
671739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -680,13 +748,23 @@
680748 }
681749
682750 maximized ^= true;
751
+
752
+ frame.validate();
683753 }
754
+
755
+ cButton minButton;
756
+ cButton maxButton;
757
+ cButton fullButton;
684758
685759 void ToggleFullScreen()
686760 {
687
- if (CameraPane.FULLSCREEN)
761
+ cameraView.ToggleFullScreen();
762
+
763
+ if (!CameraPane.FULLSCREEN)
688764 {
689765 device.setFullScreenWindow(null);
766
+ frame.validate();
767
+
690768 //frame.setVisible(false);
691769 // frame.removeNotify();
692770 // frame.setUndecorated(false);
....@@ -712,6 +790,7 @@
712790 // frame.getToolkit().getScreenSize().height);
713791 //frame.setVisible(false);
714792 device.setFullScreenWindow(frame);
793
+ frame.validate();
715794 // frame.removeNotify();
716795 // frame.setUndecorated(true);
717796 // frame.addNotify();
....@@ -720,12 +799,11 @@
720799 // X frame.getContentPane().add(/*"Center",*/bigThree);
721800 framePanel.setDividerLocation(0);
722801
723
- radio.layout = twoButton;
802
+ radio.layout = fullscreenLayout;
724803 radio.layout.doClick();
725804 //frame.setVisible(true);
726805 }
727
-
728
- cameraView.ToggleFullScreen();
806
+ frame.validate();
729807 }
730808
731809 private JTextPane createTextPane()
....@@ -866,7 +944,12 @@
866944 JCheckBox speedupCB;
867945 JCheckBox rewindCB;
868946 JCheckBox flipVCB;
947
+
948
+ cCheckBox toggleTextureCB;
949
+ cCheckBox toggleSwitchCB;
950
+
869951 JComboBox texresMenu;
952
+
870953 JButton resetButton;
871954 JButton stepButton;
872955 JButton stepAllButton;
....@@ -1053,12 +1136,12 @@
10531136 namePanel = new cGridBag();
10541137
10551138 nameField = AddText(namePanel, copy.GetName());
1056
- namePanel.add(nameField);
1139
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10571140 oe.ctrlPanel.add(namePanel);
10581141
10591142 oe.ctrlPanel.Return();
10601143
1061
- if (!GroupEditor.allparams)
1144
+ if (!allparams)
10621145 return;
10631146
10641147 setupPanel = new cGridBag().setVertical(false);
....@@ -1071,15 +1154,15 @@
10711154 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10721155 hideCB.setToolTipText("Hide object");
10731156 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
- markCB.setToolTipText("Set the animation target transform");
1157
+ markCB.setToolTipText("As animation target transform");
10751158
10761159 setupPanel2 = new cGridBag().setVertical(false);
10771160
10781161 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10791162 rewindCB.setToolTipText("Rewind animation");
10801163
1081
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1164
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1165
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10831166
10841167 if (Globals.ADVANCED)
10851168 {
....@@ -1401,6 +1484,7 @@
14011484 // objectPanel.add(north);
14021485 objectPanel.add(editPanel);
14031486 objectPanel.add(infoPanel);
1487
+ objectPanel.add(toolboxPanel);
14041488
14051489 /*
14061490 aConstraints.gridx = 0;
....@@ -1409,7 +1493,7 @@
14091493 aConstraints.gridy += 1;
14101494 aConstraints.gridwidth = 1;
14111495 mainPanel.add(objectPanel, aConstraints);
1412
- */
1496
+ */
14131497
14141498 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14151499 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1426,9 +1510,7 @@
14261510 JTabbedPane tabbedPane = new JTabbedPane();
14271511 tabbedPane.add(scrollpane);
14281512
1429
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1430
-
1431
- optionsPanel = new cGridBag().setVertical(true);
1513
+ optionsPanel = new cGridBag().setVertical(false);
14321514
14331515 optionsPanel.setName("Options");
14341516
....@@ -1436,6 +1518,8 @@
14361518
14371519 tabbedPane.add(optionsPanel);
14381520
1521
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1522
+
14391523 scenePanel.add(tabbedPane);
14401524
14411525 /*
....@@ -1528,6 +1612,8 @@
15281612 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15291613
15301614 frame.setSize(1280, 860);
1615
+
1616
+ frame.validate();
15311617 frame.setVisible(true);
15321618
15331619 cameraView.requestFocusInWindow();
....@@ -1619,24 +1705,6 @@
16191705 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16201706 colorSection.add(texture);
16211707
1622
- cGridBag anisoU = new cGridBag();
1623
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1624
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1626
- colorSection.add(anisoU);
1627
-
1628
- cGridBag anisoV = new cGridBag();
1629
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1630
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1631
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1632
- colorSection.add(anisoV);
1633
-
1634
- cGridBag shadowbias = new cGridBag();
1635
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1636
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1637
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1638
- colorSection.add(shadowbias);
1639
-
16401708 panel.add(new JSeparator());
16411709
16421710 panel.add(colorSection);
....@@ -1686,6 +1754,12 @@
16861754 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16871755 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16881756 diffuseSection.add(fakedepth);
1757
+
1758
+ cGridBag shadowbias = new cGridBag();
1759
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1760
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1761
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1762
+ diffuseSection.add(shadowbias);
16891763
16901764 panel.add(new JSeparator());
16911765
....@@ -1737,6 +1811,18 @@
17371811 // aConstraints.gridy += 1;
17381812 // aConstraints.gridwidth = 1;
17391813
1814
+ cGridBag anisoU = new cGridBag();
1815
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1816
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1817
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
+ specularSection.add(anisoU);
1819
+
1820
+ cGridBag anisoV = new cGridBag();
1821
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1822
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1823
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1824
+ specularSection.add(anisoV);
1825
+
17401826
17411827 panel.add(new JSeparator());
17421828
....@@ -1744,35 +1830,35 @@
17441830
17451831 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17461832
1747
- cGridBag globalSection = new cGridBag().setVertical(true);
1833
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17481834
17491835 cGridBag camera = new cGridBag();
17501836 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17511837 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17521838 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1753
- globalSection.add(camera);
1839
+ colorSection.add(camera);
17541840
17551841 cGridBag ambient = new cGridBag();
17561842 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17571843 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17581844 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
- globalSection.add(ambient);
1845
+ colorSection.add(ambient);
17601846
17611847 cGridBag backlit = new cGridBag();
17621848 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17631849 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17641850 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
- globalSection.add(backlit);
1851
+ colorSection.add(backlit);
17661852
17671853 cGridBag opacity = new cGridBag();
17681854 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17691855 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17701856 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1771
- globalSection.add(opacity);
1857
+ colorSection.add(opacity);
17721858
1773
- panel.add(new JSeparator());
1859
+ //panel.add(new JSeparator());
17741860
1775
- panel.add(globalSection);
1861
+ //panel.add(globalSection);
17761862
17771863 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17781864
....@@ -2847,6 +2933,8 @@
28472933
28482934 void SetMaterial(Object3D object)
28492935 {
2936
+ latestObject = object;
2937
+
28502938 cMaterial mat = object.material;
28512939
28522940 if (mat == null)
....@@ -2958,12 +3046,17 @@
29583046 // }
29593047
29603048 /**/
2961
- if (deselect)
3049
+ if (deselect || child == null)
29623050 {
29633051 //group.deselectAll();
29643052 //freeze = true;
29653053 GetTree().clearSelection();
29663054 //freeze = false;
3055
+
3056
+ if (child == null)
3057
+ {
3058
+ return;
3059
+ }
29673060 }
29683061
29693062 //group.addSelectee(child);
....@@ -3032,7 +3125,7 @@
30323125 cameraView.ToggleDL();
30333126 cameraView.repaint();
30343127 return;
3035
- } else if (event.getSource() == toggleTextureItem)
3128
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30363129 {
30373130 cameraView.ToggleTexture();
30383131 // june 2013 copy.HardTouch();
....@@ -3071,7 +3164,7 @@
30713164 frame.validate();
30723165
30733166 return;
3074
- } else if (event.getSource() == toggleSwitchItem)
3167
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30753168 {
30763169 cameraView.ToggleSwitch();
30773170 cameraView.repaint();
....@@ -3464,8 +3557,10 @@
34643557
34653558 copy.ExtractBigData(hashtable);
34663559
3560
+ byte[] compress = Compress(copy);
3561
+
34673562 //EditorFrame.m_MainFrame.requestFocusInWindow();
3468
- tab.graphs[tab.undoindex++] = Compress(copy);
3563
+ tab.graphs[tab.undoindex++] = compress;
34693564
34703565 copy.RestoreBigData(hashtable);
34713566
....@@ -3478,6 +3573,8 @@
34783573 tab.graphs[i] = null;
34793574 }
34803575
3576
+ SetUndoStates();
3577
+
34813578 // test save
34823579 if (false)
34833580 {
....@@ -3500,6 +3597,8 @@
35003597
35013598 void CopyChanged(Object3D obj)
35023599 {
3600
+ SetUndoStates();
3601
+
35033602 boolean temp = CameraPane.SWITCH;
35043603 CameraPane.SWITCH = false;
35053604
....@@ -3537,6 +3636,17 @@
35373636 }
35383637
35393638 refreshContents();
3639
+ }
3640
+
3641
+ cButton undoButton;
3642
+ cButton redoButton;
3643
+
3644
+ void SetUndoStates()
3645
+ {
3646
+ cRadio tab = GetCurrentTab();
3647
+
3648
+ undoButton.setEnabled(tab.undoindex > 0);
3649
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
35403650 }
35413651
35423652 public void Undo()
....@@ -3726,7 +3836,7 @@
37263836 assert false;
37273837 }
37283838
3729
- void EditSelection()
3839
+ void EditSelection(boolean newWindow)
37303840 {
37313841 }
37323842
....@@ -4221,7 +4331,7 @@
42214331
42224332 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42234333 {
4224
- if (Globals.SAVEONMAKE)
4334
+ if (Globals.SAVEONMAKE) // && resetmodel)
42254335 Save();
42264336 //Tween.set(thing, 0).target(1).start(tweenManager);
42274337 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4309,6 +4419,12 @@
43094419 {
43104420 ResetModel();
43114421 Select(thing.GetTreePath(), true, false); // unselect... false);
4422
+
4423
+ if (thing.Size() == 0)
4424
+ {
4425
+ //EditSelection(false);
4426
+ }
4427
+
43124428 refreshContents();
43134429 }
43144430
....@@ -4710,6 +4826,8 @@
47104826 String filename = browser.getFile();
47114827 if (filename != null && filename.length() > 0)
47124828 {
4829
+ if (!filename.endsWith(".gfd"))
4830
+ filename += ".gfd";
47134831 lastname = browser.getDirectory() + filename;
47144832 save();
47154833 }
....@@ -4903,18 +5021,31 @@
49035021 CheckboxMenuItem togglePaintItem;
49045022 JSplitPane mainPanel;
49055023 JScrollPane scrollpane;
5024
+
49065025 JPanel toolbarPanel;
5026
+
49075027 cGridBag treePanel;
5028
+
49085029 JPanel radioPanel;
49095030 ButtonGroup buttonGroup;
4910
- cGridBag ctrlPanel;
5031
+
5032
+ cGridBag toolboxPanel;
49115033 cGridBag materialPanel;
5034
+ cGridBag ctrlPanel;
5035
+
49125036 JScrollPane infoPanel;
5037
+
49135038 cGridBag optionsPanel;
5039
+
49145040 JTabbedPane objectPanel;
5041
+ boolean materialFlushed;
5042
+ Object3D latestObject;
5043
+
49155044 cGridBag XYZPanel;
5045
+
49165046 JSplitPane gridPanel;
49175047 JSplitPane bigPanel;
5048
+
49185049 cGridBag bigThree;
49195050 cGridBag scenePanel;
49205051 cGridBag centralPanel;
....@@ -5029,7 +5160,7 @@
50295160 cNumberSlider fogField;
50305161 JLabel opacityPowerLabel;
50315162 cNumberSlider opacityPowerField;
5032
- JTree jTree;
5163
+ cTree jTree;
50335164 //ObjectUI parent;
50345165
50355166 cNumberSlider normalpushField;