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

added the rest of the glfw cursors to CursorStyle #296

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/main/java/io/wispforest/owo/ui/core/CursorStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,53 @@ public enum CursorStyle {
*/
HAND(GLFW.GLFW_HAND_CURSOR),

/**
* the Crosshair cursor
*/
CROSSHAIR(GLFW.GLFW_CROSSHAIR_CURSOR),

/**
* The cross-shaped cursor which signals
* draggable/movable areas
*/
MOVE(GLFW.GLFW_RESIZE_ALL_CURSOR);
MOVE(GLFW.GLFW_RESIZE_ALL_CURSOR),

/**
* The horizontal resize cursor
* @see #VERTICAL_RESIZE
*/
HORIZONTAL_RESIZE(GLFW.GLFW_HRESIZE_CURSOR),

/**
* The vertical resize cursor
* @see #HORIZONTAL_RESIZE
*/
VERTICAL_RESIZE(GLFW.GLFW_VRESIZE_CURSOR),

/**
* The NorthWest-SouthEast resize cursor
* @see #NESW_RESIZE
*
* @implNote This cursor style is not necessarily supported by all cursor themes
*/
NWSE_RESIZE(GLFW.GLFW_RESIZE_NWSE_CURSOR),

/**
* The NorthEast-SouthWest resize cursor
* @see #NWSE_RESIZE
*
* @implNote This cursor style is not necessarily supported by all cursor themes
*/
NESW_RESIZE(GLFW.GLFW_RESIZE_NESW_CURSOR),


/**
* The Not-Allowed cursor style
*
* @implNote This cursor style is not necessarily supported by all cursor themes
*/
NOT_ALLOWED(GLFW.GLFW_NOT_ALLOWED_CURSOR);


public final int glfw;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/wispforest/owo/ui/util/CursorAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class CursorAdapter {

protected static final CursorStyle[] ACTIVE_STYLES = {CursorStyle.POINTER, CursorStyle.TEXT, CursorStyle.HAND, CursorStyle.MOVE};
protected static final CursorStyle[] ACTIVE_STYLES = {CursorStyle.POINTER, CursorStyle.TEXT, CursorStyle.HAND, CursorStyle.CROSSHAIR, CursorStyle.MOVE, CursorStyle.HORIZONTAL_RESIZE, CursorStyle.VERTICAL_RESIZE, CursorStyle.NWSE_RESIZE, CursorStyle.NESW_RESIZE, CursorStyle.NOT_ALLOWED};

protected final EnumMap<CursorStyle, Long> cursors = new EnumMap<>(CursorStyle.class);
protected final long windowHandle;
Expand Down
22 changes: 22 additions & 0 deletions src/testmod/java/io/wispforest/uwu/client/ComponentTestScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Colors;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
import org.jetbrains.annotations.Nullable;
Expand All @@ -36,6 +37,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.UUID;
import java.util.stream.IntStream;

Expand Down Expand Up @@ -353,6 +355,26 @@ protected void init() {
.positioning(Positioning.relative(50, 100))
);

rootComponent.child(
Containers.verticalFlow(Sizing.content(), Sizing.content())
.child(Components.label(Text.literal("Cursor Tester").withColor(Colors.GRAY))
.tooltip(Text.literal("by chyzman")))
.child(
Components.list(
Arrays.stream(CursorStyle.values()).toList(),
flowLayout -> flowLayout.margins(Insets.bottom(10)),
cursor -> Components.label(Text.literal(cursor.toString()).withColor(Colors.GRAY))
.cursorStyle(cursor)
.margins(Insets.horizontal(3)),
true
)
)
.surface(Surface.PANEL)
.padding(Insets.of(4, 5, 5, 5))
.margins(Insets.bottom(5))
.positioning(Positioning.relative(100, 100))
);

// infinity scroll test
// rootComponent.child(
// Containers.verticalScroll(Sizing.fixed(243), Sizing.fixed(145),
Expand Down
Loading