74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
package editor
|
|
|
|
import (
|
|
"gioui.org/unit"
|
|
|
|
"pad/internal/ui"
|
|
)
|
|
|
|
// State holds all application state owned by the logic goroutine.
|
|
type State struct {
|
|
ScreenWidth unit.Dp
|
|
ScreenHeight unit.Dp
|
|
Elems []ui.Element
|
|
}
|
|
|
|
// NewState creates a new State with initial editor layout.
|
|
func NewState(screenWidth, screenHeight unit.Dp) *State {
|
|
return &State{
|
|
ScreenWidth: screenWidth,
|
|
ScreenHeight: screenHeight,
|
|
Elems: EditorLayout(screenWidth, screenHeight),
|
|
}
|
|
}
|
|
|
|
// EditorLayout computes regions for the editor page.
|
|
// It takes screen dimensions and returns []Element.
|
|
func EditorLayout(screenWidth, screenHeight unit.Dp) []ui.Element {
|
|
// Margin to avoid clipping on macOS round corners
|
|
margin := unit.Dp(10)
|
|
|
|
// Compute StatusBar region
|
|
// Line 1: filename (24 DP)
|
|
// Line 2: icons (24 DP)
|
|
statusBarHeight := unit.Dp(48)
|
|
statusBarRegion := ui.Region{
|
|
X: margin,
|
|
Y: margin,
|
|
W: screenWidth - margin*2,
|
|
H: statusBarHeight,
|
|
}
|
|
|
|
// Compute BottomBar region (fixed height, at bottom of screen)
|
|
bottomBarHeight := unit.Dp(24)
|
|
bottomBarY := screenHeight - margin - bottomBarHeight
|
|
bottomBarRegion := ui.Region{
|
|
X: margin,
|
|
Y: bottomBarY,
|
|
W: screenWidth - margin*2,
|
|
H: bottomBarHeight,
|
|
}
|
|
|
|
// Create StatusBar with mocked filename
|
|
statusBar := ui.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 := ui.NewBottomBar(
|
|
bottomBarRegion,
|
|
"Ln 47, Col 12",
|
|
"1024 / 50000",
|
|
true, // WordWrap
|
|
)
|
|
|
|
return []ui.Element{statusBar, bottomBar}
|
|
}
|