From 4dbbee4efa0a942394f133fd4a64f3215a7d1811 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 21 Jul 2024 22:41:41 +0200 Subject: [PATCH] Add isClosureRequested() method --- .../sosengine/base/classes/Event.java | 2 ++ .../graphics/opengl/classes/Window.java | 6 ++++ .../sosengine/graphics/classes/Window.java | 31 ++++++++++++------- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/base/src/main/java/de/staropensource/sosengine/base/classes/Event.java b/base/src/main/java/de/staropensource/sosengine/base/classes/Event.java index 7718ea6..b9c066c 100644 --- a/base/src/main/java/de/staropensource/sosengine/base/classes/Event.java +++ b/base/src/main/java/de/staropensource/sosengine/base/classes/Event.java @@ -28,6 +28,8 @@ package de.staropensource.sosengine.base.classes; public interface Event { /** * Calls the event and notifies all annotated methods. + * + * @since v1-alpha0 */ void callEvent(); } diff --git a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java index 8599b95..1a16d70 100644 --- a/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java +++ b/graphics/opengl/src/main/java/de/staropensource/sosengine/graphics/opengl/classes/Window.java @@ -131,6 +131,12 @@ public class Window extends de.staropensource.sosengine.graphics.classes.Window return getPosition(); } + /** {@inheritDoc} */ + @Override + public boolean isClosureRequested() { + return glfwWindowShouldClose(getIdentifierAsLong()); + } + /** * Returns the window identifier as a long. * diff --git a/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/Window.java b/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/Window.java index 85ad79e..0903a68 100644 --- a/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/Window.java +++ b/graphics/src/main/java/de/staropensource/sosengine/graphics/classes/Window.java @@ -329,6 +329,17 @@ public abstract class Window { @Setter private boolean rendering; + /** + * Returns a set of active windows. + * + * @return active windows + * @since v1-alpha2 + */ + @NotNull + public static ImmutableHashSet<@NotNull Window> getWindows() { + return new ImmutableHashSet<>(windows); + } + /** * Creates a new window. * @@ -377,17 +388,6 @@ public abstract class Window { windows.add(this); } - /** - * Returns a set of active windows. - * - * @return active windows - * @since v1-alpha2 - */ - @NotNull - public static ImmutableHashSet<@NotNull Window> getWindows() { - return new ImmutableHashSet<>(windows); - } - /** * Allows the Graphics API to initialize the window. *

@@ -433,6 +433,15 @@ public abstract class Window { @NotNull public abstract Vec2i getPositionWithDecorations(); + /** + * Returns if the user, window manager or + * compositor send a request for the window to close. + * + * @return {@code true} if a window closure has been requested + * @since v1-alpha2 + */ + public abstract boolean isClosureRequested(); + /** * Provides an API for building {@link Window} classes more easily. *