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
|
protected void startUp() throws Exception
|
||||||
{
|
{
|
||||||
loginButton = NavigationButton.builder()
|
loginButton = NavigationButton.builder()
|
||||||
|
.tab(false)
|
||||||
.icon(LOGIN_IMAGE)
|
.icon(LOGIN_IMAGE)
|
||||||
.tooltip("Login to RuneLite")
|
.tooltip("Login to RuneLite")
|
||||||
.onClick(this::loginClick)
|
.onClick(this::loginClick)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
logoutButton = NavigationButton.builder()
|
logoutButton = NavigationButton.builder()
|
||||||
|
.tab(false)
|
||||||
.icon(LOGOUT_IMAGE)
|
.icon(LOGOUT_IMAGE)
|
||||||
.tooltip("Logout of RuneLite")
|
.tooltip("Logout of RuneLite")
|
||||||
.onClick(this::logoutClick)
|
.onClick(this::logoutClick)
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ public class DiscordPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
discordButton = NavigationButton.builder()
|
discordButton = NavigationButton.builder()
|
||||||
|
.tab(false)
|
||||||
.tooltip("Join Discord")
|
.tooltip("Join Discord")
|
||||||
.icon(icon)
|
.icon(icon)
|
||||||
.onClick(() -> LinkBrowser.browse(properties.getDiscordInvite()))
|
.onClick(() -> LinkBrowser.browse(properties.getDiscordInvite()))
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
titleBarButton = NavigationButton.builder()
|
titleBarButton = NavigationButton.builder()
|
||||||
|
.tab(false)
|
||||||
.tooltip("Take screenshot")
|
.tooltip("Take screenshot")
|
||||||
.icon(iconImage)
|
.icon(iconImage)
|
||||||
.onClick(() -> takeScreenshot(format(new Date())))
|
.onClick(() -> takeScreenshot(format(new Date())))
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import java.awt.Component;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import javax.swing.JToolBar;
|
import javax.swing.JToolBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,6 +42,7 @@ public class ClientPluginToolbar extends JToolBar
|
|||||||
private final Map<NavigationButton, Component> componentMap = new TreeMap<>((a, b) ->
|
private final Map<NavigationButton, Component> componentMap = new TreeMap<>((a, b) ->
|
||||||
ComparisonChain
|
ComparisonChain
|
||||||
.start()
|
.start()
|
||||||
|
.compare(a.isTab(), b.isTab())
|
||||||
.compare(a.getPriority(), b.getPriority())
|
.compare(a.getPriority(), b.getPriority())
|
||||||
.compare(a.getTooltip(), b.getTooltip())
|
.compare(a.getTooltip(), b.getTooltip())
|
||||||
.result());
|
.result());
|
||||||
@@ -78,7 +80,19 @@ public class ClientPluginToolbar extends JToolBar
|
|||||||
private void update()
|
private void update()
|
||||||
{
|
{
|
||||||
removeAll();
|
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();
|
repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ public class NavigationButton
|
|||||||
*/
|
*/
|
||||||
private final BufferedImage icon;
|
private final BufferedImage icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the button is tab or not
|
||||||
|
*/
|
||||||
|
@Builder.Default
|
||||||
|
private boolean tab = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tooltip to show when hovered.
|
* Tooltip to show when hovered.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user