mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Increase height of titlebar and size of minimize, maximize, and close icons
Fix so minimize, maximize, and close buttons allow clicking very top of screen and allow canceling click by moving mouse away before releasing
This commit is contained in:
@@ -42,7 +42,7 @@ public class FTitleBar extends JMenuBar {
|
|||||||
public FTitleBar(FFrame f) {
|
public FTitleBar(FFrame f) {
|
||||||
this.frame = f;
|
this.frame = f;
|
||||||
f.setJMenuBar(this);
|
f.setJMenuBar(this);
|
||||||
setPreferredSize(new Dimension(f.getWidth(), 22));
|
setPreferredSize(new Dimension(f.getWidth(), 26));
|
||||||
setLayout(this.layout);
|
setLayout(this.layout);
|
||||||
FSkin.get(this).setBackground(backColor);
|
FSkin.get(this).setBackground(backColor);
|
||||||
setTitle(f.getTitle()); //set default title based on frame title
|
setTitle(f.getTitle()); //set default title based on frame title
|
||||||
@@ -52,11 +52,11 @@ public class FTitleBar extends JMenuBar {
|
|||||||
|
|
||||||
add(lblTitle);
|
add(lblTitle);
|
||||||
layout.putConstraint(SpringLayout.WEST, lblTitle, 1, SpringLayout.WEST, this);
|
layout.putConstraint(SpringLayout.WEST, lblTitle, 1, SpringLayout.WEST, this);
|
||||||
layout.putConstraint(SpringLayout.NORTH, lblTitle, 2, SpringLayout.NORTH, this);
|
layout.putConstraint(SpringLayout.NORTH, lblTitle, 4, SpringLayout.NORTH, this);
|
||||||
|
|
||||||
add(btnClose);
|
add(btnClose);
|
||||||
layout.putConstraint(SpringLayout.EAST, btnClose, 0, SpringLayout.EAST, this);
|
layout.putConstraint(SpringLayout.EAST, btnClose, 0, SpringLayout.EAST, this);
|
||||||
layout.putConstraint(SpringLayout.NORTH, btnClose, 1, SpringLayout.NORTH, this);
|
layout.putConstraint(SpringLayout.NORTH, btnClose, 0, SpringLayout.NORTH, this);
|
||||||
|
|
||||||
add(btnMaximize);
|
add(btnMaximize);
|
||||||
layout.putConstraint(SpringLayout.EAST, btnMaximize, 0, SpringLayout.WEST, btnClose);
|
layout.putConstraint(SpringLayout.EAST, btnMaximize, 0, SpringLayout.WEST, btnClose);
|
||||||
@@ -105,7 +105,7 @@ public class FTitleBar extends JMenuBar {
|
|||||||
private boolean pressed, hovered;
|
private boolean pressed, hovered;
|
||||||
|
|
||||||
private TitleBarButton() {
|
private TitleBarButton() {
|
||||||
setPreferredSize(new Dimension(19, 19));
|
setPreferredSize(new Dimension(25, 25));
|
||||||
addMouseListener(new MouseAdapter() {
|
addMouseListener(new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
@@ -119,11 +119,13 @@ public class FTitleBar extends JMenuBar {
|
|||||||
if (SwingUtilities.isLeftMouseButton(e)) {
|
if (SwingUtilities.isLeftMouseButton(e)) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
pressed = false;
|
pressed = false;
|
||||||
|
if (hovered) { //only handle click if mouse released over button
|
||||||
repaintSelf();
|
repaintSelf();
|
||||||
onClick();
|
onClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent e) {
|
public void mouseEntered(MouseEvent e) {
|
||||||
hovered = true;
|
hovered = true;
|
||||||
@@ -147,17 +149,19 @@ public class FTitleBar extends JMenuBar {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
|
if (hovered) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
skin.setGraphicsColor(g, buttonDownColor);
|
skin.setGraphicsColor(g, buttonDownColor);
|
||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
g.fillRect(0, 0, getWidth(), getHeight());
|
||||||
g.translate(1, 1); //translate icon to give pressed button look
|
g.translate(1, 1); //translate icon to give pressed button look
|
||||||
}
|
}
|
||||||
else if (hovered) {
|
else {
|
||||||
skin.setGraphicsColor(g, buttonHoverColor);
|
skin.setGraphicsColor(g, buttonHoverColor);
|
||||||
g.fillRect(0, 0, getWidth(), getHeight());
|
g.fillRect(0, 0, getWidth(), getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class MinimizeButton extends TitleBarButton {
|
public class MinimizeButton extends TitleBarButton {
|
||||||
private MinimizeButton() {
|
private MinimizeButton() {
|
||||||
@@ -172,10 +176,11 @@ public class FTitleBar extends JMenuBar {
|
|||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
int thickness = 2;
|
int thickness = 2;
|
||||||
int offset = 6;
|
int offsetX = 8;
|
||||||
int x1 = offset;
|
int offsetY = 7;
|
||||||
int x2 = getWidth() - offset;
|
int x1 = offsetX;
|
||||||
int y = getHeight() - offset - thickness;
|
int x2 = getWidth() - offsetX;
|
||||||
|
int y = getHeight() - offsetY - thickness;
|
||||||
|
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
skin.setGraphicsColor(g2d, foreColor);
|
skin.setGraphicsColor(g2d, foreColor);
|
||||||
@@ -197,8 +202,8 @@ public class FTitleBar extends JMenuBar {
|
|||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
int thickness = 2;
|
int thickness = 2;
|
||||||
int offsetX = 5;
|
int offsetX = 7;
|
||||||
int offsetY = 6;
|
int offsetY = 8;
|
||||||
int x = offsetX;
|
int x = offsetX;
|
||||||
int y = offsetY;
|
int y = offsetY;
|
||||||
int width = getWidth() - 2 * offsetX;
|
int width = getWidth() - 2 * offsetX;
|
||||||
@@ -244,7 +249,7 @@ public class FTitleBar extends JMenuBar {
|
|||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
||||||
int thickness = 2;
|
int thickness = 2;
|
||||||
int offset = 6;
|
int offset = 7;
|
||||||
int x1 = offset;
|
int x1 = offset;
|
||||||
int y1 = offset;
|
int y1 = offset;
|
||||||
int x2 = getWidth() - offset - 1;
|
int x2 = getWidth() - offset - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user