feat(dashboard): implement smart auto-layout with expansion and better defaults
This commit implements 5 major improvements to the dashboard layout system:
**1. Improved Default Layout (defaultLayout.js)**
- Changed from 2 tabs to 3 tabs for better organization:
- Tab 1 (Status): User widgets only (userInfo, userStats, userMood, userAttributes)
- Tab 2 (Scene): Scene widgets + characters (calendar, weather, temp, clock, location, presentCharacters)
- Tab 3 (Inventory): Full inventory widget
- Cleaner separation prevents cramming all widgets on one tab
**2. Widget Max Size Limits (widget definition files)**
- Added maxAutoSize property to all widgets (enforced only during auto-arrange):
- Info widgets (calendar, weather, temp, clock): { w: 2, h: 3 }
- Location: { w: 3, h: 3 }
- presentCharacters: { w: 3, h: 6 } (can expand significantly)
- Inventory: { w: 3, h: 8 } (full tab)
- Prevents blind expansion while allowing intelligent space filling
**3. Smart Expansion Algorithm (gridEngine.js)**
- Added expansion pass after compaction in autoLayout():
- Sorts widgets top-to-bottom, left-to-right
- Tries to expand height first (fills vertical gaps)
- Then tries to expand width (fills horizontal gaps)
- Respects maxAutoSize limits from widget definitions
- Only expands if no collision with other widgets
- Widgets now fill available space instead of staying at default sizes
- Example: presentCharacters expands from 2x3 to 3x6 when space available
**4. Auto-Reflow on Column Change (dashboardManager.js)**
- Modified onColumnsChange callback to auto-layout after column count changes
- When grid transitions (2→3 or 3→2), automatically reflo ws widgets
- Prevents overlap and optimizes for new column count
- User experience: seamless adaptation when console opens/closes
**5. Fixed Grid Height/Scrollbar CSS (style.css)**
- Added flex: 1, overflow-y: auto, min-height: 0 to .rpg-dashboard-grid
- Grid now properly fills available space in dashboard container
- Accounts for bottom buttons (manual update, settings)
- Prevents "fingernail of extra height" that caused scrollbars
**Technical Changes:**
- Passed widget registry to GridEngine for maxAutoSize lookups
- getWidgetMaxSize() helper looks up definitions from registry
- Moved registry initialization before GridEngine construction
- Grid now uses flexbox to fill available vertical space
**User-Facing Improvements:**
- Reset layout creates logical 3-tab structure from the start
- Auto-arrange expands widgets to fill available space intelligently
- Resizing window/console automatically reflows layout
- No more unwanted scrollbars from slight overflow
Fixes cramped layouts, underutilized space, and scrollbar issues.
This commit is contained in:
@@ -194,6 +194,7 @@ export function registerCalendarWidget(registry, dependencies) {
|
||||
category: 'scene',
|
||||
minSize: { w: 1, h: 2 },
|
||||
defaultSize: { w: 1, h: 2 },
|
||||
maxAutoSize: { w: 2, h: 3 }, // Max size for auto-arrange expansion
|
||||
requiresSchema: false,
|
||||
|
||||
render(container, config = {}) {
|
||||
@@ -281,6 +282,7 @@ export function registerWeatherWidget(registry, dependencies) {
|
||||
description: 'Weather emoji and forecast',
|
||||
minSize: { w: 1, h: 2 },
|
||||
defaultSize: { w: 1, h: 2 },
|
||||
maxAutoSize: { w: 2, h: 3 }, // Max size for auto-arrange expansion
|
||||
requiresSchema: false,
|
||||
|
||||
render(container, config = {}) {
|
||||
@@ -314,6 +316,7 @@ export function registerTemperatureWidget(registry, dependencies) {
|
||||
description: 'Temperature display with thermometer',
|
||||
minSize: { w: 1, h: 2 },
|
||||
defaultSize: { w: 1, h: 2 },
|
||||
maxAutoSize: { w: 2, h: 3 }, // Max size for auto-arrange expansion
|
||||
requiresSchema: false,
|
||||
|
||||
render(container, config = {}) {
|
||||
@@ -354,6 +357,7 @@ export function registerClockWidget(registry, dependencies) {
|
||||
description: 'Analog clock with time display',
|
||||
minSize: { w: 1, h: 2 },
|
||||
defaultSize: { w: 1, h: 2 },
|
||||
maxAutoSize: { w: 2, h: 3 }, // Max size for auto-arrange expansion
|
||||
requiresSchema: false,
|
||||
|
||||
render(container, config = {}) {
|
||||
@@ -403,6 +407,7 @@ export function registerLocationWidget(registry, dependencies) {
|
||||
description: 'Map with location display',
|
||||
minSize: { w: 1, h: 2 },
|
||||
defaultSize: { w: 2, h: 2 },
|
||||
maxAutoSize: { w: 3, h: 3 }, // Max size for auto-arrange expansion
|
||||
requiresSchema: false,
|
||||
|
||||
render(container, config = {}) {
|
||||
|
||||
Reference in New Issue
Block a user