Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

104 Commits

Folders and files

Repository files navigation

gd-responsive

Build responsive Godot 4 UI that adapts to phone, tablet, desktop, and web viewports.

Use this addon to compute layout scale, margins, content width, breakpoints, flex rows, and grids without hardcoding every screen size.

Installation

Via gdam

gdam install @aviorstudio/gd-responsive

Manual

Copy addon/ into res://addons/@aviorstudio_gd-responsive/ and enable the plugin.

Enabling the plugin adds the GdResponsive autoload and registers these editor-visible types:

  • ResponsiveLayout
  • ResponsiveFlex
  • ResponsiveGrid
  • ResponsiveFlexItem
  • ResponsiveGridItem
  • ResponsiveLayoutConfig

Quick Start

const ResponsiveScaleModule = preload("res://addons/@aviorstudio_gd-responsive/src/responsive_scale_module.gd")

var responsive := ResponsiveScaleModule.new()
var viewport_size := get_viewport_rect().size
var device_type := responsive.resolve_device_type(viewport_size)
var scale := responsive.compute_scale(viewport_size, 1.0)
var margin := responsive.resolve_margin(device_type, false)

Responsive Layout Scene

Use ResponsiveLayout when you want a reusable Control base that applies computed margins, content widths, and optional font scaling.

ResponsiveLayout is editor-first: it runs as a @tool script, so margin, content width, and spacing changes are visible while authoring scenes. Instance res://addons/@aviorstudio_gd-responsive/src/responsive_layout.tscn, then tune or duplicate its layout_config resource in the inspector.

The bundled default config lives at:

res://addons/@aviorstudio_gd-responsive/config/default_responsive_layout_config.tres

Bundled presets live under:

  • res://addons/@aviorstudio_gd-responsive/presets/compact_layout_config.tres
  • res://addons/@aviorstudio_gd-responsive/presets/app_shell_layout_config.tres

An inspectable app-shell example scene lives at:

res://addons/@aviorstudio_gd-responsive/examples/app_shell/responsive_example_main.tscn

Useful editor-facing fields:

  • layout_config: reusable .tres settings for widths, margins, scale, breakpoints, spacing, and base font sizes.
  • editor_preview_enabled: enables live editor layout preview.
  • editor_preview_viewport_size: optional phone/tablet/desktop preview size override. Leave at zero to use the control size.

ResponsiveLayoutConfig reports cross-field warnings when minimum content width exceeds maximum content width, minimum scale exceeds maximum scale, or the mobile breakpoint is not below the tablet breakpoint. Invalid live edits and saved resources keep the artist-authored numbers unchanged; correct the highlighted fields to clear the warning.

If one of the configured child paths is missing or points at the wrong node type, ResponsiveLayout reports a Godot node configuration warning in the Scene dock.

Configurable child paths:

  • scroll_path, default ScrollContainer
  • margin_path, default ScrollContainer/MarginContainer
  • center_path, default ScrollContainer/MarginContainer/CenterContainer
  • content_path, default ScrollContainer/MarginContainer/CenterContainer/VBoxContainer

ResponsiveLayout.adjust_font_sizes defaults to false; enable it only when you want recursive font rewriting.

What You Get

  • ResponsiveScaleModule: viewport classification and scale/margin/content-width calculations.
  • ResponsiveLayoutConfig: reusable artist-authored layout config resource.
  • ResponsiveLayout: reusable base layout scene/script.
  • ResponsiveFlex / ResponsiveFlexItem: row and column flow helpers.
  • ResponsiveGrid / ResponsiveGridItem: breakpoint-aware grid helpers.
  • GdResponsiveAutoload: optional facade for global access.

Font Scaling

  • apply_font_scaling_on_node(...): scale one node.
  • apply_font_scaling_recursive(...): scale a subtree explicitly.

Notes

  • Works in Godot 4.x native and web exports.
  • You can use only the scale module if you already have custom UI containers.
  • Route, page, and HUD composition stay in your game project.

License

See LICENSE.

Contributor checks

Install mise, then use the pinned cookbook entrypoint:

mise run setup
mise run build
mise run test

mise.toml pins SDK versions and reviewed engine/template checksums. cookbook.toml declares native package inputs, fixture exports and test groups; the generated mise.toml task block loads the exact shared cookbook revision. mise run build packages and validates the closed addon payload and exports its installed Web fixture. Tests use those existing artifacts and never build or install dependencies.

Use mise run test:lint, mise run test:unit, mise run test:integration and mise run test:security for individual groups. The unit suite retains the native assertion reach and failure controls; integration covers installed editor lifecycle and consumer autoload ownership. mise run fmt formats native GDScript, mise run clean removes declared generated outputs, and mise run help describes the supported commands. Build and test receipts remain in .artifacts/verification.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages