replace/all read/binary file crlf lf
How do you deal with time-consuming computation in the gui?
make-random-image: has [img ] [
img: make image! 200x200
forall img [img/1: random 255.255.255]
wait 2 img
]
view [i: image [i/image: make-random-image]]
Let's suppose that make-random-image
just takes at least 2 seconds to compute. In those 2 seconds I'm left with unresponsive window. Is there anything I can do to make user experience better such in cases?
ps. I know about memoization and I'm not sure if I can translate this part of code to Red/System.
call
.call "red my-heavy-script.red"
that will write result to some fileon-time
check periodically if second process finished (result file exists, or something like that)window: [
title "Layout"
size 800x800
group-box "01-file-header" 780x50 [
panel
]
return
group-box "02-bookmarks" 780x600 [
panel [
group-box "01.init-variables" 740x70 [
panel [
text {.url-0: >url}
]
]
return
group-box "02.reload-favorites" 740x70 [
panel [
text {.reload-favorites}
]
]
return
group-box "04.add-bookmark.sub-function" 740x70 [
panel [
text {.add-readable favorites 'bookmarks reduce [>url]}
]
]
return
group-box "05.either-block-url" 740x400 [
panel [
group-box "true" 350x400 [
panel
]
group-box "false" 350x400[
panel
]
]
]
]
]
]
view window
Red [
Title: ""
]
file-header: [
]
init-variables: [
]
bookmarks: [
groupbox [
panel init-variables
]
]
window: [
title "Layout"
size 1200x800
group-box "01-file-header" 1000x50 [
panel
]
return
group-box "02-bookmarks" 1150x600 [
panel [
group-box "01.init-variables" 740x80 [
panel [
area 500x40 {.url-0: >url}
]
]
return
group-box "02.reload-favorites" 740x80 [
panel [
area 500x40 {.reload-favorites}
]
]
return
group-box "04.add-bookmark.sub-function" 740x80 [
panel [
area 500x40 {.add-readable favorites 'bookmarks reduce [>url]}
]
]
return
group-box "05.either-block-url" 1100x400 [
panel [
group-box "01.is-block.url.true" 800x400 [
panel [
group-box "01.is-category.first-word.true" 330x400 [
panel [
area "stackoverflow !!!!!!"
]
]
group-box "01.is-category.first-word.false" 330x400 [
panel
]
]
]
group-box "01.is-block.url.false" 500x400 [
panel [
area {.add-readable favorites 'bookmarks (>url)} wrap
]
]
]
]
]
]
]
view window
Red [
Title: ""
]
window: [
title "Layout"
size 1200x800
group-box "01-file-header" 1000x50 [
panel
]
return
group-box "02-bookmarks" 1150x600 [
panel [
group-box "01.init-variables" 740x80 [
panel [
area 500x40 {.url-0: >url}
]
]
return
group-box "02.reload-favorites" 740x80 [
panel [
area 500x40 {.reload-favorites}
]
]
return
group-box "04.add-bookmark.sub-function" 740x80 [
panel [
area 500x40 {.add-readable favorites 'bookmarks reduce [>url]}
]
]
return
group-box "05.either-block-url" 1100x400 [
panel [
group-box "01.is-block.url.true" 800x400 [
panel [
group-box "01.is-category.first-word.true" 430x400 [
panel [
area wrap {favorite-bookmarks: favorites/bookmarks
existing-category: select (favorite-bookmarks) (category)}
group-box "01" [
panel [
area {crash under october build}
]
]
group-box "02" [
]
]
]
group-box "02.is-category.first-word.false" 230x400 [
panel [
area wrap {.add-readable favorites 'bookmarks reduce [>url]}
]
]
]
]
group-box "02.is-block.url.false" 500x400 [
panel [
area wrap {.add-readable favorites 'bookmarks (>url)} wrap
]
]
]
]
]
]
]
view window
view [
across
do [p-size: 200x100 ]
p: panel 200x100 [base blue base red] return
t: text yellow "this should move" return
button "hide" [p/size/y: p-size/y * 20% t/offset/y: (p/offset/y + p/size/y + 10) probe t/offset]
button "show" [p/size: p-size t/offset/y: probe ((probe p/offset/y) + p/size/y + 10) probe t/offset]
]