Layout in more than one pane
[1/25] from: ammonjohnson:y:ahoo at: 31-Oct-2001 19:42
Hi,
I have been playing with panes & I have discovered some interesting behavior. If you
try to dynamically create two panes that are in essence the same, but need to function
seperately (as copies?). How do I copy a layout? I have tried:
a: layout [
b: box
c: box
]
d: [box "hello"]
b/pane: copy layout d
c/pane: copy layout d
ERROR!
** Script Error: copy expected value argument of type: series port bitset
** Where: make-win
** Near: new-bar/pane: copy layout/offset bar-content 0x0
so then I tried:
a: layout [
b: box
c: box
]
d: layout [box "hello"]
b/pane: copy d
c/pane: copy d
ERROR! Face in more than one pane.
This also returns face in more than one pane:
a: layout [
b: box
c: box
]
d: to-block layout [box "hello"]
e: copy d
b/pane: do d
c/pane: do e
Any thoughts? Has anyone dealt with this before?
Thanks!!
Ammon
[2/25] from: dockimbel:free at: 1-Nov-2001 3:00
Hi Ammon,
>> a: layout [b: box c: box]
>> d: [box "hello"]
== [box "hello"]
>> type? a
== object!
so
>> b/pane: make layout d []
>> c/pane: make layout d []
HTH,
-DocKimbel.
Ammon Johnson wrote:
[3/25] from: ammonjohnson:ya:hoo at: 1-Nov-2001 11:34
I can't seem to make that work in a little different application. What is
wrong with this code?
a: layout/offset [origin 0x0 space 0x0 box "hello"] 100x100
b: layout [origin 0x0 box "hello"]
c: layout [box with [pane: make b []]]
append a/pane make c []
append a/pane make c []
it returns the infamous "Face in more than....."
Thanks!!
Ammon
----- Original Message -----
From: "Nenad Rakocevic" <[dockimbel--free--fr]>
To: <[rebol-list--rebol--com]>
Sent: Wednesday, October 31, 2001 7:00 PM
Subject: [REBOL] Re: Layout in more than one pane
> Hi Ammon,
> >> a: layout [b: box c: box]
<<quoted lines omitted: 12>>
> >
> > I have been playing with panes & I have discovered some interesting
behavior. If you try to dynamically create two panes that are in essence
the same, but need to function seperately (as copies?). How do I copy a
layout? I have tried:
[4/25] from: media:quazart at: 1-Nov-2001 15:30
I encountered the exact problem this week :-)
ok, where there are several things wrong... first is that the layout
function returns a pane within a pane... so if you just append that you'll
run into problems... cause each time your just returning the same object!
start by using b/pane/1 and you already clear one thing BUT even that face
still contains a link to the same object, you're trying to append twice...
I always thought of the "make" function as a dynamic thing. but in reality
it is a static, one time evaluation. so since you are adding your box with
a nested pane twice it is adding a different pane, but each pane references
that same and unique instance of "make b []" (the VID box).
its like if you say that make b executes itself once and then every other
time its first evaluation is returned instead...
in your example, the window pane created in b is new everytime, but the pane
which holds the box is always the same... cause layout encapsulates your box
inside another pane...
there is another insidious occurence of the same kind of problem when you
just use "something: []" instead of "something: copy [] " within a function
which creates faces... everyone ends up refering to the same pane...
In practice, I have noticed that trying to mix VID and direct View usage is
just plain frustrating... you're better of doing just one or just the
other... otherwise it's really hard trying to make sure that binding is
exact and that problems like the one you illustrate do not crop up... (which
in my experience is sometimes impossible without a completely direct view
hack
...)
I would have included a "fixed" example but the truth is that it just wont
work unless I completely rewrite it... and in that case there's no real
point... in using any of the VID calls anyways...
this should work:
rebol[]
vidbox: layout [box "hello" 90x30 ibevel]
master-face: make face [offset: 100x100 ]
sub-face: make vidbox/pane/1 ;extract the actual box...
master-face/pane: copy []
append master-face/pane prev-face: make sub-face [offset: 0x0]
append master-face/pane make sub-face [
offset/y: prev-face/offset/y + size/y offset/x: prev-face/offset/x
]
view master-face
I added some positioning stuff on the second make face, just to align them
together.
hope this helps
-MAx
[5/25] from: ammonjohnson:ya:hoo at: 1-Nov-2001 16:32
getting closer... now we got two single faces in the same face. How about
two? That's simple:
a: layout/offset [size 250x250 origin 0x0 space 0x0 text ""] 100x100
b: layout [origin 0x0 box "hi!"]
c: layout [origin 0x0 button "push me!"]
d: make b/pane/1 []
append a/pane make d [pane: make c/pane/1 []]
append a/pane make d [pane: make c/pane/1 [] offset: 0x100]
view a
Thanks!!
Ammon
[6/25] from: ptretter:charter at: 1-Nov-2001 17:18
Is this an alternative?
face1: make face [pane: make face [text: "pane1"]]
view face1
face2: make face [pane: make face [text: "pane2"]]
view face 2
face1/pane/pane: face2
view face 1
This is just adding panes to a face but I am having a hard time really
determining the real difference between a face and a pane as it seems that
all panes begin with make face. So this approach seems to make sense to me
anyway. Anybody else?
Paul Tretter
[7/25] from: sterling:rebol at: 1-Nov-2001 15:26
I missed the beginning of this thread so I'm just jumping into the
middle here.
A pane is a collection of faces. It can be a single face, but it can
also be a block. For example:
; ake two layouts with some faces in them
lay1: layout [button red "Red Button" [unview]]
lay2: layout [pad 50x0 button green "Green Button" [unview]]
; make some other face or a layout with a pane
main: make face [size: 200x200 pane: copy []]
; add in the faces that are in the other layouts
append main/pane lay1/pane ; first
append main/pane lay2/pane ; layered on top
view main
; now reverse them
clear main/pane
append main/pane lay2/pane
append main/pane lay1/pane
view main
Does that help out at all?
Sterling
[8/25] from: ptretter:charter at: 1-Nov-2001 18:27
Good info Sterling. This would be good to add to the RT site or better yet
some information regarding using faces outside of using VID. I know when I
was inquiring about this that many people had similiar interests and as well
with this topic.
Paul Tretter
[9/25] from: giesse:writeme at: 8-Nov-2001 11:03
Cyphre wrote:
> Aha.The key won't work because of "find-key-face" VID mezanine-function:
Indeed, but are you sure there are no other things like that which
do not support words in panes? Since the thing is not documented,
I would not rely heavily on it... (considering that a reduce is
easy to do...)
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[10/25] from: cyphre:seznam:cz at: 2-Nov-2001 9:58
Hi Sterling and list,
---- Original Message -----
From: <[sterling--rebol--com]>
To: <[rebol-list--rebol--com]>
Sent: Friday, November 02, 2001 12:26 AM
Subject: [REBOL] Re: Layout in more than one pane
........
> I missed the beginning of this thread so I'm just jumping into the
> middle here.
>
> A pane is a collection of faces. It can be a single face, but it can
> also be a block. For example:
>
........
maybe this is a little bit out of topic but I'm posting it to remind you
this two bugs (which I had already posted to feedback) because I believe you
are intensively working on the next release ;-)
first bug:
a: make face [size: 50x50 color: red]
b: make face [color: blue pane: [a]]
view layout [bx: box with [pane: [b]] button "hide box" [hide bx]]
second bug:
a: make face [size: 50x50 color: red]
view layout [box with [color: blue pane: [a]] button "hide box" [hide
a/parent-face]]
regards,
Cyphre
[11/25] from: media:quazart at: 2-Nov-2001 7:16
Hi Paul,
did you go over the How-To which covers handling input !?
-MAx
[12/25] from: rotenca:telvia:it at: 2-Nov-2001 22:43
Hi, Cyphre
> maybe this is a little bit out of topic but I'm posting it to remind you
> this two bugs (which I had already posted to feedback) because I believe you
<<quoted lines omitted: 3>>
> b: make face [color: blue pane: [a]]
> view layout [bx: box with [pane: [b]] button "hide box" [hide bx]]
I think this is not a bug of Vid, but of this piece of code which put a word
in the block of pane, not a face, the correct version should be:
a: make face [size: 50x50 color: red]
b: make face [color: blue pane: reduce [a]]
view layout [bx: box with [pane: reduce [b]] button "hide box" [hide bx]]
> second bug:
>
> a: make face [size: 50x50 color: red]
> view layout [box with [color: blue pane: [a]] button "hide box" [hide
> a/parent-face]]
The same i think for the last.
---
Ciao
Romano
[13/25] from: ammonjohnson:yaho:o at: 2-Nov-2001 21:44
On Win2K REBOL just kills over. Is that what you see, or is there an error
it normally returns?
Thanks!!
Ammon
[14/25] from: cyphre:seznam:cz at: 5-Nov-2001 10:01
Hi Romano,
......snip......
> I think this is not a bug of Vid, but of this piece of code which put a
word
> in the block of pane, not a face, the correct version should be:
> a: make face [size: 50x50 color: red]
<<quoted lines omitted: 6>>
> > a/parent-face]]
> The same i think for the last.
Yes, but as you can see(and Sterling said it too) "pane can be a single
face, but it can
also be a block.". There is no problem with reducing of the pane, because
faces are shown properly even when the pane contains block of words. I think
problem is in 'hide command which don't work properly in that case. Maybe
you will ask why I need to be pane a block of words? Because it is a lot
better accesible, readable, easier,(and IMO faster) to manipulate with block
of words than block
of objects. I'm just wondering that almost noone is using this method ;)
regards
Cyphre
[15/25] from: cyphre:seznam:cz at: 5-Nov-2001 10:05
> On Win2K REBOL just kills over. Is that what you see, or is there an
error
> it normally returns?
>
Under WIN98 Rebol just crashes:
Aplikace REBOL způsobila neplatnost stránky
v modulu REBOL.EXE na adrese 015f:0041924f.
Registry:
EAX=00000737 CS=015f EIP=0041924f EFLGS=00010206
EBX=00dd3098 SS=0167 ESP=006bf158 EBP=006bf170
ECX=00d0e104 DS=0167 ESI=00d0e104 FS=1337
EDX=000005c9 ES=0167 EDI=00cc88e4 GS=0000
Bajty v CS:EIP:
8b 40 0c 8b 40 08 83 c0 50 80 38 09 75 29 83 65
Výpis zásobníku:
00cc88e4 00d0e114 00000004 00d137a4 00000000 006bf1c0 006bf198 004192d2
00c5e618 00d0e104 00cc88e4 00c5e618 00000000 00000001 00000001 00cc88e4
regards,
Cyphre
[16/25] from: brett:codeconscious at: 5-Nov-2001 23:52
Cyphre,
> Maybe
> you will ask why I need to be pane a block of words? Because it is a lot
> better accesible, readable, easier,(and IMO faster) to manipulate with
block
> of words than block
> of objects. I'm just wondering that almost noone is using this method ;)
Because I had no idea. Thanks for the tip!
Brett.
[17/25] from: media:quazart at: 5-Nov-2001 10:59
hi Cyphre,
I just noticed, that you mentioned rebol being able to handle a pane with a
block of WORDS!
I have never tried... must the words be preset objects
do you mean something like?:
mybox: make face []
mybox2: make face []
mywindow: make face [offset: 30x30 pane: copy [] ]
append mywindow/pane 'mybox
append mywindow/pane 'mybox2
view mywindow
in this case, is the binding/context always global?
-MAx
[18/25] from: rotenca:telvia:it at: 5-Nov-2001 17:20
Hi, Cyphre
> > > a: make face [size: 50x50 color: red]
> > > view layout [box with [color: blue pane: [a]] button "hide box" [hide
<<quoted lines omitted: 5>>
> also be a block.". There is no problem with reducing of the pane, because
> faces are shown properly even when the pane contains block of words.
I did not know this feature! I was asking me why i see the 2 areas in your
example...
> regards
>
> Cyphre
ciao
romano
[19/25] from: cyphre:seznam:cz at: 5-Nov-2001 18:14
Hi MAx,
here is simple example of the method I mentioned before:
(note that subfaces can be in non-global context as well, but it is up to
you)
---------------------snip------------------------------------
my-window: make face [
red-face: make face [color: red size: 50x50 offset: 0x0]
blue-face: make face [color: blue size: 50x50 offset: 25x25]
edge: none
pane: copy []
]
append my-window/pane in my-window 'blue-face
append my-window/pane in my-window 'red-face
view layout [
box with [pane: my-window]
button "switch" [
remove append next my-window/pane first my-window/pane
show my-window
]
button "rnd color" [
foreach obj my-window/pane [
my-window/:obj/color: random 255.255.255
]
show my-window
]
]
--------------------snip--------------------------------
as you can see with this method you can really very easy control subfaces in
pane ;)
I believe RT will fix the 'hide bug in the next release.
regards
Cyphre
[20/25] from: media:quazart at: 5-Nov-2001 12:30
hi Cyphre!
Really cool, now I have to see if I should provide support (or at least some
error handling) for this useage...
thanks!
-MAx
[21/25] from: g:santilli:tiscalinet:it at: 5-Nov-2001 22:55
Hello Cyphre!
On 05-Nov-01, you wrote:
C> of objects. I'm just wondering that almost noone is using this
C> method ;)
Because most of the code does not handle it. (Try, for example, to
assign a key to a button and reference it or its pane via a
word...)
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[22/25] from: cyphre:seznam:cz at: 6-Nov-2001 9:40
Hi Gabrielle,
> C> of objects. I'm just wondering that almost noone is using this
> C> method ;)
>
> Because most of the code does not handle it. (Try, for example, to
> assign a key to a button and reference it or its pane via a
> word...)
Sorry but I don't exactly know how do you mean that. Could you make a little
example?
regards
Cyphre
[23/25] from: allenk:powerup:au at: 6-Nov-2001 22:11
Hi Cyphre,
I think it is an interesting technique (I remember from when you used it in
the first SWIS.)
However I do a lot of pane manipulation with loops and found that works
better for me in many cases.
I also thought that it would slow down the rendering of a pane as View
determines if each element is face or not.
But it is a good way of simplifying a pane and more easily
identifying/selecting objects from the pane, so I do use it as the case
warrants.
Cheers,
Allen K
[24/25] from: giesse:writeme at: 7-Nov-2001 15:28
Cyphre wrote:
> Sorry but I don't exactly know how do you mean that. Could you make a little
> example?
panel: layout [
Button "Hello!" #"H" [print "Hello!"]
]
view panel ; try pressing "H"
view make face [
size: panel/size + 50x50
pane: [panel]
] ; try pressing "H"
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[25/25] from: cyphre:seznam:cz at: 7-Nov-2001 16:59
Aha.The key won't work because of "find-key-face" VID mezanine-function:
here is fixed function replacement which solve the bug, I believe RT will
fix it in the next release ;)
--------------------snip--------------------
find-key-face: func [
"Search faces to determine if keycode applies."
face [object!] keycode [char! word!] /local w f result
][
either all [
w: in face 'keycode
w: get w
any [keycode = w all [block? w find w keycode]]
] [face] [
w: in face 'pane
either block? w: get w [
result: none
foreach f w [
if word? f [f: get f]; quick-fixed by Cyphre-use at
your own risk ;)
if all [object? f f: find-key-face f keycode]
[result: f break]
]
result
] [
if object? :w [find-key-face w keycode]
]
]
]
-------------snip------------
Regards,
Cyphre
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted