Merge pull request #6363 from Abextm/chromeless-closer

runelite-client: Use Runescape themed closer for sidebar when overlaying
This commit is contained in:
Abex
2018-11-06 02:05:37 -07:00
committed by GitHub
3 changed files with 19 additions and 35 deletions

View File

@@ -104,16 +104,7 @@ public class ClientUI
private static final String CONFIG_CLIENT_MAXIMIZED = "clientMaximized"; private static final String CONFIG_CLIENT_MAXIMIZED = "clientMaximized";
private static final int CLIENT_WELL_HIDDEN_MARGIN = 160; private static final int CLIENT_WELL_HIDDEN_MARGIN = 160;
private static final int CLIENT_WELL_HIDDEN_MARGIN_TOP = 10; private static final int CLIENT_WELL_HIDDEN_MARGIN_TOP = 10;
public static final BufferedImage ICON; public static final BufferedImage ICON = ImageUtil.getResourceStreamFromClass(ClientUI.class, "/runelite.png");
private static final BufferedImage SIDEBAR_OPEN;
private static final BufferedImage SIDEBAR_CLOSE;
static
{
ICON = ImageUtil.getResourceStreamFromClass(ClientUI.class, "/runelite.png");
SIDEBAR_OPEN = ImageUtil.getResourceStreamFromClass(ClientUI.class, "open.png");
SIDEBAR_CLOSE = ImageUtil.flipImage(SIDEBAR_OPEN, true, false);
}
@Getter @Getter
private TrayIcon trayIcon; private TrayIcon trayIcon;
@@ -127,6 +118,9 @@ public class ClientUI
private final Provider<ClientThread> clientThreadProvider; private final Provider<ClientThread> clientThreadProvider;
private final CardLayout cardLayout = new CardLayout(); private final CardLayout cardLayout = new CardLayout();
private final Rectangle sidebarButtonPosition = new Rectangle(); private final Rectangle sidebarButtonPosition = new Rectangle();
private boolean withTitleBar;
private BufferedImage sidebarOpenIcon;
private BufferedImage sidebarClosedIcon;
private ContainableFrame frame; private ContainableFrame frame;
private JPanel navContainer; private JPanel navContainer;
private PluginPanel pluginPanel; private PluginPanel pluginPanel;
@@ -179,8 +173,7 @@ public class ClientUI
{ {
final NavigationButton navigationButton = event.getButton(); final NavigationButton navigationButton = event.getButton();
final PluginPanel pluginPanel = navigationButton.getPanel(); final PluginPanel pluginPanel = navigationButton.getPanel();
final boolean inTitle = !event.getButton().isTab() && final boolean inTitle = !event.getButton().isTab() && withTitleBar;
(config.enableCustomChrome() || SwingUtil.isCustomTitlePanePresent(frame));
final int iconSize = 16; final int iconSize = 16;
if (pluginPanel != null) if (pluginPanel != null)
@@ -382,7 +375,7 @@ public class ClientUI
mouseManager.registerMouseListener(mouseListener); mouseManager.registerMouseListener(mouseListener);
// Decorate window with custom chrome and titlebar if needed // Decorate window with custom chrome and titlebar if needed
final boolean withTitleBar = config.enableCustomChrome(); withTitleBar = config.enableCustomChrome();
frame.setUndecorated(withTitleBar); frame.setUndecorated(withTitleBar);
if (withTitleBar) if (withTitleBar)
@@ -436,10 +429,14 @@ public class ClientUI
updateFrameConfig(true); updateFrameConfig(true);
// Create hide sidebar button // Create hide sidebar button
sidebarOpenIcon = ImageUtil.getResourceStreamFromClass(ClientUI.class, withTitleBar ? "open.png" : "open_rs.png");
sidebarClosedIcon = ImageUtil.flipImage(sidebarOpenIcon, true, false);
sidebarNavigationButton = NavigationButton sidebarNavigationButton = NavigationButton
.builder() .builder()
.priority(100) .priority(100)
.icon(SIDEBAR_CLOSE) .icon(sidebarClosedIcon)
.onClick(this::toggleSidebar) .onClick(this::toggleSidebar)
.build(); .build();
@@ -618,21 +615,21 @@ public class ClientUI
*/ */
public void paintOverlays(final Graphics2D graphics) public void paintOverlays(final Graphics2D graphics)
{ {
if (!(client instanceof Client) || config.enableCustomChrome()) if (!(client instanceof Client) || withTitleBar)
{ {
return; return;
} }
final Client client = (Client)this.client; final Client client = (Client) this.client;
final int x = client.getRealDimensions().width - SIDEBAR_OPEN.getWidth() - 5; final int x = client.getRealDimensions().width - sidebarOpenIcon.getWidth() - 5;
// Offset sidebar button if resizable mode logout is visible // Offset sidebar button if resizable mode logout is visible
final Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_LOGOUT_BUTTON); final Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_VIEWPORT_BOTTOM_LINE_LOGOUT_BUTTON);
final int y = logoutButton != null && !logoutButton.isHidden() && logoutButton.getParent() != null final int y = logoutButton != null && !logoutButton.isHidden() && logoutButton.getParent() != null
? logoutButton.getHeight() + logoutButton.getRelativeY() + 5 ? logoutButton.getHeight() + logoutButton.getRelativeY()
: 5; : 5;
final BufferedImage image = sidebarOpen ? SIDEBAR_OPEN : SIDEBAR_CLOSE; final BufferedImage image = sidebarOpen ? sidebarOpenIcon : sidebarClosedIcon;
graphics.drawImage(image, x, y, null); graphics.drawImage(image, x, y, null);
// Update button dimensions // Update button dimensions
@@ -663,7 +660,7 @@ public class ClientUI
if (isSidebarOpen) if (isSidebarOpen)
{ {
sidebarNavigationJButton.setIcon(new ImageIcon(SIDEBAR_OPEN)); sidebarNavigationJButton.setIcon(new ImageIcon(sidebarOpenIcon));
sidebarNavigationJButton.setToolTipText("Open SideBar"); sidebarNavigationJButton.setToolTipText("Open SideBar");
contract(); contract();
@@ -673,7 +670,7 @@ public class ClientUI
} }
else else
{ {
sidebarNavigationJButton.setIcon(new ImageIcon(SIDEBAR_CLOSE)); sidebarNavigationJButton.setIcon(new ImageIcon(sidebarClosedIcon));
sidebarNavigationJButton.setToolTipText("Close SideBar"); sidebarNavigationJButton.setToolTipText("Close SideBar");
// Try to restore last panel // Try to restore last panel
@@ -807,7 +804,7 @@ public class ClientUI
} }
frame.setExpandResizeType(config.automaticResizeType()); frame.setExpandResizeType(config.automaticResizeType());
frame.setContainedInScreen(config.containInScreen() && config.enableCustomChrome()); frame.setContainedInScreen(config.containInScreen() && withTitleBar);
if (!config.rememberScreenBounds()) if (!config.rememberScreenBounds())
{ {

View File

@@ -31,7 +31,6 @@ import java.awt.Frame;
import java.awt.Image; import java.awt.Image;
import java.awt.SystemTray; import java.awt.SystemTray;
import java.awt.TrayIcon; import java.awt.TrayIcon;
import java.awt.Window;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
@@ -59,7 +58,6 @@ import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.NavigationButton; import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.components.CustomScrollBarUI; import net.runelite.client.ui.components.CustomScrollBarUI;
import org.pushingpixels.substance.internal.SubstanceSynapse; import org.pushingpixels.substance.internal.SubstanceSynapse;
import org.pushingpixels.substance.internal.utils.SubstanceCoreUtilities;
/** /**
* Various Swing utilities. * Various Swing utilities.
@@ -279,15 +277,4 @@ public class SwingUtil
navigationButton.setOnSelect(button::doClick); navigationButton.setOnSelect(button::doClick);
return button; return button;
} }
/**
* Checks if custom substance title pane is present.
*
* @param frame the parent frame
* @return true if title pane is present
*/
public static boolean isCustomTitlePanePresent(final Window frame)
{
return SubstanceCoreUtilities.getTitlePaneComponent(frame) != null;
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB