Archived messages from: gitter.im/red/red/gui-branch from year: 2023

luce80
14:54Promotion:
Inspired by various example scripts posted here and with the aid of @hiiamboris 's elasticity...
After a few hours of playing I have made [this](https://gist.github.com/luce80/a5bb54f128934140e36c7a1073958455)
try it by typing this in the console:
do/args https://t.ly/cq6ih "test"


14:56@hiiamboris If you think I would have not "stolen" your work, please tell me and I will erase it.
hiiamboris
15:22Nobody owns ideas, they just use us to conquer the world ;)
So my work is free for anyone to build upon and take inspiration from.
15:33I like your idea of composable reaction templates :+1:
But emit-rule is totally esoteric :)
15:35Another way to check for 4 ints: parse block [4 integer! end]
luce80
15:39>totally esoteric

I am waiting for a more idiomatic version ;) . And while you are at it what about you implementing the system/script/header/Notes TODO part ;) ?
> check 4 ints

Nice! I think I will steal also this.
hiiamboris
15:47> more idiomatic version

You could rewrite every some/path/value: x into set in some/path 'value x or rather set in (path) 'value x... or even better set in (object) 'value x... or just bind the whole block to the face in question... ;)
15:52As for
> it would be nice to have some widgets being "attached" to their neighbours to keep their relative distances so not to have to explicitly set #move- when not necessary

This thing (which is employed by #fill strategy) takes about half of the elasticity.red code - distance measurement in a chaotic ensemble of boxes. Well, measurement less, filling strategy more, but it's still problematic.
15:56You may find some useful funcs here: https://codeberg.org/hiiamboris/red-spaces/src/branch/master/auxi.red#L114-L150
luce80
16:07
*** Script Error: invalid function definition: [{Get coordinates of the point on box B1-B2 closest to ORIGIN} B1 [pair!] "inclu
*** Where: either
*** Near : closest-box-point?: function [{Get coordi} ]

Have you redefined function somewhere to accept default values ?
hiiamboris
16:09https://codeberg.org/hiiamboris/red-common/src/branch/master/advanced-function.red
16:26While you're thinking on how to maintain distance to this or that face, here's a layout to meditate upon :)
![](https://i.gyazo.com/04a90a99357e9b07e82ec23a6a4f31e7.png)
luce80
16:38:) simple, just use AI ;) . But I prefer to meditate on resizing normal table-like layouts. Just imagine , for instance, that simply defining the 1st field of my example as "resizable" it will push and pull the nearby buttonand same for text-list and bottom widgets. Shouldn't that be too hard, but not in my *immediate* todo list so if you want to take the challenge ;) ... or does anyone else dare ?
hiiamboris
16:43(: delegating decisions to AI is the first step towards Skynet (or Matrix)
luce80
16:50We already did that step, it's just a matter of time.

luce80
10:05A variation on #5221 :
view/flags [
	base: base 50x200 255.100.100;.100
	at 200x100 base brick 20x30 loose
	react later [base/size: face/offset - base/offset show base/parent]
] 'resize

- Why are there **3** rectangles ?
- If I drag the "brick" and then resize the window the resizing is slow and with black bands but if I uncomment the transparency and try again the resizing is faster !?
- If I change show base/parent with show face/parent the brick will not move. (A reaction loop ?)
- If I remove later the window does not open centered on the screen anymore !?
hiiamboris
10:22https://github.com/red/red/issues/4473
10:24probably the reason behind all of it
10:24add this example there please
10:24so when it's fixed we don't overlook anything
luce80
18:33A "better" version:
view/flags [
    base: base "1" 50x200 255.100.100;.200
    at 200x100 text "2" sky 20x30 loose
    react later [base/size: face/offset - base/offset show base/parent]
] 'resize

If I resize the window, the text is "blitted" on the "ghost" face, with alpha channel the text is not blitted.

greggirwin
02:14Nice work @luce80. Nice meditation @hiiamboris.

tangentstorm
23:20is it possible to get a reference to the red console window? system/view/screens/1 seems to be the whole desktop... other red windows get added to system/view/screens, but I can't seem to find the console itself.
greggirwin
23:30gui-console-ctx/win, or look at that entire object, depending on what you're trying to do.

tangentstorm
00:03awesome! con: gui-console-ctx/win/pane/1 con/color: hex-to-rgb #ff9999 makes the background light red. haven't found the right place to set the foreground color yet.
greggirwin
01:11gui-console-ctx/set-font-color

mikeyaunish
15:25Is there a way to disable an individual tab in a tab-panel?
hiiamboris
15:28you mean let it stay there but not be selectable?
mikeyaunish
hiiamboris
15:37theoretically I think this should work:
system/view/capturing?: on view [tab-panel 200 data ["a" [button "A"] "b" [button "B"] "c" [button "C"]] on-detect [if event/type = 'select [if (probe event/picked) = 3 ['stop]]]]

