Class SubWindowObject
GUIObject
representing a resizable, movable, and
optionally decorated sub-window within the GUI.
This class manages its own constraints, background rendering, title bar,
and embedded objects (including other SubWindowObject
instances).
It provides functionality for scrolling, layering, and parent-child window
relationships.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SubWindowObject
The absolute top-level parent subwindow in the hierarchy.static final int
Window alignment constant: bottom-center.static final int
Window alignment constant: bottom-left corner.static final int
Window alignment constant: bottom-right corner.static final int
Window alignment constant: absolute center.static final int
Window alignment constant: center-left.static final int
Window alignment constant: center-right.static final int
Window movement type: free (no constraint).protected boolean
Whether this window is nested inside another subwindow.static final int
Window movement type: constrained to parent window.static final int
Layer offset factor for embedded objects.Tracks scroll offsets for scrollable objects within this subwindow.protected int
The original constraint used when nested inside another subwindow.protected SubWindowObject
The immediate parent subwindow, if nested.static final int
Layer offset factor for nested sub-windows.Title text object (only exists if decorated).Title text for the window.static final int
Window alignment constant: top-center.static final int
Window alignment constant: top-left corner.static final int
Window alignment constant: top-right corner.static HashMap
<String, SubWindowObject> Global registry of subwindows by name. -
Constructor Summary
ConstructorsConstructorDescriptionSubWindowObject
(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, Color bkgColor, Color topColor, boolean decorated, boolean resizable, Color titleColor, String title) Creates a new decorated or undecorated subwindow object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds aGUIObject
to this subwindow with a positional constraint.void
addObjectConstraintOffset
(GUIObject o, int offsetX, int offsetY) Adds a constraint offset for the given object within this window.void
Enables drag-based scrolling (click and drag to scroll).void
Enables mouse wheel scrolling within this subwindow.static boolean
Checks whether the given window is free to interact, i.e. no other window is currently dragging or resizing.void
changeConstraint
(GUIObject o, int constraint) Changes the constraint bucket for an existing child and reapplies positioning.void
Destroys this subwindow and all of its children.void
Disables drag-based scrolling.void
Disables mouse wheel scrolling within this subwindow.void
Brings this window to focus, forcing it to the top of the rendering hierarchy.static boolean
Checks whether the given window is free to interact, i.e. no other window is currently dragging or resizing.int
Gets the horizontal scroll offset from drag scrolling.int
Gets the vertical scroll offset from drag scrolling.int
Gets the highest layer value used by this window and its children.int
getHighestLayer
(GUIObject ignore) Gets the highest layer value used by this window and its children, excluding a specific object.int
Returns the current multiplier used for mouse wheel scroll calculations.int
Returns the current accumulated mouse wheel scroll offset for this subwindow.Returns the height of this window's top bar (title bar region).int
Returns the height of this window's top bar (title bar region).boolean
Returns whether this window is currently being dragged.boolean
Returns whether this window is currently being dragged.void
Marks aGUIObject
as scrollable within this subwindow.boolean
Returns whether the current cursor is the "normal" system cursor.void
Removes a child object by name from this subwindow.void
render
(long window, int windowWidth, int windowHeight) Renders the subwindow’s background and borders using its shader.void
Resets the texture ID for this subwindow and all contained child objects, forcing them to reload textures if necessary.void
resize
(int x, int y) Resizes this window object, enforcing minimum (225x225) and maximum bounds based on the current window size.void
sendKey
(int key, int action) Sends a key input event to this window.void
sendMouseButton
(long window, int button, int action, int mods) Sends a mouse button event to this window, handling dragging, resizing, and scroll-drag interactions.void
sendMousePos
(long window, double xPos, double yPos) Sends the current mouse position to this window, updating resize and drag state if applicable.void
sendMouseScroll
(long window, double xOffset, double yOffset) Sends a mouse scroll event to this window, updating scroll offsets if enabled.void
setDragScrollX
(int v) Sets the horizontal scroll offset used when drag scrolling.void
setDragScrollY
(int v) Sets the vertical scroll offset used when drag scrolling.void
setLayer
(int layer) Sets the rendering layer of this window and updates all contained objects to maintain correct z-ordering.void
setMouseScrollMultiplier
(int i) Sets the multiplier applied to mouse wheel scroll offsets.void
setObjectLayerInWindow
(GUIObject o, int layer) Assigns a GUI object to a relative layer within this subwindow.void
setUseMaxScroll
(boolean useMaxScroll, int max) Enables or disables maximum scroll clamping.void
setUseMinScroll
(boolean useMinScroll, int min) Enables or disables minimum scroll clamping.void
setX
(int x) Safely sets this object's X position, constraining it to window bounds and applying parent constraints if necessary.void
setY
(int y) Safely sets this object's Y position, constraining it to window bounds and applying parent constraints if necessary.void
update
(boolean showFrame) Per-frame update for this subwindow.Methods inherited from class com.iragui.objects.GUIObject
allowReTexture, focus, getGlPixelInt, getHFlip, getLayer, getLimitX, getLimitY, getMinX, getMinY, getRotation, getScale, getSizeX, getSizeY, getTextureID, getVFlip, getVisible, getWinLimitX, getWinLimitY, getWinMinX, getWinMinY, getX, getY, hide, includesKeyCallback, includesMouseCallback, interactionInVisibleBounds, isDestroyed, isFocused, isNearestFilter, setAll, setAll, setHFlip, setLimitX, setLimitY, setMinX, setMinY, setNearestFilter, setPixel, setPreserveTextureIDOverride, setRotation, setScale, setTextureID, setVFlip, setVisible, setWinLimitX, setWinLimitY, setWinMinX, setWinMinY, unfocus, updates
-
Field Details
-
TOP_LEFT
public static final int TOP_LEFTWindow alignment constant: top-left corner.- See Also:
-
TOP_CENTER
public static final int TOP_CENTERWindow alignment constant: top-center.- See Also:
-
TOP_RIGHT
public static final int TOP_RIGHTWindow alignment constant: top-right corner.- See Also:
-
CENTER_LEFT
public static final int CENTER_LEFTWindow alignment constant: center-left.- See Also:
-
CENTER
public static final int CENTERWindow alignment constant: absolute center.- See Also:
-
CENTER_RIGHT
public static final int CENTER_RIGHTWindow alignment constant: center-right.- See Also:
-
BOTTOM_LEFT
public static final int BOTTOM_LEFTWindow alignment constant: bottom-left corner.- See Also:
-
BOTTOM_CENTER
public static final int BOTTOM_CENTERWindow alignment constant: bottom-center.- See Also:
-
BOTTOM_RIGHT
public static final int BOTTOM_RIGHTWindow alignment constant: bottom-right corner.- See Also:
-
MOVABLE
public static final int MOVABLEWindow movement type: constrained to parent window.- See Also:
-
FREE
public static final int FREEWindow movement type: free (no constraint).- See Also:
-
OBJECT_LAYER_FACTOR
public static final int OBJECT_LAYER_FACTORLayer offset factor for embedded objects.- See Also:
-
SUBWINDOW_LAYER_FACTOR
public static final int SUBWINDOW_LAYER_FACTORLayer offset factor for nested sub-windows.- See Also:
-
windows
Global registry of subwindows by name. -
objectConstraintOffset
-
insideAnotherSubWindow
protected boolean insideAnotherSubWindowWhether this window is nested inside another subwindow. -
parentWindow
The immediate parent subwindow, if nested. -
absoluteParentWindow
The absolute top-level parent subwindow in the hierarchy. -
title
Title text object (only exists if decorated). -
originalConstraint
protected int originalConstraintThe original constraint used when nested inside another subwindow. -
titleText
Title text for the window.
-
-
Constructor Details
-
SubWindowObject
public SubWindowObject(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, Color bkgColor, Color topColor, boolean decorated, boolean resizable, Color titleColor, String title) Creates a new decorated or undecorated subwindow object.- Parameters:
name
- the subwindow namelayer
- the rendering layergui
- the parent GUI instancex
- initial X positiony
- initial Y positionsizeX
- width of the windowsizeY
- height of the windownearestFilter
- true to use nearest-neighbor filteringrgba
- true if window textures use RGBAbkgColor
- background fill colortopColor
- top bar and border colordecorated
- whether the window has borders and title barresizable
- whether the window can be resizedtitleColor
- font color for the title texttitle
- initial title string
-
-
Method Details
-
getMouseWheelScrollOffset
public int getMouseWheelScrollOffset()Returns the current accumulated mouse wheel scroll offset for this subwindow.- Returns:
- the number of mouse wheel scroll steps
-
allowMouseWheelScroll
public void allowMouseWheelScroll()Enables mouse wheel scrolling within this subwindow. -
disallowMouseWheelScroll
public void disallowMouseWheelScroll()Disables mouse wheel scrolling within this subwindow. -
allowDragScroll
public void allowDragScroll()Enables drag-based scrolling (click and drag to scroll). -
disallowDragScroll
public void disallowDragScroll()Disables drag-based scrolling. -
getDragScrollX
public int getDragScrollX()Gets the horizontal scroll offset from drag scrolling.- Returns:
- the drag scroll X offset
-
getDragScrollY
public int getDragScrollY()Gets the vertical scroll offset from drag scrolling.- Returns:
- the drag scroll Y offset
-
setDragScrollX
public void setDragScrollX(int v) Sets the horizontal scroll offset used when drag scrolling.- Parameters:
v
- the new horizontal offset
-
setDragScrollY
public void setDragScrollY(int v) Sets the vertical scroll offset used when drag scrolling.- Parameters:
v
- the new vertical offset
-
setUseMinScroll
public void setUseMinScroll(boolean useMinScroll, int min) Enables or disables minimum scroll clamping.- Parameters:
useMinScroll
- whether to enforce a minimum scroll offsetmin
- the minimum scroll offset to enforce
-
setUseMaxScroll
public void setUseMaxScroll(boolean useMaxScroll, int max) Enables or disables maximum scroll clamping.- Parameters:
useMaxScroll
- whether to enforce a maximum scroll offsetmax
- the maximum scroll offset to enforce
-
setObjectLayerInWindow
Assigns a GUI object to a relative layer within this subwindow.- Parameters:
o
- the object to re-layerlayer
- the relative layer value
-
render
-
resetTextureID
public void resetTextureID()Resets the texture ID for this subwindow and all contained child objects, forcing them to reload textures if necessary.- Overrides:
resetTextureID
in classGUIObject
-
add
Adds aGUIObject
to this subwindow with a positional constraint.If the object is another
SubWindowObject
, this will properly configure its parent relationships and assign its rendering layer. Non-window objects are placed above the window layer usingOBJECT_LAYER_FACTOR
.- Parameters:
o
- the object to addconstraint
- the constraint constant (e.g.FREE
,TOP_LEFT
, etc.)
-
getMouseWheelScrollMultiplier
public int getMouseWheelScrollMultiplier()Returns the current multiplier used for mouse wheel scroll calculations.- Returns:
- the scroll multiplier
-
setMouseScrollMultiplier
public void setMouseScrollMultiplier(int i) Sets the multiplier applied to mouse wheel scroll offsets.- Parameters:
i
- the new scroll multiplier
-
makeObjectScrollable
-
changeConstraint
Changes the constraint bucket for an existing child and reapplies positioning.This removes
o
from its current internal list and reassigns it to the list forconstraint
, then immediately callsconstrainObject(GUIObject, int)
to update its position and limits. -
remove
Removes a child object by name from this subwindow.This method deletes the reference from internal collections. If the removed object is itself a
SubWindowObject
, its parent/containment flags are reset. This does not callGUIObject.destroyObject()
on the removed object; it only detaches it from this container.- Parameters:
name
- the name of the child object to remove
-
destroyObject
public void destroyObject()Destroys this subwindow and all of its children.Steps performed:
- Unregisters this window from the global
windows
map. - Rebuilds the
windowsByLayer
index. - Resets the cursor on the owning window.
- Calls
GUIObject.destroyObject()
on all child objects and clears internal collections. - Invokes
super.destroyObject()
to release this object’s own resources.
- Overrides:
destroyObject
in classGUIObject
- Unregisters this window from the global
-
update
public void update(boolean showFrame) Per-frame update for this subwindow.Behavior:
- No-op when
showFrame == false
. - Updates title color based on focus state.
- Enables/disables window control buttons depending on focus, dragging, and resizing state.
- If dragging, repositions the window within the screen bounds.
- Re-applies constraints for all child objects each frame.
- Handles clicks on close/minimize (destroys the window).
- Handles maximize/split toggle: maximizes to parent or full window, and restores on split.
- No-op when
-
resize
public void resize(int x, int y) Resizes this window object, enforcing minimum (225x225) and maximum bounds based on the current window size.- Parameters:
x
- new width in pixelsy
- new height in pixels
-
setLayer
-
getHighestLayer
public int getHighestLayer()Gets the highest layer value used by this window and its children.- Returns:
- highest layer index
-
getHighestLayer
Gets the highest layer value used by this window and its children, excluding a specific object.- Parameters:
ignore
- object to ignore- Returns:
- highest layer index without
ignore
-
forceFocus
public void forceFocus()Brings this window to focus, forcing it to the top of the rendering hierarchy. -
sendKey
-
setX
-
setY
-
freeToInteract
Checks whether the given window is free to interact, i.e. no other window is currently dragging or resizing.- Parameters:
o
- subwindow to test- Returns:
true
if free to interact, otherwisefalse
-
anyWindowsInResizeRange
public static boolean anyWindowsInResizeRange()Checks whether the given window is free to interact, i.e. no other window is currently dragging or resizing.- Parameters:
o
- subwindow to test- Returns:
true
if free to interact, otherwisefalse
-
sendMousePos
public void sendMousePos(long window, double xPos, double yPos) Sends the current mouse position to this window, updating resize and drag state if applicable.- Specified by:
sendMousePos
in classGUIObject
-
sendMouseButton
public void sendMouseButton(long window, int button, int action, int mods) Sends a mouse button event to this window, handling dragging, resizing, and scroll-drag interactions.- Specified by:
sendMouseButton
in classGUIObject
-
mouseIsNormal
public boolean mouseIsNormal()Returns whether the current cursor is the "normal" system cursor.- Returns:
true
if cursor is normal, otherwisefalse
-
sendMouseScroll
public void sendMouseScroll(long window, double xOffset, double yOffset) Sends a mouse scroll event to this window, updating scroll offsets if enabled.- Specified by:
sendMouseScroll
in classGUIObject
-
getTopSize
public int getTopSize()Returns the height of this window's top bar (title bar region).- Returns:
- top bar height in pixels
-
getObjectsByName
-
addObjectConstraintOffset
Adds a constraint offset for the given object within this window.- Parameters:
o
- target GUI objectoffsetX
- horizontal offsetoffsetY
- vertical offset
-
isDragging
public boolean isDragging()Returns whether this window is currently being dragged.- Returns:
true
if dragging
-
isResizing
public boolean isResizing()Returns whether this window is currently being dragged.- Returns:
true
if dragging
-