.. | .. |
---|
4 | 4 | |
---|
5 | 5 | import java.awt.*; |
---|
6 | 6 | import java.awt.event.*; |
---|
| 7 | +import java.awt.image.BufferedImage; |
---|
7 | 8 | import javax.swing.*; |
---|
8 | 9 | import javax.swing.event.*; |
---|
9 | 10 | import javax.swing.text.*; |
---|
.. | .. |
---|
13 | 14 | import javax.swing.plaf.metal.MetalLookAndFeel; |
---|
14 | 15 | //import javax.swing.plaf.ColorUIResource; |
---|
15 | 16 | //import javax.swing.plaf.metal.DefaultMetalTheme; |
---|
| 17 | + |
---|
| 18 | +import javax.swing.plaf.basic.BasicSplitPaneDivider; |
---|
| 19 | +import javax.swing.plaf.basic.BasicSplitPaneUI; |
---|
16 | 20 | |
---|
17 | 21 | //import javax.media.opengl.GLCanvas; |
---|
18 | 22 | |
---|
.. | .. |
---|
37 | 41 | JFrame frame; |
---|
38 | 42 | |
---|
39 | 43 | static ObjEditor theFrame; |
---|
| 44 | + |
---|
| 45 | + cButton GetButton(String name, boolean border) |
---|
| 46 | + { |
---|
| 47 | + try |
---|
| 48 | + { |
---|
| 49 | + ImageIcon icon = GetIcon(name); |
---|
| 50 | + return new cButton(icon, border); |
---|
| 51 | + } |
---|
| 52 | + catch (Exception e) |
---|
| 53 | + { |
---|
| 54 | + 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); |
---|
| 68 | + } |
---|
| 69 | + } |
---|
| 70 | + |
---|
| 71 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 72 | + { |
---|
| 73 | + try |
---|
| 74 | + { |
---|
| 75 | + ImageIcon icon = GetIcon(name); |
---|
| 76 | + return new cCheckBox(icon, border); |
---|
| 77 | + } |
---|
| 78 | + catch (Exception e) |
---|
| 79 | + { |
---|
| 80 | + return new cCheckBox(name, border); |
---|
| 81 | + } |
---|
| 82 | + } |
---|
| 83 | + |
---|
| 84 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 85 | + { |
---|
| 86 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 87 | + |
---|
| 88 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 89 | + { |
---|
| 90 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 91 | + Graphics2D g = resized.createGraphics(); |
---|
| 92 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 93 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 94 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 95 | + g.dispose(); |
---|
| 96 | + |
---|
| 97 | + image = resized; |
---|
| 98 | + } |
---|
| 99 | + |
---|
| 100 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 101 | + return icon; |
---|
| 102 | + } |
---|
40 | 103 | |
---|
41 | 104 | // SCRIPT |
---|
42 | 105 | |
---|
.. | .. |
---|
147 | 210 | |
---|
148 | 211 | objEditor.ctrlPanel.remove(namePanel); |
---|
149 | 212 | |
---|
150 | | - if (!GroupEditor.allparams) |
---|
| 213 | + if (!allparams) |
---|
151 | 214 | return; |
---|
152 | 215 | |
---|
153 | 216 | // objEditor.ctrlPanel.remove(liveCB); |
---|
.. | .. |
---|
277 | 340 | return frame.action(event, obj); |
---|
278 | 341 | } |
---|
279 | 342 | |
---|
| 343 | + // Cannot work without static |
---|
| 344 | + static boolean allparams = true; |
---|
| 345 | + |
---|
| 346 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 347 | + |
---|
280 | 348 | void SetupMenu() |
---|
281 | 349 | { |
---|
282 | 350 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
.. | .. |
---|
323 | 391 | closeItem.addActionListener(this); |
---|
324 | 392 | |
---|
325 | 393 | 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 | + |
---|
326 | 420 | toolbarPanel = new JPanel(); |
---|
327 | 421 | toolbarPanel.setName("Toolbar"); |
---|
328 | 422 | treePanel = new cGridBag(); |
---|
.. | .. |
---|
337 | 431 | editPanel.add(editCommandsPanel); |
---|
338 | 432 | editPanel.add(ctrlPanel); |
---|
339 | 433 | |
---|
340 | | - materialPanel = new cGridBag().setVertical(true); |
---|
| 434 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 435 | + toolboxPanel.setName("Toolbox"); |
---|
341 | 436 | |
---|
| 437 | + materialPanel = new cGridBag().setVertical(true); |
---|
342 | 438 | materialPanel.setName("Material"); |
---|
| 439 | + |
---|
343 | 440 | /*JTextPane*/ |
---|
344 | 441 | infoarea = createTextPane(); |
---|
345 | 442 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
364 | 461 | mainPanel.setDividerSize(9); |
---|
365 | 462 | mainPanel.setDividerLocation(0.5); //1.0); |
---|
366 | 463 | mainPanel.setResizeWeight(0.5); |
---|
367 | | - |
---|
| 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 | + |
---|
368 | 472 | //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5)); |
---|
369 | 473 | //mainPanel.setLayout(new GridBagLayout()); |
---|
370 | 474 | toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); |
---|
.. | .. |
---|
612 | 716 | |
---|
613 | 717 | boolean maximized; |
---|
614 | 718 | |
---|
| 719 | + cButton fullscreenLayout; |
---|
| 720 | + |
---|
615 | 721 | void Minimize() |
---|
616 | 722 | { |
---|
617 | 723 | frame.setState(Frame.ICONIFIED); |
---|
.. | .. |
---|
637 | 743 | |
---|
638 | 744 | void ToggleFullScreen() |
---|
639 | 745 | { |
---|
640 | | - if (CameraPane.FULLSCREEN) |
---|
| 746 | + cameraView.ToggleFullScreen(); |
---|
| 747 | + |
---|
| 748 | + if (!CameraPane.FULLSCREEN) |
---|
641 | 749 | { |
---|
642 | 750 | device.setFullScreenWindow(null); |
---|
643 | 751 | //frame.setVisible(false); |
---|
.. | .. |
---|
673 | 781 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
674 | 782 | framePanel.setDividerLocation(0); |
---|
675 | 783 | |
---|
676 | | - radio.layout = twoButton; |
---|
| 784 | + radio.layout = fullscreenLayout; |
---|
677 | 785 | radio.layout.doClick(); |
---|
678 | 786 | //frame.setVisible(true); |
---|
679 | 787 | } |
---|
680 | | - |
---|
681 | | - cameraView.ToggleFullScreen(); |
---|
682 | 788 | } |
---|
683 | 789 | |
---|
684 | 790 | private JTextPane createTextPane() |
---|
.. | .. |
---|
819 | 925 | JCheckBox speedupCB; |
---|
820 | 926 | JCheckBox rewindCB; |
---|
821 | 927 | JCheckBox flipVCB; |
---|
| 928 | + |
---|
| 929 | + cCheckBox toggleTextureCB; |
---|
| 930 | + cCheckBox toggleSwitchCB; |
---|
| 931 | + |
---|
822 | 932 | JComboBox texresMenu; |
---|
| 933 | + |
---|
823 | 934 | JButton resetButton; |
---|
824 | 935 | JButton stepButton; |
---|
825 | 936 | JButton stepAllButton; |
---|
.. | .. |
---|
1011 | 1122 | |
---|
1012 | 1123 | oe.ctrlPanel.Return(); |
---|
1013 | 1124 | |
---|
1014 | | - if (!GroupEditor.allparams) |
---|
| 1125 | + if (!allparams) |
---|
1015 | 1126 | return; |
---|
1016 | 1127 | |
---|
1017 | 1128 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
1024 | 1135 | hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); |
---|
1025 | 1136 | hideCB.setToolTipText("Hide object"); |
---|
1026 | 1137 | markCB = AddCheckBox(setupPanel, "Mark", copy.marked); |
---|
1027 | | - markCB.setToolTipText("Set the animation target transform"); |
---|
| 1138 | + markCB.setToolTipText("As animation target transform"); |
---|
1028 | 1139 | |
---|
1029 | 1140 | setupPanel2 = new cGridBag().setVertical(false); |
---|
1030 | 1141 | |
---|
.. | .. |
---|
1032 | 1143 | rewindCB.setToolTipText("Rewind animation"); |
---|
1033 | 1144 | |
---|
1034 | 1145 | randomCB = AddCheckBox(setupPanel2, "Rand", copy.random); |
---|
1035 | | - randomCB.setToolTipText("Randomly Rewind or Go back and forth"); |
---|
| 1146 | + randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1036 | 1147 | |
---|
1037 | 1148 | if (Globals.ADVANCED) |
---|
1038 | 1149 | { |
---|
.. | .. |
---|
1354 | 1465 | // objectPanel.add(north); |
---|
1355 | 1466 | objectPanel.add(editPanel); |
---|
1356 | 1467 | objectPanel.add(infoPanel); |
---|
| 1468 | + objectPanel.add(toolboxPanel); |
---|
1357 | 1469 | |
---|
1358 | 1470 | /* |
---|
1359 | 1471 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1362 | 1474 | aConstraints.gridy += 1; |
---|
1363 | 1475 | aConstraints.gridwidth = 1; |
---|
1364 | 1476 | mainPanel.add(objectPanel, aConstraints); |
---|
1365 | | - */ |
---|
| 1477 | + */ |
---|
1366 | 1478 | |
---|
1367 | 1479 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1368 | 1480 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1379 | 1491 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1380 | 1492 | tabbedPane.add(scrollpane); |
---|
1381 | 1493 | |
---|
1382 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1383 | | - |
---|
1384 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1494 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1385 | 1495 | |
---|
1386 | 1496 | optionsPanel.setName("Options"); |
---|
1387 | 1497 | |
---|
.. | .. |
---|
1389 | 1499 | |
---|
1390 | 1500 | tabbedPane.add(optionsPanel); |
---|
1391 | 1501 | |
---|
| 1502 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1503 | + |
---|
1392 | 1504 | scenePanel.add(tabbedPane); |
---|
1393 | 1505 | |
---|
1394 | 1506 | /* |
---|
.. | .. |
---|
1481 | 1593 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1482 | 1594 | |
---|
1483 | 1595 | frame.setSize(1280, 860); |
---|
| 1596 | + |
---|
| 1597 | + frame.validate(); |
---|
1484 | 1598 | frame.setVisible(true); |
---|
1485 | 1599 | |
---|
1486 | 1600 | cameraView.requestFocusInWindow(); |
---|
.. | .. |
---|
2800 | 2914 | |
---|
2801 | 2915 | void SetMaterial(Object3D object) |
---|
2802 | 2916 | { |
---|
| 2917 | + latestObject = object; |
---|
| 2918 | + |
---|
2803 | 2919 | cMaterial mat = object.material; |
---|
2804 | 2920 | |
---|
2805 | 2921 | if (mat == null) |
---|
.. | .. |
---|
2911 | 3027 | // } |
---|
2912 | 3028 | |
---|
2913 | 3029 | /**/ |
---|
2914 | | - if (deselect) |
---|
| 3030 | + if (deselect || child == null) |
---|
2915 | 3031 | { |
---|
2916 | 3032 | //group.deselectAll(); |
---|
2917 | 3033 | //freeze = true; |
---|
2918 | 3034 | GetTree().clearSelection(); |
---|
2919 | 3035 | //freeze = false; |
---|
| 3036 | + |
---|
| 3037 | + if (child == null) |
---|
| 3038 | + { |
---|
| 3039 | + return; |
---|
| 3040 | + } |
---|
2920 | 3041 | } |
---|
2921 | 3042 | |
---|
2922 | 3043 | //group.addSelectee(child); |
---|
.. | .. |
---|
2985 | 3106 | cameraView.ToggleDL(); |
---|
2986 | 3107 | cameraView.repaint(); |
---|
2987 | 3108 | return; |
---|
2988 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3109 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2989 | 3110 | { |
---|
2990 | 3111 | cameraView.ToggleTexture(); |
---|
2991 | 3112 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3024 | 3145 | frame.validate(); |
---|
3025 | 3146 | |
---|
3026 | 3147 | return; |
---|
3027 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3148 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3028 | 3149 | { |
---|
3029 | 3150 | cameraView.ToggleSwitch(); |
---|
3030 | 3151 | cameraView.repaint(); |
---|
.. | .. |
---|
3408 | 3529 | |
---|
3409 | 3530 | public void Save() |
---|
3410 | 3531 | { |
---|
| 3532 | + System.err.println("Save"); |
---|
| 3533 | + |
---|
3411 | 3534 | cRadio tab = GetCurrentTab(); |
---|
3412 | 3535 | |
---|
3413 | 3536 | boolean temp = CameraPane.SWITCH; |
---|
.. | .. |
---|
3429 | 3552 | tab.graphs[i] = null; |
---|
3430 | 3553 | } |
---|
3431 | 3554 | |
---|
| 3555 | + SetUndoStates(); |
---|
| 3556 | + |
---|
3432 | 3557 | // test save |
---|
3433 | 3558 | if (false) |
---|
3434 | 3559 | { |
---|
.. | .. |
---|
3451 | 3576 | |
---|
3452 | 3577 | void CopyChanged(Object3D obj) |
---|
3453 | 3578 | { |
---|
| 3579 | + SetUndoStates(); |
---|
| 3580 | + |
---|
3454 | 3581 | boolean temp = CameraPane.SWITCH; |
---|
3455 | 3582 | CameraPane.SWITCH = false; |
---|
3456 | 3583 | |
---|
.. | .. |
---|
3490 | 3617 | refreshContents(); |
---|
3491 | 3618 | } |
---|
3492 | 3619 | |
---|
| 3620 | + cButton undoButton; |
---|
| 3621 | + cButton redoButton; |
---|
| 3622 | + |
---|
| 3623 | + void SetUndoStates() |
---|
| 3624 | + { |
---|
| 3625 | + cRadio tab = GetCurrentTab(); |
---|
| 3626 | + |
---|
| 3627 | + undoButton.setEnabled(tab.undoindex > 0); |
---|
| 3628 | + redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3629 | + } |
---|
| 3630 | + |
---|
3493 | 3631 | public void Undo() |
---|
3494 | 3632 | { |
---|
| 3633 | + System.err.println("Undo"); |
---|
| 3634 | + |
---|
3495 | 3635 | cRadio tab = GetCurrentTab(); |
---|
3496 | 3636 | |
---|
3497 | 3637 | if (tab.undoindex == 0) |
---|
.. | .. |
---|
3675 | 3815 | assert false; |
---|
3676 | 3816 | } |
---|
3677 | 3817 | |
---|
3678 | | - void EditSelection() |
---|
| 3818 | + void EditSelection(boolean newWindow) |
---|
3679 | 3819 | { |
---|
3680 | 3820 | } |
---|
3681 | 3821 | |
---|
.. | .. |
---|
4170 | 4310 | |
---|
4171 | 4311 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4172 | 4312 | { |
---|
4173 | | - Save(); |
---|
| 4313 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4314 | + Save(); |
---|
4174 | 4315 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4175 | 4316 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4176 | 4317 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4257 | 4398 | { |
---|
4258 | 4399 | ResetModel(); |
---|
4259 | 4400 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4401 | + |
---|
| 4402 | + if (thing.Size() == 0) |
---|
| 4403 | + { |
---|
| 4404 | + //EditSelection(false); |
---|
| 4405 | + } |
---|
| 4406 | + |
---|
4260 | 4407 | refreshContents(); |
---|
4261 | 4408 | } |
---|
4262 | 4409 | |
---|
.. | .. |
---|
4479 | 4626 | |
---|
4480 | 4627 | if (readobj != null) |
---|
4481 | 4628 | { |
---|
| 4629 | + if (Globals.SAVEONMAKE) |
---|
4482 | 4630 | Save(); |
---|
4483 | 4631 | try |
---|
4484 | 4632 | { |
---|
.. | .. |
---|
4657 | 4805 | String filename = browser.getFile(); |
---|
4658 | 4806 | if (filename != null && filename.length() > 0) |
---|
4659 | 4807 | { |
---|
| 4808 | + if (!filename.endsWith(".gfd")) |
---|
| 4809 | + filename += ".gfd"; |
---|
4660 | 4810 | lastname = browser.getDirectory() + filename; |
---|
4661 | 4811 | save(); |
---|
4662 | 4812 | } |
---|
.. | .. |
---|
4850 | 5000 | CheckboxMenuItem togglePaintItem; |
---|
4851 | 5001 | JSplitPane mainPanel; |
---|
4852 | 5002 | JScrollPane scrollpane; |
---|
| 5003 | + |
---|
4853 | 5004 | JPanel toolbarPanel; |
---|
| 5005 | + |
---|
4854 | 5006 | cGridBag treePanel; |
---|
| 5007 | + |
---|
4855 | 5008 | JPanel radioPanel; |
---|
4856 | 5009 | ButtonGroup buttonGroup; |
---|
4857 | | - cGridBag ctrlPanel; |
---|
| 5010 | + |
---|
| 5011 | + cGridBag toolboxPanel; |
---|
4858 | 5012 | cGridBag materialPanel; |
---|
| 5013 | + cGridBag ctrlPanel; |
---|
| 5014 | + |
---|
4859 | 5015 | JScrollPane infoPanel; |
---|
| 5016 | + |
---|
4860 | 5017 | cGridBag optionsPanel; |
---|
| 5018 | + |
---|
4861 | 5019 | JTabbedPane objectPanel; |
---|
| 5020 | + boolean materialFlushed; |
---|
| 5021 | + Object3D latestObject; |
---|
| 5022 | + |
---|
4862 | 5023 | cGridBag XYZPanel; |
---|
| 5024 | + |
---|
4863 | 5025 | JSplitPane gridPanel; |
---|
4864 | 5026 | JSplitPane bigPanel; |
---|
| 5027 | + |
---|
4865 | 5028 | cGridBag bigThree; |
---|
4866 | 5029 | cGridBag scenePanel; |
---|
4867 | 5030 | cGridBag centralPanel; |
---|
.. | .. |
---|
4976 | 5139 | cNumberSlider fogField; |
---|
4977 | 5140 | JLabel opacityPowerLabel; |
---|
4978 | 5141 | cNumberSlider opacityPowerField; |
---|
4979 | | - JTree jTree; |
---|
| 5142 | + cTree jTree; |
---|
4980 | 5143 | //ObjectUI parent; |
---|
4981 | 5144 | |
---|
4982 | 5145 | cNumberSlider normalpushField; |
---|