diff --git a/build.gradle b/build.gradle index cafd187..37eb35d 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { mavenCentral() } -def runeLiteVersion = '1.6.10.1' +def runeLiteVersion = '1.6.19' dependencies { compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion @@ -26,7 +26,7 @@ dependencies { } group = 'com.github.zakru.advancednotifications' -version = '1.1' +version = '1.1.1' sourceCompatibility = '1.8' tasks.withType(JavaCompile) { diff --git a/src/main/java/com/github/zakru/advancednotifications/NotificationGroup.java b/src/main/java/com/github/zakru/advancednotifications/NotificationGroup.java index f70ffdd..f8bf723 100644 --- a/src/main/java/com/github/zakru/advancednotifications/NotificationGroup.java +++ b/src/main/java/com/github/zakru/advancednotifications/NotificationGroup.java @@ -12,6 +12,9 @@ public class NotificationGroup extends Notification implements DraggableContaine @Setter private String name = "Group"; @Getter + @Setter + private boolean collapsed = false; + @Getter private final List notifications = new ArrayList<>(); public NotificationGroup(AdvancedNotificationsPlugin plugin) diff --git a/src/main/java/com/github/zakru/advancednotifications/ui/NotificationGroupPanel.java b/src/main/java/com/github/zakru/advancednotifications/ui/NotificationGroupPanel.java index 62150bc..8adb840 100644 --- a/src/main/java/com/github/zakru/advancednotifications/ui/NotificationGroupPanel.java +++ b/src/main/java/com/github/zakru/advancednotifications/ui/NotificationGroupPanel.java @@ -22,6 +22,11 @@ public class NotificationGroupPanel extends NotificationPanel private static final ImageIcon RENAME_ICON; private static final ImageIcon RENAME_HOVER_ICON; + private static final ImageIcon COLLAPSE_ICON; + private static final ImageIcon COLLAPSE_HOVER_ICON; + private static final ImageIcon EXPAND_ICON; + private static final ImageIcon EXPAND_HOVER_ICON; + private final JTextField nameLabel; private final JLabel rename; @@ -36,6 +41,16 @@ public class NotificationGroupPanel extends NotificationPanel = ImageUtil.getResourceStreamFromClass(AdvancedNotificationsPlugin.class, "rename_icon.png"); RENAME_ICON = new ImageIcon(renameIcon); RENAME_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(renameIcon, 0.53f)); + + final BufferedImage collapseIcon + = ImageUtil.getResourceStreamFromClass(AdvancedNotificationsPlugin.class, "collapse_icon.png"); + COLLAPSE_ICON = new ImageIcon(collapseIcon); + COLLAPSE_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(collapseIcon, 0.53f)); + + final BufferedImage expandIcon + = ImageUtil.getResourceStreamFromClass(AdvancedNotificationsPlugin.class, "expand_icon.png"); + EXPAND_ICON = new ImageIcon(expandIcon); + EXPAND_HOVER_ICON = new ImageIcon(ImageUtil.alphaOffset(expandIcon, 0.53f)); } public NotificationGroupPanel(NotificationGroup notification, DraggableContainer container) @@ -152,28 +167,57 @@ public void mouseExited(MouseEvent e) actions.add(new EnabledButton(notification.getPlugin(), notification)); actions.add(deleteButton); + JLabel collapseOrExpand = new JLabel(notification.isCollapsed() ? EXPAND_ICON : COLLAPSE_ICON); + collapseOrExpand.addMouseListener(new MouseAdapter() + { + @Override + public void mousePressed(MouseEvent e) + { + notification.setCollapsed(!notification.isCollapsed()); + notification.getPlugin().updateConfig(); + notification.getPlugin().rebuildPluginPanel(); + } + + @Override + public void mouseEntered(MouseEvent e) + { + collapseOrExpand.setIcon(notification.isCollapsed() ? EXPAND_HOVER_ICON : COLLAPSE_HOVER_ICON); + } + + @Override + public void mouseExited(MouseEvent e) + { + collapseOrExpand.setIcon(notification.isCollapsed() ? EXPAND_ICON : COLLAPSE_ICON); + } + }); + + northPanel.add(collapseOrExpand, BorderLayout.WEST); northPanel.add(nameLabel, BorderLayout.CENTER); northPanel.add(actions, BorderLayout.EAST); - JPanel notificationView = new JPanel(); - notificationView.setLayout(new BoxLayout(notificationView, BoxLayout.Y_AXIS)); - notificationView.setOpaque(false); - notificationView.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + add(northPanel, BorderLayout.NORTH); - int index = 0; - notificationView.add(new DropSpace(plugin, notification, index++)); - for (final Notification notif : notification.getNotifications()) + if (!notification.isCollapsed()) { - NotificationPanel panel = NotificationPanel.buildPanel(notification, notif); - if (panel != null) + JPanel notificationView = new JPanel(); + notificationView.setLayout(new BoxLayout(notificationView, BoxLayout.Y_AXIS)); + notificationView.setOpaque(false); + notificationView.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); + + int index = 0; + notificationView.add(new DropSpace(plugin, notification, index++)); + for (final Notification notif : notification.getNotifications()) { - notificationView.add(panel); - notificationView.add(new DropSpace(plugin, notification, index++)); + NotificationPanel panel = NotificationPanel.buildPanel(notification, notif); + if (panel != null) + { + notificationView.add(panel); + notificationView.add(new DropSpace(plugin, notification, index++)); + } } - } - add(northPanel, BorderLayout.NORTH); - add(notificationView, BorderLayout.CENTER); + add(notificationView, BorderLayout.CENTER); + } } public void resetScroll() diff --git a/src/main/resources/com/github/zakru/advancednotifications/collapse_icon.png b/src/main/resources/com/github/zakru/advancednotifications/collapse_icon.png new file mode 100644 index 0000000..8a65734 Binary files /dev/null and b/src/main/resources/com/github/zakru/advancednotifications/collapse_icon.png differ diff --git a/src/main/resources/com/github/zakru/advancednotifications/expand_icon.png b/src/main/resources/com/github/zakru/advancednotifications/expand_icon.png new file mode 100644 index 0000000..ad4d317 Binary files /dev/null and b/src/main/resources/com/github/zakru/advancednotifications/expand_icon.png differ