Documentation
¶
Index ¶
- Constants
- func IsBasicMode(width int) bool
- func IsCompactMode(width int) bool
- func IsExtendedMode(width int) bool
- func IsFullMode(width int) bool
- type BoxLayout
- type BreakpointConfig
- type ComponentInfo
- type Constraints
- type Layout
- type LayoutManager
- type Manager
- func (m *Manager) Clear()
- func (m *Manager) GetComponentBounds(id string) Rectangle
- func (m *Manager) GetComponentCount() int
- func (m *Manager) IsDirty() bool
- func (m *Manager) RecalculateLayout() error
- func (m *Manager) RegisterComponent(id string, constraints Constraints) error
- func (m *Manager) SetAvailableSize(width, height int)
- func (m *Manager) SetLayout(layout Layout)
- func (m *Manager) UnregisterComponent(id string) error
- type Orientation
- type Rectangle
- type ResponsiveLayout
- func (r *ResponsiveLayout) AddBreakpoint(minWidth int, layout Layout)
- func (r *ResponsiveLayout) Calculate(available Rectangle, components []ComponentInfo) map[string]Rectangle
- func (r *ResponsiveLayout) ClearBreakpoints()
- func (r *ResponsiveLayout) GetBreakpointCount() int
- func (r *ResponsiveLayout) GetCurrentBreakpoint(width int) string
- func (r *ResponsiveLayout) SetDefaultLayout(layout Layout)
Constants ¶
const ( // BreakpointCompact is the threshold for compact mode (< 40 cols) BreakpointCompact = 40 // BreakpointBasic is the threshold for basic mode (40-80 cols) BreakpointBasic = 80 // BreakpointFull is the threshold for full mode (80-100 cols) BreakpointFull = 100 // BreakpointExtended is the threshold for extended mode (100+ cols) BreakpointExtended = 100 )
Breakpoint constants from statusbar.go (preserved from existing implementation)
Variables ¶
This section is empty.
Functions ¶
func IsBasicMode ¶
IsBasicMode returns true if width is in basic mode
func IsCompactMode ¶
IsCompactMode returns true if width is in compact mode
func IsExtendedMode ¶
IsExtendedMode returns true if width is in extended mode
Types ¶
type BoxLayout ¶
type BoxLayout struct {
// contains filtered or unexported fields
}
BoxLayout arranges components in a single direction (vertical or horizontal)
func NewBoxLayout ¶
func NewBoxLayout(orientation Orientation) *BoxLayout
NewBoxLayout creates a new box layout with the specified orientation
func NewBoxLayoutWithSpacing ¶
func NewBoxLayoutWithSpacing(orientation Orientation, spacing int) *BoxLayout
NewBoxLayoutWithSpacing creates a new box layout with custom spacing
func (*BoxLayout) Calculate ¶
func (b *BoxLayout) Calculate(available Rectangle, components []ComponentInfo) map[string]Rectangle
Calculate computes component bounds based on box layout algorithm
func (*BoxLayout) GetOrientation ¶
func (b *BoxLayout) GetOrientation() Orientation
GetOrientation returns the current layout orientation
func (*BoxLayout) GetSpacing ¶
GetSpacing returns the current spacing between components
func (*BoxLayout) SetOrientation ¶
func (b *BoxLayout) SetOrientation(orientation Orientation)
SetOrientation changes the layout orientation
func (*BoxLayout) SetSpacing ¶
SetSpacing updates the spacing between components
type BreakpointConfig ¶
type BreakpointConfig struct {
MinWidth int // Minimum width for this breakpoint
Layout Layout // Layout to use at this breakpoint
}
BreakpointConfig defines a layout configuration for a specific breakpoint
type ComponentInfo ¶
type ComponentInfo struct {
ID string
Constraints Constraints
Order int // Registration order for stable sorting
}
ComponentInfo holds component metadata for layout calculation
type Constraints ¶
type Constraints struct {
MinWidth int // Minimum width (0 = no minimum)
MinHeight int // Minimum height (0 = no minimum)
MaxWidth int // Maximum width (0 = unlimited)
MaxHeight int // Maximum height (0 = unlimited)
Grow bool // Whether the component can grow to fill available space
Shrink bool // Whether the component can shrink below its preferred size
Weight int // Flex weight for distributing extra space (higher = more space)
}
Constraints define size requirements and flexibility for a component
func DefaultConstraints ¶
func DefaultConstraints() Constraints
DefaultConstraints returns constraints with sensible defaults
func FixedConstraints ¶
func FixedConstraints(width, height int) Constraints
FixedConstraints creates constraints for a fixed-size component
func FlexConstraints ¶
func FlexConstraints(minHeight, weight int) Constraints
FlexConstraints creates constraints for a flexible component
type Layout ¶
type Layout interface {
// Calculate computes component bounds based on available space and constraints
Calculate(available Rectangle, components []ComponentInfo) map[string]Rectangle
}
Layout defines how components are arranged within a container
type LayoutManager ¶
type LayoutManager interface {
// RegisterComponent registers a component with its constraints
RegisterComponent(id string, constraints Constraints) error
// UnregisterComponent removes a component from management
UnregisterComponent(id string) error
// SetAvailableSize sets the container size available for layout
SetAvailableSize(width, height int)
// GetComponentBounds returns the calculated bounds for a component
GetComponentBounds(id string) Rectangle
// RecalculateLayout recalculates all component positions
RecalculateLayout() error
// IsDirty returns whether the layout needs recalculation
IsDirty() bool
}
LayoutManager manages component positioning within a container
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the default implementation of LayoutManager
func NewManager ¶
NewManager creates a new layout manager with the specified layout algorithm
func (*Manager) Clear ¶
func (m *Manager) Clear()
Clear removes all components and resets the manager
func (*Manager) GetComponentBounds ¶
GetComponentBounds returns the calculated bounds for a component
func (*Manager) GetComponentCount ¶
GetComponentCount returns the number of registered components
func (*Manager) RecalculateLayout ¶
RecalculateLayout recalculates all component positions using the layout algorithm
func (*Manager) RegisterComponent ¶
func (m *Manager) RegisterComponent(id string, constraints Constraints) error
RegisterComponent registers a component with its layout constraints
func (*Manager) SetAvailableSize ¶
SetAvailableSize updates the container size and marks layout as dirty
func (*Manager) UnregisterComponent ¶
UnregisterComponent removes a component from layout management
type Orientation ¶
type Orientation int
Orientation defines the direction of layout flow
const ( // Vertical orientation stacks components top to bottom Vertical Orientation = iota // Horizontal orientation arranges components left to right Horizontal )
type Rectangle ¶
type Rectangle struct {
X int // X position (left edge)
Y int // Y position (top edge)
Width int // Width in characters
Height int // Height in lines
}
Rectangle represents a positioned area in the UI
type ResponsiveLayout ¶
type ResponsiveLayout struct {
// contains filtered or unexported fields
}
ResponsiveLayout switches between different layouts based on container width
func NewResponsiveLayout ¶
func NewResponsiveLayout(defaultLayout Layout) *ResponsiveLayout
NewResponsiveLayout creates a new responsive layout with a default layout
func (*ResponsiveLayout) AddBreakpoint ¶
func (r *ResponsiveLayout) AddBreakpoint(minWidth int, layout Layout)
AddBreakpoint adds a layout configuration for a specific width breakpoint
func (*ResponsiveLayout) Calculate ¶
func (r *ResponsiveLayout) Calculate(available Rectangle, components []ComponentInfo) map[string]Rectangle
Calculate selects the appropriate layout based on width and calculates component bounds
func (*ResponsiveLayout) ClearBreakpoints ¶
func (r *ResponsiveLayout) ClearBreakpoints()
ClearBreakpoints removes all breakpoint configurations
func (*ResponsiveLayout) GetBreakpointCount ¶
func (r *ResponsiveLayout) GetBreakpointCount() int
GetBreakpointCount returns the number of configured breakpoints
func (*ResponsiveLayout) GetCurrentBreakpoint ¶
func (r *ResponsiveLayout) GetCurrentBreakpoint(width int) string
GetCurrentBreakpoint returns the name of the current breakpoint for the given width
func (*ResponsiveLayout) SetDefaultLayout ¶
func (r *ResponsiveLayout) SetDefaultLayout(layout Layout)
SetDefaultLayout changes the default layout