Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModalPane dialog examples are not complete #87

Open
mcantrell opened this issue Mar 13, 2024 · 1 comment
Open

ModalPane dialog examples are not complete #87

mcantrell opened this issue Mar 13, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation sampler

Comments

@mcantrell
Copy link

Some of the snippets have the exact same content. For instance, the positioning sample is exactly the same as the default

image

It's also not clear that the pane needs to be used within a StackPane. Going through the source code for the sampler cleared things up but adding these details to the documentation would help save others some time.

@mrasadatik
Copy link

The documentation for modal pane in atlantaFX could benefit from including more comprehensive examples and potential workarounds. Here's an improved implementation of a ModalPane:

package com.example.modalpane;

import atlantafx.base.controls.ModalPane;
import atlantafx.base.theme.Styles;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.material2.Material2OutlinedAL;

public class App extends Application {
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setWidth(640);
        primaryStage.setHeight(480);
        primaryStage.setMinWidth(320);
        Scene scene = getScene();
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    private static Scene getScene() {
        StackPane root = new StackPane();
        VBox sceneRoot = new VBox();
        ModalPane aboutModalPane = new ModalPane();

        aboutModalPane.setId("aboutModal");
        aboutModalPane.displayProperty().addListener((obs, old, val) -> {
            if (!val) {
                aboutModalPane.setAlignment(Pos.CENTER);
                aboutModalPane.usePredefinedTransitionFactories(null);
            }
        });

        Dialog aboutDialog = new Dialog(300, 300);

        Button aboutDialogOpenBtn = new Button(null, new FontIcon(Material2OutlinedAL.INFO));
        aboutDialogOpenBtn.getStyleClass().addAll(Styles.ROUNDED);
        aboutDialogOpenBtn.setOnAction(evt -> {
            aboutModalPane.show(aboutDialog);
        });

        Button aboutDialogCloseBtn = new Button(null, new FontIcon(Material2OutlinedAL.CLOSE));
        aboutDialogCloseBtn.getStyleClass().addAll(Styles.ROUNDED);
        aboutDialogCloseBtn.setOnAction(evt -> {
            aboutModalPane.hide(true);
        });
        aboutDialog.getChildren().setAll(aboutDialogCloseBtn);

        sceneRoot.getChildren().addAll(aboutDialogOpenBtn);

        root.getChildren().addAll(sceneRoot, aboutModalPane);

        return new Scene(root);
    }

    private static class Dialog extends VBox {

        public Dialog(int width, int height) {
            super();
            setSpacing(10);
            setMinSize(width, height);
            setMaxSize(width, height);
            setStyle("-fx-background-color: -color-bg-default;");
        }
    }
}

@mkpaz mkpaz added documentation Improvements or additions to documentation sampler labels Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation sampler
Projects
None yet
Development

No branches or pull requests

3 participants