✨ Added window snapping feature
This commit is contained in:
@@ -68,6 +68,10 @@ type GeneralConfig struct {
|
||||
EnableSystemTray bool `json:"enableSystemTray"` // 是否启用系统托盘
|
||||
StartAtLogin bool `json:"startAtLogin"` // 开机启动设置
|
||||
|
||||
// 窗口吸附设置
|
||||
EnableWindowSnap bool `json:"enableWindowSnap"` // 是否启用窗口吸附功能
|
||||
SnapThreshold int `json:"snapThreshold"` // 吸附距离阈值(像素)
|
||||
|
||||
// 全局热键设置
|
||||
EnableGlobalHotkey bool `json:"enableGlobalHotkey"` // 是否启用全局热键
|
||||
GlobalHotkey HotkeyCombo `json:"globalHotkey"` // 全局热键组合
|
||||
@@ -145,6 +149,8 @@ func NewDefaultAppConfig() *AppConfig {
|
||||
DataPath: dataDir,
|
||||
EnableSystemTray: true,
|
||||
StartAtLogin: false,
|
||||
EnableWindowSnap: true, // 默认启用窗口吸附
|
||||
SnapThreshold: 15, // 默认15像素的吸附阈值
|
||||
EnableGlobalHotkey: false,
|
||||
GlobalHotkey: HotkeyCombo{
|
||||
Ctrl: false,
|
||||
|
||||
41
internal/models/window.go
Normal file
41
internal/models/window.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// SnapEdge 表示吸附的边缘类型
|
||||
type SnapEdge int
|
||||
|
||||
const (
|
||||
SnapEdgeNone SnapEdge = iota // 未吸附
|
||||
SnapEdgeTop // 吸附到上边缘
|
||||
SnapEdgeRight // 吸附到右边缘
|
||||
SnapEdgeBottom // 吸附到下边缘
|
||||
SnapEdgeLeft // 吸附到左边缘
|
||||
SnapEdgeTopRight // 吸附到右上角
|
||||
SnapEdgeBottomRight // 吸附到右下角
|
||||
SnapEdgeBottomLeft // 吸附到左下角
|
||||
SnapEdgeTopLeft // 吸附到左上角
|
||||
)
|
||||
|
||||
// WindowPosition 窗口位置
|
||||
type WindowPosition struct {
|
||||
X int `json:"x"` // X坐标
|
||||
Y int `json:"y"` // Y坐标
|
||||
}
|
||||
|
||||
// SnapPosition 表示吸附的相对位置
|
||||
type SnapPosition struct {
|
||||
X int `json:"x"` // X轴相对偏移
|
||||
Y int `json:"y"` // Y轴相对偏移
|
||||
}
|
||||
|
||||
// WindowInfo 窗口信息
|
||||
type WindowInfo struct {
|
||||
DocumentID int64 `json:"documentID"` // 文档ID
|
||||
Title string `json:"title"` // 窗口标题
|
||||
IsSnapped bool `json:"isSnapped"` // 是否处于吸附状态
|
||||
SnapOffset SnapPosition `json:"snapOffset"` // 与主窗口的相对位置偏移
|
||||
SnapEdge SnapEdge `json:"snapEdge"` // 吸附的边缘类型
|
||||
LastPos WindowPosition `json:"lastPos"` // 上一次记录的窗口位置
|
||||
MoveTime time.Time `json:"moveTime"` // 上次移动时间,用于判断移动速度
|
||||
}
|
||||
Reference in New Issue
Block a user