r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

ChristianE
14-Mar-2006
[4505]
If it's the LAYOUT user who want's different fonts, let him specify 
them.

If it''s you wanting to to have e.g. a second bold font just for 
the pressed tab in one tab-view, I think you may for example allocate 
two font objects and dynamically swap them in the FEEL/REDRAW.
Code fragment:


 redraw: func [face action offset] [... face/font: pick face/fonts 
 face/state ...]

You may even get along with changing a single font object:


 redraw: func [face action offset] [... face/font/style: if face/state 
 ['bold] ...]
Anton
15-Mar-2006
[4506]
Henrik, yes, if you expect the user will want to change the font 
attributes, you should clone the font in INIT, like this :

	font: make font []


That clones the original, shared font object that the style comes 
with. Now every instance of your style has its own font object.

(The same goes for any other facets that are objects. If you don't 
want to share them, clone them in init.)
Henrik
15-Mar-2006
[4507]
now it's a chicken and egg thing. If I clone the object inside INIT, 
the font settings inside the layout is ignored, apparently because 
they are parsed before INIT is run.
Maxim
15-Mar-2006
[4508]
imagine all the fun I am trying using VID within GLayout  ;-)
Pekr
15-Mar-2006
[4509]
GWhat? :-)
Gabriele
15-Mar-2006
[4510]
henrik, just clone on change. VID also uses a flag in face/flags 
to indicate if a given subobject has been already cloned or not (so 
to clone only once)
Henrik
15-Mar-2006
[4511]
FACE/CHANGES ?
DideC
15-Mar-2006
[4512]
In face/flags, if 'font word is in the block, then the font has already 
been cloned.
Maxim
15-Mar-2006
[4513]
Pekr:  hahahaha
Anton
15-Mar-2006
[4514x4]
Henrik, can I see an example of what you mean by "font settings inside 
the layout" ? because I am not sure it's true, given:
view layout [style bx box "box" navy with [append init [font: make 
font []]] bx bx bx font-size 40 bx]
On Gabriele's note, use FLAG-FACE? to check for flags:

	>> layout [b: box]
	>> flag-face? b font
	== none
	>> layout [b: box font-size 30]
	>> flag-face? b font
	== [font]

and FLAG-FACE when you want to set a flag yourself.
so I suppose in INIT you might do:

	append init [
		if not flag-face? self font [  ; font not already cloned ?
			font: make font []   ; clone the font
			flag-face self font  ; remember that we cloned the font
		]
	]
Ashley
15-Mar-2006
[4518]
So simple! ;)
Anton
15-Mar-2006
[4519]
Strangely, I don't recall ever having to use this technique in my 
styles, and I'm sure I dealt with these issues.
Maxim
15-Mar-2006
[4520x3]
how do we know if current view or core version has access to pro 
features (a part from doing an /attempt on a lib call
/attempt = 'attempt
(catching an error if the call is not licenced)...  obviously this 
works, but its not very nice and it would be cool to be able to list 
available /pro features.
Maxim
16-Mar-2006
[4523]
I've browsed the 'system word throughout but didn't notice any place 
where the license made a difference when I enabled/disabled it.
Anton
16-Mar-2006
[4524x3]
system/user-license  ?
Yes, that changes. You could do:
got-pro-license?: found? system/user-license/id
BrianH
16-Mar-2006
[4527x2]
component? 'library
Never mind, component? doesn't return none when the component isn't 
enabled. That seems a little silly to me.
Gabriele
16-Mar-2006
[4529]
henrik: face/changes is used to optimize show. e.g. face/changes: 
'offset means that only the offset has changed, so there's no need 
to recompute the face, but it can just be blitted to the new location.
Rebolek
16-Mar-2006
[4530]
I've tried following to get 'b local in panel but 'b is still global

>>layout [panel with [b: none][b: button]]

Is there some other way?
Anton
16-Mar-2006
[4531x2]
layout [panel with [b: none][face/b: button]]
The action function cannot know for sure that self is the face, that's 
why face is passed into every action function each time.
Rebolek
16-Mar-2006
[4533x3]
aha, I see. Thanks Anton
It looks OK, but actually, it's not working.
>> layout [panel with [b: none][face/b: button]]
Misplaced item: face/b:
Anton you're right with 'face in action block, but what I want is 
to have local words not in action but in panel definition block.
Anton
16-Mar-2006
[4536x2]
oops I see.
That's what happens when I don't test first.
Rebolek
16-Mar-2006
[4538]
I know that very well :)
Anton
16-Mar-2006
[4539]
I have an idea.
Rebolek
16-Mar-2006
[4540]
Yes?
Anton
16-Mar-2006
[4541x4]
...
>> layout [p: panel with [ctx: none insert init [ctx: context [b: 
none] bind second :action ctx]][b: button]]
>> ctx
** Script Error: ctx has no value
** Near: ctx
>> b
** Script Error: b has no value
** Near: b
>> p/ctx/b/style
== button
So you might rename CTX to VARS to give it a meaningful name.
The above approach (storing the words in a context) makes it safe 
to add variables of any name (without having to check if it would 
override a some facet of the panel style).
Rebolek
16-Mar-2006
[4545]
Yes, that works. Great, Anton!
Maxim
16-Mar-2006
[4546x3]
anton:  WRT license,  (I had found that one  ;-) this only tells 
you that a pro license is installed... not the components which it 
enables...
since components of the pro package have changed from one version 
to another... its getting a bit tedious to hope everything is properly 
mapped...
and we aren't talking of other obscure packages like dll, link, sdk... 
for which I have no clue what is enabled.
MichaelB
16-Mar-2006
[4549]
I tried to create with the following code a circle with a transparent 
background and save it. I tried some different versions, but currently 
I have no glue how to achieve this. The point is I need a file with 
a circle and a transparent background :-) and I thought I quickly 
do this with Rebol instead of using a paintprogram. So am I doing 
something wrong ? It's saving the background from the window and 
if that is set to 'none then it's black ?

view layout [
    b: box 22x22 effect [
        draw [pen red line-width 2 circle 11x11 10]
    ]
    across 
    f: field 200 button "Save" [
        file-name: to-file f/text

        unless find/last file-name ".png" [append file-name ".png"]
        save/png file-name to-image b
    ]
]
DideC
16-Mar-2006
[4550x2]
There is some rebol-XXX? words and one is 'rebol-pro?
>> help rebol-
Found these words:
   rebol-command?  logic!    false
   rebol-encap?    logic!    false
   rebol-link?     logic!    false
   rebol-pro?      logic!    false
   rebol-view?     logic!    true
   to-rebol-file   native!   Converts a local
Seems pretty recent (almost 1.2.48, not in 1.2.8)
Geomol
16-Mar-2006
[4552]
MichaelB, maybe you wanna something like:
i: to-image b
repeat n length? i [t: i/:n t/4: 255 - t/1 poke i n t]
Gabriele
16-Mar-2006
[4553]
i: make image! 22x22
i/alpha: 255
draw i [pen red line-width 2 circle 11x11 10]
save/png %test.png i
Ashley
16-Mar-2006
[4554]
component? might be another one to try.