Skip to content

Stack Panel

Elysio Martins edited this page Nov 4, 2023 · 1 revision

panel

What is a StackPanel ?

A stack panel is a UI element that arranges its child elements in a single stack, either vertically or horizontally, providing an organized layout.

How to Create a Stack Panel on My Root Builder? 🔥

  1. Instantiate the panel:
$panel = StackPanel::create("pstack_anel_test");
  1. Set the desired properties:
# VERY IMPORTANT /!\
$panel->setOrientation(OrientationHelper::VERTICAL);


// Set the visibility of the panel
$panel->setVisible(true); // Set the panel as visible
$panel->setVisible(false); // Set the panel as invisible

// Set the enabled state of the panel
$panel->setEnabled(true); // Enable the panel and its children
$panel->setEnabled(false); // Disable the panel and its children if locked

// Set the Z-Index/Layer of the panel relative to the parent
$panel->setLayer($zIndex);

// Set the alpha/transparency of the panel
$panel->setAlpha($alpha); // Set the alpha value (0.0 to 1.0)

// Enable or disable alpha propagation to children
$panel->setPropagateAlpha(true); // Enable alpha propagation to children
$panel->setPropagateAlpha(false); // Disable alpha propagation to children

// Cut off visually and interactively everything beyond the panel's boundaries
$panel->setClipsChildren(true); // Cut off content beyond boundaries
$panel->setClipsChildren(false); // Allow content to overflow

// Control if clips_children works in the panel
$panel->setAllowClipping(true); // Enable clipping behavior
$panel->setAllowClipping(false); // Disable clipping behavior

// Set the clip offset from the start of the clipping
$panel->setClipOffset([$x, $y]);

// Set the scissor test property
$panel->setEnableScissorTest(true); // Enable scissor test
$panel->setEnableScissorTest(false); // Disable scissor test

// Set the property bag (variables more related to data)
$panel->setPropertyBag($propertyBag);

// Set if the panel is selected by default
$panel->setSelected(true); // Panel is selected
$panel->setSelected(false); // Panel is not selected

// Use child anchors (anchor_from and anchor_to) for the panel
$panel->setUseChildAnchors(true); // Use child anchors
$panel->setUseChildAnchors(false); // Do not use child anchors

// Add children elements to the panel
$panel->addElements($elements);

// Set animations for the panel
$panel->setAnimations($animations);

// Disable fast-forwarding animations
$panel->setDisableAnimFastForward(true); // Disable animation fast-forwarding

// Set the animation reset name
$panel->setAnimationResetName($resetName);

// Ignore the panel (set to false to display)
$panel->setIgnored(true); // Panel is ignored (not displayed)
$panel->setIgnored(false); // Panel is not ignored (displayed)

// Set variables and conditions to change variable values
$panel->setVariables($variables);

// Modify UI files of resource packs with modifications
$panel->setModifications($modifications);

// Set the grid position in rows and columns
$panel->setGridPosition([$row, $column]);

// Set the collection index
$panel->setCollectionIndex($index);

# Additional functions are available for further customization.
  1. Set the desired properties:
# Add the element to the root instance
$root->addElement($panel);
  1. Add element in root
# Add the element to the root instance
$root->addElement($panel);

childs

// Create an array of child elements
$elements = [
    $child1,
    $child2,
    // Add more child elements as needed
];

// Add the child elements to the panel
$panel->addChilds($elements);
Clone this wiki locally