.. | .. |
---|
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.*; |
---|
.. | .. |
---|
37 | 38 | JFrame frame; |
---|
38 | 39 | |
---|
39 | 40 | static ObjEditor theFrame; |
---|
| 41 | + |
---|
| 42 | + cButton GetButton(String name, boolean border) |
---|
| 43 | + { |
---|
| 44 | + try |
---|
| 45 | + { |
---|
| 46 | + ImageIcon icon = GetIcon(name); |
---|
| 47 | + return new cButton(icon, border); |
---|
| 48 | + } |
---|
| 49 | + catch (Exception e) |
---|
| 50 | + { |
---|
| 51 | + return new cButton(name, border); |
---|
| 52 | + } |
---|
| 53 | + } |
---|
| 54 | + |
---|
| 55 | + cToggleButton GetToggleButton(String name, boolean border) |
---|
| 56 | + { |
---|
| 57 | + try |
---|
| 58 | + { |
---|
| 59 | + ImageIcon icon = GetIcon(name); |
---|
| 60 | + return new cToggleButton(icon, border); |
---|
| 61 | + } |
---|
| 62 | + catch (Exception e) |
---|
| 63 | + { |
---|
| 64 | + return new cToggleButton(name, border); |
---|
| 65 | + } |
---|
| 66 | + } |
---|
| 67 | + |
---|
| 68 | + cCheckBox GetCheckBox(String name, boolean border) |
---|
| 69 | + { |
---|
| 70 | + try |
---|
| 71 | + { |
---|
| 72 | + ImageIcon icon = GetIcon(name); |
---|
| 73 | + return new cCheckBox(icon, border); |
---|
| 74 | + } |
---|
| 75 | + catch (Exception e) |
---|
| 76 | + { |
---|
| 77 | + return new cCheckBox(name, border); |
---|
| 78 | + } |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + private ImageIcon GetIcon(String name) throws IOException |
---|
| 82 | + { |
---|
| 83 | + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); |
---|
| 84 | + |
---|
| 85 | + if (image.getWidth() != 24 && image.getHeight() != 24) |
---|
| 86 | + { |
---|
| 87 | + BufferedImage resized = new BufferedImage(24, 24, image.getType()); |
---|
| 88 | + Graphics2D g = resized.createGraphics(); |
---|
| 89 | + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
---|
| 90 | + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); |
---|
| 91 | + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); |
---|
| 92 | + g.dispose(); |
---|
| 93 | + |
---|
| 94 | + image = resized; |
---|
| 95 | + } |
---|
| 96 | + |
---|
| 97 | + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); |
---|
| 98 | + return icon; |
---|
| 99 | + } |
---|
40 | 100 | |
---|
41 | 101 | // SCRIPT |
---|
42 | 102 | |
---|
.. | .. |
---|
147 | 207 | |
---|
148 | 208 | objEditor.ctrlPanel.remove(namePanel); |
---|
149 | 209 | |
---|
150 | | - if (!GroupEditor.allparams) |
---|
| 210 | + if (!allparams) |
---|
151 | 211 | return; |
---|
152 | 212 | |
---|
153 | 213 | // objEditor.ctrlPanel.remove(liveCB); |
---|
.. | .. |
---|
171 | 231 | |
---|
172 | 232 | objEditor.ctrlPanel.remove(setupPanel); |
---|
173 | 233 | objEditor.ctrlPanel.remove(setupPanel2); |
---|
174 | | - objEditor.ctrlPanel.remove(commandsPanel); |
---|
| 234 | + objEditor.ctrlPanel.remove(objectCommandsPanel); |
---|
175 | 235 | objEditor.ctrlPanel.remove(pushPanel); |
---|
176 | 236 | //objEditor.ctrlPanel.remove(fillPanel); |
---|
177 | 237 | |
---|
.. | .. |
---|
277 | 337 | return frame.action(event, obj); |
---|
278 | 338 | } |
---|
279 | 339 | |
---|
| 340 | + // Cannot work without static |
---|
| 341 | + static boolean allparams = true; |
---|
| 342 | + |
---|
| 343 | + static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>(); |
---|
| 344 | + |
---|
280 | 345 | void SetupMenu() |
---|
281 | 346 | { |
---|
282 | 347 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
.. | .. |
---|
323 | 388 | closeItem.addActionListener(this); |
---|
324 | 389 | |
---|
325 | 390 | objectPanel = new JTabbedPane(); |
---|
| 391 | + |
---|
| 392 | + ChangeListener changeListener = new ChangeListener() |
---|
| 393 | + { |
---|
| 394 | + public void stateChanged(ChangeEvent changeEvent) |
---|
| 395 | + { |
---|
| 396 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) |
---|
| 397 | +// { |
---|
| 398 | +// if (latestObject != null) |
---|
| 399 | +// { |
---|
| 400 | +// refreshContents(true); |
---|
| 401 | +// SetMaterial(latestObject); |
---|
| 402 | +// } |
---|
| 403 | +// |
---|
| 404 | +// materialFlushed = true; |
---|
| 405 | +// } |
---|
| 406 | +// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit")) |
---|
| 407 | +// { |
---|
| 408 | +// if (listUI.size() == 0) |
---|
| 409 | +// EditSelection(false); |
---|
| 410 | +// } |
---|
| 411 | + |
---|
| 412 | + refreshContents(false); // To refresh Info tab |
---|
| 413 | + } |
---|
| 414 | + }; |
---|
| 415 | + objectPanel.addChangeListener(changeListener); |
---|
| 416 | + |
---|
326 | 417 | toolbarPanel = new JPanel(); |
---|
327 | 418 | toolbarPanel.setName("Toolbar"); |
---|
328 | 419 | treePanel = new cGridBag(); |
---|
329 | 420 | treePanel.setName("Tree"); |
---|
| 421 | + |
---|
| 422 | + editPanel = new cGridBag().setVertical(true); |
---|
| 423 | + editPanel.setName("Edit"); |
---|
| 424 | + |
---|
330 | 425 | ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); |
---|
331 | | - ctrlPanel.setName("Edit"); |
---|
| 426 | + |
---|
| 427 | + editCommandsPanel = new cGridBag(); |
---|
| 428 | + editPanel.add(editCommandsPanel); |
---|
| 429 | + editPanel.add(ctrlPanel); |
---|
| 430 | + |
---|
| 431 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 432 | + toolboxPanel.setName("Toolbox"); |
---|
| 433 | + |
---|
332 | 434 | materialPanel = new cGridBag().setVertical(true); |
---|
333 | 435 | materialPanel.setName("Material"); |
---|
| 436 | + |
---|
334 | 437 | /*JTextPane*/ |
---|
335 | 438 | infoarea = createTextPane(); |
---|
336 | 439 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
603 | 706 | |
---|
604 | 707 | boolean maximized; |
---|
605 | 708 | |
---|
| 709 | + cButton fullscreenLayout; |
---|
| 710 | + |
---|
606 | 711 | void Minimize() |
---|
607 | 712 | { |
---|
608 | 713 | frame.setState(Frame.ICONIFIED); |
---|
.. | .. |
---|
628 | 733 | |
---|
629 | 734 | void ToggleFullScreen() |
---|
630 | 735 | { |
---|
631 | | - if (CameraPane.FULLSCREEN) |
---|
| 736 | + cameraView.ToggleFullScreen(); |
---|
| 737 | + |
---|
| 738 | + if (!CameraPane.FULLSCREEN) |
---|
632 | 739 | { |
---|
633 | 740 | device.setFullScreenWindow(null); |
---|
634 | 741 | //frame.setVisible(false); |
---|
.. | .. |
---|
664 | 771 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
665 | 772 | framePanel.setDividerLocation(0); |
---|
666 | 773 | |
---|
667 | | - radio.layout = twoButton; |
---|
| 774 | + radio.layout = fullscreenLayout; |
---|
668 | 775 | radio.layout.doClick(); |
---|
669 | 776 | //frame.setVisible(true); |
---|
670 | 777 | } |
---|
671 | | - |
---|
672 | | - cameraView.ToggleFullScreen(); |
---|
673 | 778 | } |
---|
674 | 779 | |
---|
675 | 780 | private JTextPane createTextPane() |
---|
.. | .. |
---|
810 | 915 | JCheckBox speedupCB; |
---|
811 | 916 | JCheckBox rewindCB; |
---|
812 | 917 | JCheckBox flipVCB; |
---|
| 918 | + |
---|
| 919 | + cCheckBox toggleTextureCB; |
---|
| 920 | + cCheckBox toggleSwitchCB; |
---|
| 921 | + |
---|
813 | 922 | JComboBox texresMenu; |
---|
| 923 | + |
---|
814 | 924 | JButton resetButton; |
---|
815 | 925 | JButton stepButton; |
---|
816 | 926 | JButton stepAllButton; |
---|
.. | .. |
---|
819 | 929 | JButton fasterButton; |
---|
820 | 930 | JButton remarkButton; |
---|
821 | 931 | |
---|
| 932 | + cGridBag editPanel; |
---|
| 933 | + cGridBag editCommandsPanel; |
---|
| 934 | + |
---|
822 | 935 | cGridBag namePanel; |
---|
823 | 936 | cGridBag setupPanel; |
---|
824 | 937 | cGridBag setupPanel2; |
---|
825 | | - cGridBag commandsPanel; |
---|
| 938 | + cGridBag objectCommandsPanel; |
---|
826 | 939 | cGridBag pushPanel; |
---|
827 | 940 | cGridBag fillPanel; |
---|
828 | 941 | |
---|
.. | .. |
---|
999 | 1112 | |
---|
1000 | 1113 | oe.ctrlPanel.Return(); |
---|
1001 | 1114 | |
---|
1002 | | - if (!GroupEditor.allparams) |
---|
| 1115 | + if (!allparams) |
---|
1003 | 1116 | return; |
---|
1004 | 1117 | |
---|
1005 | 1118 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
1035 | 1148 | oe.ctrlPanel.add(setupPanel2); |
---|
1036 | 1149 | oe.ctrlPanel.Return(); |
---|
1037 | 1150 | |
---|
1038 | | - commandsPanel = new cGridBag().setVertical(false); |
---|
| 1151 | + objectCommandsPanel = new cGridBag().setVertical(false); |
---|
1039 | 1152 | |
---|
1040 | | - resetButton = AddButton(commandsPanel, "Reset"); |
---|
| 1153 | + resetButton = AddButton(objectCommandsPanel, "Reset"); |
---|
1041 | 1154 | resetButton.setToolTipText("Jump to frame zero"); |
---|
1042 | | - stepButton = AddButton(commandsPanel, "Step"); |
---|
| 1155 | + stepButton = AddButton(objectCommandsPanel, "Step"); |
---|
1043 | 1156 | stepButton.setToolTipText("Step one frame"); |
---|
1044 | 1157 | // resetAllButton = AddButton(oe, "Reset All"); |
---|
1045 | 1158 | // stepAllButton = AddButton(oe, "Step All"); |
---|
1046 | 1159 | // Return(); |
---|
1047 | | - slowerButton = AddButton(commandsPanel, "Slow"); |
---|
| 1160 | + slowerButton = AddButton(objectCommandsPanel, "Slow"); |
---|
1048 | 1161 | slowerButton.setToolTipText("Decrease animation speed"); |
---|
1049 | | - fasterButton = AddButton(commandsPanel, "Fast"); |
---|
| 1162 | + fasterButton = AddButton(objectCommandsPanel, "Fast"); |
---|
1050 | 1163 | fasterButton.setToolTipText("Increase animation speed"); |
---|
1051 | | - remarkButton = AddButton(commandsPanel, "Remark"); |
---|
| 1164 | + remarkButton = AddButton(objectCommandsPanel, "Remark"); |
---|
1052 | 1165 | remarkButton.setToolTipText("Set the current transform as the target"); |
---|
1053 | 1166 | |
---|
1054 | | - oe.ctrlPanel.add(commandsPanel); |
---|
| 1167 | + oe.ctrlPanel.add(objectCommandsPanel); |
---|
1055 | 1168 | oe.ctrlPanel.Return(); |
---|
1056 | 1169 | |
---|
1057 | 1170 | pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons |
---|
.. | .. |
---|
1340 | 1453 | // north.setName("Edit"); |
---|
1341 | 1454 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1342 | 1455 | // objectPanel.add(north); |
---|
1343 | | - objectPanel.add(ctrlPanel); |
---|
| 1456 | + objectPanel.add(editPanel); |
---|
1344 | 1457 | objectPanel.add(infoPanel); |
---|
| 1458 | + objectPanel.add(toolboxPanel); |
---|
1345 | 1459 | |
---|
1346 | 1460 | /* |
---|
1347 | 1461 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1350 | 1464 | aConstraints.gridy += 1; |
---|
1351 | 1465 | aConstraints.gridwidth = 1; |
---|
1352 | 1466 | mainPanel.add(objectPanel, aConstraints); |
---|
1353 | | - */ |
---|
| 1467 | + */ |
---|
1354 | 1468 | |
---|
1355 | 1469 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1356 | 1470 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1367 | 1481 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1368 | 1482 | tabbedPane.add(scrollpane); |
---|
1369 | 1483 | |
---|
1370 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1371 | | - |
---|
1372 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1484 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1373 | 1485 | |
---|
1374 | 1486 | optionsPanel.setName("Options"); |
---|
1375 | 1487 | |
---|
.. | .. |
---|
1377 | 1489 | |
---|
1378 | 1490 | tabbedPane.add(optionsPanel); |
---|
1379 | 1491 | |
---|
| 1492 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1493 | + |
---|
1380 | 1494 | scenePanel.add(tabbedPane); |
---|
1381 | 1495 | |
---|
1382 | 1496 | /* |
---|
.. | .. |
---|
1469 | 1583 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1470 | 1584 | |
---|
1471 | 1585 | frame.setSize(1280, 860); |
---|
| 1586 | + |
---|
| 1587 | + frame.validate(); |
---|
1472 | 1588 | frame.setVisible(true); |
---|
1473 | 1589 | |
---|
1474 | 1590 | cameraView.requestFocusInWindow(); |
---|
.. | .. |
---|
2788 | 2904 | |
---|
2789 | 2905 | void SetMaterial(Object3D object) |
---|
2790 | 2906 | { |
---|
| 2907 | + latestObject = object; |
---|
| 2908 | + |
---|
2791 | 2909 | cMaterial mat = object.material; |
---|
2792 | 2910 | |
---|
2793 | 2911 | if (mat == null) |
---|
.. | .. |
---|
2973 | 3091 | cameraView.ToggleDL(); |
---|
2974 | 3092 | cameraView.repaint(); |
---|
2975 | 3093 | return; |
---|
2976 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3094 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2977 | 3095 | { |
---|
2978 | 3096 | cameraView.ToggleTexture(); |
---|
2979 | 3097 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3012 | 3130 | frame.validate(); |
---|
3013 | 3131 | |
---|
3014 | 3132 | return; |
---|
3015 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3133 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3016 | 3134 | { |
---|
3017 | 3135 | cameraView.ToggleSwitch(); |
---|
3018 | 3136 | cameraView.repaint(); |
---|
.. | .. |
---|
3396 | 3514 | |
---|
3397 | 3515 | public void Save() |
---|
3398 | 3516 | { |
---|
| 3517 | + System.err.println("Save"); |
---|
| 3518 | + |
---|
3399 | 3519 | cRadio tab = GetCurrentTab(); |
---|
3400 | 3520 | |
---|
3401 | 3521 | boolean temp = CameraPane.SWITCH; |
---|
.. | .. |
---|
3417 | 3537 | tab.graphs[i] = null; |
---|
3418 | 3538 | } |
---|
3419 | 3539 | |
---|
| 3540 | + SetUndoStates(); |
---|
| 3541 | + |
---|
3420 | 3542 | // test save |
---|
3421 | 3543 | if (false) |
---|
3422 | 3544 | { |
---|
.. | .. |
---|
3439 | 3561 | |
---|
3440 | 3562 | void CopyChanged(Object3D obj) |
---|
3441 | 3563 | { |
---|
| 3564 | + SetUndoStates(); |
---|
| 3565 | + |
---|
3442 | 3566 | boolean temp = CameraPane.SWITCH; |
---|
3443 | 3567 | CameraPane.SWITCH = false; |
---|
3444 | 3568 | |
---|
.. | .. |
---|
3478 | 3602 | refreshContents(); |
---|
3479 | 3603 | } |
---|
3480 | 3604 | |
---|
| 3605 | + cButton undoButton; |
---|
| 3606 | + cButton redoButton; |
---|
| 3607 | + |
---|
| 3608 | + void SetUndoStates() |
---|
| 3609 | + { |
---|
| 3610 | + cRadio tab = GetCurrentTab(); |
---|
| 3611 | + |
---|
| 3612 | + undoButton.setEnabled(tab.undoindex > 0); |
---|
| 3613 | + redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3614 | + } |
---|
| 3615 | + |
---|
3481 | 3616 | public void Undo() |
---|
3482 | 3617 | { |
---|
| 3618 | + System.err.println("Undo"); |
---|
| 3619 | + |
---|
3483 | 3620 | cRadio tab = GetCurrentTab(); |
---|
3484 | 3621 | |
---|
3485 | 3622 | if (tab.undoindex == 0) |
---|
.. | .. |
---|
3663 | 3800 | assert false; |
---|
3664 | 3801 | } |
---|
3665 | 3802 | |
---|
3666 | | - void EditSelection() |
---|
| 3803 | + void EditSelection(boolean newWindow) |
---|
3667 | 3804 | { |
---|
3668 | 3805 | } |
---|
3669 | 3806 | |
---|
.. | .. |
---|
4158 | 4295 | |
---|
4159 | 4296 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4160 | 4297 | { |
---|
4161 | | - Save(); |
---|
| 4298 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4299 | + Save(); |
---|
4162 | 4300 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4163 | 4301 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4164 | 4302 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4245 | 4383 | { |
---|
4246 | 4384 | ResetModel(); |
---|
4247 | 4385 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4386 | + |
---|
| 4387 | + if (thing.Size() == 0) |
---|
| 4388 | + { |
---|
| 4389 | + //EditSelection(false); |
---|
| 4390 | + } |
---|
| 4391 | + |
---|
4248 | 4392 | refreshContents(); |
---|
4249 | 4393 | } |
---|
4250 | 4394 | |
---|
.. | .. |
---|
4467 | 4611 | |
---|
4468 | 4612 | if (readobj != null) |
---|
4469 | 4613 | { |
---|
| 4614 | + if (Globals.SAVEONMAKE) |
---|
4470 | 4615 | Save(); |
---|
4471 | 4616 | try |
---|
4472 | 4617 | { |
---|
.. | .. |
---|
4645 | 4790 | String filename = browser.getFile(); |
---|
4646 | 4791 | if (filename != null && filename.length() > 0) |
---|
4647 | 4792 | { |
---|
| 4793 | + if (!filename.endsWith(".gfd")) |
---|
| 4794 | + filename += ".gfd"; |
---|
4648 | 4795 | lastname = browser.getDirectory() + filename; |
---|
4649 | 4796 | save(); |
---|
4650 | 4797 | } |
---|
.. | .. |
---|
4838 | 4985 | CheckboxMenuItem togglePaintItem; |
---|
4839 | 4986 | JSplitPane mainPanel; |
---|
4840 | 4987 | JScrollPane scrollpane; |
---|
| 4988 | + |
---|
4841 | 4989 | JPanel toolbarPanel; |
---|
| 4990 | + |
---|
4842 | 4991 | cGridBag treePanel; |
---|
| 4992 | + |
---|
4843 | 4993 | JPanel radioPanel; |
---|
4844 | 4994 | ButtonGroup buttonGroup; |
---|
4845 | | - cGridBag ctrlPanel; |
---|
| 4995 | + |
---|
| 4996 | + cGridBag toolboxPanel; |
---|
4846 | 4997 | cGridBag materialPanel; |
---|
| 4998 | + cGridBag ctrlPanel; |
---|
| 4999 | + |
---|
4847 | 5000 | JScrollPane infoPanel; |
---|
| 5001 | + |
---|
4848 | 5002 | cGridBag optionsPanel; |
---|
| 5003 | + |
---|
4849 | 5004 | JTabbedPane objectPanel; |
---|
| 5005 | + boolean materialFlushed; |
---|
| 5006 | + Object3D latestObject; |
---|
| 5007 | + |
---|
4850 | 5008 | cGridBag XYZPanel; |
---|
| 5009 | + |
---|
4851 | 5010 | JSplitPane gridPanel; |
---|
4852 | 5011 | JSplitPane bigPanel; |
---|
| 5012 | + |
---|
4853 | 5013 | cGridBag bigThree; |
---|
4854 | 5014 | cGridBag scenePanel; |
---|
4855 | 5015 | cGridBag centralPanel; |
---|
.. | .. |
---|
4964 | 5124 | cNumberSlider fogField; |
---|
4965 | 5125 | JLabel opacityPowerLabel; |
---|
4966 | 5126 | cNumberSlider opacityPowerField; |
---|
4967 | | - JTree jTree; |
---|
| 5127 | + cTree jTree; |
---|
4968 | 5128 | //ObjectUI parent; |
---|
4969 | 5129 | |
---|
4970 | 5130 | cNumberSlider normalpushField; |
---|