Pad/internal/ui/layout.go
Greg Pomerantz 869f0b13ac Implement initial editor mockup with StatusBar, BottomBar, window resize
Elements implemented:
- StatusBar (top bar with filename, action icons, conflict/search icons)
- BottomBar (bottom bar with cursor position, byte position, word wrap button)
- Button (interactive button element)
- AlphaIndex, SearchBar, Cursor, MergeHunk, Toast, Spacer (stubs)

Layout:
- EditorLayout function computes regions for StatusBar and BottomBar
- Filename truncation with ellipsis (mocked filename for testing)
- Mocked data: "very_long_filename...", "Ln 47, Col 12", "1024 / 50000"

Renderer:
- drawStatusBar: draws filename line + icon line
- drawBottomBar: draws cursor pos, byte pos, word wrap button
- drawButton: draws button text
- drawIconButton: draws icon buttons

Window resize:
- configChan setup in main.go
- ConfigEvent handling in event loop
- Layout recomputation on resize

Builds and runs successfully.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-05-08 16:22:46 -04:00

62 lines
1.4 KiB
Go

package ui
import "gioui.org/unit"
const (
// Standard dimensions in Dp
statusBarLineHeight = unit.Dp(24)
statusBarFilenameLine = unit.Dp(24)
statusBarIconsLine = unit.Dp(24)
bottomBarHeight = unit.Dp(24)
iconSize = unit.Dp(24)
iconGap = unit.Dp(36)
padding = unit.Dp(8)
buttonPadding = unit.Dp(8)
)
// EditorLayout computes regions for the editor page.
// It takes screen dimensions and returns []Element.
func EditorLayout(screenWidth, screenHeight unit.Dp) []Element {
// Compute StatusBar region
// Line 1: filename (24 DP)
// Line 2: icons (24 DP)
statusBarHeight := statusBarFilenameLine + statusBarIconsLine
statusBarRegion := Region{
X: 0,
Y: 0,
W: screenWidth,
H: statusBarHeight,
}
// Compute BottomBar region (fixed height, at bottom of screen)
bottomBarY := screenHeight - bottomBarHeight
bottomBarRegion := Region{
X: 0,
Y: bottomBarY,
W: screenWidth,
H: bottomBarHeight,
}
// Create StatusBar with mocked filename
statusBar := NewStatusBar(
statusBarRegion,
"very_long_filename_that_does_not_fit_on_a_single_line.txt",
false, // FilenameExp
true, // CutCopy
false, // Copy
true, // Paste
false, // ConflictIcon
true, // Search
)
// Create BottomBar with mocked data
bottomBar := NewBottomBar(
bottomBarRegion,
"Ln 47, Col 12",
"1024 / 50000",
true, // WordWrap
)
return []Element{statusBar, bottomBar}
}