ui

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ui 持久化 UI 运行时状态(AGENTS.md §0.5「少量 JSON」)。 与 internal/config(结构性应用配置)区分:这里只放自动记住的运行时 UI 状态, 不进 SQLite(那是业务数据的唯一真相,AGENTS.md §1.5)。

Index

Constants

View Source
const (
	MinWidth  = 600
	MinHeight = 400
)

MinWidth/MinHeight 是恢复时的最小尺寸护栏,防止持久化的过小值导致窗口不可用。

View Source
const MinVisible = 100

MinVisible 是恢复位置时窗口必须与屏幕工作区重叠的最小尺寸(DIP)。

Variables

This section is empty.

Functions

func SaveWindow

func SaveWindow(path string, s WindowState) error

SaveWindow 把窗口状态原子写入 path(先写 .tmp 再 rename,避免半截文件)。

func VisibleOn

func VisibleOn(workAreas []Bounds, b Bounds) bool

VisibleOn 报告窗口 b 是否与某个工作区有至少 MinVisible×MinVisible 的重叠。 用于跳过「恢复到屏幕外」的位置(如保存时的外接显示器已拔除), 否则窗口会落到可视区域之外,看起来像应用没启动。

Types

type Bounds

type Bounds struct {
	X, Y, Width, Height int
}

Bounds 是一个轴对齐矩形(屏幕工作区或窗口几何),纯值,不耦合 GUI 库,便于单测。

type WindowState

type WindowState struct {
	X         int  `json:"x"`
	Y         int  `json:"y"`
	Width     int  `json:"width"`
	Height    int  `json:"height"`
	Maximized bool `json:"maximized"`
}

WindowState 是窗口几何/状态的持久化表示(ui_state.json)。 X/Y/Width/Height 记录的是「正常(非最大化)」几何, Maximized 标记是否应最大化打开。

func LoadWindow

func LoadWindow(path string) (WindowState, error)

LoadWindow 从 path 读取窗口状态。文件不存在视为无记录(零值 + nil)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL