Oh, well read the manual: Shoes thinks of percentages in decimals from
0.0 to 1.0 (0% to 100%). 50% = 0.5 in Shoes.

On Fri, May 22, 2009 at 10:10 AM, Satoshi Asakawa <[email protected]> wrote:
> Hi _why,
>
> Thank you for the explanation.
> I understood to need `start` block!
>
> But still a bit confusing for the following behavior. :(
>
> Shoes.app do
>   o = oval :top => "50%", :left => "50%"
>   start do
>     para "oval is at (#{o.top}, #{o.left})"
>   end
> end
>
> Run the above snippet, it didn't work and I got the error
> on Shoes console window:
>
> Error in C:/Program Files/Common Files/Shoes/0.r1134/lib/shoes.rb line 394 :
> can't convert String into Integer
>
> Then replaced "50%" to 0.5.
> It works but displayed `oval is at(0, 0)`.
>
> Then again replaced "50%" to 100.
> It works and displayed `oval is at(100, 100)`.
>
> Umm... I'm using Windows XP and Shoes 2 (0.r1134).
>
> Regards,
> ashbb
>
>
> On Sat, May 23, 2009 at 12:50 AM, _why <[email protected]> wrote:
>>
>> On Fri, May 22, 2009 at 12:04:35PM +0000, Ehsanul Hoque wrote:
>> > Ahh, well I did expect it to work like that, hmmm... It still
>> > could be justified I suppose, it's really upto _why whether
>> > it's a bug, or just a "feature", just how it works.
>>
>> Until the image is drawn, you can't really know `top` and `left`.
>>
>> For instance, let's say you're using percentages:
>>
>>  Shoes.app do
>>    o = oval :top => "50%", :left => "50%", :radius => 20
>>    para "Oval is at (#{oval.top}, #{oval.left})"
>>  end
>>
>> Until we compute the window size, the coordinates can't be shown.
>> So, what you do is get the coordinates in the `start` block:
>>
>>  Shoes.app do
>>    o = oval :top => "50%", :left => "50%", :radius => 20
>>    start do
>>      para "Oval is at (#{oval.top}, #{oval.left})"
>>    end
>>  end
>>
>> Because the start block runs after the first paint.
>>
>> It still feels like a bug, but I'm not sure if I want to recompute
>> every slot each time a new element is added. I will probably have
>> `top` and `left` and `width` and so on return exceptions if you
>> try to use them before the window is painted... I don't know.
>>
>> _why
>
>



-- 
    ~devyn

Reply via email to