Normalize plugin panel display
- Add same padding to each panel - Wrap each panel in JScrollPane - Clean up plugin panel API and set normalized width, height and layout to each panel instead of having to manually specify it for each panel - Make PluginPanel class abstract Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -24,11 +24,12 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.config;
|
||||
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||
import static javax.swing.JOptionPane.YES_OPTION;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
@@ -37,10 +38,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JColorChooser;
|
||||
@@ -50,17 +48,12 @@ import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import static javax.swing.JOptionPane.WARNING_MESSAGE;
|
||||
import static javax.swing.JOptionPane.YES_NO_OPTION;
|
||||
import static javax.swing.JOptionPane.YES_OPTION;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpinnerModel;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.client.config.ConfigDescriptor;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
@@ -71,70 +64,37 @@ import net.runelite.client.ui.PluginPanel;
|
||||
@Slf4j
|
||||
public class ConfigPanel extends PluginPanel
|
||||
{
|
||||
private static final EmptyBorder BORDER_PADDING = new EmptyBorder(6, 6, 6, 6);
|
||||
private static final int TEXT_FIELD_WIDTH = 7;
|
||||
private static final int SPINNER_FIELD_WIDTH = 6;
|
||||
|
||||
private final ConfigManager configManager;
|
||||
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
public ConfigPanel(ConfigManager configManager)
|
||||
{
|
||||
super();
|
||||
this.configManager = configManager;
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
setLayout(new BorderLayout());
|
||||
setVisible(true);
|
||||
populateConfig();
|
||||
}
|
||||
|
||||
public void init()
|
||||
private void populateConfig()
|
||||
{
|
||||
add(createConfigPanel(), BorderLayout.NORTH);
|
||||
}
|
||||
removeAll();
|
||||
add(new JLabel("Plugin Configuration", SwingConstants.CENTER));
|
||||
|
||||
private List<ConfigDescriptor> getConfig()
|
||||
{
|
||||
List<ConfigDescriptor> list = new ArrayList<>();
|
||||
for (Object config : configManager.getConfigProxies())
|
||||
{
|
||||
ConfigDescriptor configDescriptor = configManager.getConfigDescriptor(config);
|
||||
configManager.getConfigProxies().stream()
|
||||
.map(configManager::getConfigDescriptor)
|
||||
.sorted(Comparator.comparing(left -> left.getGroup().name()))
|
||||
.forEach(cd ->
|
||||
{
|
||||
JPanel groupPanel = new JPanel();
|
||||
groupPanel.setLayout(new BorderLayout());
|
||||
JButton viewGroupItemsButton = new JButton(cd.getGroup().name());
|
||||
viewGroupItemsButton.addActionListener(ae -> openGroupConfigPanel(cd, configManager));
|
||||
groupPanel.add(viewGroupItemsButton);
|
||||
add(groupPanel);
|
||||
});
|
||||
|
||||
list.add(configDescriptor);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private JComponent createConfigPanel()
|
||||
{
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBorder(BORDER_PADDING);
|
||||
panel.setLayout(new GridLayout(0, 1, 0, 3));
|
||||
panel.add(new JLabel("Plugin Configuration", SwingConstants.CENTER));
|
||||
|
||||
List<ConfigDescriptor> config = getConfig();
|
||||
|
||||
// Sort by name
|
||||
Comparator<ConfigDescriptor> comparator = (ConfigDescriptor left, ConfigDescriptor right) -> left.getGroup().name().compareTo(right.getGroup().name());
|
||||
config.sort(comparator);
|
||||
|
||||
for (ConfigDescriptor cd : config)
|
||||
{
|
||||
JPanel groupPanel = new JPanel();
|
||||
groupPanel.setLayout(new BorderLayout());
|
||||
JButton viewGroupItemsButton = new JButton(cd.getGroup().name());
|
||||
viewGroupItemsButton.addActionListener(ae -> openGroupConfigPanel(cd, configManager));
|
||||
groupPanel.add(viewGroupItemsButton);
|
||||
panel.add(groupPanel);
|
||||
}
|
||||
|
||||
//Make the panel scrollable
|
||||
scrollPane = new JScrollPane(panel);
|
||||
scrollPane.setBorder(BorderFactory.createEmptyBorder());
|
||||
scrollPane.setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(16); //Otherwise scrollspeed is really slow
|
||||
return scrollPane;
|
||||
revalidate();
|
||||
}
|
||||
|
||||
private void changeConfiguration(JComponent component, ConfigDescriptor cd, ConfigItemDescriptor cid)
|
||||
@@ -186,13 +146,11 @@ public class ConfigPanel extends PluginPanel
|
||||
|
||||
private void openGroupConfigPanel(ConfigDescriptor cd, ConfigManager configManager)
|
||||
{
|
||||
JPanel itemPanel = new JPanel();
|
||||
itemPanel.setBorder(BORDER_PADDING);
|
||||
itemPanel.setLayout(new GridLayout(0, 1, 0, 6));
|
||||
removeAll();
|
||||
String name = cd.getGroup().name() + " Configuration";
|
||||
JLabel title = new JLabel(name);
|
||||
title.setToolTipText(cd.getGroup().description());
|
||||
itemPanel.add(title, SwingConstants.CENTER);
|
||||
add(title, SwingConstants.CENTER);
|
||||
|
||||
for (ConfigItemDescriptor cid : cd.getItems())
|
||||
{
|
||||
@@ -309,24 +267,19 @@ public class ConfigPanel extends PluginPanel
|
||||
item.add(box, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
itemPanel.add(item);
|
||||
add(item);
|
||||
}
|
||||
|
||||
JButton backButton = new JButton("Back");
|
||||
backButton.addActionListener(this::getBackButtonListener);
|
||||
itemPanel.add(backButton);
|
||||
|
||||
removeAll();
|
||||
updateUI();
|
||||
add(itemPanel, BorderLayout.NORTH);
|
||||
add(backButton);
|
||||
revalidate();
|
||||
}
|
||||
|
||||
public void getBackButtonListener(ActionEvent e)
|
||||
{
|
||||
removeAll();
|
||||
updateUI();
|
||||
|
||||
add(scrollPane, BorderLayout.NORTH);
|
||||
populateConfig();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,10 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.devtools;
|
||||
|
||||
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
|
||||
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -43,16 +44,12 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import static net.runelite.api.widgets.WidgetInfo.TO_CHILD;
|
||||
import static net.runelite.api.widgets.WidgetInfo.TO_GROUP;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
|
||||
@Slf4j
|
||||
public class DevToolsPanel extends PluginPanel
|
||||
{
|
||||
private final EmptyBorder PADDING_BORDER = new EmptyBorder(3, 3, 3, 3);
|
||||
|
||||
private JButton renderPlayersBtn = new JButton();
|
||||
private JButton renderNpcsBtn = new JButton();
|
||||
private JButton renderGroundItemsBtn = new JButton();
|
||||
@@ -61,8 +58,6 @@ public class DevToolsPanel extends PluginPanel
|
||||
private JButton renderWallsBtn = new JButton();
|
||||
private JButton renderDecorBtn = new JButton();
|
||||
private JButton renderInventoryBtn = new JButton();
|
||||
private JButton settingsSnapshotBtn = new JButton();
|
||||
private JButton settingsClearBtn = new JButton();
|
||||
|
||||
private JLabel textLbl = new JLabel();
|
||||
private JLabel textColorLbl = new JLabel();
|
||||
@@ -80,26 +75,22 @@ public class DevToolsPanel extends PluginPanel
|
||||
@Inject
|
||||
public DevToolsPanel(@Nullable Client client, DevToolsPlugin plugin)
|
||||
{
|
||||
super();
|
||||
this.client = client;
|
||||
this.plugin = plugin;
|
||||
|
||||
settingsTracker = new SettingsTracker(client);
|
||||
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
setLayout(new BorderLayout());
|
||||
setVisible(true);
|
||||
|
||||
add(createOptionsPanel(), BorderLayout.NORTH);
|
||||
add(createWidgetTreePanel(), BorderLayout.CENTER);
|
||||
final JPanel borderedWrap = new JPanel();
|
||||
borderedWrap.setLayout(new BorderLayout(0, 3));
|
||||
borderedWrap.add(createOptionsPanel(), BorderLayout.NORTH);
|
||||
borderedWrap.add(createWidgetTreePanel(), BorderLayout.CENTER);
|
||||
add(borderedWrap);
|
||||
}
|
||||
|
||||
private JPanel createOptionsPanel()
|
||||
{
|
||||
JPanel container = new JPanel();
|
||||
container.setLayout(new GridLayout(5, 2, 3, 3));
|
||||
container.setBorder(PADDING_BORDER);
|
||||
|
||||
renderPlayersBtn = new JButton("Players");
|
||||
renderPlayersBtn.addActionListener(e ->
|
||||
@@ -165,11 +156,11 @@ public class DevToolsPanel extends PluginPanel
|
||||
});
|
||||
container.add(renderInventoryBtn);
|
||||
|
||||
settingsSnapshotBtn = new JButton("Get Settings");
|
||||
JButton settingsSnapshotBtn = new JButton("Get Settings");
|
||||
settingsSnapshotBtn.addActionListener(settingsTracker::snapshot);
|
||||
container.add(settingsSnapshotBtn);
|
||||
|
||||
settingsClearBtn = new JButton("Clear Settings");
|
||||
JButton settingsClearBtn = new JButton("Clear Settings");
|
||||
settingsClearBtn.addActionListener(settingsTracker::clear);
|
||||
container.add(settingsClearBtn);
|
||||
|
||||
@@ -179,7 +170,7 @@ public class DevToolsPanel extends PluginPanel
|
||||
private JPanel createWidgetTreePanel()
|
||||
{
|
||||
JPanel container = new JPanel();
|
||||
container.setLayout(new BorderLayout());
|
||||
container.setLayout(new BorderLayout(0, 3));
|
||||
|
||||
JTree tree = new JTree(new DefaultMutableTreeNode());
|
||||
tree.setRootVisible(false);
|
||||
@@ -205,7 +196,6 @@ public class DevToolsPanel extends PluginPanel
|
||||
});
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(tree);
|
||||
scrollPane.setBorder(PADDING_BORDER);
|
||||
container.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
JButton refreshWidgetsBtn = new JButton("Refresh Widgets");
|
||||
@@ -217,7 +207,6 @@ public class DevToolsPanel extends PluginPanel
|
||||
|
||||
JPanel btnContainer = new JPanel();
|
||||
btnContainer.setLayout(new BorderLayout());
|
||||
btnContainer.setBorder(PADDING_BORDER);
|
||||
btnContainer.add(refreshWidgetsBtn);
|
||||
container.add(btnContainer, BorderLayout.NORTH);
|
||||
|
||||
|
||||
@@ -24,8 +24,16 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.hiscore;
|
||||
|
||||
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
|
||||
import com.google.common.base.Strings;
|
||||
import java.awt.*;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
@@ -34,14 +42,25 @@ import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
import javax.swing.*;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.MouseInputAdapter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Experience;
|
||||
import net.runelite.client.ui.PluginPanel;
|
||||
import net.runelite.http.api.hiscore.*;
|
||||
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
|
||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
||||
import net.runelite.http.api.hiscore.Skill;
|
||||
|
||||
@Slf4j
|
||||
public class HiscorePanel extends PluginPanel
|
||||
@@ -77,19 +96,13 @@ public class HiscorePanel extends PluginPanel
|
||||
|
||||
public HiscorePanel()
|
||||
{
|
||||
super();
|
||||
|
||||
// Panel "constants"
|
||||
// This was an EtchedBorder, but the style would change when the window was maximized.
|
||||
Border subPanelBorder = BorderFactory.createLineBorder(this.getBackground().brighter(), 2);
|
||||
Insets subPanelInsets = new Insets(2, 4, 2, 4);
|
||||
Font labelFont = UIManager.getFont("Label.font");
|
||||
|
||||
// Setting base panel size
|
||||
Dimension panelSize = new Dimension(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
setMinimumSize(panelSize);
|
||||
setPreferredSize(panelSize);
|
||||
setSize(panelSize);
|
||||
setVisible(true);
|
||||
|
||||
// Create GBL to arrange sub items
|
||||
GridBagLayout gridBag = new GridBagLayout();
|
||||
setLayout(gridBag);
|
||||
@@ -124,7 +137,7 @@ public class HiscorePanel extends PluginPanel
|
||||
c.gridy = 0;
|
||||
c.weightx = 1;
|
||||
c.weighty = 0;
|
||||
c.insets = subPanelInsets;
|
||||
c.insets = new Insets(0, 0, 3, 0);
|
||||
gridBag.setConstraints(inputPanel, c);
|
||||
add(inputPanel);
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.runelite.client.ui.PluginPanel;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashMap;
|
||||
@@ -42,7 +41,6 @@ import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@@ -50,7 +48,6 @@ public class XpPanel extends PluginPanel
|
||||
{
|
||||
private Map<Skill, JPanel> labelMap = new HashMap<>();
|
||||
private final XpTrackerPlugin xpTracker;
|
||||
private JPanel statsPanel;
|
||||
|
||||
@Inject
|
||||
@Nullable
|
||||
@@ -62,15 +59,9 @@ public class XpPanel extends PluginPanel
|
||||
@Inject
|
||||
public XpPanel(XpTrackerPlugin xpTracker)
|
||||
{
|
||||
super();
|
||||
this.xpTracker = xpTracker;
|
||||
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
setVisible(true);
|
||||
statsPanel = new JPanel();
|
||||
statsPanel.setLayout(new GridLayout(24, 1));
|
||||
|
||||
try
|
||||
{
|
||||
for (Skill skill : Skill.values())
|
||||
@@ -90,14 +81,9 @@ public class XpPanel extends PluginPanel
|
||||
}
|
||||
|
||||
JButton resetButton = new JButton("Reset All");
|
||||
resetButton.setPreferredSize(new Dimension(PANEL_WIDTH, 32));
|
||||
resetButton.addActionListener((e) -> executor.execute(this::resetAllSkillXpHr));
|
||||
|
||||
statsPanel.add(resetButton);
|
||||
JScrollPane scroll = new JScrollPane(statsPanel);
|
||||
scroll.add(statsPanel);
|
||||
|
||||
add(statsPanel);
|
||||
resetButton.setPreferredSize(new Dimension(0, 32));
|
||||
add(resetButton);
|
||||
}
|
||||
|
||||
private JButton makeSkillResetButton(Skill skill) throws IOException
|
||||
@@ -114,13 +100,12 @@ public class XpPanel extends PluginPanel
|
||||
BorderLayout borderLayout = new BorderLayout();
|
||||
borderLayout.setHgap(12);
|
||||
JPanel iconLevel = new JPanel(borderLayout);
|
||||
iconLevel.setPreferredSize(new Dimension(PANEL_WIDTH, 32));
|
||||
iconLevel.setPreferredSize(new Dimension(0, 32));
|
||||
|
||||
String skillIcon = "/skill_icons/" + skill.getName().toLowerCase() + ".png";
|
||||
log.debug("Loading skill icon from {}", skillIcon);
|
||||
JLabel icon = new JLabel(new ImageIcon(ImageIO.read(XpPanel.class.getResourceAsStream(skillIcon))));
|
||||
iconLevel.add(icon, BorderLayout.LINE_START);
|
||||
|
||||
iconLevel.add(levelLabel, BorderLayout.CENTER);
|
||||
iconLevel.add(makeSkillResetButton(skill), BorderLayout.LINE_END);
|
||||
|
||||
@@ -131,9 +116,8 @@ public class XpPanel extends PluginPanel
|
||||
{
|
||||
int skillIdx = skill.ordinal();
|
||||
xpTracker.getXpInfos()[skillIdx].reset(client.getSkillExperience(skill));
|
||||
statsPanel.remove(labelMap.get(skill));
|
||||
statsPanel.revalidate();
|
||||
statsPanel.repaint();
|
||||
remove(labelMap.get(skill));
|
||||
revalidate();
|
||||
}
|
||||
|
||||
public void resetAllSkillXpHr()
|
||||
@@ -165,11 +149,10 @@ public class XpPanel extends PluginPanel
|
||||
JLabel xpHr = (JLabel) skillPanel.getComponent(1);
|
||||
xpHr.setText(NumberFormat.getInstance().format(skillXPInfo.getXpHr()) + " xp/hr");
|
||||
|
||||
if (skillPanel.getParent() != statsPanel)
|
||||
if (skillPanel.getParent() != this)
|
||||
{
|
||||
statsPanel.add(skillPanel);
|
||||
statsPanel.revalidate();
|
||||
statsPanel.repaint();
|
||||
add(skillPanel);
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ import java.util.Enumeration;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
@@ -45,9 +47,9 @@ import org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI;
|
||||
@Slf4j
|
||||
public class ClientUI extends JFrame
|
||||
{
|
||||
private static final int PANEL_WIDTH = 809;
|
||||
private static final int PANEL_HEIGHT = 536;
|
||||
private static final int EXPANDED_WIDTH = PANEL_WIDTH + PluginPanel.PANEL_WIDTH;
|
||||
private static final int CLIENT_WIDTH = 809;
|
||||
private static final int SCROLLBAR_WIDTH = 17;
|
||||
private static final int EXPANDED_WIDTH = CLIENT_WIDTH + PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH;
|
||||
|
||||
private final RuneLite runelite;
|
||||
private JPanel container;
|
||||
@@ -92,8 +94,7 @@ public class ClientUI extends JFrame
|
||||
assert SwingUtilities.isEventDispatchThread();
|
||||
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
|
||||
setMinimumSize(new Dimension(CLIENT_WIDTH, 0));
|
||||
addWindowListener(new WindowAdapter()
|
||||
{
|
||||
@Override
|
||||
@@ -140,23 +141,46 @@ public class ClientUI extends JFrame
|
||||
}
|
||||
|
||||
pluginPanel = panel;
|
||||
navContainer.add(pluginPanel, BorderLayout.WEST);
|
||||
navContainer.add(wrapPanel(pluginPanel), BorderLayout.WEST);
|
||||
container.validate();
|
||||
this.setMinimumSize(new Dimension(EXPANDED_WIDTH, PANEL_HEIGHT));
|
||||
this.setMinimumSize(new Dimension(EXPANDED_WIDTH, 0));
|
||||
}
|
||||
|
||||
void contract()
|
||||
{
|
||||
navContainer.remove(1);
|
||||
container.validate();
|
||||
this.setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
|
||||
this.setMinimumSize(new Dimension(CLIENT_WIDTH, 0));
|
||||
if (this.getWidth() == EXPANDED_WIDTH)
|
||||
{
|
||||
this.setSize(PANEL_WIDTH, PANEL_HEIGHT);
|
||||
this.setSize(CLIENT_WIDTH, getHeight());
|
||||
}
|
||||
pluginPanel = null;
|
||||
}
|
||||
|
||||
private JPanel wrapPanel(PluginPanel panel)
|
||||
{
|
||||
final JPanel northPanel = new JPanel();
|
||||
northPanel.setLayout(new BorderLayout());
|
||||
northPanel.add(panel, BorderLayout.NORTH);
|
||||
|
||||
final JScrollPane scrollPane = new JScrollPane(northPanel);
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(16); //Otherwise scrollspeed is really slow
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
final JPanel panelWrap = new JPanel();
|
||||
|
||||
// Adjust the preferred size to expand to width of scrollbar to
|
||||
// to preven scrollbar overlapping over contents
|
||||
panelWrap.setPreferredSize(new Dimension(
|
||||
PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH,
|
||||
0));
|
||||
|
||||
panelWrap.setLayout(new BorderLayout());
|
||||
panelWrap.add(scrollPane, BorderLayout.CENTER);
|
||||
return panelWrap;
|
||||
}
|
||||
|
||||
private void checkExit()
|
||||
{
|
||||
Client client = runelite.getClient();
|
||||
|
||||
@@ -24,9 +24,27 @@
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridLayout;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
public class PluginPanel extends JPanel
|
||||
public abstract class PluginPanel extends JPanel
|
||||
{
|
||||
public static final int PANEL_WIDTH = 225, PANEL_HEIGHT = 503;
|
||||
public static final int PANEL_WIDTH = 225;
|
||||
private static final int OFFSET = 6;
|
||||
private static final EmptyBorder BORDER_PADDING = new EmptyBorder(OFFSET, OFFSET, OFFSET, OFFSET);
|
||||
|
||||
public PluginPanel()
|
||||
{
|
||||
super();
|
||||
setBorder(BORDER_PADDING);
|
||||
setLayout(new GridLayout(0, 1, 0, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize()
|
||||
{
|
||||
return new Dimension(PANEL_WIDTH, super.getPreferredSize().height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user