Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL]Panel Problems

 [1/9] from: sanghabum:aol at: 27-Jun-2001 2:41


Can anyone replicate or explain this problem with panels? And then suggest a work-around? On my machine (PC / Win 98; View 1.2) the change to one box alters ALL boxes in BOTH Panels. I get the same problem when changing text effects, and other features, when using subpanels. Thanks, Colin. mainlayout: layout [across My-panel: box 400x600 green ;field for subpanels return Button "Display panel 1" [ My-panel/pane: panel1 Show My-Panel ] Button "Display Panel 2" [ My-panel/pane: panel2 Show My-Panel ] Button "Modify&Display panel2" [MyBox/edge/size: 3x3 MyBox/edge/color: 255.255.255 My-panel/pane: panel2 Show My-Panel ] ] ;layout Panel1: layout [info "Panel1" box red box white box blue ] panel2: layout [info "panel2" mybox: box silver box gray box maroon] unview/all view mainlayout halt

 [2/9] from: arolls::bigpond::net::au at: 27-Jun-2001 17:49

Re: [REBOL]Panel Problems - make a copy of box/edge


The boxes use an embedded object 'edge. This is shared by all the boxes. To see it: probe get-style 'box You will need to make a copy of the edge object and set it into your own style of box. Let's see source at bottom:
> Can anyone replicate or explain this problem with panels? And > then suggest a
<<quoted lines omitted: 32>>
> view mainlayout > halt
rebol [ Title: "" File: %stylize-box-edge.r Date: 27-Jun-2001 Version: 1.0.0 Needs: [view] Author: "Anton Rolls" Language: 'English Purpose: { Demonstrate how to make a new style of box with a different embedded edge object, so that changes to the edge of a box don't affect the edges of all boxes. } ToDo: { - } History: [ 1.0.0 [27-Jun-2001 {First version} "Anton"] ] Notes: { probe get-style 'box } ] my-style: stylize [ my-box: box with [ ; you could just box: box with [...] ; modify the box's init function append init [ edge: make edge [ ; make a copy of the box/edge color: black ; make it black too ] ] ] ] view center-face layout [ styles my-style ; using default box ; - both change as a result of changing first box's edge b: box "b: box" blue [ b/edge/size: 4x4 ; large b/edge/color: red show [b b2 b3 b4] ; show all boxes ] b2: box "b2: box" blue / 2 [ b/edge/size: 1x1 ; small b/edge/color: red show [b b2 b3 b4] ; show all boxes ] ; now using my-box, a style based on box ; - only third box changes as a result of ;changing third box's edge b3: my-box "b3: my-box" green / 2 [ b3/edge/size: 4x4 ; large show [b b2 b3 b4] ; show all boxes ] b4: my-box "b4: my-box" green / 3 [ b3/edge/size: 1x1 ; small show [b b2 b3 b4] ; show all boxes ] ]

 [3/9] from: brett:codeconscious at: 27-Jun-2001 17:34

Re: [REBOL]Panel Problems


Hi Colin, Edges in View are represented by the object! type of Rebol. All of your boxes, in this case, share the same object to define their edges. You code changes this object and bingo all of your boxes instantly reflect that fact. Quite nice if that is what you want :) The layout function appears to create a new edge object only if you have some edge settings as part of your layout specification. So here is one work around: panel2: layout [info "panel2" mybox: box edge [] silver box gray box maroon] For interest, the following demonstrates the same issue in a different way: view layout [ mybox: box silver box blue (mybox/edge/size: 3x3 mybox/edge/color: white) ] note what happens when you run the following straight afterward view layout [box] So the same object is being modified. Here it is: probe system/view/vid/vid-styles/box/edge Which is the same one as probe system/view/vid/vid-styles/image/edge because (I believe) that box inherits the object from image. Also for interest, I've a program that displays the ancestry (I think it does anyway :) ). do http://www.codeconscious.com/rebsite/vid-ancestry.r Brett.

 [4/9] from: sanghabum::aol::com at: 27-Jun-2001 4:51


