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

World: r3wp

[!REBOL3-OLD1]

Reichart
17-Oct-2008
[7434]
(I was simply answering just Henrik's last question)
Henrik
17-Oct-2008
[7435x2]
Anyone can make a UI (just look at the billions of Linux distros 
out there), but really few can make a lasting, memorable, useful 
and beautiful UI.
Reichart, as far as I read, they tried to make it work on the worst 
possible TV set they could find, so that's definitely a factor for 
the original color choice. But I wonder if they grabbed the look 
for OS2.0 and up from NeXTStep.
Pekr
17-Oct-2008
[7437]
Nice second video, Henrik :-) Is there being an 'over effect? If 
so, it is very mild, first time watching the video I did not notice 
anything ....
Henrik
17-Oct-2008
[7438x3]
yes, it's perhaps a little too mild. there is also a bug with 'up 
not being followed by an 'over, but Carl is fixing that.
The nice thing about the states is that I don't need to code them 
up manually for each style. Carl takes care of that and I just have 
to make the graphics for each state. Almost as good as having frames.
no need for all that hacking as was necessary with FEEL
BrianH
17-Oct-2008
[7441]
I think that the skin strategy should be to make it easy to make 
and apply skins, get Henrik to make a good default, and then let 
third parties create good new ones. There are whole web communities 
devoted to reskinning apps - if we can make a skinning infrastructure 
that appeals to them, we win.
Henrik
17-Oct-2008
[7442]
yes, I can definitely see different skins for different purposes 
or environments.
BrianH
17-Oct-2008
[7443]
Making the GUI more skinnable without much programming knowledge 
would be advertisement for R3. Every new skin put on one of the skinning 
sites gets the R3 name out there - viral marketing.
Pekr
17-Oct-2008
[7444]
Henrik - that is interesting. I asked Carl several questions privately 
(waiting for replies), and one of them being, if frames concept should 
not return back? Where is different states being expressed? All I 
can see is only single draw block? Single draw block using dynamically 
only some facets is surely not enough to express states like - enabled, 
disabled, focused, over, dragged-over, up, down, etc.?
Henrik
17-Oct-2008
[7445x3]
Pekr, having a single draw block is why they are not really frames. 
All that happens is that a state is stored as a word, in this case 
'up 'down and 'over (as far as I've observed) and then you make the 
necessary modifications to colors or other parameters to the single 
draw block. This happens inside ON-DRAW.
I'm going to post a bit of code now. The word FRAME does appear in 
it, but this appears to be from a previous version which was frame 
based. Carl has not yet come up with a new word, so don't be confused:
on-click: [ ; arg: event
	face/state/frame: arg/type
	draw-face face
	if arg/type = 'up [do-face face]
	none
]

This is where we save the state and draw the face.
Pekr
17-Oct-2008
[7448]
State as word? Do you mean in face/state block? What if you want 
e.g. focused state to be drawn by glow effect or some animation should 
be made? Imo having single draw block is not sufficient.
Henrik
17-Oct-2008
[7449x2]
on-draw: [
	material: get-facet face 'material
	frame: face/state/frame

	; change shadow, gradient and edge color

	face/facets/shadow-color:	select material/shadow frame
	face/facets/surface-color:	copy select material/surface frame

	; create average area-color

	foreach [c: color offset] face/facets/surface-color [
		change c average-colors c/1 face/facets/area-color
	]

	arg ; return draw block
]

This is the code to alter parameters for the draw block.
And that's all that is needed.
Pekr
17-Oct-2008
[7451]
so in face/state/frame, there are different draw blocks for each 
"frame"?
Henrik
17-Oct-2008
[7452x2]
draw: [
	; shadow
	pen false
	fill-pen shadow-color
	box 0x1 (area-size + 0x2) 3

	; edge
	fill-pen edge-color
	box 0x1 (area-size + 0x1) 3

	; background
	grad-pen linear 0x1 1 (area-size/y - 1) 90 1 1 surface-color
	box 1x2 (area-size - 1x0) 2
]

