mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Performance update restored on FLabel.
This commit is contained in:
@@ -2,6 +2,7 @@ package forge.view.toolbox;
|
|||||||
|
|
||||||
import java.awt.AlphaComposite;
|
import java.awt.AlphaComposite;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
@@ -216,9 +217,14 @@ public class FLabel extends JLabel {
|
|||||||
// Mouse event handler
|
// Mouse event handler
|
||||||
private final MouseAdapter madEvents = new MouseAdapter() {
|
private final MouseAdapter madEvents = new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) { hovered = true; repaint(); }
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
hovered = true; repaintOnlyThisLabel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited(MouseEvent e) { hovered = false; repaint(); }
|
public void mouseExited(MouseEvent e) {
|
||||||
|
hovered = false; repaintOnlyThisLabel();
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (cmdClick != null) { cmdClick.execute(); }
|
if (cmdClick != null) { cmdClick.execute(); }
|
||||||
@@ -241,7 +247,7 @@ public class FLabel extends JLabel {
|
|||||||
// Must be public.
|
// Must be public.
|
||||||
public void setSelected(boolean b0) {
|
public void setSelected(boolean b0) {
|
||||||
this.selected = b0;
|
this.selected = b0;
|
||||||
repaint();
|
repaintOnlyThisLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets alpha if icon is in background.
|
/** Sets alpha if icon is in background.
|
||||||
@@ -315,8 +321,14 @@ public class FLabel extends JLabel {
|
|||||||
super.setOpaque(false);
|
super.setOpaque(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Major performance kicker - won't repaint whole screen! */
|
||||||
|
public void repaintOnlyThisLabel() {
|
||||||
|
final Dimension d = FLabel.this.getSize();
|
||||||
|
repaint(0, 0, d.width, d.height);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
g2d = (Graphics2D) g.create();
|
g2d = (Graphics2D) g.create();
|
||||||
w = getWidth();
|
w = getWidth();
|
||||||
h = getHeight();
|
h = getHeight();
|
||||||
@@ -364,7 +376,6 @@ public class FLabel extends JLabel {
|
|||||||
switch (fontStyle) {
|
switch (fontStyle) {
|
||||||
case Font.BOLD:
|
case Font.BOLD:
|
||||||
setFont(FSkin.getBoldFont((int) (ref * fontScaleFactor)));
|
setFont(FSkin.getBoldFont((int) (ref * fontScaleFactor)));
|
||||||
repaint();
|
|
||||||
break;
|
break;
|
||||||
case Font.ITALIC:
|
case Font.ITALIC:
|
||||||
setFont(FSkin.getItalicFont((int) (ref * fontScaleFactor)));
|
setFont(FSkin.getItalicFont((int) (ref * fontScaleFactor)));
|
||||||
|
|||||||
Reference in New Issue
Block a user