From b1d79b74514041a059b454a9f6fc3970773c0cb8 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 12 Aug 2019 18:19:30 -0400 Subject: [PATCH] Compact toolbar. --- GroupEditor.java | 280 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 199 insertions(+), 81 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index d8844d1..1e9db13 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -16,6 +16,7 @@ //import buoy.widget.BFileChooser; class GroupEditor extends ObjEditor implements //iParse, //iCallBack, + Grafreed.iResourceCallBack, ObjectUI, Runnable, ActionListener, @@ -41,6 +42,22 @@ }); } + public void AddTextureButton(String f, String c, final String t, int count, cGridBag row) + { + cButton textureButton; + final String path = "textures/" + f + "/" + c + "/"; // + t; + row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF)); + textureButton.setToolTipText(c + count); + textureButton.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + ChangeTexture(path + t); + } + }); + } + public void AddSkyboxTab0(JTabbedPane skyboxpanel) { cGridBag tab0 = new cGridBag().setVertical(true); @@ -311,14 +328,47 @@ } } - public void ChangeSkybox(String name) + public void ChangeSkybox(String skybox) { //cameraView.envyoff = false; - group.skyboxname = name; + group.skyboxname = skybox; group.skyboxext = "jpg"; cameraView.repaint(); } + + public void CreateSkyboxPanel(cGridBag skyboxPanel) + { + JTabbedPane skyboxpane = new JTabbedPane(); + + AddSkyboxTab0(skyboxpane); + AddSkyboxTab1(skyboxpane); + AddSkyboxTab2(skyboxpane); + AddSkyboxTab3(skyboxpane); + + skyboxPanel.add(skyboxpane); + } + public void ChangeTexture(String texture) + { + for (int i=0; i<group.selection.size(); i++) + { + Object3D obj = group.selection.get(i); + obj.SetPigmentTexture("@" + texture); + } + + refreshContents(); + } + + public void Show3DView() + { + // bug + //gridPanel.setDividerLocation(1.0); + //bigPanel.setDividerLocation(0.0); + bigThree.ClearUI(); + bigThree.add(centralPanel); + bigThree.FlushUI(); + } + //ObjEditor objEditor; public void closeUI2() { @@ -859,6 +909,73 @@ buildToolsMenu(menu); } + JTabbedPane resourcecontainer; + cGridBag currenttab; + boolean added; // patch for jar + + int tabcount = 0; + int colcount = 0; + int rowcount = 0; + int texturecount = 0; + + int columns = 5; + int rows = 7; + + public void ResourceCallBack(String[] path) + { +// for (int i = 0; i < path.length; i++) +// System.out.print(path[i] + "/"); +// System.out.println(); + + if (//rowcount == 0 || + path.length == 1) + { + currenttab = new cGridBag(); + added = false; + String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); + currenttab.setName(tabname); + rowcount = 1; + colcount = 0; + texturecount = 0; + } + + if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg")) + { + if (!added) + { + added = true; + resourcecontainer.add(currenttab); + String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); + resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname); + } + + AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab); + + if (++colcount >= columns) + { + colcount = 0; + currenttab.Return(); + + if (rowcount++ >= rows) + { + rowcount = 0; + } + } + } + else + { +// if (!path[path.length-1].equals("icons")) +// resourcecontainer.Return(); + } + } + + void CreateTexturePanel(cGridBag container) + { + resourcecontainer = new JTabbedPane(JTabbedPane.LEFT); + container.add(resourcecontainer); + + Grafreed.ParseResources("textures", this); + } void SetupUI2(ObjEditor oe) { @@ -877,11 +994,6 @@ //new Exception().printStackTrace(); oe.radioPanel = new JPanel(new GridBagLayout()); - oe.aConstraints.weightx = 1; - oe.aConstraints.weighty = 0; - oe.aConstraints.fill = GridBagConstraints.HORIZONTAL; - oe.aConstraints.gridwidth = 100; - oe.aConstraints.gridheight = 1; // oe.toolbarPanel.add(radioPanel); //, oe.aConstraints); oe.buttonGroup = new ButtonGroup(); @@ -919,6 +1031,45 @@ maxButton.addActionListener(this); } + cButton gcButton; + + oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + gcButton.setToolTipText("Garbage collect"); + gcButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + System.gc(); + } + }); + + oe.toolbarPanel.add(collapseButton = GetButton("icons/collapse.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + collapseButton.setToolTipText("Collapse toolbar"); + collapseButton.addActionListener(this); + + oe.toolbarPanel.add(maximize3DButton = GetButton("", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + maximize3DButton.setToolTipText("Maximize 3D view"); + maximize3DButton.addActionListener(this); + + oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + twoButton.setToolTipText("Show 3D view only"); + twoButton.addActionListener(this); + this.fullscreenLayout = twoButton; + + oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + threeButton.setToolTipText("Show controls and 3D view"); + threeButton.addActionListener(this); + if (Globals.ADVANCED) + { + oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + sixButton.setToolTipText("Show 3D view and controls"); + sixButton.addActionListener(this); + } +// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); +// sevenButton.setToolTipText("3-column layout"); +// sevenButton.addActionListener(this); + // + oe.toolbarPanel.add(fullButton = GetButton("icons/fullscreen.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); fullButton.setToolTipText("Full-screen window"); fullButton.addActionListener(this); @@ -948,12 +1099,12 @@ updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); restoreButton.setToolTipText("Undo (restore current version)"); restoreButton.addActionListener(this); - restoreButton.setEnabled(false); + //restoreButton.setEnabled(false); updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); replaceButton.setToolTipText("Save (replace current version)"); replaceButton.addActionListener(this); - replaceButton.setEnabled(false); + //replaceButton.setEnabled(false); copyOptionsPanel.add(updown); @@ -962,14 +1113,14 @@ nextVersionButton.addActionListener(this); nextVersionButton.setEnabled(false); - oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); - liveCB.setToolTipText("Enable animation"); - liveCB.addItemListener(this); - oe.toolbarPanel.add(oneStepButton = GetButton("icons/step.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); oneStepButton.setToolTipText("Animate one step forward"); oneStepButton.addActionListener(this); + oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); + liveCB.setToolTipText("Enable animation"); + liveCB.addItemListener(this); + oe.toolbarPanel.add(fastCB = GetToggleButton("icons/runfast.png", CameraPane.FAST)); //, constraints); fastCB.setToolTipText("Fast mode"); fastCB.addItemListener(this); @@ -996,21 +1147,6 @@ //oe.toolbarPanel.add(new JSeparator(SwingConstants.VERTICAL)); - oe.toolbarPanel.add(twoButton = GetButton("icons/cube.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - twoButton.setToolTipText("Show 3D view only"); - twoButton.addActionListener(this); - this.fullscreenLayout = twoButton; - - oe.toolbarPanel.add(threeButton = GetButton("icons/controlsview.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - threeButton.setToolTipText("Show controls and 3D view"); - threeButton.addActionListener(this); - oe.toolbarPanel.add(sixButton = GetButton("icons/viewcontrols.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - sixButton.setToolTipText("Show 3D view and controls"); - sixButton.addActionListener(this); -// oe.toolbarPanel.add(sevenButton = new cButton("-|-|-", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); -// sevenButton.setToolTipText("3-column layout"); -// sevenButton.addActionListener(this); - // oe.toolbarPanel.add(rootButton = GetButton("icons/openwindow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); rootButton.setToolTipText("Open selection in new tab"); @@ -1094,19 +1230,15 @@ oe.toolboxPanel.add(row2); - // ENVYMAPS - cGridBag skyboxpane = new cGridBag(); - skyboxpane.preferredHeight = 100; + cGridBag textures = new cGridBag(); - oe.toolboxPanel.add(skyboxpane); + CreateTexturePanel(textures); - JTabbedPane skyboxpanel = new JTabbedPane(); - skyboxpane.add(skyboxpanel); + oe.toolboxPanel.add(textures); - AddSkyboxTab0(skyboxpanel); - AddSkyboxTab1(skyboxpanel); - AddSkyboxTab2(skyboxpanel); - AddSkyboxTab3(skyboxpanel); + textures.preferredHeight = 100; + + CreateSkyboxPanel(oe.skyboxPanel); // EDIT panel editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); @@ -1118,16 +1250,16 @@ uneditButton.addActionListener(this); editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints); - allParamsButton.setToolTipText("Show all controle"); + allParamsButton.setToolTipText("Show all controls"); allParamsButton.addActionListener(this); editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - clearPanelButton.setToolTipText("Clear edit panel"); + clearPanelButton.setToolTipText("Clear all controls"); clearPanelButton.addActionListener(this); - editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - unselectButton.setToolTipText("Unselect"); - unselectButton.addActionListener(this); + //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + //unselectButton.setToolTipText("Unselect"); + //unselectButton.addActionListener(this); editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); flashSelectionButton.setToolTipText("Highlight selection"); @@ -1712,7 +1844,12 @@ TreePath path; public TransferableTreePath(TreePath tp) { - path = tp; + Object[] objs = new Object[tp.getPathCount()]; + for (int i=0; i<objs.length; i++) + { + objs[i] = ((Object3D)tp.getPathComponent(i)).GetUUID(); + } + path = new TreePath(objs); } public synchronized DataFlavor[] getTransferDataFlavors() { @@ -2606,6 +2743,18 @@ { ToggleFullScreen(); } else + if (source == collapseButton) + { + this.expandedLayout = radio.layout; + CollapseToolbar(); + } else + if (source == maximize3DButton) + { + this.expandedLayout = radio.layout; + radio.layout = twoButton; + Show3DView(); + CollapseToolbar(); + } else if (source == previousVersionButton) { // Go to previous version @@ -2617,13 +2766,13 @@ { // Restore current version Restore(); - restoreButton.setEnabled(false); + //restoreButton.setEnabled(false); } else if (source == replaceButton) { // Overwrite current version Replace(); - replaceButton.setEnabled(false); + //replaceButton.setEnabled(false); } else if (source == nextVersionButton) { @@ -3557,38 +3706,7 @@ if (CameraPane.FULLSCREEN) fullscreenLayout = radio.layout; - // bug - //gridPanel.setDividerLocation(1.0); - //bigPanel.setDividerLocation(0.0); -// bigThree.remove(scenePanel); -// bigThree.remove(centralPanel); -// bigThree.remove(XYZPanel); -// aWindowConstraints.gridx = 0; -// aWindowConstraints.gridy = 0; -// aWindowConstraints.gridwidth = 1; -// // aConstraints.gridheight = 3; -// aWindowConstraints.fill = GridBagConstraints.VERTICAL; -// aWindowConstraints.weightx = 0; -// aWindowConstraints.weighty = 1; -// //bigThree.add(jtp, aWindowConstraints); -// aWindowConstraints.weightx = 1; -// aWindowConstraints.gridwidth = 3; -// // aConstraints.gridheight = 3; -// aWindowConstraints.gridx = 1; -// aWindowConstraints.fill = GridBagConstraints.BOTH; -// bigThree.add(centralPanel, aWindowConstraints); -// aWindowConstraints.weightx = 0; -// aWindowConstraints.gridx = 4; -// aWindowConstraints.gridwidth = 1; -// // aConstraints.gridheight = 3; -// aWindowConstraints.fill = GridBagConstraints.VERTICAL; -// //bigThree.add(XYZPanel, aWindowConstraints); -// scenePanel.setVisible(false); -// centralPanel.setVisible(true); -// XYZPanel.setVisible(false); - bigThree.ClearUI(); - bigThree.add(centralPanel); - bigThree.FlushUI(); + Show3DView(); cameraView.requestFocusInWindow(); @@ -5169,7 +5287,7 @@ { editButton.setEnabled(enabled); uneditButton.setEnabled(enabled); - unselectButton.setEnabled(enabled); + //unselectButton.setEnabled(enabled); flashSelectionButton.setEnabled(enabled); clearPanelButton.setEnabled(!listUI.isEmpty()); @@ -5177,7 +5295,7 @@ void refreshContents(boolean cp) { - if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info")) + //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info")) if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING) { objEditor.ClearInfo(); // .GetMaterial()); @@ -5187,7 +5305,7 @@ Object3D child = (Object3D) group.selection.get(i); objEditor.AddInfo(child, this, true); - System.err.println("info : " + child.GetPath()); +// System.err.println("info : " + child.GetPath()); } objEditor.SetText(); // jan 2014 -- Gitblit v1.6.2