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

Styles, 'with, shared stuff & confusion ...

 [1/2] from: petr::krenzelok::trz::cz at: 13-Nov-2000 15:06


Hi, last two or three weeks I try to use /View for various purposes, and am struggling with strange /View behavior and in my opinion the rebol object architecture is the reason for unwanted behavior .... As we know: once you create clone of object, you will receive separate context, except the subobjects - they are shared. I am not sure what it is good for (memory saving?), but I remember Carl's message to one of the latest /View releases, stating "more stuff is copied now" or something similar. 1) ----------- First I met the problem when I tried to put several progress bars into one window, and tried to change it's bar property - the change was reflected thru ALL progress bars in the view, and you will surely agree that's something I didn't want to do. So I had to save the bar first to solve my problem: saved-bar: make system/view/vid/vid-styles/progress/bar [] styly: stylize [ txt: text bold font [shadow: none] progr1: progress with [ color: none bar: make saved-bar [] ; and here we make the copy of our saved-bar ... bar/color: none bar/effect: [gradmul 0x1 255.100.100] ] ] Now the question - wouldn't we expect such behavior by default? ---------------- 2) the 'stylize or 'with is buggy in a similar way, or so it seems so .... scenario: I have panel and large bitmap inside of it. I want to put another face in the view, which I want to be transparent .... -------- observations: ------------- - once I created 'imagemap style, each new 'image was affected. Just touch the zooming face and try to move mouse. Because of reverse-confine function it jumps at the corner ... No matter if you use 'image, 'box, etc, they will all share 'engage method, while they shouldn't imho ... note - reverse confine is reverse behavior of confine function - very good aproach to keep larger bitmap on-bonds ... - second observation is speed. Try to uncomment second line and comment out first line: at 100x100 b: box 100x100 "Zoom" effect [crop 0x0 50x50 fit] edge [size: 2x2] ; at 100x100 b: box 100x100 "Zoom" effect [crop 0x0 50x50 fit] with [edge/size: 2x2] you will see so drastical speed difference you will not believe it even on your pentium 600 box ;-) So - is 'with flawed? Shouldn't it produce the same result? note1 - once setting 2x2 edge - EACH 'image, 'box, etc. in view will have the same edge - shared stuff in action once again ... note2 - try to comment out second line, and uncoment first one, and you will receive still the same results ... I tried, unviewing, unsetting, recycling, but the result is still very low speed. The only one thing which seems to help is restarting rebol ... 3) Now comment out following line from stylize block: face/offset: reverse-confine face/offset face/size 0x0 face/parent-face/size After restarting the script you will be able to move your Zoom face, and you can also move your imagemap out of boundaries of panel (black background will appear). -Move Zoom face to the left side of the panel - can you see the reflection? A bug? It should be clipped by pane boundaries imho ... - Move corner of imagemap over the Zoom face .... part of "Zoom" text appears on the Zoom face once again ... - try to move the background - ugh ... even backtile is reflected ... - btw: don't try to "print mold p", as panel doesn't seem to use it's pane - instead of that it uses parent-face field, and its pane. You will end up printing all rebol/view styles in endless "?" loop (well, after 2 megs of data I stopped echoing to file) 4) delete 'black from panel definition and move the imagemap - you will notice the slowdown, as we don't cache the background. So let's do it all by following code: p: panel 500x400 [ at 0x0 img: imagemap mapa at 100x100 b: box 100x100 "Zoom" effect [crop 0x0 50x50 fit] edge [size: 2x2] ; at 100x100 b: box 100x100 "Zoom" effect [crop 0x0 50x50 fit] with [edge/size: 2x2] ] with [saved-area: true] - move imagemap away and you will see another one under it - rebol saves it's face backrounds together with already displayed stuff upon it ... it's a bug in layout imho .... OK, here's the all script ... I hope some of you will find my observations informative to avoid struggling with similar behavior once coding in /View ... PS: sent to feedback ... Cheers, -pekr- ----------------- REBOL [ Title: "Cyklotrasy ..." Author: "Petr Krenželok" Email: [pekr--rebol--cz] Date: 12-Nov-2000 ] reverse-confine: func [ {Return the correct offset to keep rectangular area on-bounds.} offset [pair!] "Initial offset" size [pair!] "Size of area" origin [pair!] "Lower bound (upper left)" margin [pair!] "Upper bound (lower right)" ][ if offset/x > origin/x [offset/x: origin/x] if offset/y > origin/y [offset/y: origin/y] margin: margin - size if offset/x < margin/x [offset/x: margin/x] if offset/y < margin/y [offset/y: margin/y] offset ] cyklo-styles: stylize [ imagemap: image with [ feel/engage: func [face action event][ if action = 'down [face/data: event/offset] if event/type = 'move [ face/offset: face/offset + event/offset - face/data face/offset: reverse-confine face/offset face/size 0x0 face/parent-face/size ] show face ] ] ] print "Downloading images .... Wait please." titl: load-thru http://www.rebol.cz/~kondik/cyklo/grafika/00cyklo.GIF mapa: load-thru http://www.rebol.cz/~kondik/cyklo/grafika/4mapa.jpg main: center-face layout/size [ styles cyklo-styles bckgr: backtile %carlwaves.jpg effect [tile gradcol 0x1 0.0.100 0.0.250] nadpis: image titl across p: panel black 500x400 [ at 0x0 img: imagemap mapa at 100x100 b: box 100x100 "Zoom" effect [crop 0x0 50x50 fit] edge [size: 2x2] ; at 100x100 b: box 100x100 "Zoom" effect [crop 0x0 50x50 fit] with [edge/size: 2x2] ] sly: slider 16x400 [ img/offset/y: negate to-integer ((img/size/y - p/size/y) * sly/data) show img ] below slx: slider 500x16 [ img/offset/x: negate to-integer ((img/size/x - p/size/x) * slx/data) show img ] ] 640x490 none view main

 [2/2] from: al:bri:xtra at: 14-Nov-2000 15:54


pekr wrote:
> last two or three weeks I try to use /View for various purposes, and am
struggling with strange /View behavior and in my opinion the rebol object architecture is the reason for unwanted behavior ....
> As we know: once you create clone of object, you will receive separate
context, except the subobjects - they are shared. I am not sure what it is good for (memory saving?), but I remember Carl's message to one of the latest /View releases, stating "more stuff is copied now" or something similar. This could help you, pekr. It clones a object! and correctly copies objects that are members. [ Rebol [ Name: 'Clone Title: "Clone" File: %Clone.r Home: http://members.nbci.com/AndrewMartin/Rebol/Enhancements/ Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 17/October/2000 Version: 1.0.0 Enhancement: 'Clone Acknowledgements: "Erin A. Thomas" Purpose: { Clone objects by copying objects inside. } Example: [ New_object: Clone Original_Object [] ] ] Clone: function [ {Clones all sub-objects and hashes, so there are no multiple references.} [catch] Object [object!] "The object to clone." Block [block!] "Extra code for this object." ][ Cloned Member ][ throw-on-error [ Cloned: make Object Block foreach Word next first Object [ Member: get in Cloned :Word if same? Member get in Object :Word [ set in Cloned :Word either object? Member [ Clone Member [] ][ either any [ series? Member port? Member bitset? Member ][ copy/deep Member ][ Member ] ] ] ] Cloned ] ] ] Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/