Skip to content

Commit

Permalink
bg transparent: Windows OK
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatao Li committed Feb 12, 2020
1 parent 1a66f96 commit f1d4094
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions Views/MainWindow.xaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ type MainWindow() as this =
m_bgopacity <- States.background_opacity
let comp =
match m_bgcomp with
| States.Acrylic -> ui.AdvancedBlur(m_bgopacity, m_bgcolor)
| States.Blur -> ui.GaussianBlur(m_bgopacity, m_bgcolor)
| _ -> ui.SolidBackground m_bgcolor
| States.Acrylic -> ui.AdvancedBlur(m_bgopacity, m_bgcolor)
| States.Blur -> ui.GaussianBlur(m_bgopacity, m_bgcolor)
| States.Transparent -> ui.TransparentBackground(m_bgopacity, m_bgcolor)
| _ -> ui.SolidBackground m_bgcolor
trace "mainwindow" "configBackground: %A" comp
ui.SetWindowBackgroundComposition this comp

Expand Down
3 changes: 3 additions & 0 deletions states.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ let mutable ui_hlstate = false

type BackgroundComposition =
| NoComposition
| Transparent
| Blur
| Acrylic

Expand Down Expand Up @@ -190,6 +191,7 @@ let parseBackgroundComposition (v: obj) =
| "none" -> Some NoComposition
| "blur" -> Some Blur
| "acrylic" -> Some Acrylic
| "transparent" -> Some Transparent
| _ -> None
| _ -> None

Expand All @@ -198,6 +200,7 @@ let backgroundCompositionToString =
| NoComposition -> "none"
| Blur -> "blur"
| Acrylic -> "acrylic"
| Transparent -> "transparent"

let Shutdown code = _appLifetime.Shutdown code

Expand Down
8 changes: 7 additions & 1 deletion ui.fs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ open linux

type WindowBackgroundComposition =
| SolidBackground of color: Color
| TransparentBackground of opacity: float * color: Color
| GaussianBlur of opacity: float * color: Color
| AdvancedBlur of opacity: float * color: Color

Expand All @@ -448,6 +449,10 @@ let SetWindowBackgroundComposition (win: Avalonia.Controls.Window) (composition:
| SolidBackground c ->
win.Background <- SolidColorBrush(c)
AccentState.ACCENT_DISABLED, 0u, 0u
| TransparentBackground (op, c) ->
let c = Color(byte(op * 255.0), c.R, c.G, c.B)
win.Background <- SolidColorBrush(c)
AccentState.ACCENT_ENABLE_TRANSPARENTGRADIENT, 0u, 0u
| GaussianBlur(op, c) ->
let c = Color(byte(op * 255.0), c.R, c.G, c.B)
win.Background <- SolidColorBrush(c)
Expand Down Expand Up @@ -477,6 +482,7 @@ let SetWindowBackgroundComposition (win: Avalonia.Controls.Window) (composition:
match composition with
| SolidBackground c ->
win.Background <- SolidColorBrush(c)
| TransparentBackground(op, c) // TODO verify
| GaussianBlur(op, c)
| AdvancedBlur(op, c) ->
let c = Color(byte(op * 255.0), c.R, c.G, c.B)
Expand Down Expand Up @@ -537,8 +543,8 @@ let SetWindowBackgroundComposition (win: Avalonia.Controls.Window) (composition:
match composition with
| SolidBackground c ->
win.Background <- SolidColorBrush(c)
| TransparentBackground(op, c) // TODO verify
| GaussianBlur(op, c)
| AdvancedBlur(op, c) ->
let c = Color(byte(op * 255.0), c.R, c.G, c.B)
win.Background <- SolidColorBrush(c)
(*ignore <| vh_add_view(win.PlatformImpl.Handle.Handle)*)

0 comments on commit f1d4094

Please sign in to comment.