minui 0.3.1

A minimalist Rust framework for TUIs and terminal games.
Documentation
//! # Layout System
//!
//! A sophisticated layout management system that provides the foundational building blocks
//! for creating responsive and flexible terminal user interfaces. This module defines the
//! core layout primitives including directional constraints, size calculations, and
//! rectangular area management that power MinUI's container-based widget positioning.
//!
//! ## Features
//!
//! - **Flexible constraints**: Fixed, percentage, minimum, and fill-based sizing
//! - **Directional layouts**: Horizontal and vertical arrangement strategies
//! - **Responsive design**: Automatic adaptation to terminal size changes
//! - **Precise positioning**: Character-accurate rectangular area calculations
//! - **Nested layouts**: Support for complex hierarchical layout structures
//! - **Space optimization**: Intelligent distribution of available space
//! - **Container integration**: Seamless integration with MinUI's widget system
//!
//! ## Layout Philosophy
//!
//! The layout system follows a CSS Flexbox-inspired model adapted for terminal interfaces.
//! Instead of pixels, all calculations use character units, providing precise control
//! over text-based layouts while maintaining the flexibility needed for responsive design.
//!
//! ## Visual Layout Model
//!
//! ```text
//! Horizontal Layout (Direction::Horizontal):
//! ┌─────────┬─────────────────┬──────────┐
//! │ Fixed   │     Fill        │  Fixed   │
//! │ (20)    │   (remaining)   │  (15)    │
//! └─────────┴─────────────────┴──────────┘
//!
//! Vertical Layout (Direction::Vertical):
//! ┌─────────────────────────────────────────┐
//! │              Fixed (5)                  │
//! ├─────────────────────────────────────────┤
//! │                                         │
//! │            Fill (remaining)             │
//! │                                         │
//! ├─────────────────────────────────────────┤
//! │           Percentage (30%)              │
//! └─────────────────────────────────────────┘
//! ```
//!
//! ## Basic Usage
//!
//! ```rust
//! use minui::widgets::layout::{Direction, Constraint, Rect};
//!
//! // Define a three-panel horizontal layout
//! let constraints = [
//!     Constraint::Fixed(20),      // Left sidebar: 20 characters wide
//!     Constraint::Fill,           // Main content: takes remaining space
//!     Constraint::Fixed(15),      // Right panel: 15 characters wide
//! ];
//!
//! let terminal_area = Rect::new(0, 0, 80, 24);
//! let layout = Layout::default()
//!     .direction(Direction::Horizontal)
//!     .constraints(constraints)
//!     .split(terminal_area);
//!
//! // Result: Three rectangles representing the layout areas
//! // layout[0]: Rect { x: 0, y: 0, width: 20, height: 24 }   (sidebar)
//! // layout[1]: Rect { x: 20, y: 0, width: 45, height: 24 }  (main)
//! // layout[2]: Rect { x: 65, y: 0, width: 15, height: 24 }  (right panel)
//! ```
//!
//! ## Advanced Layout Strategies
//!
//! ```rust
//! use minui::widgets::layout::{Constraint, Direction, Layout};
//!
//! // Responsive dashboard layout
//! let main_layout = Layout::default()
//!     .direction(Direction::Vertical)
//!     .constraints([
//!         Constraint::Fixed(3),       // Header bar
//!         Constraint::Fill,           // Content area
//!         Constraint::Fixed(1),       // Status bar
//!     ]);
//!
//! // Content area sub-layout
//! let content_layout = Layout::default()
//!     .direction(Direction::Horizontal)
//!     .constraints([
//!         Constraint::Percentage(0.25),  // 25% for navigation
//!         Constraint::Fill,              // Remaining space for main content
//!         Constraint::Min(20),           // At least 20 characters for sidebar
//!     ]);
//! ```
//!
//! ## Complex Nested Layouts
//!
//! ```rust
//! use minui::widgets::layout::{Layout, Direction, Constraint, Rect};
//!
//! // Create a sophisticated application layout
//! fn create_app_layout(terminal_size: Rect) -> Vec<Rect> {
//!     let main_areas = Layout::default()
//!         .direction(Direction::Vertical)
//!         .margin(1)
//!         .constraints([
//!             Constraint::Fixed(3),   // Title bar
//!             Constraint::Fill,       // Main content
//!             Constraint::Fixed(3),   // Button area
//!         ])
//!         .split(terminal_size);
//!
//!     let content_areas = Layout::default()
//!         .direction(Direction::Horizontal)
//!         .constraints([
//!             Constraint::Percentage(0.3),    // Left panel
//!             Constraint::Fill,               // Center content
//!             Constraint::Percentage(0.2),    // Right info panel
//!         ])
//!         .split(main_areas[1]);
//!
//!     // Combine all areas for final layout
//!     vec![main_areas[0], content_areas[0], content_areas[1],
//!          content_areas[2], main_areas[2]]
//! }
//! ```
//!
//! ## Constraint Types
//!
//! The layout system provides four primary constraint types for flexible sizing:
//!
//! - **Fixed(u16)**: Exact size in characters - never changes
//! - **Percentage(f32)**: Proportional to available space (0.0 to 1.0)
//! - **Min(u16)**: Minimum size that can grow if space is available
//! - **Fill**: Consumes all remaining space after other constraints
//!
//! The layout system integrates seamlessly with MinUI's container widgets, providing
//! the mathematical foundation for responsive terminal user interface design.
//! ];
//! ```
//!
//! ## Future Layout Widgets
//!
//! This module will eventually support layout widgets like:
//!
//! ```rust,ignore
//! use minui::widgets::layout::{HBox, VBox, Grid};
//!
//! // Horizontal layout
//! let hbox = HBox::new()
//!     .add_child(sidebar, Constraint::Fixed(20))
//!     .add_child(main_content, Constraint::Fill)
//!     .add_child(info_panel, Constraint::Fixed(15));
//!
//! // Vertical layout
//! let vbox = VBox::new()
//!     .add_child(header, Constraint::Fixed(3))
//!     .add_child(body, Constraint::Fill)
//!     .add_child(footer, Constraint::Fixed(1));
//!
//! // Grid layout
//! let grid = Grid::new(3, 3)
//!     .add_widget(widget, 0, 0, 2, 1); // span 2 columns, 1 row
//! ```

// use super::Widget;
// use crate::{Result, Window};