Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PBR light toggle button in Material editor #603

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
Expand All @@ -39,7 +38,6 @@
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
//import org.openide.util.ImageUtilities;
import org.netbeans.api.settings.ConvertAsProperties;
import org.openide.cookies.SaveCookie;
import org.openide.filesystems.FileUtil;
Expand All @@ -50,20 +48,16 @@
import org.openide.windows.CloneableTopComponent;

/**
* Top component which displays something.
* Top component for Material Editor
*/
@ConvertAsProperties(dtd = "-//com.jme3.gde.materials.multiview//MaterialEditor//EN",
autostore = false)
@SuppressWarnings({"unchecked", "rawtypes"})
public final class MaterialEditorTopComponent extends CloneableTopComponent implements MaterialWidgetListener, MaterialChangeProvider {

private static MaterialEditorTopComponent instance;
/** path to the icon used by the component and its open action */
// static final String ICON_PATH = "SET/PATH/TO/ICON/HERE";
private static final String PREFERRED_ID = "MaterialEditorTopComponent";
//private Lookup lookup;
private final InstanceContent lookupContents = new InstanceContent();
// private SaveNode saveNode;
private DataObject dataObject;
private EditableMaterialFile materialFile;
private String materialFileName;
Expand Down Expand Up @@ -444,8 +438,6 @@ public int getPersistenceType() {
@Override
public HelpCtx getHelpCtx() {
HelpCtx ctx = new HelpCtx("sdk.material_editing");
//this call is for single components:
//HelpCtx.setHelpIDString(this, "com.jme3.gde.core.sceneviewer");
return ctx;
}

Expand All @@ -470,11 +462,8 @@ public void componentClosed() {
}

void writeProperties(java.util.Properties p) {
// better to version settings since initial version as advocated at
// http://wiki.apidesign.org/wiki/PropertyFiles
p.setProperty("version", "1.0");
p.setProperty("MaterialFileName", materialFileName);
// TODO store your settings
}

Object readProperties(java.util.Properties p) {
Expand Down Expand Up @@ -530,8 +519,6 @@ public void addAllMaterialChangeListener(List<MaterialChangeListener> listeners)

private class DocumentChangeListener implements DocumentListener {

String newline = "\n";

@Override
public void insertUpdate(DocumentEvent e) {
checkSave();
Expand Down Expand Up @@ -585,21 +572,17 @@ public void setMatDefList(final String[] matDefs, String selected) {
materialFile = null;
jComboBox1.removeAllItems();
jComboBox1.addItem("");
List<String> matDefList = Arrays.asList(matDefs);
List<String> matDefList = new ArrayList<>();
for(String s: matDefs) {
if (!matDefList.contains(s)){
matDefList.add(s);
}
}
Collections.sort(matDefList);
String[] sortedMatDefs = matDefList.toArray(String[]::new);
for (String string : sortedMatDefs) {
jComboBox1.addItem(string);
}

// jComboBox1.addItem("Common/MatDefs/Light/Lighting.j3md");
// jComboBox1.addItem("Common/MatDefs/Misc/Unshaded.j3md");
// jComboBox1.addItem("Common/MatDefs/Misc/Particle.j3md");
// jComboBox1.addItem("Common/MatDefs/Misc/Sky.j3md");
// jComboBox1.addItem("Common/MatDefs/Gui/Gui.j3md");
// jComboBox1.addItem("Common/MatDefs/Terrain/TerrainLighting.j3md");
// jComboBox1.addItem("Common/MatDefs/Terrain/Terrain.j3md");
// jComboBox1.addItem("Common/MatDefs/Misc/ShowNormals.j3md");
jComboBox1.setSelectedItem(selected);
materialFile = prop;
}
Expand Down Expand Up @@ -670,8 +653,8 @@ private void updateProperties() {

private void updateStates() {
for (Component component : statesPanel.getComponents()) {
if (component instanceof MaterialPropertyWidget) {
((MaterialPropertyWidget) component).registerChangeListener(null);
if (component instanceof MaterialPropertyWidget materialPropertyWidget) {
materialPropertyWidget.registerChangeListener(null);
}
}
statesPanel.removeAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@
<Property name="pressedIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="Icons.lightOn" type="code"/>
</Property>
<Property name="selectedIcon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="Icons.lightOn" type="code"/>
</Property>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2023 jMonkeyEngine
* Copyright (c) 2009-2024 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -50,6 +50,7 @@ public class MaterialPreviewWidget extends javax.swing.JPanel {

private boolean init=false;
private MaterialPreviewRenderer matRenderer;

/** Creates new form MaterialPreviewWidget */
public MaterialPreviewWidget() {
initComponents();
Expand Down Expand Up @@ -204,6 +205,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
togglePbrEnvButton.setName("togglePbrEnvButton"); // NOI18N
togglePbrEnvButton.setPreferredSize(new java.awt.Dimension(40, 40));
togglePbrEnvButton.setPressedIcon(Icons.lightOn);
togglePbrEnvButton.setSelectedIcon(Icons.lightOn);
togglePbrEnvButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
togglePbrEnvButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Expand Down
Loading