Add isTab property to title buttons
In order to differentiate between title and sidebar buttons in sidebar add isTab property that will place them after separator. Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -85,12 +85,14 @@ public class AccountPlugin extends Plugin
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
loginButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.icon(LOGIN_IMAGE)
|
||||
.tooltip("Login to RuneLite")
|
||||
.onClick(this::loginClick)
|
||||
.build();
|
||||
|
||||
logoutButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.icon(LOGOUT_IMAGE)
|
||||
.tooltip("Logout of RuneLite")
|
||||
.onClick(this::logoutClick)
|
||||
|
||||
@@ -95,6 +95,7 @@ public class DiscordPlugin extends Plugin
|
||||
}
|
||||
|
||||
discordButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.tooltip("Join Discord")
|
||||
.icon(icon)
|
||||
.onClick(() -> LinkBrowser.browse(properties.getDiscordInvite()))
|
||||
|
||||
@@ -203,6 +203,7 @@ public class ScreenshotPlugin extends Plugin
|
||||
}
|
||||
|
||||
titleBarButton = NavigationButton.builder()
|
||||
.tab(false)
|
||||
.tooltip("Take screenshot")
|
||||
.icon(iconImage)
|
||||
.onClick(() -> takeScreenshot(format(new Date())))
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.swing.JToolBar;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,7 @@ public class ClientPluginToolbar extends JToolBar
|
||||
private final Map<NavigationButton, Component> componentMap = new TreeMap<>((a, b) ->
|
||||
ComparisonChain
|
||||
.start()
|
||||
.compare(a.isTab(), b.isTab())
|
||||
.compare(a.getPriority(), b.getPriority())
|
||||
.compare(a.getTooltip(), b.getTooltip())
|
||||
.result());
|
||||
@@ -78,7 +80,19 @@ public class ClientPluginToolbar extends JToolBar
|
||||
private void update()
|
||||
{
|
||||
removeAll();
|
||||
componentMap.forEach((key, value) -> add(value));
|
||||
|
||||
final AtomicBoolean isDelimited = new AtomicBoolean(false);
|
||||
componentMap.forEach((key, value) ->
|
||||
{
|
||||
if (!key.isTab() && !isDelimited.get())
|
||||
{
|
||||
isDelimited.set(true);
|
||||
addSeparator();
|
||||
}
|
||||
|
||||
add(value);
|
||||
});
|
||||
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,12 @@ public class NavigationButton
|
||||
*/
|
||||
private final BufferedImage icon;
|
||||
|
||||
/**
|
||||
* If the button is tab or not
|
||||
*/
|
||||
@Builder.Default
|
||||
private boolean tab = true;
|
||||
|
||||
/**
|
||||
* Tooltip to show when hovered.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user