Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm decorated and resizable, just have window style #39

Merged
merged 2 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/windy/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ type
MSAA* = enum
msaaDisabled = 0, msaa2x = 2, msaa4x = 4, msaa8x = 8

WindowStyle* = enum
DecoratedResizable, Decorated, Undecorated

Callback* = proc()
ButtonCallback* = proc(button: Button)
RuneCallback* = proc(rune: Rune)
Expand Down
43 changes: 15 additions & 28 deletions src/windy/platforms/win32/platform.nim
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ proc monitorInfo(window: Window): MONITORINFO =
proc visible*(window: Window): bool =
IsWindowVisible(window.hWnd) != 0

proc decorated*(window: Window): bool =
proc style*(window: Window): WindowStyle =
let style = getWindowStyle(window.hWnd)
(style and WS_BORDER) != 0

proc resizable*(window: Window): bool =
let style = getWindowStyle(window.hWnd)
(style and WS_THICKFRAME) != 0
if (style and WS_THICKFRAME) != 0:
return DecoratedResizable
if (style and WS_BORDER) != 0:
return Decorated
Undecorated

proc fullscreen*(window: Window): bool =
window.exitFullscreenInfo != nil
Expand Down Expand Up @@ -273,32 +273,19 @@ proc `visible=`*(window: Window, visible: bool) =
else:
discard ShowWindow(window.hWnd, SW_HIDE)

proc `decorated=`*(window: Window, decorated: bool) =
proc `style=`*(window: Window, windowStyle: WindowStyle) =
if window.fullscreen:
return

var style: LONG
if decorated:
style = decoratedWindowStyle
else:
style = undecoratedWindowStyle

if window.visible:
style = style or WS_VISIBLE
var style: Long

updateWindowStyle(window.hWnd, style)

proc `resizable=`*(window: Window, resizable: bool) =
if window.fullscreen:
return
if not window.decorated:
return

var style = decoratedWindowStyle.LONG
if resizable:
style = style or (WS_MAXIMIZEBOX or WS_THICKFRAME)
else:
style = style and not (WS_MAXIMIZEBOX or WS_THICKFRAME)
case windowStyle:
of DecoratedResizable:
style = decoratedWindowStyle or (WS_MAXIMIZEBOX or WS_THICKFRAME)
of Decorated:
style = decoratedWindowStyle and not (WS_MAXIMIZEBOX or WS_THICKFRAME)
of Undecorated:
style = undecoratedWindowStyle

if window.visible:
style = style or WS_VISIBLE
Expand Down