The single draw block for BUTTON.
So... very little code needed. Some words are referenced in FACETS 
for the style.
Pekr
17-Oct-2008
[7454]
OK, button - how does it solve, over, and down/up differences?
Henrik
17-Oct-2008
[7455x3]
Pekr, no, face/state/frame is only a word, like 'up, 'down, 'over, 
etc.
Pekr, this is done by altering the fill gradient. What you see is 
simply using different gradients for different states for the button.
The "geometry" of the button is fixed.
Pekr
17-Oct-2008
[7458]
So really only one draw block for all possible states? I think it 
might not be sufficient for more complex styles/skins, e.g. animated 
states.
Henrik
17-Oct-2008
[7459]
Pekr, we'll see how that works later, when I get to build a small 
DRAW editor.
Pekr
17-Oct-2008
[7460x3]
So - how do you add focus, or disabled state to button? By just changing 
gradients? Disabled - maybe, but focused?
We will see, so far it seems good for basic styles, but really simplified 
:-)
thanks for code examples!
Henrik
17-Oct-2008
[7463]
I've not yet studied focus or disabled. We'll see later how that 
is handled.
Gregg
17-Oct-2008
[7464]
'Fontize doesn't grab me on a first reading either. Carl always thinks 
hard about words, so he may have ruled out 'stylesheet and 'fontsheet 
system, or something like it. Not sure how ize-ing things will work, 
be he may have.
MattAnton
17-Oct-2008
[7465x3]
>> 1134903170 + 1836311903
** Math Error: Math or number overflow
** Near: 1134903170 + 1836311903
Hey guys, does anyone have any idea why rebol wouldn't be able to 
add those two numbers together?
My friend Abe challenged me to write a simple recursive fibonacci 
sequence and on the 46th iteration the program quits because rebol 
can't do that calculation. I tried it on Linux rebview and rebol/core 
and on windows vista rebview even without running my script. The 
strangest thing is that rebol can add much larger numbers, but just 
not these. Does that make any sense? try the equation in a rebol 
terminal yourself and see what I'm talking about. Very strange.
Geomol
17-Oct-2008
[7468]
Max integer is

>> to-integer 2 ** 31 - 1
== 2147483647
>> 1134903170.0 + 1836311903.0
== 2971215073.0

We see, your result is larger.
Gregg
17-Oct-2008
[7469]
But why doesn't it coerce to decimal automatically, as it does for 
larger numbers? 

Wondering why I've never seen this.
MattAnton
17-Oct-2008
[7470]
Thanks Geomol. That makes perfect sense. Should I be using decimal! 
instead?
Geomol
17-Oct-2008
[7471x3]
Becuase of 32-bit.
>> to-integer #7fffffff
== 2147483647
>> to-integer #80000000
== -2147483648
If you use decimals, you can have larger numbers, before you loose 
precision.
Up near
>> 2 ** 49
== 562949953421312.0
>> 2 ** 50
== 1.12589990684262E+15
Gregg
17-Oct-2008
[7474]
Why was I sure REBOL coerced the result in this case? Hmmm.
Geomol
17-Oct-2008
[7475]
I don't know. :-)

I often forget the math rules in REBOL too and just have to check.
MattAnton
17-Oct-2008
[7476]
I just tried "1134903170 [decimal!] + 1836311903 [decimal!] and that 
didn't work either... how can I get througth the "addition" barrier?
BrianH
17-Oct-2008
[7477x2]
People use integer! rather than decimal! because they don't want 
to lose precision at all, rather than eventually.
Matt, do this:
    (to-decimal 1134903170) + (to-decimal 1836311903)
or this:
    1134903170.0 + 1836311903.0
MattAnton
17-Oct-2008
[7479]
Thanks, now my script should work perfectly.
Geomol
17-Oct-2008
[7480]
If you write a number without a decimal point, it's an integer datatype. 
With a decimal point, it's a decimal datatype. You can use either 
in many functions:

>> for i 1 2 1 [print i] 
1
2
>> for i 1.0 2.0 1.0 [print i]
1.0
2.0
MattAnton
17-Oct-2008
[7481x2]
Rebol[]

fibonacci: func [{Makes a list of fibonacci numbers and stores them
	to a block called fibonacci-block.} loops [integer!] {Number of 
	iterations to run}
	] [
	fibonacci-block: [0.0 1.0]
	count: 0
	loop loops [
		addend-1: index? back back tail fibonacci-block
		addend-2: index? back tail fibonacci-block
		new: fibonacci-block/(addend-1) + fibonacci-block/(addend-2)
		append fibonacci-block new
		count: count + 1
		print count
		print new
		]
	Print fibonacci-block
	write %fibonacci.txt fibonacci-block
	unset fibonacci-block
	halt
	]
Print "Type fibonacci [# of loops] to make fibonacci-block."
halt
Thanks to all all of you my script works perfectly now. :-)
Geomol
17-Oct-2008
[7483]
:-)