Index of every page on this site: llms.txt
All skills
jame581 avatar

/responsive-ui

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when handling multiple resolutions — stretch modes, aspect ratios, DPI scaling, and mobile/desktop adaptation

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/responsive-ui

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesadaptive-layouts.md

≈722 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Adaptive Layouts

Reference for skills/responsive-ui/SKILL.md — anchor + container strategy, detecting resolution changes, size_flags reference.

← Back to SKILL.md


7. Adaptive Layouts

Anchor + Container Strategy

Design for your base resolution, anchor every HUD element to the nearest screen edge, and use Container nodes for anything that must reflow.

HUD (CanvasLayer)
└── SafeAreaMargin (MarginContainer — anchor: Full Rect)
    ├── TopBar (HBoxContainer — anchor: Top Wide)
    │   ├── HealthLabel (Label — size_flags_h: EXPAND_FILL)
    │   └── ScoreLabel  (Label)
    └── BottomBar (HBoxContainer — anchor: Bottom Wide)
        ├── InventoryButton (Button — custom_minimum_size: Vector2(64, 64))
        └── MapButton       (Button — custom_minimum_size: Vector2(64, 64))

GDScript — setting size flags and minimum sizes in code:

func _ready() -> void:
    # Expand to fill available horizontal space
    $TopBar/HealthLabel.size_flags_horizontal = Control.SIZE_EXPAND_FILL

    # Never collapse below 64x64
    $BottomBar/InventoryButton.custom_minimum_size = Vector2(64.0, 64.0)

C#:

public override void _Ready()
{
    GetNode<Label>("TopBar/HealthLabel").SizeFlagsHorizontal = Control.SizeFlags.ExpandFill;
    GetNode<Button>("BottomBar/InventoryButton").CustomMinimumSize = new Vector2(64f, 64f);
}

Detecting Resolution Changes

GDScript:

func _ready() -> void:
    get_viewport().size_changed.connect(_on_viewport_size_changed)


func _on_viewport_size_changed() -> void:
    var new_size: Vector2 = get_viewport().get_visible_rect().size
    _relayout(new_size)


func _relayout(size: Vector2) -> void:
    # Example: switch between side-by-side and stacked layout
    if size.x >= 1280.0:
        $SplitContainer.vertical = false   # wide layout
    else:
        $SplitContainer.vertical = true    # stacked layout

C#:

public override void _Ready()
{
    GetViewport().SizeChanged += OnViewportSizeChanged;
}

private void OnViewportSizeChanged()
{
    Vector2 size = GetViewport().GetVisibleRect().Size;
    Relayout(size);
}

private void Relayout(Vector2 size)
{
    var split = GetNode<SplitContainer>("SplitContainer");
    split.Vertical = size.X < 1280f;
}

Useful size_flags Values

Constant Behaviour in Container
SIZE_SHRINK_BEGIN Align to start; take only minimum size
SIZE_FILL Expand to fill available space without claiming extra
SIZE_EXPAND Claim extra space from the container
SIZE_EXPAND_FILL Claim extra space and fill it — most common for stretchy widgets
SIZE_SHRINK_CENTER Centre within available space at minimum size
SIZE_SHRINK_END Align to end; take only minimum size

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts29d3 checks · Risk SAFE
  • Gen Agent Trust Hub29d

    The skill provides comprehensive documentation and code snippets for creating responsive user interfaces in Godot 4.3+. It covers project settings, DPI scaling, mobile safe areas, and pixel art configurations. No security issues were detected.

  • Socket29d

    No alerts

  • Snyk29d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last month

README badge

README badge for jame581/godotprompter/responsive-ui