.. | .. |
---|
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); |
---|
.. | .. |
---|
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(); |
---|
.. | .. |
---|
337 | 428 | editPanel.add(editCommandsPanel); |
---|
338 | 429 | editPanel.add(ctrlPanel); |
---|
339 | 430 | |
---|
340 | | - materialPanel = new cGridBag().setVertical(true); |
---|
| 431 | + toolboxPanel = new cGridBag().setVertical(false); |
---|
| 432 | + toolboxPanel.setName("Toolbox"); |
---|
341 | 433 | |
---|
| 434 | + materialPanel = new cGridBag().setVertical(true); |
---|
342 | 435 | materialPanel.setName("Material"); |
---|
| 436 | + |
---|
343 | 437 | /*JTextPane*/ |
---|
344 | 438 | infoarea = createTextPane(); |
---|
345 | 439 | doc = infoarea.getStyledDocument(); |
---|
.. | .. |
---|
612 | 706 | |
---|
613 | 707 | boolean maximized; |
---|
614 | 708 | |
---|
| 709 | + cButton fullscreenLayout; |
---|
| 710 | + |
---|
615 | 711 | void Minimize() |
---|
616 | 712 | { |
---|
617 | 713 | frame.setState(Frame.ICONIFIED); |
---|
.. | .. |
---|
637 | 733 | |
---|
638 | 734 | void ToggleFullScreen() |
---|
639 | 735 | { |
---|
640 | | - if (CameraPane.FULLSCREEN) |
---|
| 736 | + cameraView.ToggleFullScreen(); |
---|
| 737 | + |
---|
| 738 | + if (!CameraPane.FULLSCREEN) |
---|
641 | 739 | { |
---|
642 | 740 | device.setFullScreenWindow(null); |
---|
643 | 741 | //frame.setVisible(false); |
---|
.. | .. |
---|
673 | 771 | // X frame.getContentPane().add(/*"Center",*/bigThree); |
---|
674 | 772 | framePanel.setDividerLocation(0); |
---|
675 | 773 | |
---|
676 | | - radio.layout = twoButton; |
---|
| 774 | + radio.layout = fullscreenLayout; |
---|
677 | 775 | radio.layout.doClick(); |
---|
678 | 776 | //frame.setVisible(true); |
---|
679 | 777 | } |
---|
680 | | - |
---|
681 | | - cameraView.ToggleFullScreen(); |
---|
682 | 778 | } |
---|
683 | 779 | |
---|
684 | 780 | private JTextPane createTextPane() |
---|
.. | .. |
---|
819 | 915 | JCheckBox speedupCB; |
---|
820 | 916 | JCheckBox rewindCB; |
---|
821 | 917 | JCheckBox flipVCB; |
---|
| 918 | + |
---|
| 919 | + cCheckBox toggleTextureCB; |
---|
| 920 | + cCheckBox toggleSwitchCB; |
---|
| 921 | + |
---|
822 | 922 | JComboBox texresMenu; |
---|
| 923 | + |
---|
823 | 924 | JButton resetButton; |
---|
824 | 925 | JButton stepButton; |
---|
825 | 926 | JButton stepAllButton; |
---|
.. | .. |
---|
1011 | 1112 | |
---|
1012 | 1113 | oe.ctrlPanel.Return(); |
---|
1013 | 1114 | |
---|
1014 | | - if (!GroupEditor.allparams) |
---|
| 1115 | + if (!allparams) |
---|
1015 | 1116 | return; |
---|
1016 | 1117 | |
---|
1017 | 1118 | setupPanel = new cGridBag().setVertical(false); |
---|
.. | .. |
---|
1354 | 1455 | // objectPanel.add(north); |
---|
1355 | 1456 | objectPanel.add(editPanel); |
---|
1356 | 1457 | objectPanel.add(infoPanel); |
---|
| 1458 | + objectPanel.add(toolboxPanel); |
---|
1357 | 1459 | |
---|
1358 | 1460 | /* |
---|
1359 | 1461 | aConstraints.gridx = 0; |
---|
.. | .. |
---|
1362 | 1464 | aConstraints.gridy += 1; |
---|
1363 | 1465 | aConstraints.gridwidth = 1; |
---|
1364 | 1466 | mainPanel.add(objectPanel, aConstraints); |
---|
1365 | | - */ |
---|
| 1467 | + */ |
---|
1366 | 1468 | |
---|
1367 | 1469 | scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS, |
---|
1368 | 1470 | VERTICAL_SCROLLBAR_AS_NEEDED, |
---|
.. | .. |
---|
1379 | 1481 | JTabbedPane tabbedPane = new JTabbedPane(); |
---|
1380 | 1482 | tabbedPane.add(scrollpane); |
---|
1381 | 1483 | |
---|
1382 | | - tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
1383 | | - |
---|
1384 | | - optionsPanel = new cGridBag().setVertical(true); |
---|
| 1484 | + optionsPanel = new cGridBag().setVertical(false); |
---|
1385 | 1485 | |
---|
1386 | 1486 | optionsPanel.setName("Options"); |
---|
1387 | 1487 | |
---|
.. | .. |
---|
1389 | 1489 | |
---|
1390 | 1490 | tabbedPane.add(optionsPanel); |
---|
1391 | 1491 | |
---|
| 1492 | + tabbedPane.add(FSPane = new cFileSystemPane(this)); |
---|
| 1493 | + |
---|
1392 | 1494 | scenePanel.add(tabbedPane); |
---|
1393 | 1495 | |
---|
1394 | 1496 | /* |
---|
.. | .. |
---|
1481 | 1583 | // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc); |
---|
1482 | 1584 | |
---|
1483 | 1585 | frame.setSize(1280, 860); |
---|
| 1586 | + |
---|
| 1587 | + frame.validate(); |
---|
1484 | 1588 | frame.setVisible(true); |
---|
1485 | 1589 | |
---|
1486 | 1590 | cameraView.requestFocusInWindow(); |
---|
.. | .. |
---|
2800 | 2904 | |
---|
2801 | 2905 | void SetMaterial(Object3D object) |
---|
2802 | 2906 | { |
---|
| 2907 | + latestObject = object; |
---|
| 2908 | + |
---|
2803 | 2909 | cMaterial mat = object.material; |
---|
2804 | 2910 | |
---|
2805 | 2911 | if (mat == null) |
---|
.. | .. |
---|
2985 | 3091 | cameraView.ToggleDL(); |
---|
2986 | 3092 | cameraView.repaint(); |
---|
2987 | 3093 | return; |
---|
2988 | | - } else if (event.getSource() == toggleTextureItem) |
---|
| 3094 | + } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB) |
---|
2989 | 3095 | { |
---|
2990 | 3096 | cameraView.ToggleTexture(); |
---|
2991 | 3097 | // june 2013 copy.HardTouch(); |
---|
.. | .. |
---|
3024 | 3130 | frame.validate(); |
---|
3025 | 3131 | |
---|
3026 | 3132 | return; |
---|
3027 | | - } else if (event.getSource() == toggleSwitchItem) |
---|
| 3133 | + } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB) |
---|
3028 | 3134 | { |
---|
3029 | 3135 | cameraView.ToggleSwitch(); |
---|
3030 | 3136 | cameraView.repaint(); |
---|
.. | .. |
---|
3408 | 3514 | |
---|
3409 | 3515 | public void Save() |
---|
3410 | 3516 | { |
---|
| 3517 | + System.err.println("Save"); |
---|
| 3518 | + |
---|
3411 | 3519 | cRadio tab = GetCurrentTab(); |
---|
3412 | 3520 | |
---|
3413 | 3521 | boolean temp = CameraPane.SWITCH; |
---|
.. | .. |
---|
3429 | 3537 | tab.graphs[i] = null; |
---|
3430 | 3538 | } |
---|
3431 | 3539 | |
---|
| 3540 | + SetUndoStates(); |
---|
| 3541 | + |
---|
3432 | 3542 | // test save |
---|
3433 | 3543 | if (false) |
---|
3434 | 3544 | { |
---|
.. | .. |
---|
3451 | 3561 | |
---|
3452 | 3562 | void CopyChanged(Object3D obj) |
---|
3453 | 3563 | { |
---|
| 3564 | + SetUndoStates(); |
---|
| 3565 | + |
---|
3454 | 3566 | boolean temp = CameraPane.SWITCH; |
---|
3455 | 3567 | CameraPane.SWITCH = false; |
---|
3456 | 3568 | |
---|
.. | .. |
---|
3490 | 3602 | refreshContents(); |
---|
3491 | 3603 | } |
---|
3492 | 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 | + |
---|
3493 | 3616 | public void Undo() |
---|
3494 | 3617 | { |
---|
| 3618 | + System.err.println("Undo"); |
---|
| 3619 | + |
---|
3495 | 3620 | cRadio tab = GetCurrentTab(); |
---|
3496 | 3621 | |
---|
3497 | 3622 | if (tab.undoindex == 0) |
---|
.. | .. |
---|
3675 | 3800 | assert false; |
---|
3676 | 3801 | } |
---|
3677 | 3802 | |
---|
3678 | | - void EditSelection() |
---|
| 3803 | + void EditSelection(boolean newWindow) |
---|
3679 | 3804 | { |
---|
3680 | 3805 | } |
---|
3681 | 3806 | |
---|
.. | .. |
---|
4170 | 4295 | |
---|
4171 | 4296 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4172 | 4297 | { |
---|
4173 | | - Save(); |
---|
| 4298 | + if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4299 | + Save(); |
---|
4174 | 4300 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4175 | 4301 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
4176 | 4302 | // if (thing instanceof GenericJointDemo) |
---|
.. | .. |
---|
4257 | 4383 | { |
---|
4258 | 4384 | ResetModel(); |
---|
4259 | 4385 | Select(thing.GetTreePath(), true, false); // unselect... false); |
---|
| 4386 | + |
---|
| 4387 | + if (thing.Size() == 0) |
---|
| 4388 | + { |
---|
| 4389 | + //EditSelection(false); |
---|
| 4390 | + } |
---|
| 4391 | + |
---|
4260 | 4392 | refreshContents(); |
---|
4261 | 4393 | } |
---|
4262 | 4394 | |
---|
.. | .. |
---|
4479 | 4611 | |
---|
4480 | 4612 | if (readobj != null) |
---|
4481 | 4613 | { |
---|
| 4614 | + if (Globals.SAVEONMAKE) |
---|
4482 | 4615 | Save(); |
---|
4483 | 4616 | try |
---|
4484 | 4617 | { |
---|
.. | .. |
---|
4657 | 4790 | String filename = browser.getFile(); |
---|
4658 | 4791 | if (filename != null && filename.length() > 0) |
---|
4659 | 4792 | { |
---|
| 4793 | + if (!filename.endsWith(".gfd")) |
---|
| 4794 | + filename += ".gfd"; |
---|
4660 | 4795 | lastname = browser.getDirectory() + filename; |
---|
4661 | 4796 | save(); |
---|
4662 | 4797 | } |
---|
.. | .. |
---|
4850 | 4985 | CheckboxMenuItem togglePaintItem; |
---|
4851 | 4986 | JSplitPane mainPanel; |
---|
4852 | 4987 | JScrollPane scrollpane; |
---|
| 4988 | + |
---|
4853 | 4989 | JPanel toolbarPanel; |
---|
| 4990 | + |
---|
4854 | 4991 | cGridBag treePanel; |
---|
| 4992 | + |
---|
4855 | 4993 | JPanel radioPanel; |
---|
4856 | 4994 | ButtonGroup buttonGroup; |
---|
4857 | | - cGridBag ctrlPanel; |
---|
| 4995 | + |
---|
| 4996 | + cGridBag toolboxPanel; |
---|
4858 | 4997 | cGridBag materialPanel; |
---|
| 4998 | + cGridBag ctrlPanel; |
---|
| 4999 | + |
---|
4859 | 5000 | JScrollPane infoPanel; |
---|
| 5001 | + |
---|
4860 | 5002 | cGridBag optionsPanel; |
---|
| 5003 | + |
---|
4861 | 5004 | JTabbedPane objectPanel; |
---|
| 5005 | + boolean materialFlushed; |
---|
| 5006 | + Object3D latestObject; |
---|
| 5007 | + |
---|
4862 | 5008 | cGridBag XYZPanel; |
---|
| 5009 | + |
---|
4863 | 5010 | JSplitPane gridPanel; |
---|
4864 | 5011 | JSplitPane bigPanel; |
---|
| 5012 | + |
---|
4865 | 5013 | cGridBag bigThree; |
---|
4866 | 5014 | cGridBag scenePanel; |
---|
4867 | 5015 | cGridBag centralPanel; |
---|
.. | .. |
---|
4976 | 5124 | cNumberSlider fogField; |
---|
4977 | 5125 | JLabel opacityPowerLabel; |
---|
4978 | 5126 | cNumberSlider opacityPowerField; |
---|
4979 | | - JTree jTree; |
---|
| 5127 | + cTree jTree; |
---|
4980 | 5128 | //ObjectUI parent; |
---|
4981 | 5129 | |
---|
4982 | 5130 | cNumberSlider normalpushField; |
---|