Skip to content

Commit

Permalink
fix: calendar dtail's style
Browse files Browse the repository at this point in the history
  • Loading branch information
teletha committed Dec 31, 2023
1 parent b9c3a9b commit 95ea613
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
28 changes: 16 additions & 12 deletions src/main/java/viewtify/ViewtyDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.function.Supplier;

import javafx.beans.property.DoubleProperty;
import javafx.collections.ObservableList;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Bounds;
Expand Down Expand Up @@ -685,7 +686,7 @@ protected void initialize() {
Window window = pane.getScene().getWindow();
window.focusedProperty().addListener((object, old, focused) -> {
if (!focused) {
hidePopup(window);
hidePopup(window, fadeTime);
}
});
window.addEventHandler(WindowEvent.WINDOW_HIDDEN, e -> {
Expand All @@ -694,20 +695,10 @@ protected void initialize() {
});
}

// /**
// * Close the current popup window.
// */
// public static void hidePopup() {
// if (popupWindow != null) {
// popupWindow.fireEvent(new WindowEvent(popupWindow, WindowEvent.WINDOW_CLOSE_REQUEST));
// popupWindow = null;
// }
// }

/**
* Close the current popup window.
*/
private void hidePopup(Window window) {
private static void hidePopup(Window window, double fadeTime) {
if (window != null) {
popupable = System.currentTimeMillis() + (long) (fadeTime * 1000);
window.fireEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSE_REQUEST));
Expand Down Expand Up @@ -833,6 +824,19 @@ private <V> Variable<V> showAndTell(Dialog<V> dialog, Supplier<V> defaultValue)
}
}

/**
* Close all dialogs.
*/
public static void close() {
ObservableList<Window> windows = Window.getWindows();
for (int i = windows.size() - 1; 0 <= i; i--) {
Window window = windows.get(i);
if (window.getScene().getRoot() instanceof DialogPane) {
hidePopup(window, 0.2);
}
}
}

/**
* Specialized view for dialog.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/viewtify/ui/calendar/Visualizers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import stylist.Style;
import stylist.StyleDSL;
import stylist.value.Color;
import viewtify.ViewtyDialog;
import viewtify.ui.UIHBox;
import viewtify.ui.UILabel;
import viewtify.ui.UserInterfaceProvider;
import viewtify.ui.View;
import viewtify.ui.ViewDSL;
import viewtify.ui.helper.User;

class Visualizers {

Expand Down Expand Up @@ -185,9 +187,11 @@ protected ViewDSL declareUI() {

interface Styles extends StyleDSL {
Style popup = () -> {
padding.size(12, px);
};

Style box = () -> {
display.minWidth(185, px);
padding.bottom(5, px).horizontal(8, px);
};

Expand Down Expand Up @@ -229,7 +233,7 @@ interface Styles extends StyleDSL {
protected void initialize() {
edit.text(FontAwesome.Glyph.PENCIL).tooltip(en("Edit")).enable(event.isEditable());
delete.text(FontAwesome.Glyph.TRASH).tooltip(en("Delete")).enable(event.isEditable());
close.text(FontAwesome.Glyph.CLOSE).tooltip(en("Close"));
close.text(FontAwesome.Glyph.CLOSE).tooltip(en("Close")).when(User.LeftClick, ViewtyDialog::close);
}
}
}
Expand Down

0 comments on commit 95ea613

Please sign in to comment.