tags:

views:

62

answers:

1

My shoes application has three items stacked on top of each other (with a stack, of course), in order:

  • A banner
  • An edit box
  • Two buttons in a flow

What I want to do is have the banner stay at it's default size (48px) and the buttons as well (I think this may be platform specific?) and have the edit box take up the remaining area on screen, and automatically resize with the window? Is this possible?

If not, would it be possible if the buttons were moved above the edit box? (So the edit box would fill to the bottom of the window)

+2  A: 

I can't take full credit for this, as it is inspired by this email thread and code linked in that thread, but the below works; although is crude (it polls the window every second in order to adjust sizes).

Shoes.app do
    @header = stack :height => 48 do
        background red
    end
    stack do 
        @edit = edit_box
    end
    @footer = flow do
        style(:attach => Window, :top => app.height-100, :height => 25)
        button "Button 1"
        button "Button 2"
    end
    @height = 0
    every(1) do
        @windowheight = slot.height
        # Note app.height works on Linux and Windows, but not on OSX
        # See http://article.gmane.org/gmane.comp.lib.shoes/3493/match=app+height
        # So use slot.height instead. 
        unless @windowheight == @height
            @edit.style(:height => @[email protected]@footer.height)
            @footer.style(:top => @windowheight-25)
        end
    end
end

As far as I know, if you moved the buttons above the edit box, you would still have to do the same kind of thing in order to have it dynamically resize. There is a new mailing list for Shoes you could ask on though: [email protected]

i5m
Thanks for the answer! It's working, but it only seems to update once, and then doesn't anymore. No errors in the error console
Jeffrey Aylesworth
I've tested on Windows XP, with both Shoes Raisins (r1134) and a recent Policeman build. Works there. Which platform are you on? What build of Shoes?
i5m
I'm on mac OS X, I got the build labelled "Shoes 2 (Raisins) - Lastest OS X build downloaded from Shoooes.net" from [Github](http://github.com/shoes/shoes/downloads)
Jeffrey Aylesworth
Hi, sorry for the delay. Just checked on OSX PPC and I get the same as you. Seems like a bug. I'll look into it a bit more and get back to you.
i5m
Ok, I have edited the code above to work on OSX. The key is slot.height instead of app.height, as per this thread: http://article.gmane.org/gmane.comp.lib.shoes/3493/match=app+height
i5m
Turns out, that the mailing list example I refer to was also available on Stackoverflow: http://stackoverflow.com/questions/489558/in-shoes-how-do-i-dock-a-stack-to-the-bottom-of-the-window
i5m