tags:

views:

260

answers:

2

Full disclosure: I'm very new to Ruby.

The following code seems like it should update the para's text with the app's current dimensions as you resize it.

Shoes.app do  
    stack do  
        @para = para  
    end  
    animate 1 do  
        @para.text = "%d x %d" % [ app.width, app.height]  
    end  
end

But it never changes. I am aware that animation gets blocked during the actual resize operation, but when you let go of the mouse it catches up. So, am I doing something wrong or is this just not implemented on OS X yet?

+2  A: 

I don't know Shoes well, but it looks like it's a problem with changing the app's dimensions. Your animation does update, but the width and height of the app don't update. The following code shows that it does animate (the frame number will change):

Shoes.app do
    stack do
        @para = para
    end
    animate 1 do |f|
        @para.text = "%d x %d #{f}" % [ app.width, app.height]
    end
end

It further appears that other sample programs that come with Shoes don't work when you resize the window. simple-bounce.rb, which animates a bouncing ball with the Shoes logo, sticks to bouncing around in the original box, even upon resizing of the window.

It looks like this is a bug in the Shoes code.

Rudd Zwolinski
Right; the problem is with the dimensions, not the animation. I'm wondering whether there's some magic required that I don't know about, or if this is just a bug.
Zack
Yeah, it does look that way. Now to let them know about it...
Zack
A: 

I looked into the Shoes source code and it appears that it is not catching the native window resize events to update the variables inside the App object Shoes (at least for OS X). So, while Shoes sends resize events to Cocoa, they are not receiving in the other direction.

In the mean time, something like this will work a little better:

Shoes.app do
    @stack = stack :width => 1.0, :height => 1.0 do
        @para = para 
    end  
    animate 1 do |f| 
        @para.text = "%d x %d #{f}" % [ @stack.width, @stack.height ]   
    end  
end

But the stack will still not resize in the way you might expect. Testing this out shows that the width is updated correctly, but the height can only expand...

Zachary Garrett