From 47cd0f0a3870d843cb758535316060d30f15c811 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 24 Jun 2019 19:10:13 -0400 Subject: [PATCH] Toolbox + DnD --- ObjEditor.java | 133 +++++++++++++++++++++++++++++++++++++++----- 1 files changed, 117 insertions(+), 16 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index 9be4ae9..fdd2815 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -4,6 +4,7 @@ import java.awt.*; import java.awt.event.*; +import java.awt.image.BufferedImage; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; @@ -37,6 +38,65 @@ JFrame frame; static ObjEditor theFrame; + + cButton GetButton(String name, boolean border) + { + try + { + ImageIcon icon = GetIcon(name); + return new cButton(icon, border); + } + catch (Exception e) + { + return new cButton(name, border); + } + } + + cToggleButton GetToggleButton(String name, boolean border) + { + try + { + ImageIcon icon = GetIcon(name); + return new cToggleButton(icon, border); + } + catch (Exception e) + { + return new cToggleButton(name, border); + } + } + + cCheckBox GetCheckBox(String name, boolean border) + { + try + { + ImageIcon icon = GetIcon(name); + return new cCheckBox(icon, border); + } + catch (Exception e) + { + return new cCheckBox(name, border); + } + } + + private ImageIcon GetIcon(String name) throws IOException + { + BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); + + if (image.getWidth() != 24 && image.getHeight() != 24) + { + BufferedImage resized = new BufferedImage(24, 24, image.getType()); + Graphics2D g = resized.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null); + g.dispose(); + + image = resized; + } + + javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); + return icon; + } // SCRIPT @@ -171,7 +231,7 @@ objEditor.ctrlPanel.remove(setupPanel); objEditor.ctrlPanel.remove(setupPanel2); - objEditor.ctrlPanel.remove(commandsPanel); + objEditor.ctrlPanel.remove(objectCommandsPanel); objEditor.ctrlPanel.remove(pushPanel); //objEditor.ctrlPanel.remove(fillPanel); @@ -327,10 +387,22 @@ toolbarPanel.setName("Toolbar"); treePanel = new cGridBag(); treePanel.setName("Tree"); + + editPanel = new cGridBag().setVertical(true); + editPanel.setName("Edit"); + ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout()); - ctrlPanel.setName("Edit"); + + editCommandsPanel = new cGridBag(); + editPanel.add(editCommandsPanel); + editPanel.add(ctrlPanel); + + toolboxPanel = new cGridBag().setVertical(false); + toolboxPanel.setName("Toolbox"); + materialPanel = new cGridBag().setVertical(true); materialPanel.setName("Material"); + /*JTextPane*/ infoarea = createTextPane(); doc = infoarea.getStyledDocument(); @@ -603,6 +675,8 @@ boolean maximized; + cButton fullscreenLayout; + void Minimize() { frame.setState(Frame.ICONIFIED); @@ -664,7 +738,7 @@ // X frame.getContentPane().add(/*"Center",*/bigThree); framePanel.setDividerLocation(0); - radio.layout = twoButton; + radio.layout = fullscreenLayout; radio.layout.doClick(); //frame.setVisible(true); } @@ -819,10 +893,13 @@ JButton fasterButton; JButton remarkButton; + cGridBag editPanel; + cGridBag editCommandsPanel; + cGridBag namePanel; cGridBag setupPanel; cGridBag setupPanel2; - cGridBag commandsPanel; + cGridBag objectCommandsPanel; cGridBag pushPanel; cGridBag fillPanel; @@ -1035,23 +1112,23 @@ oe.ctrlPanel.add(setupPanel2); oe.ctrlPanel.Return(); - commandsPanel = new cGridBag().setVertical(false); + objectCommandsPanel = new cGridBag().setVertical(false); - resetButton = AddButton(commandsPanel, "Reset"); + resetButton = AddButton(objectCommandsPanel, "Reset"); resetButton.setToolTipText("Jump to frame zero"); - stepButton = AddButton(commandsPanel, "Step"); + stepButton = AddButton(objectCommandsPanel, "Step"); stepButton.setToolTipText("Step one frame"); // resetAllButton = AddButton(oe, "Reset All"); // stepAllButton = AddButton(oe, "Step All"); // Return(); - slowerButton = AddButton(commandsPanel, "Slow"); + slowerButton = AddButton(objectCommandsPanel, "Slow"); slowerButton.setToolTipText("Decrease animation speed"); - fasterButton = AddButton(commandsPanel, "Fast"); + fasterButton = AddButton(objectCommandsPanel, "Fast"); fasterButton.setToolTipText("Increase animation speed"); - remarkButton = AddButton(commandsPanel, "Remark"); + remarkButton = AddButton(objectCommandsPanel, "Remark"); remarkButton.setToolTipText("Set the current transform as the target"); - oe.ctrlPanel.add(commandsPanel); + oe.ctrlPanel.add(objectCommandsPanel); oe.ctrlPanel.Return(); pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons @@ -1335,12 +1412,13 @@ //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //tmp.setName("Edit"); + objectPanel.add(toolboxPanel); objectPanel.add(materialPanel); // JPanel north = new JPanel(new BorderLayout()); // north.setName("Edit"); // north.add(ctrlPanel, BorderLayout.NORTH); // objectPanel.add(north); - objectPanel.add(ctrlPanel); + objectPanel.add(editPanel); objectPanel.add(infoPanel); /* @@ -3396,6 +3474,8 @@ public void Save() { + System.err.println("Save"); + cRadio tab = GetCurrentTab(); boolean temp = CameraPane.SWITCH; @@ -3480,6 +3560,8 @@ public void Undo() { + System.err.println("Undo"); + cRadio tab = GetCurrentTab(); if (tab.undoindex == 0) @@ -3663,7 +3745,7 @@ assert false; } - void EditSelection() + void EditSelection(boolean newWindow) { } @@ -4158,7 +4240,8 @@ void makeSomething(Object3D thing, boolean resetmodel) // deselect) { - Save(); + if (Globals.SAVEONMAKE) // && resetmodel) + Save(); //Tween.set(thing, 0).target(1).start(tweenManager); //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); // if (thing instanceof GenericJointDemo) @@ -4245,6 +4328,12 @@ { ResetModel(); Select(thing.GetTreePath(), true, false); // unselect... false); + + if (thing.Size() == 0) + { + //EditSelection(false); + } + refreshContents(); } @@ -4467,6 +4556,7 @@ if (readobj != null) { + if (Globals.SAVEONMAKE) Save(); try { @@ -4838,18 +4928,29 @@ CheckboxMenuItem togglePaintItem; JSplitPane mainPanel; JScrollPane scrollpane; + JPanel toolbarPanel; + cGridBag treePanel; + JPanel radioPanel; ButtonGroup buttonGroup; - cGridBag ctrlPanel; + + cGridBag toolboxPanel; cGridBag materialPanel; + cGridBag ctrlPanel; + JScrollPane infoPanel; + cGridBag optionsPanel; + JTabbedPane objectPanel; + cGridBag XYZPanel; + JSplitPane gridPanel; JSplitPane bigPanel; + cGridBag bigThree; cGridBag scenePanel; cGridBag centralPanel; @@ -4964,7 +5065,7 @@ cNumberSlider fogField; JLabel opacityPowerLabel; cNumberSlider opacityPowerField; - JTree jTree; + cTree jTree; //ObjectUI parent; cNumberSlider normalpushField; -- Gitblit v1.6.2