Add Icon Material Tab + Hover effects

As material tabs started being in different ways than planned, the code
around them started being a little inconsistent. With this change I hope
to create a new constructor for Icon Tabs (skill calculator, farm timer)
and also add hover effects to them.
This commit is contained in:
psikoi
2018-06-01 00:58:43 +01:00
parent ecd5180a9c
commit e370aa76ef

View File

@@ -24,12 +24,15 @@
*/
package net.runelite.client.ui.components.materialtabs;
import com.google.common.base.Strings;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import lombok.Getter;
@@ -91,6 +94,57 @@ public class MaterialTab extends JLabel
group.select(MaterialTab.this);
}
});
if (!Strings.isNullOrEmpty(string))
{
addMouseListener(new MouseAdapter()
{
@Override
public void mouseEntered(MouseEvent e)
{
MaterialTab tab = (MaterialTab) e.getSource();
tab.setForeground(Color.WHITE);
}
@Override
public void mouseExited(MouseEvent e)
{
MaterialTab tab = (MaterialTab) e.getSource();
if (!tab.isSelected())
{
tab.setForeground(Color.GRAY);
}
}
});
}
}
public MaterialTab(ImageIcon icon, MaterialTabGroup group, JComponent content)
{
this("", group, content);
setIcon(icon);
setOpaque(true);
setVerticalAlignment(SwingConstants.CENTER);
setHorizontalAlignment(SwingConstants.CENTER);
setBackground(ColorScheme.DARKER_GRAY_COLOR);
addMouseListener(new MouseAdapter()
{
@Override
public void mouseEntered(MouseEvent e)
{
MaterialTab tab = (MaterialTab) e.getSource();
tab.setBackground(ColorScheme.DARKER_GRAY_HOVER_COLOR);
}
@Override
public void mouseExited(MouseEvent e)
{
MaterialTab tab = (MaterialTab) e.getSource();
tab.setBackground(ColorScheme.DARKER_GRAY_COLOR);
}
});
}
public void select()