[REBOL] Re: VID questions
From: brett:codeconscious at: 26-May-2001 0:33
> Yes, I have read them but these docs just mentioned the objects... that's
> Anyway, I'm seeking through all kind of postings and collecting knowledge
> all the samples posted.
Yes unfortunately the VID Doco needs more work.
> > I understand what you mean, kind of like the pack command in Tcl, etc.
> > You may need to undergo a small paradigm shift. In this case, 'view is
> > a function that displays the initial face layout. It kicks it off, so
> > to speak. Later, after modifying faces in a layout, 'show allows *just*
> > that face to be updated. It is more processing-efficient than going
> > through 'view again.
> Hmm... why is the paradigm shifted? I think the difference between
> definitions/declarations and code which is actually executed is quite
> find it even more strange that I can't define Rebol variables inside the
In Rebol, I'm not sure there is any such distinction between
definitions/declarations and code which is actually executed. The only
non-executable code in Rebol is unevaluated blocks if remember correctly.
A VID specification is code that is interpreted. Interpreted differently
from normal Rebol code. I say this to highlight that VID is a more concise
way to achieve certain GUI goals - like layout.
Regarding variables. set-words in VID are used to capture references to the
face objects that are created.
Eg. layout [text-face: text "I'm a text face"]. They become global unless
you have pre-created them inside an object. You can also use the DO word to
execute normal Rebol code - though it will DO it only once. Also remember
that action blocks for various VID styles become functions.
an-object: context [
text-face: none ; Pre-creating a variable to store a reference to a
the-layout: layout [
text-face: text "I'm a text face"
button "SetVar" [just-a-variable: add 1 just-a-variable]
I want to include here some slightlyt edited stuff I wrote to myself while
learning View. I don't guarantee correctness - just showing how I think
about what I see (a programmer's viewpoint).
===Faces and VID
The most fundamental graphical element of Rebol/View is the Face.
Faces in Rebol are represented as objects and on the screen are
represented by a rectangular visual image. One can manipulate the objects
to achieve effects on the screen.
Rebol View uses the model you create (an object model) to render
the screen. The model also contains words and functions that react to
various events. The VIEW function takes a face (which may comprise
other faces - ie it is the a root of an object model) and renders it.
VID is a dialect. The purpose of VID is to describe faces in a language
which is easier to write than creating faces directly using object notation.
structure of VID and the machinery that supports it comprise an ingenious
solution to this problem. Producing simple GUIs with VID is probably very
important to the uptake of Rebol/View. For those that have not programmed
before VID provides a very easy entry to building a GUI.
The main interpreter of VID is the LAYOUT function. This function takes
a VID specification and create the faces. It returns a face which
encompasses all the faces created from the VID specification.
===Is understanding VID enough?
While, I believe VID achieves the goal of creating screen representations
easily, there comes a point where one wants to create a more complex user
interface using VID. By complex I mean where there is a relationship
between one "widget" on screen and another. Such relationships are common
in user interfaces. For example, press a button and something becomes
disabled, or move a slider and something scrolls.
When programming at this level, I believe it helps to keep in mind what work
VID is accomplishing for you - creating faces and adding them to an object
model of faces.
I also think that one should remember that Rebol/View interprets the face
model in order to create the screen representation (image) and to react to
events. This concept helps when one encounters an unexpected behaviour. For
example moving a slider and seeing the text on a different window scrolling.
In this case one should remember how words and values are treated in Rebol.
Consider strings, this code [a: "the cat" b: a clear b] - would result in
the string referred to by a being empty. In the same way, faces are objects
point to all sorts of values. If a value is shared amongst different faces
changes that value what is the effect? All faces sharing the same string
object value, etc would be changed.
This can be useful - it can also be very confusing
when you have worked with other GUI development tools and you bring along a
habits of thought from those environments.
So is understanding VID enough? Most definitely sometimes and perhaps not