but in practice we don't know what tab *is going to be* selected, since event/picked reports the one *previously selected* (+1), so I guess you've just found two more bugs
15:39'change event (where event/picked is correct) doesn't stop it from changing
15:42ok third bug: tab-panel doesn't have a pane
15:43oh that's because I used data (and it kind of worked but not really lol)
ne1uno
15:44panel/pane/n/enabled?: false didn't work
hiiamboris
15:45yeah just tried that: it disables actual contents of the panel, but not the panel itself
15:46I guess you're out of luck for now @mikeyaunish :)
15:47set-focus doesn't work either
mikeyaunish
15:49OK - thanks for looking at this for me @hiiamboris.
ne1uno
15:49panel/selected: n works
hiiamboris
15:49yes indeed!
15:49view [p: tab-panel 200 ["a" [button "A"] "b" [b: button "B"] "c" [button "C"]] on-select [old: event/picked] on-change [if event/picked = 2 [face/selected: old]]]
15:50this won't let you select tab 2
mikeyaunish
15:52OK - I'll play with that.
ne1uno
15:53rename tab
15:53"don't click"
hiiamboris
15:57and if user clicks it, crash the program :) that'll teach him
mikeyaunish
15:59Haven't used the "crash-the-program" function yet :)
greggirwin
17:33You don't have to be so extreme as to crash the program. Triggering a spring-loaded boxing glove next to the computer should be enough.
hiiamboris
18:08now that would be a *responsive UI* ;)
greggirwin
18:08Indeed! :^)

