client: Add option to disable custom window chrome/style

This commit is contained in:
Abex
2018-01-09 17:25:25 -07:00
committed by Adam
parent 81ebc99e99
commit 6a57783541
4 changed files with 66 additions and 23 deletions

View File

@@ -41,6 +41,7 @@ import net.runelite.api.Client;
import net.runelite.client.account.SessionManager;
import net.runelite.client.chat.ChatMessageManager;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.plugins.PluginManager;
import net.runelite.client.ui.ClientUI;
@@ -84,6 +85,9 @@ public class RuneLite
@Inject
private SessionManager sessionManager;
@Inject
private RuneLiteConfig runeliteConfig;
Client client;
ClientUI gui;
Notifier notifier;
@@ -157,6 +161,8 @@ public class RuneLite
// Begin watching for new plugins
pluginManager.watch();
SwingUtilities.invokeAndWait(() -> gui.showWithChrome(runeliteConfig.enableCustomChrome()));
}
public void setGui(ClientUI gui)

View File

@@ -41,6 +41,17 @@ public interface RuneLiteConfig extends Config
return true;
}
@ConfigItem(
keyName = "uiEnableCustomChrome",
name = "Enable custom window chrome",
description = "Use Runelite's custom window title and borders.",
confirmationWarining = "Please restart your client after changing this setting"
)
default boolean enableCustomChrome()
{
return true;
}
@ConfigItem(
keyName = "enablePlugins",
name = "Enable loading of external plugins",

View File

@@ -42,11 +42,13 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.Enumeration;
import javax.imageio.ImageIO;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JRootPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
@@ -65,9 +67,8 @@ import org.pushingpixels.substance.internal.ui.SubstanceRootPaneUI;
@Slf4j
public class ClientUI extends JFrame
{
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 static final int PANEL_EXPANDED_WIDTH = PluginPanel.PANEL_WIDTH + SCROLLBAR_WIDTH;
private static final BufferedImage ICON;
@Getter
@@ -111,9 +112,6 @@ public class ClientUI extends JFrame
// the applet is resized.
System.setProperty("sun.awt.noerasebackground", "true");
// Use custom window decorations
JFrame.setDefaultLookAndFeelDecorated(true);
// Use substance look and feel
try
{
@@ -138,15 +136,31 @@ public class ClientUI extends JFrame
this.trayIcon = setupTrayIcon();
init();
pack();
new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI)this.getRootPane().getUI()).editTitleBar(this);
setTitle(null);
setIconImage(ICON);
// Prevent substance from using a resize cursor for pointing
getLayeredPane().setCursor(Cursor.getDefaultCursor());
setLocationRelativeTo(getOwner());
setResizable(true);
}
public void showWithChrome(boolean customChrome)
{
setUndecorated(customChrome);
if (customChrome)
{
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
}
pack();
revalidateMinimumSize();
setLocationRelativeTo(getOwner());
if (customChrome)
{
new TitleBarPane(this.getRootPane(), (SubstanceRootPaneUI) this.getRootPane().getUI()).editTitleBar(this);
}
setVisible(true);
toFront();
}
private static void setUIFont(FontUIResource f)
@@ -219,7 +233,6 @@ public class ClientUI extends JFrame
assert SwingUtilities.isEventDispatchThread();
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setMinimumSize(new Dimension(CLIENT_WIDTH, 0));
addWindowListener(new WindowAdapter()
{
@Override
@@ -230,41 +243,53 @@ public class ClientUI extends JFrame
});
container = new JPanel();
container.setLayout(new BorderLayout(0, 0));
container.add(new ClientPanel(client), BorderLayout.CENTER);
container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
container.add(new ClientPanel(client));
navContainer = new JPanel();
navContainer.setLayout(new BorderLayout(0, 0));
container.add(navContainer, BorderLayout.EAST);
navContainer.setLayout(new BorderLayout(0,0));
navContainer.setMinimumSize(new Dimension(0,0));
navContainer.setMaximumSize(new Dimension(0,Integer.MAX_VALUE));
container.add(navContainer);
pluginToolbar = new PluginToolbar(this);
navContainer.add(pluginToolbar, BorderLayout.EAST);
container.add(pluginToolbar);
add(container);
}
private void revalidateMinimumSize()
{
// The JFrame only respects minimumSize if it was set by setMinimumSize, for some reason. (atleast on windows/native)
this.setMinimumSize(this.getLayout().minimumLayoutSize(this));
}
void expand(PluginPanel panel)
{
if (pluginPanel != null)
{
navContainer.remove(1);
container.validate();
navContainer.remove(0);
}
pluginPanel = panel;
navContainer.add(wrapPanel(pluginPanel), BorderLayout.WEST);
container.validate();
this.setMinimumSize(new Dimension(EXPANDED_WIDTH, 0));
navContainer.setMinimumSize(new Dimension(PANEL_EXPANDED_WIDTH, 0));
navContainer.setMaximumSize(new Dimension(PANEL_EXPANDED_WIDTH, Integer.MAX_VALUE));
navContainer.add(wrapPanel(pluginPanel));
navContainer.revalidate();
revalidateMinimumSize();
}
void contract()
{
navContainer.remove(1);
container.validate();
this.setMinimumSize(new Dimension(CLIENT_WIDTH, 0));
if (this.getWidth() == EXPANDED_WIDTH)
boolean wasMinimumWidth = this.getWidth() == (int) this.getMinimumSize().getWidth();
navContainer.remove(0);
navContainer.setMinimumSize(new Dimension(0, 0));
navContainer.setMaximumSize(new Dimension(0, Integer.MAX_VALUE));
navContainer.revalidate();
revalidateMinimumSize();
if (wasMinimumWidth)
{
this.setSize(CLIENT_WIDTH, getHeight());
this.setSize((int) this.getMinimumSize().getWidth(), getHeight());
}
pluginPanel = null;
}

View File

@@ -48,6 +48,7 @@ public class PluginToolbar extends JToolBar
super.setSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
super.setMinimumSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
super.setPreferredSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT));
super.setMaximumSize(new Dimension(TOOLBAR_WIDTH, Integer.MAX_VALUE));
}
public void addNavigation(NavigationButton button)