Skip to content

Instantly share code, notes, and snippets.

@gurzgri
Last active April 4, 2023 17:02
Show Gist options
  • Save gurzgri/610edac8799072e3b5542934d8523ba6 to your computer and use it in GitHub Desktop.
Save gurzgri/610edac8799072e3b5542934d8523ba6 to your computer and use it in GitHub Desktop.
resize no-border no-title
Red [
author: "Christian Ensel"
needs: 'view
]
;-- requires the following patch for Red/View
;
patch: {
$ git diff --unified=1
diff --git a/modules/view/backends/platform.red b/modules/view/backends/platform.red
index 25758501f..c3d3e83e6 100644
--- a/modules/view/backends/platform.red
+++ b/modules/view/backends/platform.red
@@ -299,2 +299,4 @@ system/view/platform: context [
_resize-ew: symbol/make "resize-ew"
+ _resize-nwse: symbol/make "resize-nwse"
+ _resize-nesw: symbol/make "resize-nesw"
diff --git a/modules/view/backends/windows/gui.reds b/modules/view/backends/windows/gui.reds
index cae619e96..a04624b72 100644
--- a/modules/view/backends/windows/gui.reds
+++ b/modules/view/backends/windows/gui.reds
@@ -1350,2 +1350,4 @@ parse-common-opts: func [
] [32644]
+ sym = _resize-nwse [32642]
+ sym = _resize-nesw [32643]
true [IDC_ARROW]
}
send-window-message: routine [face [object!] msg [integer!] w [integer!] l [integer!] /local hwnd] [
hwnd: gui/get-face-handle face
gui/SendMessage hwnd msg w l
]
window-of: function [face [object!]] [
until [face: face/parent face/type = 'window] face
]
drag-window: function [face [object!]] [
send-window-message face A1h 02h 0 ;WM_NCLBUTTONDOWN HT_CAPTION 0
]
size-window: function [face [object!] dir [word!]] [
send-window-message face A1h select [min 8 nw 13 n 12 ne 14 w 10 e 11 sw 16 s 15 se 17 max 9] dir 0
]
win: view/no-wait/flags layout [
space 0x0
origin 0x0 across
t: base 750x50 navy [drag-window win] c: base 50x50 maroon [unview]
origin 0x0 across
nw: base red 10x10 cursor resize-nwse [size-window win 'nw]
n: base sky 780x10 cursor resize-ns [size-window win 'n ]
ne: base red 10x10 cursor resize-nesw [size-window win 'ne]
return
w: base sky 10x580 cursor resize-we [size-window win 'w ]
pad 780x0
e: base sky 10x580 cursor resize-we [size-window win 'e ]
return
sw: base red 10x10 cursor resize-nesw [size-window win 'sw]
s: base sky 780x10 cursor resize-ns [size-window win 's ]
se: base red 10x10 cursor resize-nwse [size-window win 'se]
][resize no-border no-title]
react [
n/size: s/size: win/size * 1x0 + -20x+10
e/size: w/size: win/size * 0x1 + 10x-20
ne/offset: n/offset + n/size * 1x0
sw/offset: w/offset + w/size * 0x1
se/offset: as-pair ne/offset/x sw/offset/y
e/offset: as-pair ne/offset/x ne/size/y
s/offset: as-pair sw/size/x sw/offset/y
t/size: win/size * 1x0 + -50x50
c/offset: 1x0 * t/size
]
do-events
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment