Home   Archive   Permalink

displaying a requested image

Hi! I would like to display a thumbnail of a pic chosen by the user. Following Nick's tutorial (thanks!) I know that this is possible:
view layout [image load to-file request-file]
but this calls for the Select File dialog box before displaying the GUI. So I was hoping that something like this could work:
view layout [ a: image 160x120 btn "Load" [ a load to-file request-file show a ]]
But no image is displayed. What am I doing wrong?
Thanks for your help!

posted by:   Damian     23-May-2013/2:09:17-7:00

Untested, but you need to assign the image correctly to A:
view layout [ a: image 160x120 btn "Load" [ a/image: load to-file request-file show a ]]
The image size will also need to be adjusted, if your thumbnails aren't of equal size.

posted by:   Henrik     25-May-2013/3:05:07-7:00

Thanks Henrik, it does work.
Is this /image some kind of refinement for, well, image? If I wanted to change width or height, can I access the coordinates through some other refinement (like, for example: a/width)? Where can I find a list of the refinements available to widgets?
Thanks again!

posted by:   Damian     26-May-2013/3:01:43-7:00

Hi Damian,
Most of what you need to know about VID can be found by exploring:
help system/view/vid    
That's the same as:
? svv
Start by taking a look at this:
? svv/vid-styles
or to read it more easily:
editor svv/vid-styles
Take a look at this example:
view layout [ a: image 160x120 btn "Load" [ a/image: logo.gif a/size: 50x50 show a ]]
A really useful tool to help explore is:
do http://www.rebol.it/romano/anamonitor300.r
Click view > VID > vid-styles > image (object)

posted by:   Nick     27-May-2013/2:54:56-7:00

No, it's simpler than that: Faces are objects and you access their properties directly using refinements. The image is simply the bitmap that is assigned to that face, and with the code a/image: .... we simply assign the image manually.
You cannot set the size like this, as the assignment is "dumb". You will then need to set the size afterwards, but you will then also need to move the button manually.
If you escape your little program to the console and:
? a
you will get the face object content dumped on the console and you'll see the image assigned to that face.
You can also read the docs available here:
They are docs for an extended VID, but there is a good share of information that is related to plain VID as well, including how styles are built, how to access properties in them, etc.

posted by:   Henrik     30-May-2013/4:51:43-7:00

Thanks so much to both!

posted by:   Damian     31-May-2013/18:31:50-7:00