Skip to content

Commit 8c732f9

Browse files
author
Yatao Li
committed
implement #245
1 parent 18454bc commit 8c732f9

File tree

5 files changed

+39
-13
lines changed

5 files changed

+39
-13
lines changed

Program.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ let startMainWindow app opts =
8484
(mainwinVM.WindowState.ToString())
8585
(backgroundCompositionToString states.background_composition)
8686
mainwinVM.CustomTitleBar
87+
mainwinVM.NoTitleBar
8788
0
8889

8990
let startCrashReportWindow app ex =

ViewModels/FrameViewModel.fs

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type FrameViewModel(cfg: config.ConfigObject.Workspace option, ?_maingrid: GridV
4444

4545
let mutable m_windowState = WindowState.Normal
4646
let mutable m_customTitleBar = false
47+
let mutable m_noTitleBar = false
4748
let mutable m_fullscreen = false
4849
let mutable m_title = "FVim"
4950

@@ -94,6 +95,9 @@ type FrameViewModel(cfg: config.ConfigObject.Workspace option, ?_maingrid: GridV
9495
match cfg.Mainwin.CustomTitleBar with
9596
| Some true -> m_customTitleBar <- true
9697
| _ -> ()
98+
match cfg.Mainwin.NoTitleBar with
99+
| Some true -> m_noTitleBar <- true
100+
| _ -> ()
97101
| _, Some grid ->
98102
this.Height <- grid.BufferHeight
99103
this.Width <- grid.BufferWidth
@@ -103,11 +107,15 @@ type FrameViewModel(cfg: config.ConfigObject.Workspace option, ?_maingrid: GridV
103107
match cfg.Mainwin.CustomTitleBar with
104108
| Some true -> m_customTitleBar <- true
105109
| _ -> ()
110+
match cfg.Mainwin.NoTitleBar with
111+
| Some true -> m_noTitleBar <- true
112+
| _ -> ()
106113
| _ -> ()
107114
| _ -> ()
108115
this.Watch [
109116
rpc.register.notify "ToggleFullScreen" (fun _ -> toggleFullScreen())
110117
rpc.register.notify "CustomTitleBar" (fun [| Bool(v) |] -> this.CustomTitleBar <- v )
118+
rpc.register.notify "NoTitleBar" (fun [| Bool(v) |] -> this.NoTitleBar <- v )
111119
rpc.register.watch "background.image" (fun _ -> updateBackgroundImage())
112120
]
113121
match _maingrid with
@@ -141,21 +149,35 @@ type FrameViewModel(cfg: config.ConfigObject.Workspace option, ?_maingrid: GridV
141149

142150
member this.CustomTitleBarHeight
143151
with get() =
144-
if this.CustomTitleBar && (not this.Fullscreen) then GridLength 26.0
145-
else GridLength 0.0
152+
GridLength <|
153+
if this.CustomTitleBar && (not this.Fullscreen) && (not this.NoTitleBar) then 26.0
154+
else 0.0
146155

147156
member this.BorderSize
148157
with get() =
149-
if this.CustomTitleBar && (not this.Fullscreen) && (this.WindowState <> WindowState.Maximized)
150-
then GridLength 1.0
151-
else GridLength 0.0
158+
GridLength <|
159+
if (this.NoSystemTitleBar) && (not this.Fullscreen) && (this.WindowState <> WindowState.Maximized)
160+
then 1.0
161+
else 0.0
152162

153163
member this.CustomTitleBar
154164
with get() = m_customTitleBar
155165
and set(v) =
156166
ignore <| this.RaiseAndSetIfChanged(&m_customTitleBar, v)
157167
this.RaisePropertyChanged("CustomTitleBarHeight")
158168
this.RaisePropertyChanged("BorderSize")
169+
this.RaisePropertyChanged("NoSystemTitleBar")
170+
171+
member this.NoTitleBar
172+
with get() = m_noTitleBar
173+
and set(v) =
174+
ignore <| this.RaiseAndSetIfChanged(&m_noTitleBar, v)
175+
this.RaisePropertyChanged("CustomTitleBarHeight")
176+
this.RaisePropertyChanged("BorderSize")
177+
this.RaisePropertyChanged("NoSystemTitleBar")
178+
179+
member __.NoSystemTitleBar
180+
with get() = m_customTitleBar || m_noTitleBar
159181

160182
member __.BackgroundImage with get(): IBitmap = m_bgimg_src :> IBitmap
161183
member __.BackgroundImageHAlign with get(): HorizontalAlignment = m_bgimg_halign
@@ -174,6 +196,7 @@ type FrameViewModel(cfg: config.ConfigObject.Workspace option, ?_maingrid: GridV
174196
member __.Sync(_other: IFrame) =
175197
let that = _other :?> FrameViewModel
176198
m_customTitleBar <- that.CustomTitleBar
199+
m_noTitleBar <- that.NoTitleBar
177200
m_bgimg_src <- that.BackgroundImage :?> Bitmap
178201
m_bgimg_halign <- that.BackgroundImageHAlign
179202
m_bgimg_valign <- that.BackgroundImageVAlign

Views/Frame.xaml.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ type Frame() as this =
6565
let setCursor c =
6666
this.Cursor <- c
6767

68-
let toggleTitleBar(custom) =
69-
this.SystemDecorations <- if custom then SystemDecorations.BorderOnly else SystemDecorations.Full
68+
let toggleTitleBar(noTitleBar) =
69+
this.SystemDecorations <- if noTitleBar then SystemDecorations.BorderOnly else SystemDecorations.Full
7070

7171
let toggleFullscreen(v) =
7272
if not v then
7373
this.WindowState <- m_saved_state
7474
this.PlatformImpl.Resize(m_saved_size)
7575
this.Position <- m_saved_pos
76-
toggleTitleBar this.ViewModel.CustomTitleBar
76+
toggleTitleBar this.ViewModel.NoSystemTitleBar
7777
else
7878
// The order of actions is very important.
7979
// 1. Remove decorations
@@ -180,7 +180,7 @@ type Frame() as this =
180180
override this.OnDataContextChanged _ =
181181
let ctx = this.DataContext :?> FrameViewModel
182182
this.ViewModel <- ctx
183-
toggleTitleBar ctx.CustomTitleBar
183+
toggleTitleBar ctx.NoSystemTitleBar
184184

185185
if ctx.MainGrid.Id = 1 then
186186
let pos = PixelPoint(int ctx.X, int ctx.Y)
@@ -227,5 +227,5 @@ type Frame() as this =
227227
m_bgcolor <- c.Value
228228
configBackground())
229229
ctx.ObservableForProperty((fun x -> x.Fullscreen), skipInitial=true).Subscribe(fun v -> toggleFullscreen <| v.GetValue())
230-
ctx.ObservableForProperty((fun x -> x.CustomTitleBar), skipInitial=true).Subscribe(fun v -> toggleTitleBar <| v.GetValue())
230+
ctx.ObservableForProperty((fun x -> x.NoSystemTitleBar), skipInitial=true).Subscribe(fun v -> toggleTitleBar <| v.GetValue())
231231
]

config.fs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ let sample_config = """
1919
"h": 600,
2020
"state": "Normal",
2121
"BackgroundComposition": "acrylic",
22-
"CustomTitleBar": false
22+
"CustomTitleBar": false,
23+
"NoTitleBar": false
2324
}
2425
},
2526
{
@@ -67,10 +68,10 @@ let save
6768
(cfg: ConfigObject.Root)
6869
(x: int) (y: int) (w: int) (h: int)
6970
(def_w: int) (def_h: int)
70-
(state: string) (composition: string) (customTitleBar: bool) =
71+
(state: string) (composition: string) (customTitleBar: bool) (noTitleBar: bool) =
7172
let dict = cfg.Workspace |> Array.map (fun ws -> (ws.Path, ws)) |> Map.ofArray
7273
let cwd = Environment.CurrentDirectory |> Path.GetFullPath
73-
let ws = ConfigObject.Workspace(cwd, ConfigObject.Mainwin(x, y, w, h, state, Some composition, Some customTitleBar))
74+
let ws = ConfigObject.Workspace(cwd, ConfigObject.Mainwin(x, y, w, h, state, Some composition, Some customTitleBar, Some noTitleBar))
7475
let wss = dict.Add(cwd, ws)
7576
let defaults = ConfigObject.Default(def_w, def_h)
7677
let cfg = ConfigObject.Root(wss |> Map.toArray |> Array.map snd, cfg.Logging, Some defaults)

fvim.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ command! -complete=expression -nargs=1 FVimUIWildMenu call rpcnotify(g:fvim_chan
4141

4242
command! -complete=expression -nargs=1 FVimDrawFPS call rpcnotify(g:fvim_channel, 'DrawFPS', <args>)
4343
command! -complete=expression -nargs=1 FVimCustomTitleBar call rpcnotify(g:fvim_channel, 'CustomTitleBar', <args>)
44+
command! -complete=expression -nargs=1 FVimNoTitleBar call rpcnotify(g:fvim_channel, 'NoTitleBar', <args>)
4445

4546
command! -complete=expression -nargs=1 FVimBackgroundOpacity call rpcnotify(g:fvim_channel, 'background.opacity', <args>)
4647
command! -complete=expression -nargs=1 FVimBackgroundComposition call rpcnotify(g:fvim_channel, 'background.composition', <args>)

0 commit comments

Comments
 (0)