[brett--codeconscious--com]
> Edges in View are represented by the object! type of Rebol. All of your > boxes, in this case, share the same object to define their edges. You code > changes this object and bingo all of your boxes instantly reflect that
fact.
> Quite nice if that is what you want :)
Thanks Brett and Anton, No It's not an effect I want! The shared object in View problem occurs elsewhere too---I first stumbled across this when text font sizes in Info boxes started changing in sync. I'll copy this exchange to Feedback as (at the very least) it needs mentioning in some documentation-----I can't be the only one out there who has spent a long time puzzling over this. And mabe a better soluton is a facet/Vid word that says "don't clone items for this face), eg: layout [mybox1: box unique blue mybox2: box red] So Mybox1 has all its own data objects without my having to specify them. Thanks again, --Coiln

 [5/9] from: brett:codeconscious at: 27-Jun-2001 18:25


Hi Colin, I responded once, but my machine crashed so I don't know if this will be the second message on this topic. Basically, try this. panel2: layout [info "panel2" mybox: box silver edge [] box gray box maroon] The extra "edge []" will force a new object! to be created for the specific box rather than sharing the object that Anton has described. Brett.

 [6/9] from: arolls:bigpond:au at: 27-Jun-2001 19:13

Re: [REBOL]Panel Problems - clarification


Of course, Brett, you show a much simpler way!
> panel2: layout [info "panel2" > mybox: box silver edge [] box gray box maroon] > > The extra "edge []" will force a new object! to be created for > the specific > box rather than sharing the object that Anton has described.
But, to be clear, I am not suggesting to share an object. My code demonstrates both behaviours; shared and with edge cloned each time. Incidentally, it is interesting to put an edge on a box and then go into desktop. :) Anton.

 [7/9] from: arolls::bigpond::net::au at: 27-Jun-2001 19:31

Re: [REBOL]Panel Problems - not sharing sub-objects


> I'll copy this exchange to Feedback as (at the very least) it needs > mentioning in some documentation-----I can't be the only one out > there who > has spent a long time puzzling over this.
No, you aren't. :)
> And mabe a better soluton is a facet/Vid word that says "don't > clone items
<<quoted lines omitted: 3>>
> Thanks again, > --Coiln
Surely you mean: "don't -share- items for this face". Not a bad idea. I just wouldn't use 'unique, because it's taken already. Perhaps 'clone, or 'share-not? :) However, once you get used to the system, you see it is quite efficient. You only have to clone sub-objects when you need to. I see if it is easy to clone heirarchys of objects then beginners will find it easier to create very memory-inefficient programs rather than learn how the system works and make efficient ones. Anton.

 [8/9] from: brett:codeconscious at: 27-Jun-2001 20:33

Re: [REBOL]Panel Problems - clarification


> But, to be clear, I am not suggesting to share an object. > My code demonstrates both behaviours; shared and > with edge cloned each time.
Sorry Anton, I didn't mean to suggest that. My phrasing was poor as I was rushed. I meant you had described the "why" of the sharing issue. On another issue, I also agree that economy of memory is a good thing, so shared objects makes sense. We just need a nice Vid expression that handles this case without having to drop all the way back to the wherefors of objects. Hmm... phrasing seems to be a real problem for me tonight ... :) Brett.

 [9/9] from: petr::krenzelok::trz::cz at: 27-Jun-2001 14:44


Anton wrote:
> Of course, Brett, you show a much simpler way! > > panel2: layout [info "panel2"
<<quoted lines omitted: 8>>
> Incidentally, it is interesting to > put an edge on a box and then go into desktop. :)
Yes, still the same song. :-) A little bit confusing :-) I vote for native make/deep, which would produce unshared sub-objects, or something like that. You have to be carefull and better use 'copy sometimes :-) -pekr-

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted