Module org.snapfx

Class DockFloatingWindow

java.lang.Object
org.snapfx.floating.DockFloatingWindow

public final class DockFloatingWindow extends Object
Represents an external floating window that can host a full dock-layout subtree.

Floating windows support dock-node interactions similar to the main host: split/tab drops, context actions, optional snapping, and attach-back workflows.

Programmatic example:


 DockFloatingWindow floating = new DockFloatingWindow(node, dragService);
 floating.setOnAttachRequested(() -> snapFX.attachFloatingWindow(floating));
 floating.show(primaryStage);
 
  • Constructor Details

    • DockFloatingWindow

      public DockFloatingWindow(DockNode dockNode)
      Creates a floating window from one dock node using default title prefix and drag service.
      Parameters:
      dockNode - initial dock node shown in the floating window
    • DockFloatingWindow

      public DockFloatingWindow(DockNode dockNode, DockDragService dragService)
      Creates a floating window from one dock node using default title prefix.
      Parameters:
      dockNode - initial dock node shown in the floating window
      dragService - drag service used for floating-scene drag and drop interactions
    • DockFloatingWindow

      public DockFloatingWindow(DockNode dockNode, String titlePrefix)
      Creates a floating window from one dock node and custom title prefix.
      Parameters:
      dockNode - initial dock node shown in the floating window
      titlePrefix - title prefix used for generated floating-window titles
    • DockFloatingWindow

      public DockFloatingWindow(DockNode dockNode, String titlePrefix, DockDragService dragService)
      Creates a floating window from one dock node and custom wiring.
      Parameters:
      dockNode - initial dock node shown in the floating window
      titlePrefix - title prefix used for generated floating-window titles
      dragService - drag service used for floating-scene drag and drop interactions
    • DockFloatingWindow

      public DockFloatingWindow(DockElement floatingRoot, DockDragService dragService)
      Creates a floating window from an existing layout subtree.
      Parameters:
      floatingRoot - layout subtree used as floating root
      dragService - drag service used for floating-scene drag and drop interactions
    • DockFloatingWindow

      public DockFloatingWindow(DockElement floatingRoot, String titlePrefix, DockDragService dragService)
      Creates a floating window from an existing layout subtree with custom title prefix.
      Parameters:
      floatingRoot - layout subtree used as floating root
      titlePrefix - title prefix used for generated floating-window titles
      dragService - drag service used for floating-scene drag and drop interactions
  • Method Details

    • getId

      public String getId()
      Returns the stable floating-window ID.
      Returns:
      floating-window ID
    • getDockNode

      public DockNode getDockNode()
      Returns the representative dock node used for title/icon fallbacks.
      Returns:
      representative dock node
    • getDockGraph

      public DockGraph getDockGraph()
      Returns the dock graph hosted by this floating window.
      Returns:
      floating dock graph
    • getDockNodes

      public List<DockNode> getDockNodes()
      Returns all dock nodes currently contained in this floating window.
      Returns:
      contained dock nodes
    • containsNode

      public boolean containsNode(DockNode node)
      Returns whether the provided node is part of this floating window.
      Parameters:
      node - node to check
      Returns:
      true when the node is contained
    • isEmpty

      public boolean isEmpty()
      Returns whether this floating window has no layout root.
      Returns:
      true when the floating graph root is null
    • isShowing

      public boolean isShowing()
      Returns whether the underlying stage is currently visible.
      Returns:
      true when the floating stage is showing
    • getScene

      public javafx.scene.Scene getScene()
      Returns the current scene of this floating window, or null when not shown.
      Returns:
      floating window scene, or null
    • ownsScene

      public boolean ownsScene(javafx.scene.Scene scene)
      Returns whether the given scene belongs to this floating window.
      Parameters:
      scene - scene to check
      Returns:
      true when the scene belongs to this floating window
    • containsScreenPoint

      public boolean containsScreenPoint(double screenX, double screenY)
      Returns whether the given screen-space point hits this floating window content.
      Parameters:
      screenX - screen x-coordinate
      screenY - screen y-coordinate
      Returns:
      true when the point is inside this floating scene
    • toFront

      public void toFront()
      Brings this floating window to the foreground.
    • setPreferredPosition

      public void setPreferredPosition(Double screenX, Double screenY)
      Updates the preferred screen position used for initial show/restore.
      Parameters:
      screenX - preferred screen x-coordinate, or null
      screenY - preferred screen y-coordinate, or null
    • setPreferredSize

      public void setPreferredSize(double width, double height)
      Updates the preferred floating window size.
      Parameters:
      width - preferred width (applied when > 0)
      height - preferred height (applied when > 0)
    • getPreferredX

      public Double getPreferredX()
      Returns the preferred screen x-coordinate.
      Returns:
      preferred screen x-coordinate, or null
    • getPreferredY

      public Double getPreferredY()
      Returns the preferred screen y-coordinate.
      Returns:
      preferred screen y-coordinate, or null
    • getPreferredWidth

      public double getPreferredWidth()
      Returns the preferred floating width.
      Returns:
      preferred width in pixels
    • getPreferredHeight

      public double getPreferredHeight()
      Returns the preferred floating height.
      Returns:
      preferred height in pixels
    • captureCurrentBounds

      public void captureCurrentBounds()
      Captures current stage bounds into preferred restore values.
    • show

      public void show(javafx.stage.Stage ownerStage)
      Shows this floating window and rebuilds its layout.
      Parameters:
      ownerStage - optional owner stage
    • close

      public void close()
      Requests closing this floating window, respecting lock and close callbacks.
    • closeWithoutNotification

      public void closeWithoutNotification()
      Closes this floating window without emitting close notifications.
    • setOnAttachRequested

      public void setOnAttachRequested(Runnable onAttachRequested)
      Sets the callback invoked when the user requests "attach to layout".
      Parameters:
      onAttachRequested - attach callback, or null
    • setOnWindowClosed

      public void setOnWindowClosed(Consumer<DockFloatingWindow> onWindowClosed)
      Sets the callback invoked when this floating window is closed.
      Parameters:
      onWindowClosed - close callback, or null
    • setOnWindowActivated

      public void setOnWindowActivated(Runnable onWindowActivated)
      Sets the callback invoked when this floating window becomes active.
      Parameters:
      onWindowActivated - activation callback, or null
    • setOnCloseRequested

      public void setOnCloseRequested(BooleanSupplier onCloseRequested)
      Sets the callback used to veto or allow floating-window close requests.
      Parameters:
      onCloseRequested - callback returning close permission, or null
    • setOnNodeCloseRequest

      public void setOnNodeCloseRequest(BiConsumer<DockNode,DockCloseSource> onNodeCloseRequest)
      Sets the callback for close requests initiated by inner dock nodes.
      Parameters:
      onNodeCloseRequest - callback receiving node + close source, or null
    • setOnNodeFloatRequest

      public void setOnNodeFloatRequest(Consumer<DockNode> onNodeFloatRequest)
      Sets the callback for float requests initiated by inner dock nodes.
      Parameters:
      onNodeFloatRequest - callback receiving the requested node, or null
    • setOnNodePinToSideBarRequest

      public void setOnNodePinToSideBarRequest(BiConsumer<DockNode,javafx.geometry.Side> onNodePinToSideBarRequest)
      Sets a callback used by inner dock-node context menus to move nodes into a SnapFX sidebar.
      Parameters:
      onNodePinToSideBarRequest - callback receiving node and target side, or null
    • setSnappingEnabled

      public void setSnappingEnabled(boolean enabled)
      Enables or disables snapping while dragging the floating window title bar.
      Parameters:
      enabled - true to enable snapping
    • isSnappingEnabled

      public boolean isSnappingEnabled()
      Returns whether drag snapping is enabled.
      Returns:
      true when snapping is enabled
    • setSnapDistance

      public void setSnapDistance(double pixels)
      Sets the snap distance in pixels.
      Parameters:
      pixels - snap tolerance in pixels (must be finite and >= 0)
    • getSnapDistance

      public double getSnapDistance()
      Returns the snap distance in pixels.
      Returns:
      snap tolerance in pixels
    • setSnapTargets

      public void setSnapTargets(Set<DockFloatingSnapTarget> targets)
      Configures which snap targets are considered during drag.
      Parameters:
      targets - configured snap targets, null clears all targets
    • getSnapTargets

      public Set<DockFloatingSnapTarget> getSnapTargets()
      Returns the configured snap targets.
      Returns:
      immutable snapshot of configured snap targets
    • setSnapPeerWindowsSupplier

      public void setSnapPeerWindowsSupplier(Supplier<List<DockFloatingWindow>> supplier)
      Sets the supplier used to resolve other floating windows for snapping.
      Parameters:
      supplier - supplier returning candidate peer floating windows, or null
    • isAlwaysOnTop

      public boolean isAlwaysOnTop()
      Returns whether the window is currently configured as always-on-top.
      Returns:
      true when always-on-top is enabled
    • setAlwaysOnTop

      public void setAlwaysOnTop(boolean value)
      Sets always-on-top and marks the change as API-driven.
      Parameters:
      value - target always-on-top state
    • setAlwaysOnTop

      public void setAlwaysOnTop(boolean value, DockFloatingPinSource source)
      Sets always-on-top with an explicit change source.
      Parameters:
      value - target always-on-top state
      source - source of the state change, defaults to DockFloatingPinSource.API when null
    • getPinButtonMode

      public DockFloatingPinButtonMode getPinButtonMode()
      Returns the pin-button visibility mode.
      Returns:
      configured pin-button mode
    • setPinButtonMode

      public void setPinButtonMode(DockFloatingPinButtonMode mode)
      Sets the pin-button visibility mode.
      Parameters:
      mode - pin-button mode, defaults to DockFloatingPinButtonMode.AUTO when null
    • isPinToggleEnabled

      public boolean isPinToggleEnabled()
      Returns whether users may toggle always-on-top from the title bar.
      Returns:
      true when user pin toggling is enabled
    • setPinToggleEnabled

      public void setPinToggleEnabled(boolean enabled)
      Enables or disables title-bar pin toggling.
      Parameters:
      enabled - true to allow user pin toggling
    • getPinLockedBehavior

      public DockFloatingPinLockedBehavior getPinLockedBehavior()
      Returns the lock-mode behavior used for the pin button.
      Returns:
      configured locked-mode pin behavior
    • setPinLockedBehavior

      public void setPinLockedBehavior(DockFloatingPinLockedBehavior behavior)
      Sets how the pin button behaves while the layout is locked.
      Parameters:
      behavior - locked-mode behavior, defaults to DockFloatingPinLockedBehavior.ALLOW when null
    • setOnAlwaysOnTopChanged

      public void setOnAlwaysOnTopChanged(BiConsumer<Boolean,DockFloatingPinSource> onAlwaysOnTopChanged)
      Sets a callback that is invoked when always-on-top changes.
      Parameters:
      onAlwaysOnTopChanged - callback receiving state + change source, or null
    • undockNode

      public void undockNode(DockNode node)
      Removes a node from this floating graph.
      Parameters:
      node - node to remove
    • dockNode

      public void dockNode(DockNode node, DockElement target, DockPosition position, Integer tabIndex)
      Docks a node into this floating graph.
      Parameters:
      node - node to dock
      target - target element
      position - target dock position
      tabIndex - tab insert index for tab drops, or null
    • moveNode

      public void moveNode(DockNode node, DockElement target, DockPosition position, Integer tabIndex)
      Moves a node within this floating graph.
      Parameters:
      node - node to move
      target - target element
      position - target dock position
      tabIndex - tab insert index for tab drops, or null
    • requestFloatForNode

      public void requestFloatForNode(DockNode node)
      Routes an inner-node float request through the floating-window callback flow.
      Parameters:
      node - node that requested floating
    • getDockNodeView

      public DockNodeView getDockNodeView(DockNode node)
      Returns the rendered view for a dock node in this floating layout.
      Parameters:
      node - node whose view should be resolved
      Returns:
      rendered node view, or null
    • resolveDropTarget

      public DockFloatingWindow.DropTarget resolveDropTarget(double screenX, double screenY, DockNode draggedNode)
      Resolves the best drop target in this floating window for the given pointer position.
      Parameters:
      screenX - pointer x-coordinate in screen space
      screenY - pointer y-coordinate in screen space
      draggedNode - node currently being dragged
      Returns:
      resolved drop target, or null when none matches
    • updateDropPreview

      public void updateDropPreview(DockNode draggedNode, double screenX, double screenY, DockDropVisualizationMode visualizationMode)
      Updates floating-window drop preview visuals for the given pointer position.
      Parameters:
      draggedNode - node currently being dragged
      screenX - pointer x-coordinate in screen space
      screenY - pointer y-coordinate in screen space
      visualizationMode - drop visualization mode to apply
    • clearDropPreview

      public void clearDropPreview()
      Hides floating-window drop preview visuals.