Monday, September 10, 2007

Sketchy documentation for people too lazy to tie their own Shoes


Shoes is so new and in flux that unless you are comfortable cracking open some Ruby code and lots of C you will have a hard time getting started. I made a little cheat sheet of Shoes for the presentation I gave. It is moth eaten and worse yet, half-assed. I apologize in advance, but maybe somebody will find it useful.

The format here is that method names are in bold. An english description of the arguments (I know it is a terrible thing to do) follow, along with a description of what it does.

background - takes a filename or a color created by rgb(r,g,b) followed by an array of :top, :right, :left, :height, :width

rgb - takes 3 parameters 0-254 and returns a color

width - gives you the width of an element

button - takes a String label and a block and draws a button to the screen

show - make an element that is not visible, visible.

alert - takes a String message and pops up an alert box.

title - takes a String and prints out some big text

contents - returns an array of the elements in this Shoes Object.

ask_color - takes a String which is the title of the color selection dialog that pops up

width= - looks like it lets you set width (but it doesn't resize the base window)

rect - Takes a hash :left, :top, :width, :height and draw a rectangle

quit - close the application window

click - I think it takes a block like keypress, but i just get segfaults.

incident - causes your app to segfault

rotate - takes a number of degrees. and rotates things you have drawn.

height - gives you the height of the element.

flow - A style element that takes an array with :margin and a block consisting of other elements to display. Flows fill left to right. When they hit max width they go down to the next row.

gray - takes an integer, but nothing happens.

border - takes a rgb() color and an array of :strokewidth

display - not sure, think it has something to do with debugging messages you see.

list_box - a selection element that takes a hash of :items where items is a list of options.

height= - set the height of the element.

clear - can take a block. clears what was drawn in the block or without a block clears the whole window.

ask_open_file - takes a string which is the title of the file open dialog box.

goto - takes a url string and redirects you to some url.

text - take a string and display it on the screen. Understands html markup.

subtitle - takes a string and displays some larger than normal text.

stack - A style element that takes an array with :margin and a block consisting of other

image - Takes a filename and displays that image.

edit_line - An element that takes text input

nostroke - the things you draw won't have a stroke line.
release

smalltitle - takes a string and displays some largeish, but not too large text.

stroke - i don't know what parameters it takes, i think maybe a stack or flow, but it sets the stroke width on things you draw.

strokewidth - takes a number that becomes the width of the strokes you make

hide - make an element invisible

animate - takes a number representing frames per second and a block that happens that many times per sec.

confirm - takes a string that is the confirmation message for the confirmation dialog that pops up.

progress - show a progress bar. I have no idea how to fill it up.

keypress - takes a block that gets the value from the keypress. pretty much segfaults every time.

If you have the time I really recommend digging into the C code behind shoes. It practically documents itself!

2 comments:

Shlomo said...

By the way. This stuff is based on revision 183 of the shoes svn repo.

Ryan Platte said...

Thanks for posting this, Josh.