Normand Briere
2019-08-12 b1d79b74514041a059b454a9f6fc3970773c0cb8
GroupEditor.java
....@@ -16,6 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
+ Grafreed.iResourceCallBack,
1920 ObjectUI,
2021 Runnable,
2122 ActionListener,
....@@ -41,6 +42,22 @@
4142 });
4243 }
4344
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(c + count);
51
+ textureButton.addActionListener(new ActionListener()
52
+ {
53
+ @Override
54
+ public void actionPerformed(ActionEvent e)
55
+ {
56
+ ChangeTexture(path + t);
57
+ }
58
+ });
59
+ }
60
+
4461 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4562 {
4663 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -311,14 +328,47 @@
311328 }
312329 }
313330
314
- public void ChangeSkybox(String name)
331
+ public void ChangeSkybox(String skybox)
315332 {
316333 //cameraView.envyoff = false;
317
- group.skyboxname = name;
334
+ group.skyboxname = skybox;
318335 group.skyboxext = "jpg";
319336 cameraView.repaint();
320337 }
338
+
339
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
340
+ {
341
+ JTabbedPane skyboxpane = new JTabbedPane();
342
+
343
+ AddSkyboxTab0(skyboxpane);
344
+ AddSkyboxTab1(skyboxpane);
345
+ AddSkyboxTab2(skyboxpane);
346
+ AddSkyboxTab3(skyboxpane);
347
+
348
+ skyboxPanel.add(skyboxpane);
349
+ }
321350
351
+ public void ChangeTexture(String texture)
352
+ {
353
+ for (int i=0; i<group.selection.size(); i++)
354
+ {
355
+ Object3D obj = group.selection.get(i);
356
+ obj.SetPigmentTexture("@" + texture);
357
+ }
358
+
359
+ refreshContents();
360
+ }
361
+
362
+ public void Show3DView()
363
+ {
364
+ // bug
365
+ //gridPanel.setDividerLocation(1.0);
366
+ //bigPanel.setDividerLocation(0.0);
367
+ bigThree.ClearUI();
368
+ bigThree.add(centralPanel);
369
+ bigThree.FlushUI();
370
+ }
371
+
322372 //ObjEditor objEditor;
323373 public void closeUI2()
324374 {
....@@ -859,6 +909,73 @@
859909 buildToolsMenu(menu);
860910 }
861911
912
+ JTabbedPane resourcecontainer;
913
+ cGridBag currenttab;
914
+ boolean added; // patch for jar
915
+
916
+ int tabcount = 0;
917
+ int colcount = 0;
918
+ int rowcount = 0;
919
+ int texturecount = 0;
920
+
921
+ int columns = 5;
922
+ int rows = 7;
923
+
924
+ public void ResourceCallBack(String[] path)
925
+ {
926
+// for (int i = 0; i < path.length; i++)
927
+// System.out.print(path[i] + "/");
928
+// System.out.println();
929
+
930
+ if (//rowcount == 0 ||
931
+ path.length == 1)
932
+ {
933
+ currenttab = new cGridBag();
934
+ added = false;
935
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
936
+ currenttab.setName(tabname);
937
+ rowcount = 1;
938
+ colcount = 0;
939
+ texturecount = 0;
940
+ }
941
+
942
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
943
+ {
944
+ if (!added)
945
+ {
946
+ added = true;
947
+ resourcecontainer.add(currenttab);
948
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
949
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
950
+ }
951
+
952
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
953
+
954
+ if (++colcount >= columns)
955
+ {
956
+ colcount = 0;
957
+ currenttab.Return();
958
+
959
+ if (rowcount++ >= rows)
960
+ {
961
+ rowcount = 0;
962
+ }
963
+ }
964
+ }
965
+ else
966
+ {
967
+// if (!path[path.length-1].equals("icons"))
968
+// resourcecontainer.Return();
969
+ }
970
+ }
971
+
972
+ void CreateTexturePanel(cGridBag container)
973
+ {
974
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
975
+ container.add(resourcecontainer);
976
+
977
+ Grafreed.ParseResources("textures", this);
978
+ }
862979
863980 void SetupUI2(ObjEditor oe)
864981 {
....@@ -877,11 +994,6 @@
877994 //new Exception().printStackTrace();
878995
879996 oe.radioPanel = new JPanel(new GridBagLayout());
880
- oe.aConstraints.weightx = 1;
881
- oe.aConstraints.weighty = 0;
882
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
883
- oe.aConstraints.gridwidth = 100;
884
- oe.aConstraints.gridheight = 1;
885997 // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
886998
887999 oe.buttonGroup = new ButtonGroup();
....@@ -919,6 +1031,45 @@
9191031 maxButton.addActionListener(this);
9201032 }
9211033
1034
+ cButton gcButton;
1035
+
1036
+ oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1037
+ gcButton.setToolTipText("Garbage collect");
1038
+ gcButton.addActionListener(new ActionListener()
1039
+ {
1040
+ public void actionPerformed(ActionEvent e)
1041
+ {
1042
+ System.gc();
1043
+ }
1044
+ });
1045
+
1046
+ oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1047
+ collapseButton.setToolTipText("Collapse toolbar");
1048
+ collapseButton.addActionListener(this);
1049
+
1050
+ oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1051
+ maximize3DButton.setToolTipText("Maximize 3D view");
1052
+ maximize3DButton.addActionListener(this);
1053
+
1054
+ oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1055
+ twoButton.setToolTipText("Show 3D view only");
1056
+ twoButton.addActionListener(this);
1057
+ this.fullscreenLayout = twoButton;
1058
+
1059
+ oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1060
+ threeButton.setToolTipText("Show controls and 3D view");
1061
+ threeButton.addActionListener(this);
1062
+ if (Globals.ADVANCED)
1063
+ {
1064
+ oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1065
+ sixButton.setToolTipText("Show 3D view and controls");
1066
+ sixButton.addActionListener(this);
1067
+ }
1068
+// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1069
+// sevenButton.setToolTipText("3-column layout");
1070
+// sevenButton.addActionListener(this);
1071
+ //
1072
+
9221073 oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9231074 fullButton.setToolTipText("Full-screen window");
9241075 fullButton.addActionListener(this);
....@@ -948,12 +1099,12 @@
9481099 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9491100 restoreButton.setToolTipText("Undo (restore current version)");
9501101 restoreButton.addActionListener(this);
951
- restoreButton.setEnabled(false);
1102
+ //restoreButton.setEnabled(false);
9521103
9531104 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9541105 replaceButton.setToolTipText("Save (replace current version)");
9551106 replaceButton.addActionListener(this);
956
- replaceButton.setEnabled(false);
1107
+ //replaceButton.setEnabled(false);
9571108
9581109 copyOptionsPanel.add(updown);
9591110
....@@ -962,14 +1113,14 @@
9621113 nextVersionButton.addActionListener(this);
9631114 nextVersionButton.setEnabled(false);
9641115
965
- oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
966
- liveCB.setToolTipText("Enable animation");
967
- liveCB.addItemListener(this);
968
-
9691116 oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
9701117 oneStepButton.setToolTipText("Animate one step forward");
9711118 oneStepButton.addActionListener(this);
9721119
1120
+ oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
1121
+ liveCB.setToolTipText("Enable animation");
1122
+ liveCB.addItemListener(this);
1123
+
9731124 oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints);
9741125 fastCB.setToolTipText("Fast mode");
9751126 fastCB.addItemListener(this);
....@@ -996,21 +1147,6 @@
9961147
9971148 //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL));
9981149
999
- oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1000
- twoButton.setToolTipText("Show 3D view only");
1001
- twoButton.addActionListener(this);
1002
- this.fullscreenLayout = twoButton;
1003
-
1004
- oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1005
- threeButton.setToolTipText("Show controls and 3D view");
1006
- threeButton.addActionListener(this);
1007
- oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1008
- sixButton.setToolTipText("Show 3D view and controls");
1009
- sixButton.addActionListener(this);
1010
-// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1011
-// sevenButton.setToolTipText("3-column layout");
1012
-// sevenButton.addActionListener(this);
1013
- //
10141150
10151151 oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10161152 rootButton.setToolTipText("Open selection in new tab");
....@@ -1094,19 +1230,15 @@
10941230
10951231 oe.toolboxPanel.add(row2);
10961232
1097
- // ENVYMAPS
1098
- cGridBag skyboxpane = new cGridBag();
1099
- skyboxpane.preferredHeight = 100;
1233
+ cGridBag textures = new cGridBag();
11001234
1101
- oe.toolboxPanel.add(skyboxpane);
1235
+ CreateTexturePanel(textures);
11021236
1103
- JTabbedPane skyboxpanel = new JTabbedPane();
1104
- skyboxpane.add(skyboxpanel);
1237
+ oe.toolboxPanel.add(textures);
11051238
1106
- AddSkyboxTab0(skyboxpanel);
1107
- AddSkyboxTab1(skyboxpanel);
1108
- AddSkyboxTab2(skyboxpanel);
1109
- AddSkyboxTab3(skyboxpanel);
1239
+ textures.preferredHeight = 100;
1240
+
1241
+ CreateSkyboxPanel(oe.skyboxPanel);
11101242
11111243 // EDIT panel
11121244 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1118,16 +1250,16 @@
11181250 uneditButton.addActionListener(this);
11191251
11201252 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1121
- allParamsButton.setToolTipText("Show all controle");
1253
+ allParamsButton.setToolTipText("Show all controls");
11221254 allParamsButton.addActionListener(this);
11231255
11241256 editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- clearPanelButton.setToolTipText("Clear edit panel");
1257
+ clearPanelButton.setToolTipText("Clear all controls");
11261258 clearPanelButton.addActionListener(this);
11271259
1128
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1129
- unselectButton.setToolTipText("Unselect");
1130
- unselectButton.addActionListener(this);
1260
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1261
+ //unselectButton.setToolTipText("Unselect");
1262
+ //unselectButton.addActionListener(this);
11311263
11321264 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11331265 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1712,7 +1844,12 @@
17121844 TreePath path;
17131845
17141846 public TransferableTreePath(TreePath tp) {
1715
- path = tp;
1847
+ Object[] objs = new Object[tp.getPathCount()];
1848
+ for (int i=0; i<objs.length; i++)
1849
+ {
1850
+ objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID();
1851
+ }
1852
+ path = new TreePath(objs);
17161853 }
17171854
17181855 public synchronized DataFlavor[] getTransferDataFlavors() {
....@@ -2606,6 +2743,18 @@
26062743 {
26072744 ToggleFullScreen();
26082745 } else
2746
+ if (source == collapseButton)
2747
+ {
2748
+ this.expandedLayout = radio.layout;
2749
+ CollapseToolbar();
2750
+ } else
2751
+ if (source == maximize3DButton)
2752
+ {
2753
+ this.expandedLayout = radio.layout;
2754
+ radio.layout = twoButton;
2755
+ Show3DView();
2756
+ CollapseToolbar();
2757
+ } else
26092758 if (source == previousVersionButton)
26102759 {
26112760 // Go to previous version
....@@ -2617,13 +2766,13 @@
26172766 {
26182767 // Restore current version
26192768 Restore();
2620
- restoreButton.setEnabled(false);
2769
+ //restoreButton.setEnabled(false);
26212770 } else
26222771 if (source == replaceButton)
26232772 {
26242773 // Overwrite current version
26252774 Replace();
2626
- replaceButton.setEnabled(false);
2775
+ //replaceButton.setEnabled(false);
26272776 } else
26282777 if (source == nextVersionButton)
26292778 {
....@@ -3557,38 +3706,7 @@
35573706 if (CameraPane.FULLSCREEN)
35583707 fullscreenLayout = radio.layout;
35593708
3560
- // bug
3561
- //gridPanel.setDividerLocation(1.0);
3562
- //bigPanel.setDividerLocation(0.0);
3563
-// bigThree.remove(scenePanel);
3564
-// bigThree.remove(centralPanel);
3565
-// bigThree.remove(XYZPanel);
3566
-// aWindowConstraints.gridx = 0;
3567
-// aWindowConstraints.gridy = 0;
3568
-// aWindowConstraints.gridwidth = 1;
3569
-// // aConstraints.gridheight = 3;
3570
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3571
-// aWindowConstraints.weightx = 0;
3572
-// aWindowConstraints.weighty = 1;
3573
-// //bigThree.add(jtp, aWindowConstraints);
3574
-// aWindowConstraints.weightx = 1;
3575
-// aWindowConstraints.gridwidth = 3;
3576
-// // aConstraints.gridheight = 3;
3577
-// aWindowConstraints.gridx = 1;
3578
-// aWindowConstraints.fill = GridBagConstraints.BOTH;
3579
-// bigThree.add(centralPanel, aWindowConstraints);
3580
-// aWindowConstraints.weightx = 0;
3581
-// aWindowConstraints.gridx = 4;
3582
-// aWindowConstraints.gridwidth = 1;
3583
-// // aConstraints.gridheight = 3;
3584
-// aWindowConstraints.fill = GridBagConstraints.VERTICAL;
3585
-// //bigThree.add(XYZPanel, aWindowConstraints);
3586
-// scenePanel.setVisible(false);
3587
-// centralPanel.setVisible(true);
3588
-// XYZPanel.setVisible(false);
3589
- bigThree.ClearUI();
3590
- bigThree.add(centralPanel);
3591
- bigThree.FlushUI();
3709
+ Show3DView();
35923710
35933711 cameraView.requestFocusInWindow();
35943712
....@@ -5169,7 +5287,7 @@
51695287 {
51705288 editButton.setEnabled(enabled);
51715289 uneditButton.setEnabled(enabled);
5172
- unselectButton.setEnabled(enabled);
5290
+ //unselectButton.setEnabled(enabled);
51735291 flashSelectionButton.setEnabled(enabled);
51745292
51755293 clearPanelButton.setEnabled(!listUI.isEmpty());
....@@ -5177,7 +5295,7 @@
51775295
51785296 void refreshContents(boolean cp)
51795297 {
5180
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5298
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51815299 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51825300 {
51835301 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5187,7 +5305,7 @@
51875305 Object3D child = (Object3D) group.selection.get(i);
51885306
51895307 objEditor.AddInfo(child, this, true);
5190
- System.err.println("info : " + child.GetPath());
5308
+// System.err.println("info : " + child.GetPath());
51915309 }
51925310
51935311 objEditor.SetText(); // jan 2014