Skip to content

Commit

Permalink
Merge pull request #296 from chyzman/cursor-update
Browse files Browse the repository at this point in the history
added the rest of the glfw cursors to CursorStyle
  • Loading branch information
gliscowo authored Sep 15, 2024
2 parents 8b3eed5 + 9d76966 commit d739f6e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
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

0 comments on commit d739f6e

Please sign in to comment.