Skip to content

SurfaceWidget

Container with a composable Surface: background colors, multi-layer textures, shaders, borders, and corner radius.

Overview

SurfaceWidget is the foundation of UniGUI's modern styling system. Instead of hardcoding a specific renderer class, every SurfaceWidget embeds a composable Surface.

The background source can be a solid color, texture, or procedural GLSL shader, and can be switched dynamically via code, XML, or Theme/StylePack selectors without replacing the widget or renderer.

Textures & Overlay Layers

  • Base Background: Configured via background(color), backgroundTexture(handle), or backgroundShader(handle).
  • Nine-Slice Slicing: Enable via backgroundTextureFit(ImageFit.NINE_SLICE) and sliceBorders(n) for scalable panels without corner distortion.
  • Overlay Textures: Add multiple layered textures over the background via overlayTexture(handle). Each layer supports individual tint, source UVs, and fit modes.
  • Transitions & Animation: Visual properties such as backgroundColor, borderColor, borderWidth, and radius can be smoothly transitioned using animateBackgroundColor(...), animateRadius(...), etc.

Configured Surface Card

Box card = new Box()
        .background(ColorView.ofHex("#1A1D24"))
        .border(ColorView.ofHex("#3A3F4D"))
        .borderWidth(1.5f)
        .radius(8.0f);
card.addChild(content);

API

SurfaceWidget::backgroundVisible(boolean)

Set Background Visible

Enables or disables background fill and texture rendering.

Parameter Type Description
backgroundVisible boolean true to render background

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::backgroundVisible()

Get Background Visible

Returns whether background rendering is active.

Returns boolean: true if background is visible.

SurfaceWidget::background(ColorView)

Set Background

Sets background fill color and automatically enables background visibility.

Parameter Type Description
color ColorView background fill color or null for transparent

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::borderColor(ColorView)

Set Border Color

Sets border stroke color and automatically enables border visibility.

Parameter Type Description
color ColorView border color view or hex

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::border(ColorView)

Set Border

Sets border stroke color and automatically enables border visibility.

Parameter Type Description
color ColorView border stroke color

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::borderVisible(boolean)

Set Border Visible

Enables or disables border stroke rendering.

Parameter Type Description
borderVisible boolean true to render border stroke

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::borderWidth(float)

Set border width

Sets the thickness of the border stroke in UI pixels.

Parameter Type Description
borderWidth float Stroke width in UI pixels

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::radius(float)

Set corner radius

Sets uniform corner radius in UI pixels.

Parameter Type Description
radius float Corner radius in UI pixels

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::boxVisualEnabled(boolean)

Set Visual Enabled

Enables or disables all surface visual rendering (background, border, textures).

Parameter Type Description
boxVisualEnabled boolean true to enable surface rendering

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::themeEnabled(boolean)

Set Theme Enabled

Controls whether global Theme styles override surface properties.

Parameter Type Description
themeEnabled boolean true to allow global theme lookups

Returns SurfaceWidget: this widget for fluent configuration.

SurfaceWidget::surface()

Get Surface

Returns the underlying composable Surface model.

Returns Surface: live Surface model instance.