Browse files

finishing up elements section of manual

  • Loading branch information...
1 parent f7d83ef commit d2f4ede9c5225c1c286fc8602c80f59693a43331 @zzak committed Oct 27, 2010
View
3 elements/background-column.rb
@@ -0,0 +1,3 @@
+Shoes.app do
+ background red, :width => 40, :right => 50
+end
View
6 elements/border-cat.rb
@@ -0,0 +1,6 @@
+Shoes.app do
+ stack :width => 50 do
+ border purple, :strokewidth => 5
+ para "=^.^=", :stroke => green
+ end
+end
View
8 elements/button-block.rb
@@ -0,0 +1,8 @@
+Shoes.app do
+ button "OK!" do
+ append { para "Well okay then." }
+ end
+ button "Are you sure?" do
+ append { para "Your confidence is inspiring." }
+ end
+end
View
15 elements/check-mate.rb
@@ -0,0 +1,15 @@
+Shoes.app do
+ @list = ['Frances Johnson', 'Ignatius J. Reilly', 'Winston Niles Rumfoord']
+
+ stack do
+ @list.map! do |name|
+ flow { @c = check; para name }
+ [@c, name]
+ end
+
+ button "Who dat?" do
+ selected = @list.map { |c, name| name if c.checked? }.compact
+ alert("You selected: " + selected.join(', '))
+ end
+ end
+end
View
13 elements/common-styles.rb
@@ -0,0 +1,13 @@
+Shoes.app do
+ stack do
+ # background, text and a button: both are elements!
+ @back = background blue
+ @text = banner "This quick brown fox"
+ @press = button "Jumps over the lazy dog"
+
+ # And so, both can be styled.
+ @text.style :size => 24, :stroke => red, :margin => 10
+ @press.style :width => 400
+ @back.style :height => 10
+ end
+end
View
13 elements/displace-animation.rb
@@ -0,0 +1,13 @@
+Shoes.app do
+ flow :margin => 12 do
+ # Set up three buttons
+ button "One"
+ @two = button "Two"
+ button "Three"
+
+ # Bounce the second butotn
+ animate do |i|
+ @two.displace(0, (Math.sin(i) * 6).to_i)
+ end
+ end
+end
View
7 elements/edit_box-character-count.rb
@@ -0,0 +1,7 @@
+Shoes.app do
+ edit_box do |e|
+ @counter.text = e.text.size
+ end
+ @counter = strong("0")
+ para @counter, " characters"
+end
View
7 elements/edit_line-character-count.rb
@@ -0,0 +1,7 @@
+Shoes.app do
+ edit_line do |e|
+ @counter.text = e.text.size
+ end
+ @counter = strong("0")
+ para @counter, " characters"
+end
View
3 elements/image-icon.rb
@@ -0,0 +1,3 @@
+Shoes.app do
+ image "http://shoesrb.com/images/shoes-icon.png"
+end
View
13 elements/list_box-select-class.rb
@@ -0,0 +1,13 @@
+Shoes.app do
+ para "Choose your class:"
+ list_box :items => ["Wizard", "Warrior", "Rogue"],
+ :width => 120, :choose => "Rogue" do |list|
+ if list.text == "Wizard"
+ @player.text = "I put on my robe and wizard hat."
+ else
+ @player.text = list.text
+ end
+ end
+
+ @player = para "No class selected."
+end
View
13 elements/move-flow-animate.rb
@@ -0,0 +1,13 @@
+Shoes.app do
+ flow :margin => 12 do
+ # Set up three buttons
+ button "One"
+ @two = button "Two"
+ button "Three"
+
+ # Bounce the second button
+ animate do |i|
+ @two.move(40, 40 + (Math.sin(i) * 6).to_i)
+ end
+ end
+end
View
7 elements/phat-button.rb
@@ -0,0 +1,7 @@
+Shoes.app do
+ # A button which takes up the whole page
+ @b = button "WAT DO", :width => 1.0, :height => 1.0
+
+ # When clicked, show the styles
+ @b.click { alert(@b.style.inspect) }
+end
View
10 elements/progress-bar.rb
@@ -0,0 +1,10 @@
+Shoes.app do
+ stack :margin => 0.1 do
+ title "Progress example"
+ @p = progress :width => 1.0
+
+ animate do |i|
+ @p.fraction = (i % 100) / 100.0
+ end
+ end
+end
View
17 elements/radio-dreamcast-favs.rb
@@ -0,0 +1,17 @@
+Shoes.app do
+ stack do
+ para "Among these dreamcast games, which do you prefer?"
+ flow do
+ radio :dreamcast
+ para "Shenmue"
+ end
+ flow do
+ radio :dreamcast
+ para "Phantasy Star Online"
+ end
+ flow do
+ radio :dreamcast
+ para "Marvel Vs. Capcom II"
+ end
+ end
+end
View
8 elements/width-introspec.rb
@@ -0,0 +1,8 @@
+Shoes.app do
+ stack :width => 120 do
+ @b = button "Click me", :width => "100%" do
+ alert "button.width = #{@b.width}\n" +
+ "button.style[:width] = #{@b.style[:width]}"
+ end
+ end
+end

0 comments on commit d2f4ede

Please sign in to comment.