Red [ needs 'view ] view/flags [ ip: panel papaya [ p: image 300x300 [ g: load request-file/filter ["png" "*.png" "jpg" "*.jpg"] ; get image y of x rr: round (300.0 * (g/size/y / g/size/x)) ; attempt to scale image container, but gets cut-off p/size/y: to-integer rr p/image: g ;attempt to scale panel (should this be automatic?), but it gets cut-off ;ip/size/y = ip/size/y + (300 - rr) ] ] ] [ modal resize ]
#!/usr/local/bin/red
Red [
]
mainWin: layout [
title "Resizing Image"
f: field "256x256"
button "Quit" [quit] return
canvas: base 256x256 %lena.png
]
view/flags/options mainWin [resize] [
actors: object [
on-resizing: function [face [object!] event [event!]][
win: face
canvas/size: win/size - 20x60
f/text: form canvas/size
]
]
]= instead of : when resizing the container panel.#!/usr/local/bin/red
Red [
Title: "Resize test"
Author: "Francois Jouen"
File: %resize3.red
Needs: 'View
]
_offset: 0x0
loadImage: does [
tmp: request-file/filter ["png" "*.png" "jpg" "*.jpg"]
if not none? tmp [
_offset: canvas/offset + 10
img: load tmp
canvas/size: img/size
mainWin/size: _offset + img/size
f/text: form canvas/size
canvas/image: img
]
]
mainWin: layout [
title "Resizing Image"
button "Load Image" [loadImage]
f: field 70 "256x256"
button "Quit" [quit] return
canvas: base 256x256 black
]
;--resize event processing
view/flags/options mainWin [resize] [
actors: object [
on-resizing: function [face [object!] event [event!]][
win: face
canvas/size: win/size - _offset
f/text: form canvas/size
]
]
] tmp: request-file/filter ["Image Files" "*.png;*.jpg; *.bmp"]
Red [ needs 'view ] view [ drop-down 180x30 "" select 2 data["two" "four" "eight"] on-enter [ append face/data face/text ] ]
select only works for drop-list of the two drop-* styles. @qtxie might be able to say why.Red [ needs 'view ] view [ d: drop-list 180x30 select 2 data["two" "four" "eight"] [f/text: pick face/data face/selected ] f: field 180x30 on-enter [ append d/data face/text d/selected: (length? d/data) probe d/data ] ]
select only works for drop-list of the two drop-* styles. @qtxie might be able to say why.drop-down.Gtk-CRITICAL **: 21:33:14.063: gtk_widget_set_size_request: assertion 'width >= -1' failedRed [ needs 'view ] view [ panel 120x120 with [ extra: [name: "panel_1" id: 1 ] ] [ field 80x30 "edit" ] on-down [ print "panel selected: " probe face/extra/name ] ]
view [panel 120x120 extra [name: "panel_1" id: 1] [field 80x30 "edit" on-down [print "hit field"]]]
done in corresponding actors of contained faces to prevent these from bubbling up:view [
panel 120x120 extra [name: "panel_1" id: 1 ] [
field 80x30 "edit" on-down ['done]
] on-down [ print "panel selected: " probe face/extra/name]
]on-down ['done] is preventing text selection in this case. Also need to use events on panel to update ui elsewhere.root@ubuntu-2gb-nbg1-1:/usr/local/bin# lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.3 LTS Release: 18.04 Codename: bionic root@ubuntu-2gb-nbg1-1:/usr/local/bin# ls red-064.dms red2019.dms red.dms root@ubuntu-2gb-nbg1-1:/usr/local/bin# red.dms Unable to init server: Could not connect: Connection refused (console-2021-3-16-29645:1717): Gtk-WARNING **: 17:43:54.824: cannot open display: root@ubuntu-2gb-nbg1-1:/usr/local/bin#
red-16mar21-0051dff08(I renamed red.dms) it gives me error above
export DISPLAY=:0red.dms --no-view in this case. Don't forget to delete the old caches (folder ~/.red) before running this command.Red [ needs 'view ]
getpanel: function [ md ] [ compose/deep [ panel 55x55 30.30.30 with [ offset: (md) ] [] ] ]
view [
panel 400x600 [] on-down [
probe event/offset
append face/pane layout/only getpanel event/offset
]
](console-2021-3-28-10126:39690): Gtk-CRITICAL **: 15:12:40.593: gtk_widget_grab_focus: assertion 'GTK_IS_WIDGET (widget)' failed
wait 1 before appending to a panel/face... think I'll just restart, its been acting weird all day.layout/only, it also sets the offset to 10x10.>> get in first layout/only getpanel 200x200 'offset == 10x10
Red [ needs 'view ]
getpanel: function [ i bgc ] [
compose/deep [ panel 200x55 30.30.30 loose with [ color: (bgc) ] extra [ idx: (i) ] [ ] draw [] ]
]
view [
aa: panel 400x600 [ text "click to add panel" ] on-down [
clear face/pane
repeat n 10 [
rc: to-tuple reduce [ (min 80 random 120) (min 80 random 120) (min 80 random 120) ]
append face/pane layout/only getpanel n rc
]
foreach-face face [
unless none? face/extra/idx [
face/offset/y: to-integer ((face/extra/idx - 1) * (face/size/y + 10)) + 10
]
]
]
]*** Runtime Error 1: access violation *** at: 0807FDE3h
draw [] that's causing itlibgtk-3-0:i386 installed, I get an error:$ ./red-12apr21-630069f9e --no-view --cli Unable to init server: Could not connect: Connection refused (console-2021-4-12-26611:12814): Gtk-WARNING **: 14:27:35.576: cannot open display:
$ rm ~/.red/console-* $ ./red-12apr21-54b646f22 --no-view
draw [], then view [panel draw []] should make it crashes.recycle/off before running the script will fix it.recycle/offrequest-file doesn't work or it works but has warning?#!/usr/local/bin/red Red [ Title: "Draw tests " Needs: 'View ] img: make image! reduce [512x512 white] loadImage: does [ tmp: request-file unless none? tmp [ img: load tmp canvas/image: img ] ] view win: layout [ title "Image Tests" button "Load" [loadImage ] button 60 "Quit" [Quit] return canvas: base 512x512 img ]