Skip to content

UIPanel

Class

Source: UIPanel.h

Inherits from: UIElement

Description

Visual container that draws a background and border around a child element.

This container provides a retro-style window/panel appearance with a background color and border. Typically contains a UILayout or other UI elements. Useful for dialogs, menus, and information panels.

Inheritance

UIElementUIPanel

Methods

void setChild(UIElement* element)

Description:

Sets the child element.

Parameters:

  • element: Pointer to the UI element to wrap (typically a UILayout).

UIElement* getChild() const

Description:

Gets the child element.

Returns: Pointer to the child element, or nullptr if none set.

void setBackgroundColor(pixelroot32::graphics::Color color)

Description:

Sets the background color.

Parameters:

  • color: Background color.

pixelroot32::graphics::Color getBackgroundColor() const

Description:

Gets the background color.

Returns: Background color.

void setBorderColor(pixelroot32::graphics::Color color)

Description:

Sets the border color.

Parameters:

  • color: Border color.

pixelroot32::graphics::Color getBorderColor() const

Description:

Gets the border color.

Returns: Border color.

void setBorderWidth(uint8_t width)

Description:

Sets the border width.

Parameters:

  • width: Border width in pixels.

uint8_t getBorderWidth() const

Description:

Gets the border width.

Returns: Border width in pixels.

void setPosition(pixelroot32::math::Scalar newX, pixelroot32::math::Scalar newY)

Description:

Sets the position of the panel. Also updates the child element's position.

Parameters:

  • newX: New X coordinate.
  • newY: New Y coordinate.

void update(unsigned long deltaTime)

Description:

Updates the panel and child element.

Parameters:

  • deltaTime: Time elapsed since last frame in milliseconds.

void draw(pixelroot32::graphics::Renderer& renderer)

Description:

Draws the panel (background, border) and child element.

Parameters:

  • renderer: Reference to the renderer.

void updateChildPosition()

Description:

Updates the child element's position to match the panel.

Released under the MIT License.