diff --git a/.gitignore b/.gitignore index 3fb00ea..cf94503 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,6 @@ proxy.txt out.txt pocasi.txt test.txt -timecalc.template.conf +timecalc.conf focus.txt dist/* diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperties.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperties.java index 486c061..9480498 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperties.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcProperties.java @@ -32,7 +32,6 @@ public class TimeCalcProperties { try { String defaultConfiguration = Utils.readTextFromTextResourceInJar( "timecalc-default.conf"); - System.out.println("defaultConfiguration=" + defaultConfiguration); Arrays.stream(defaultConfiguration.split("\n")) .filter(l -> !l.trim().isEmpty()) .filter(l -> !l.trim().startsWith("#")) diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java index 78dcc82..97a5269 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/Widget.java @@ -20,6 +20,7 @@ import java.awt.Graphics2D; import java.awt.Image; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; /** * @author Robert Vokac @@ -32,6 +33,7 @@ public class Widget extends JPanel implements protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238); protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24); protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16); + public static final int CLOSE_BUTTON_SIDE = 15; public StringProperty visibilityProperty = new StringProperty("widget.visibilityProperty", @@ -46,17 +48,31 @@ public class Widget extends JPanel implements protected int side = 0; protected double donePercent = 0; protected boolean mouseOver = false; + protected boolean mouseOverCloseButton = false; protected JLabel smileyIcon; public Widget() { setBackground(BACKGROUND_COLOR); new Timer(getTimerDelay(), e -> repaint()).start(); + this.addMouseMotionListener(new MouseMotionListener() { + @Override + public void mouseDragged(MouseEvent e) { + + } + + @Override + public void mouseMoved(MouseEvent e) { + + int x=e.getX(); + int y=e.getY(); + mouseOverCloseButton = x >= getWidth() - CLOSE_BUTTON_SIDE && y <= CLOSE_BUTTON_SIDE; + } + }); addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { - int x=e.getX(); - int y=e.getY(); - if(x >= getWidth() - 15 && y <= 15) { + + if(mouseOverCloseButton) { visibleProperty.setValue(false); return; } @@ -125,14 +141,15 @@ public class Widget extends JPanel implements Visibility.valueOf(visibilityProperty.getValue()); this.setVisible(visibility != Visibility.NONE); paintWidget(brush); - if (mouseOver) { + + if (mouseOver && mouseOverCloseButton) { brush.setColor(SwingUtils.CLOSE_BUTTON_BACKGROUND_COLOR); - brush.fillOval(getWidth() - 15 - 1 ,0 + 1,15,15); + brush.fillOval(getWidth() - CLOSE_BUTTON_SIDE - 1 , 0 + 1,CLOSE_BUTTON_SIDE,CLOSE_BUTTON_SIDE); brush.setColor(Color.LIGHT_GRAY); Graphics2D brush2d = (Graphics2D) brush; brush2d.setStroke(new BasicStroke(2f)); - brush.drawLine(getWidth() - 15 - 1 + 2 ,0 + 1 + 2, getWidth() - 0 * 15 - 1 - 2 ,0 + 15 + 1 - 2); - brush.drawLine(getWidth() - 15 - 1 + 2, 0 + 15 + 1 - 2, getWidth() - 0 * 15 - 1 - 2 ,0 + 1 + 2); + brush.drawLine(getWidth() - CLOSE_BUTTON_SIDE - 1 + 2 ,0 + 1 + 2, getWidth() - 0 * CLOSE_BUTTON_SIDE - 1 - 2 ,0 + CLOSE_BUTTON_SIDE + 1 - 2); + brush.drawLine(getWidth() - CLOSE_BUTTON_SIDE - 1 + 2, 0 + CLOSE_BUTTON_SIDE + 1 - 2, getWidth() - 0 * CLOSE_BUTTON_SIDE - 1 - 2 ,0 + 1 + 2); } } diff --git a/timecalc.conf b/timecalc.conf deleted file mode 100644 index ca0ee5a..0000000 --- a/timecalc.conf +++ /dev/null @@ -1,12 +0,0 @@ -#Thu Feb 29 09:38:02 CET 2024 -commands.visible=true -smileys.colored=true -visibility.default=STRONGLY_COLORED -clock.hands.millisecond.visible=false -visibility.supported.colored=true -jokes.visible=true -clock.hands.second.visible=true -notifications.visible=true -battery.waves.visible=true -clock.hands.minute.visible=true -clock.hands.long.visible=true