lylgithub2021
07:03
view [a: drop-down data ["a" "b" "c"] with [selected: 2] button [print a/text]

When I push button before doing any selection on the face drop-down, I get none, not "b" as I expect. Why? And how to get "b" before selection?
ne1uno
07:10lylgithub2021>, which version and OS? I get b with recent latest, win10. though need to press twice to see both output
lylgithub2021
07:12@ne1uno build 0.6.4 on win7
ne1uno
07:27lylgithub2021, what does about show? works on win7 for me but older version does show none. you might try downloading latest version.
lylgithub2021
07:45[![图片.png](https://files.gitter.im/55b1d8290fc9f982beaacceb/2qL5/thumb/Tu-Pian.png)](https://files.gitter.im/55b1d8290fc9f982beaacceb/2qL5/Tu-Pian.png)
07:49@ne1uno Thank you for yourr suggestion! which version shoud I download? GUI Red or Red Tool chain? I don't know their difference.
ne1uno
lylgithub2021
07:50What is toolchain used for?
ne1uno
07:50compiling executable
lylgithub2021
07:56You mean the latest version GUI Red can not compile red script(which can be done by the version I use at present)?
ne1uno
07:59previously, they were all packed together. gui/cli/toolchain but it then required a delay unpacking on the first use, now they are ready to use
lylgithub2021
08:00@ne1uno Many thanks for your help!!
ne1uno
08:00I think it's eventually going to be simpler.
lylgithub2021
08:06In sys Windows, where are the unpacked files located?
ne1uno
08:24%rootdir%/programdata/red maybe on win7

lylgithub2021
08:38
view [group-box "title" [text "on-over" on-over [face/parent/text: "hint title"]]]

By the above codes, I try to achieve this: when mouse moves over the face of text, the title of the face group-box will change from "title" to "hint title". when mouse is off text, the title change back to "title". The second part(restore the title) fails. Any idea tto make it work? Thanks.
hiiamboris
08:47Make use of event/away?.
lylgithub2021
11:01@hiiamboris How to use it?
hiiamboris
11:10start with probeing :)
11:11https://github.com/red/docs/blob/master/en/view.adoc#112-event-datatype

lylgithub2021
01:43Many thanks!!
01:54
Red [needs 'view]
view [
dd: drop-down data []
return
text react [
myinput: attempt [to-integer trim dd/text]
either all [myinput myinput >= 0] [face/text: dd/text] [face/text: "??"]
]]

I want the content of text to change with

the value of drop-down. When I input "12" to "dd"

from keyboard, I get "21". It seems that the

cursor keep at the beginning position of the

drop-down all the time. Why and what's wrong

with my code?
ne1uno
02:00try trim copy dd/text
lylgithub2021
02:10Many thanks @ne1uno ! And I still do not understand why a simple copy solves the problem.
ne1uno
02:11hopefully, someone will comment. adding a copy solves many a problem though
02:14why the 2nd numbers was 1st and 3rd number 2nd also strange
lylgithub2021
02:18This confuses me a lot(of time and energy).
ne1uno
02:19lylgithub2021, a few functions like trim, sort, reverse etc modify series in place. that's part of the answer
hiiamboris
10:44@lylgithub2021 cursor is reset every time a modification of text is detected by drop-down

luce80
18:31I have a loose button and I want it to move only horizontally, how can I do ? The way I tried is flickering a lot :)
toomasv
19:00@luce80 With loose it is flickering, but without is smooth
view [
   button "OK" all-over 
   on-down [x: event/offset/x] 
   on-over [if event/down? [face/offset/x: face/offset/x + event/offset/x - x]]
]
hiiamboris
19:01https://github.com/red/red/issues/1637#issuecomment-1248305098
luce80
19:17@toomasv thanks! Back to the roots ;) . @hiiamboris I made a loose implementation in R2 and used step: 1x0 to move horizontally and step: 30x0 to move horizontally 30 px at a time.
hiiamboris
19:19what was the use case for 30x0?
luce80
19:24Snap to a grid, a knob of a slider that has only a few discrete values, anything you can think of.
hiiamboris
19:26you mean if I provided step = 30x30 it would not move the thing diagonally, but snapped to a 30x30 grid?
19:27yes, interesting idea, though I'm still not sure it's worth making a standard feature
luce80
19:35Perhaps not worth it but it won't hurt anyone:
view [
   button "OK" all-over 
   on-down [x: event/offset/x] 
   on-over [if event/down? [face/offset/x: face/offset/x + round/floor/to event/offset/x  5 - x]]
]

Damn , this is not working correctly but I do not want to debug and fix it and you get the idea ;) .
hiiamboris
19:39yeah thanks
dockimbel
21:15@luce80 See the [boundsoption](https://github.com/red/docs/blob/master/en/view.adoc#options-facet) that was recently introduced for restricting dragging movements. I've noticed some glitches using it in some cases, I would be interested to see if that happens in your case too. Let me know.

mikeyaunish
00:30How would I find out about new features/options (like the bounds option above)? Is there a document I can look at?
greggirwin
01:20New features are generally collected for major releases into change notes, but we also tend to watch commits to see what's being done.
mikeyaunish
02:45OK thanks @greggirwin
dockimbel
13:48As a reminder, you can switch View to debug mode using system/view/debug?: yes to get logs about events and face-related reactions. It can sometimes dump too much info, but that's a start. A possible improvement could be to have a companion GUI app with filtering options, where all those logs go to, for easier usage.

luce80
07:24I have a panel with many faces, I want to remove all the faces (and perhaps also the panel) and rebuild the panel with a lot of new faces. Which is the better way to not waste memory ?
hiiamboris
10:28Repurpose old faces?
luce80
13:24The number of faces will be different and I think/hope that rebuilding all will be simpler.
hiiamboris
13:42Then I would just do it the simplest way and worry not about preemptive optimizations.
luce80
14:07So simply clearing the panel and re-making all, won't waste a lot of memory ? Isn't at least recycle placed somewhere-I-dont't-know-where, recommended ?
hiiamboris
14:33recycling is done automatically
greggirwin
19:45As @hiiamboris said, don't worry about it until you know it's a problem. Do a test (and share it here) to generate a random combination of faces, clear, rebuild and do basic profiling. Let the computer do the work. If you *know* it's going to be a large system, and find out that the easy way won't work, then you can create pools of faces and reuse them, but that's a LOT more work and a LOT more chances to make mistakes. Then you have to ask if it's better to be a little slow than to be wrong or crash.

rebolek
09:46https://poignardazur.github.io//2023/02/02/masonry-01-and-my-vision-for-rust-ui/
The thing that I agree most with is "replay feature should be a first-class citizen". Which means user definable event!s.
ldci
09:47@luce80 . The way I adopted for removing facets and keeping others in a panel:
deleteNubs: does [
	nbFaces: 22									;--number of facets to keep
	keptFaces: copy/part radioWin/pane nbFaces	;--save facets
	append clear radioWin/pane keptFaces		;--delete nubs and add saved facets
]

luce80
18:08I am trying the bounds alternative to move a loose face only horizontally but... try this:
view [button "test" loose options [bounds: object [min: 0x0 max: 0x0]]]

>> about
Red 0.6.4 for Windows built 4-Jan-2023/9:46:38+01:00  commit #8290def
hiiamboris
18:10oopsy,
*** Runtime Error 98: assertion failed
*** in file: /d/devel/red/red-src/master/runtime/datatypes/symbol.reds
*** at line: 107
***
***   stack: red/symbol/resolve 126360808
***   stack: gui/parse-common-opts 05972240h 05720E88h
***   stack: gui/OS-make-view 049F0584h 9184474
***   stack: ctx||459~make-view 049F0584h 049F0594h
18:10you should report it
18:11works as expected when I put an object! value there
luce80
18:15There where ?
hiiamboris
18:18after bounds:
18:19(you have a word where it expects an object)
luce80
19:21Ok I 've done it and it works :) but I wouldn't say it is easy nor "as described" :(
view [
	button "move x" loose
		on-created [ append face/options compose [bounds: (object [min: face/offset - 20x0 max: face/offset + 50x0])]]
]