mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Use same border for hovered and selected items
This commit is contained in:
@@ -766,23 +766,16 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
|||||||
private void drawItemImage(Graphics2D g, ItemInfo itemInfo) {
|
private void drawItemImage(Graphics2D g, ItemInfo itemInfo) {
|
||||||
Rectangle bounds = itemInfo.getBounds();
|
Rectangle bounds = itemInfo.getBounds();
|
||||||
final int itemWidth = bounds.width;
|
final int itemWidth = bounds.width;
|
||||||
final int selBorderSize = Math.max(1, Math.round(itemWidth * GAP_SCALE_FACTOR / 2) - 1);
|
final int selBorderSize = 1;
|
||||||
final int borderSize = Math.round(itemWidth * CardPanel.BLACK_BORDER_SIZE);
|
final int borderSize = Math.round(itemWidth * CardPanel.BLACK_BORDER_SIZE);
|
||||||
final int cornerSize = Math.max(4, Math.round(itemWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
final int cornerSize = Math.max(4, Math.round(itemWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||||
|
|
||||||
if (itemInfo.selected) {
|
if (itemInfo.selected || itemInfo == hoveredItem) {
|
||||||
g.setColor(Color.green);
|
g.setColor(Color.green);
|
||||||
g.fillRoundRect(bounds.x - selBorderSize, bounds.y - selBorderSize,
|
g.fillRoundRect(bounds.x - selBorderSize, bounds.y - selBorderSize,
|
||||||
bounds.width + 2 * selBorderSize, bounds.height + 2 * selBorderSize,
|
bounds.width + 2 * selBorderSize, bounds.height + 2 * selBorderSize,
|
||||||
cornerSize + selBorderSize, cornerSize + selBorderSize);
|
cornerSize + selBorderSize, cornerSize + selBorderSize);
|
||||||
}
|
}
|
||||||
else if (itemInfo == hoveredItem) {
|
|
||||||
int hoverBorderSize = Math.max(1, selBorderSize / 2);
|
|
||||||
g.setColor(Color.green);
|
|
||||||
g.fillRoundRect(bounds.x - hoverBorderSize, bounds.y - hoverBorderSize,
|
|
||||||
bounds.width + 2 * hoverBorderSize, bounds.height + 2 * hoverBorderSize,
|
|
||||||
cornerSize + hoverBorderSize, cornerSize + hoverBorderSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
g.setColor(Color.black);
|
g.setColor(Color.black);
|
||||||
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, cornerSize, cornerSize);
|
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, cornerSize, cornerSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user