feat(overlay): add position customization for overlay placement
- Introduce PositionX and PositionY fields in OverlaySettings to allow manual positioning of the overlay. - Update validation to ensure PositionX and PositionY are not less than -1. - Modify diskConfig to include new position fields for JSON serialization. - Implement functionality to save overlay position during drag events in the GUI. - Enhance overlay placement logic to respect user-defined positions while ensuring proper display behavior.
This commit is contained in:
@@ -44,6 +44,8 @@ type diskConfig struct {
|
||||
Monitor string `json:"monitor"`
|
||||
FinalTimeout string `json:"final_timeout"`
|
||||
ClickThrough bool `json:"click_through"`
|
||||
PositionX *int `json:"position_x,omitempty"`
|
||||
PositionY *int `json:"position_y,omitempty"`
|
||||
} `json:"overlay"`
|
||||
TranscriptLog struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
@@ -163,6 +165,10 @@ func diskFromConfig(config AppConfig) diskConfig {
|
||||
disk.Overlay.Monitor = config.Overlay.Monitor
|
||||
disk.Overlay.FinalTimeout = config.Overlay.FinalTimeout.String()
|
||||
disk.Overlay.ClickThrough = config.Overlay.ClickThrough
|
||||
positionX := config.Overlay.PositionX
|
||||
positionY := config.Overlay.PositionY
|
||||
disk.Overlay.PositionX = &positionX
|
||||
disk.Overlay.PositionY = &positionY
|
||||
disk.TranscriptLog.Enabled = config.TranscriptLog.Enabled
|
||||
disk.TranscriptLog.Directory = config.TranscriptLog.Directory
|
||||
return disk
|
||||
@@ -185,6 +191,13 @@ func (disk diskConfig) toConfig() (AppConfig, error) {
|
||||
if err != nil {
|
||||
return AppConfig{}, err
|
||||
}
|
||||
positionX, positionY := -1, -1
|
||||
if disk.Overlay.PositionX != nil {
|
||||
positionX = *disk.Overlay.PositionX
|
||||
}
|
||||
if disk.Overlay.PositionY != nil {
|
||||
positionY = *disk.Overlay.PositionY
|
||||
}
|
||||
return AppConfig{
|
||||
Version: disk.Version,
|
||||
GUI: GUISettings{
|
||||
@@ -218,6 +231,8 @@ func (disk diskConfig) toConfig() (AppConfig, error) {
|
||||
Monitor: disk.Overlay.Monitor,
|
||||
FinalTimeout: finalTimeout,
|
||||
ClickThrough: disk.Overlay.ClickThrough,
|
||||
PositionX: positionX,
|
||||
PositionY: positionY,
|
||||
},
|
||||
TranscriptLog: TranscriptLogSettings{
|
||||
Enabled: disk.TranscriptLog.Enabled,
|
||||
|
||||
Reference in New Issue
Block a user