shoes 4.0.0.pre1 → 4.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +84 -32
- data/Gemfile +22 -1
- data/README.md +28 -13
- data/Rakefile +7 -210
- data/bin/ruby-shoes +2 -2
- data/ext/install/shoes.bat +4 -1
- data/lib/shoes.rb +1 -121
- data/lib/shoes/{cli.rb → ui/cli.rb} +7 -1
- data/lib/shoes/{help.rb → ui/help.rb} +2 -2
- data/lib/shoes/{manual.rb → ui/manual.rb} +1 -1
- data/lib/shoes/version.rb +1 -1
- data/manifests/common.rb +34 -0
- data/manifests/shoes.rb +44 -0
- data/samples/Gemfile +3 -0
- data/samples/Gemfile.lock +35 -0
- data/samples/README +16 -5
- data/samples/boom.rb +239 -0
- data/samples/clicky.rb +24 -0
- data/samples/flow.rb +63 -0
- data/samples/gray.rb +11 -0
- data/samples/nks_booklist.rb +24 -0
- data/samples/nks_breadsticks.rb +7 -0
- data/samples/nks_dancing_circle.rb +13 -0
- data/samples/nks_dictionary.rb +23 -0
- data/samples/nks_edit_box.rb +4 -0
- data/samples/nks_edit_line.rb +6 -0
- data/samples/nks_notes.rb +16 -0
- data/samples/nks_self.rb +6 -0
- data/samples/nks_text_sizes.rb +10 -0
- data/samples/nks_trurl.rb +5 -0
- data/samples/packaging/package_me.rb +6 -0
- data/samples/present.rb +27 -0
- data/samples/progress.rb +10 -0
- data/samples/sample31.rb +1 -1
- data/samples/simple-calc.rb +1 -1
- data/samples/simple-tictactoe.rb +238 -0
- data/samples/simple-visibility.rb +11 -0
- data/samples/simple-widget.rb +9 -0
- data/samples/swt-raw.rb +20 -0
- data/samples/troll.rb +22 -0
- data/shoes.gemspec +10 -22
- data/snapshots/sample56.png +0 -0
- data/static/manual-en.txt +16 -7
- data/tasks/changelog.rb +92 -0
- data/tasks/gem.rb +38 -0
- data/tasks/rspec.rb +106 -0
- data/tasks/sample.rb +66 -0
- data/tasks/yard.rb +13 -0
- metadata +55 -488
- data/.gitignore +0 -53
- data/.rspec +0 -3
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -31
- data/bin/shoes +0 -59
- data/bin/shoes.bat +0 -6
- data/fonts/Coolvetica.ttf +0 -0
- data/fonts/Lacuna.ttf +0 -0
- data/lib/ext/highlighter.rb +0 -2
- data/lib/ext/highlighter/common.rb +0 -197
- data/lib/ext/highlighter/lang/ruby.rb +0 -316
- data/lib/ext/highlighter/markup.rb +0 -222
- data/lib/rubygems_plugin.rb +0 -19
- data/lib/shoes/animation.rb +0 -55
- data/lib/shoes/app.rb +0 -320
- data/lib/shoes/arc.rb +0 -35
- data/lib/shoes/background.rb +0 -30
- data/lib/shoes/border.rb +0 -33
- data/lib/shoes/builtin_methods.rb +0 -73
- data/lib/shoes/button.rb +0 -32
- data/lib/shoes/check_button.rb +0 -43
- data/lib/shoes/color.rb +0 -375
- data/lib/shoes/common/background_element.rb +0 -9
- data/lib/shoes/common/changeable.rb +0 -34
- data/lib/shoes/common/clickable.rb +0 -17
- data/lib/shoes/common/common_methods.rb +0 -70
- data/lib/shoes/common/fill.rb +0 -21
- data/lib/shoes/common/registration.rb +0 -33
- data/lib/shoes/common/state.rb +0 -18
- data/lib/shoes/common/stroke.rb +0 -28
- data/lib/shoes/common/style.rb +0 -34
- data/lib/shoes/common/style_normalizer.rb +0 -16
- data/lib/shoes/configuration.rb +0 -96
- data/lib/shoes/dialog.rb +0 -27
- data/lib/shoes/dimension.rb +0 -237
- data/lib/shoes/dimensions.rb +0 -194
- data/lib/shoes/download.rb +0 -117
- data/lib/shoes/dsl.rb +0 -478
- data/lib/shoes/font.rb +0 -49
- data/lib/shoes/gradient.rb +0 -18
- data/lib/shoes/image.rb +0 -33
- data/lib/shoes/image_pattern.rb +0 -10
- data/lib/shoes/input_box.rb +0 -68
- data/lib/shoes/key_event.rb +0 -17
- data/lib/shoes/line.rb +0 -38
- data/lib/shoes/link.rb +0 -49
- data/lib/shoes/link_hover.rb +0 -5
- data/lib/shoes/list_box.rb +0 -44
- data/lib/shoes/logger.rb +0 -66
- data/lib/shoes/logger/ruby.rb +0 -18
- data/lib/shoes/mock.rb +0 -30
- data/lib/shoes/mock/animation.rb +0 -8
- data/lib/shoes/mock/app.rb +0 -44
- data/lib/shoes/mock/arc.rb +0 -8
- data/lib/shoes/mock/background.rb +0 -10
- data/lib/shoes/mock/border.rb +0 -7
- data/lib/shoes/mock/button.rb +0 -10
- data/lib/shoes/mock/check.rb +0 -24
- data/lib/shoes/mock/common_methods.rb +0 -11
- data/lib/shoes/mock/dialog.rb +0 -13
- data/lib/shoes/mock/download.rb +0 -18
- data/lib/shoes/mock/font.rb +0 -17
- data/lib/shoes/mock/image.rb +0 -12
- data/lib/shoes/mock/image_pattern.rb +0 -9
- data/lib/shoes/mock/input_box.rb +0 -23
- data/lib/shoes/mock/keypress.rb +0 -8
- data/lib/shoes/mock/keyrelease.rb +0 -8
- data/lib/shoes/mock/line.rb +0 -14
- data/lib/shoes/mock/link.rb +0 -11
- data/lib/shoes/mock/list_box.rb +0 -16
- data/lib/shoes/mock/oval.rb +0 -11
- data/lib/shoes/mock/progress.rb +0 -10
- data/lib/shoes/mock/radio.rb +0 -26
- data/lib/shoes/mock/rect.rb +0 -13
- data/lib/shoes/mock/shape.rb +0 -19
- data/lib/shoes/mock/slot.rb +0 -14
- data/lib/shoes/mock/sound.rb +0 -8
- data/lib/shoes/mock/star.rb +0 -13
- data/lib/shoes/mock/text_block.rb +0 -29
- data/lib/shoes/mock/timer.rb +0 -8
- data/lib/shoes/oval.rb +0 -28
- data/lib/shoes/point.rb +0 -43
- data/lib/shoes/progress.rb +0 -26
- data/lib/shoes/radio.rb +0 -15
- data/lib/shoes/rect.rb +0 -28
- data/lib/shoes/renamed_delegate.rb +0 -15
- data/lib/shoes/shape.rb +0 -175
- data/lib/shoes/slot.rb +0 -232
- data/lib/shoes/slot_contents.rb +0 -56
- data/lib/shoes/sound.rb +0 -16
- data/lib/shoes/span.rb +0 -16
- data/lib/shoes/star.rb +0 -49
- data/lib/shoes/swt.rb +0 -114
- data/lib/shoes/swt/animation.rb +0 -46
- data/lib/shoes/swt/app.rb +0 -300
- data/lib/shoes/swt/arc.rb +0 -70
- data/lib/shoes/swt/background.rb +0 -31
- data/lib/shoes/swt/border.rb +0 -37
- data/lib/shoes/swt/button.rb +0 -18
- data/lib/shoes/swt/check.rb +0 -14
- data/lib/shoes/swt/check_button.rb +0 -19
- data/lib/shoes/swt/color.rb +0 -45
- data/lib/shoes/swt/common/child.rb +0 -16
- data/lib/shoes/swt/common/clear.rb +0 -24
- data/lib/shoes/swt/common/clickable.rb +0 -62
- data/lib/shoes/swt/common/container.rb +0 -28
- data/lib/shoes/swt/common/fill.rb +0 -37
- data/lib/shoes/swt/common/painter.rb +0 -83
- data/lib/shoes/swt/common/painter_updates_position.rb +0 -12
- data/lib/shoes/swt/common/resource.rb +0 -14
- data/lib/shoes/swt/common/selection_listener.rb +0 -14
- data/lib/shoes/swt/common/stroke.rb +0 -41
- data/lib/shoes/swt/common/toggle.rb +0 -13
- data/lib/shoes/swt/common/update_position.rb +0 -15
- data/lib/shoes/swt/dialog.rb +0 -89
- data/lib/shoes/swt/disposed_protection.rb +0 -23
- data/lib/shoes/swt/download.rb +0 -24
- data/lib/shoes/swt/fitted_text_layout.rb +0 -94
- data/lib/shoes/swt/fitted_text_layout_collection.rb +0 -108
- data/lib/shoes/swt/font.rb +0 -32
- data/lib/shoes/swt/gradient.rb +0 -77
- data/lib/shoes/swt/image.rb +0 -130
- data/lib/shoes/swt/image_pattern.rb +0 -19
- data/lib/shoes/swt/input_box.rb +0 -73
- data/lib/shoes/swt/key_listener.rb +0 -145
- data/lib/shoes/swt/line.rb +0 -57
- data/lib/shoes/swt/link.rb +0 -37
- data/lib/shoes/swt/link_segment.rb +0 -108
- data/lib/shoes/swt/list_box.rb +0 -49
- data/lib/shoes/swt/mouse_move_listener.rb +0 -61
- data/lib/shoes/swt/oval.rb +0 -53
- data/lib/shoes/swt/progress.rb +0 -35
- data/lib/shoes/swt/radio.rb +0 -29
- data/lib/shoes/swt/radio_group.rb +0 -54
- data/lib/shoes/swt/rect.rb +0 -31
- data/lib/shoes/swt/rect_painter.rb +0 -23
- data/lib/shoes/swt/redrawing_aspect.rb +0 -122
- data/lib/shoes/swt/shape.rb +0 -101
- data/lib/shoes/swt/shoes_layout.rb +0 -43
- data/lib/shoes/swt/slot.rb +0 -25
- data/lib/shoes/swt/sound.rb +0 -119
- data/lib/shoes/swt/star.rb +0 -51
- data/lib/shoes/swt/swt_button.rb +0 -49
- data/lib/shoes/swt/text_block.rb +0 -133
- data/lib/shoes/swt/text_block_cursor_painter.rb +0 -112
- data/lib/shoes/swt/text_block_fitter.rb +0 -180
- data/lib/shoes/swt/text_block_painter.rb +0 -49
- data/lib/shoes/swt/text_font_factory.rb +0 -27
- data/lib/shoes/swt/text_style_factory.rb +0 -88
- data/lib/shoes/swt/timer.rb +0 -19
- data/lib/shoes/swt/tooling/leak_hunter.rb +0 -84
- data/lib/shoes/text.rb +0 -14
- data/lib/shoes/text_block.rb +0 -162
- data/lib/shoes/timer.rb +0 -10
- data/lib/shoes/url.rb +0 -47
- data/lib/shoes/widget.rb +0 -73
- data/lib/support/jl1.0.1.jar +0 -0
- data/lib/support/jogg-0.0.7.jar +0 -0
- data/lib/support/jorbis-0.0.15.jar +0 -0
- data/lib/support/log4j-1.2.16.jar +0 -0
- data/lib/support/mp3spi1.9.5.jar +0 -0
- data/lib/support/tritonus_share.jar +0 -0
- data/lib/support/vorbisspi1.0.3.jar +0 -0
- data/samples/good-clock-adjusted.rb +0 -49
- data/spec/async_helper.rb +0 -21
- data/spec/code_coverage.rb +0 -11
- data/spec/shoes/animation_spec.rb +0 -65
- data/spec/shoes/app_spec.rb +0 -411
- data/spec/shoes/arc_spec.rb +0 -53
- data/spec/shoes/background_spec.rb +0 -48
- data/spec/shoes/border_spec.rb +0 -43
- data/spec/shoes/builtin_methods_spec.rb +0 -84
- data/spec/shoes/button_spec.rb +0 -41
- data/spec/shoes/check_spec.rb +0 -31
- data/spec/shoes/cli_spec.rb +0 -16
- data/spec/shoes/color_spec.rb +0 -396
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -58
- data/spec/shoes/configuration_spec.rb +0 -37
- data/spec/shoes/constants_spec.rb +0 -38
- data/spec/shoes/dialog_spec.rb +0 -163
- data/spec/shoes/dimension_spec.rb +0 -381
- data/spec/shoes/dimensions_spec.rb +0 -831
- data/spec/shoes/download_spec.rb +0 -133
- data/spec/shoes/flow_spec.rb +0 -92
- data/spec/shoes/font_spec.rb +0 -38
- data/spec/shoes/framework_learning_spec.rb +0 -30
- data/spec/shoes/helpers/fake_element.rb +0 -11
- data/spec/shoes/helpers/sample17_helper.rb +0 -66
- data/spec/shoes/image_spec.rb +0 -45
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -44
- data/spec/shoes/integration_spec.rb +0 -20
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -12
- data/spec/shoes/line_spec.rb +0 -47
- data/spec/shoes/link_spec.rb +0 -89
- data/spec/shoes/list_box_spec.rb +0 -63
- data/spec/shoes/logger/ruby_spec.rb +0 -9
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -20
- data/spec/shoes/point_spec.rb +0 -51
- data/spec/shoes/progress_spec.rb +0 -40
- data/spec/shoes/radio_spec.rb +0 -28
- data/spec/shoes/rect_spec.rb +0 -38
- data/spec/shoes/renamed_delegate_spec.rb +0 -70
- data/spec/shoes/shape_spec.rb +0 -54
- data/spec/shoes/shared_examples/button.rb +0 -6
- data/spec/shoes/shared_examples/changeable.rb +0 -26
- data/spec/shoes/shared_examples/clickable.rb +0 -5
- data/spec/shoes/shared_examples/common_methods.rb +0 -42
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -42
- data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
- data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
- data/spec/shoes/shared_examples/dsl/background.rb +0 -26
- data/spec/shoes/shared_examples/dsl/border.rb +0 -10
- data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
- data/spec/shoes/shared_examples/dsl/check.rb +0 -11
- data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
- data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
- data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
- data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
- data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
- data/spec/shoes/shared_examples/dsl/gradient.rb +0 -52
- data/spec/shoes/shared_examples/dsl/image.rb +0 -21
- data/spec/shoes/shared_examples/dsl/line.rb +0 -9
- data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
- data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
- data/spec/shoes/shared_examples/dsl/oval.rb +0 -60
- data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
- data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
- data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
- data/spec/shoes/shared_examples/dsl/rgb.rb +0 -26
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -21
- data/spec/shoes/shared_examples/dsl/star.rb +0 -48
- data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
- data/spec/shoes/shared_examples/dsl/style.rb +0 -32
- data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -81
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -8
- data/spec/shoes/shared_examples/hover_leave.rb +0 -11
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -52
- data/spec/shoes/shared_examples/slot.rb +0 -272
- data/spec/shoes/shared_examples/state.rb +0 -19
- data/spec/shoes/shared_examples/style.rb +0 -24
- data/spec/shoes/slot_spec.rb +0 -60
- data/spec/shoes/sound_spec.rb +0 -15
- data/spec/shoes/span_spec.rb +0 -94
- data/spec/shoes/spec_helper.rb +0 -1
- data/spec/shoes/stack_spec.rb +0 -53
- data/spec/shoes/star_spec.rb +0 -30
- data/spec/shoes/text_block_spec.rb +0 -242
- data/spec/shoes/url_spec.rb +0 -66
- data/spec/shoes/widget_spec.rb +0 -34
- data/spec/shoes_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -16
- data/spec/swt_shoes/animation_spec.rb +0 -86
- data/spec/swt_shoes/app_spec.rb +0 -75
- data/spec/swt_shoes/arc_spec.rb +0 -101
- data/spec/swt_shoes/background_spec.rb +0 -56
- data/spec/swt_shoes/border_spec.rb +0 -51
- data/spec/swt_shoes/button_spec.rb +0 -101
- data/spec/swt_shoes/check_spec.rb +0 -28
- data/spec/swt_shoes/color_spec.rb +0 -67
- data/spec/swt_shoes/common/painter_spec.rb +0 -29
- data/spec/swt_shoes/configuration_spec.rb +0 -12
- data/spec/swt_shoes/dialog_spec.rb +0 -106
- data/spec/swt_shoes/disposed_protection_spec.rb +0 -49
- data/spec/swt_shoes/fitted_text_layout_collection_spec.rb +0 -174
- data/spec/swt_shoes/fitted_text_layout_spec.rb +0 -130
- data/spec/swt_shoes/flow_spec.rb +0 -26
- data/spec/swt_shoes/font_spec.rb +0 -33
- data/spec/swt_shoes/gradient_spec.rb +0 -20
- data/spec/swt_shoes/image_pattern_spec.rb +0 -19
- data/spec/swt_shoes/image_spec.rb +0 -100
- data/spec/swt_shoes/input_box_spec.rb +0 -110
- data/spec/swt_shoes/integration_spec.rb +0 -18
- data/spec/swt_shoes/key_listener_spec.rb +0 -320
- data/spec/swt_shoes/line_spec.rb +0 -43
- data/spec/swt_shoes/link_segment_spec.rb +0 -103
- data/spec/swt_shoes/link_spec.rb +0 -59
- data/spec/swt_shoes/list_box_spec.rb +0 -51
- data/spec/swt_shoes/minimal.png +0 -0
- data/spec/swt_shoes/mouse_move_listener_spec.rb +0 -129
- data/spec/swt_shoes/oval_spec.rb +0 -51
- data/spec/swt_shoes/progress_spec.rb +0 -44
- data/spec/swt_shoes/radio_group_spec.rb +0 -73
- data/spec/swt_shoes/radio_spec.rb +0 -56
- data/spec/swt_shoes/rect_painter_spec.rb +0 -45
- data/spec/swt_shoes/rect_spec.rb +0 -19
- data/spec/swt_shoes/shape_spec.rb +0 -81
- data/spec/swt_shoes/shared_examples/button.rb +0 -24
- data/spec/swt_shoes/shared_examples/clearable.rb +0 -32
- data/spec/swt_shoes/shared_examples/clickable.rb +0 -60
- data/spec/swt_shoes/shared_examples/movable.rb +0 -36
- data/spec/swt_shoes/shared_examples/paintable_spec.rb +0 -7
- data/spec/swt_shoes/shared_examples/painter.rb +0 -83
- data/spec/swt_shoes/shared_examples/pattern.rb +0 -32
- data/spec/swt_shoes/shared_examples/swt_app_context.rb +0 -17
- data/spec/swt_shoes/shared_examples/togglable.rb +0 -15
- data/spec/swt_shoes/shell_control_listener_spec.rb +0 -23
- data/spec/swt_shoes/sound.rb +0 -10
- data/spec/swt_shoes/spec_helper.rb +0 -31
- data/spec/swt_shoes/star_spec.rb +0 -47
- data/spec/swt_shoes/text_block_cursor_painter_spec.rb +0 -202
- data/spec/swt_shoes/text_block_fitter_spec.rb +0 -181
- data/spec/swt_shoes/text_block_painter_spec.rb +0 -221
- data/spec/swt_shoes/text_block_spec.rb +0 -183
data/samples/clicky.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Shoes.app do
|
2
|
+
@elements = []
|
3
|
+
@elements << arc(0, 0,
|
4
|
+
100, 100,
|
5
|
+
0,
|
6
|
+
Shoes::TWO_PI - Shoes::HALF_PI)
|
7
|
+
@elements << rect(100, 100, 100, 100)
|
8
|
+
@elements << para("text", left: 200)
|
9
|
+
@elements << para(link("link") { |*args| alert(args.inspect) })
|
10
|
+
@elements << button("Ok")
|
11
|
+
@elements << check
|
12
|
+
@elements << image(File.expand_path("~/source/shoes4/static/shoes-icon.png"))
|
13
|
+
@elements << stack(width: 100, height: 100) do
|
14
|
+
background green
|
15
|
+
para "text"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
@elements.each do |e|
|
20
|
+
e.style(:click => Proc.new do |*args|
|
21
|
+
alert args.inspect
|
22
|
+
end)
|
23
|
+
end
|
24
|
+
end
|
data/samples/flow.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#require 'pry'
|
2
|
+
#require 'pry-nav'
|
3
|
+
#require 'shoes/swt/tooling/leak_hunter'
|
4
|
+
|
5
|
+
Shoes.app width: 250, height: 500 do
|
6
|
+
@r = rect 100, 100, 100, 100, fill:gradient(red, blue) #"/Users/jclark/.hacketyhack/princess/king.jpg")
|
7
|
+
oval 100, 100, 100, 200, angle: 120
|
8
|
+
|
9
|
+
button "change" do
|
10
|
+
@r.style(fill: green)
|
11
|
+
end
|
12
|
+
#COLORS = [red, green, blue, yellow, orange, purple]
|
13
|
+
#3.times do
|
14
|
+
#flow do
|
15
|
+
#COLORS.each do |color|
|
16
|
+
#para "Boo Hoo Hoo Hoo", fill: color, size: 24
|
17
|
+
#end
|
18
|
+
#end
|
19
|
+
#end
|
20
|
+
end
|
21
|
+
#Shoes.app do
|
22
|
+
##rect 100, 100, 100, 100, fill: blue
|
23
|
+
##line 10, 10, 20, 20
|
24
|
+
|
25
|
+
#button "booo" do
|
26
|
+
#@p.cursor ||= 0
|
27
|
+
#@p.cursor += 100
|
28
|
+
#end
|
29
|
+
|
30
|
+
#keypress do |key|
|
31
|
+
#if key == :right
|
32
|
+
#@p.cursor ||= 0
|
33
|
+
#@p.cursor += 1
|
34
|
+
#elsif key == :left
|
35
|
+
#@p.cursor ||= 0
|
36
|
+
#@p.cursor -= 1
|
37
|
+
#end
|
38
|
+
#end
|
39
|
+
#@p = para 'Hello ' * 20, cursor: 0, width:200
|
40
|
+
#puts "#{@p.height}, #{@p.width}"
|
41
|
+
|
42
|
+
#button "boo" do
|
43
|
+
#alert "#{@p.height}, #{@p.width}"
|
44
|
+
#end
|
45
|
+
##stack do
|
46
|
+
##rect 100, 100, 100, 100, fill: red, stroke: blue
|
47
|
+
###background lightgreen, stroke: blue
|
48
|
+
##para "Some of this text will not be seen", underline: 1, undercolor: orange, size: 16, fill: red, stroke: blue, margin: 10
|
49
|
+
##para "Nope", strikethrough: 1, strikecolor: orange, size: 16, stroke: blue, margin: 10
|
50
|
+
###para("wat", click: proc { alert "Boo" })
|
51
|
+
###flow width:100 do
|
52
|
+
###background lightgreen
|
53
|
+
###para "I am important!", size: 16
|
54
|
+
###end
|
55
|
+
##end
|
56
|
+
|
57
|
+
##keypress do |key|
|
58
|
+
##if key == :'control_alt_q'
|
59
|
+
##clear
|
60
|
+
##quit
|
61
|
+
##end
|
62
|
+
##end
|
63
|
+
#end
|
data/samples/gray.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class BookList < Shoes
|
2
|
+
url '/', :index
|
3
|
+
url '/twain', :twain
|
4
|
+
url '/kv', :vonnegut
|
5
|
+
|
6
|
+
def index
|
7
|
+
para "Books I've read: ",
|
8
|
+
link("by Mark Twain", :click => "/twain"),
|
9
|
+
link("by Kurt Vonnegut", :click => "/kv")
|
10
|
+
end
|
11
|
+
|
12
|
+
def twain
|
13
|
+
para "Just Huck Finn.\n",
|
14
|
+
link("Go back.", :click => "/")
|
15
|
+
end
|
16
|
+
|
17
|
+
def vonnegut
|
18
|
+
para "Cat's Cradle. Sirens of Titan. ",
|
19
|
+
"Breakfast of Champions.\n",
|
20
|
+
link("Go back.", :click => "/")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Shoes.app :width => 400, :height => 500
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Dictionary < Shoes
|
2
|
+
url '/', :index
|
3
|
+
url '/(\w+)', :word
|
4
|
+
|
5
|
+
def index
|
6
|
+
stack do
|
7
|
+
title "Enter a Word"
|
8
|
+
@word = edit_line
|
9
|
+
button "OK" do
|
10
|
+
visit "/#{@word.text}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def word(string)
|
16
|
+
stack do
|
17
|
+
para "No definition found for #{string}. ",
|
18
|
+
"Sorry this doesn't actually work."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Shoes.app
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Shoes.app do
|
2
|
+
stack :margin => 20, :width => 250 do
|
3
|
+
subtitle "Shoes Notebook"
|
4
|
+
para "Add a note."
|
5
|
+
@add = edit_line
|
6
|
+
|
7
|
+
button "Save" do
|
8
|
+
@notes.append do
|
9
|
+
para @add.text, " ",
|
10
|
+
link("delete") { |x| x.parent.remove }
|
11
|
+
end
|
12
|
+
@add.text = ""
|
13
|
+
end
|
14
|
+
end
|
15
|
+
@notes = stack :margin => 20, :width => -250
|
16
|
+
end
|
data/samples/nks_self.rb
ADDED
data/samples/present.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Shoes.app do
|
2
|
+
|
3
|
+
def center_x(length)
|
4
|
+
width/2 - length/ 2
|
5
|
+
end
|
6
|
+
|
7
|
+
def center_text_on(text, rectangle)
|
8
|
+
new_left = rectangle.left + rectangle.width / 2 - 55 / 2
|
9
|
+
new_top = rectangle.top + rectangle.height / 2 - 35 / 2
|
10
|
+
text.move new_left, new_top
|
11
|
+
puts "new_left: #{new_left}, new_top: #{new_top}"
|
12
|
+
end
|
13
|
+
|
14
|
+
button 'boom' do
|
15
|
+
clear
|
16
|
+
s = stack width: width do
|
17
|
+
background red
|
18
|
+
dsl_length = 400
|
19
|
+
dsl_top = 300
|
20
|
+
rect_height = 100
|
21
|
+
dsl_rect = rect center_x(dsl_length), dsl_top, dsl_length, rect_height, fill: green
|
22
|
+
dsl_text = para 'DSL'
|
23
|
+
center_text_on dsl_text, dsl_rect
|
24
|
+
end
|
25
|
+
puts s.width
|
26
|
+
end
|
27
|
+
end
|
data/samples/progress.rb
ADDED
data/samples/sample31.rb
CHANGED
@@ -7,7 +7,7 @@ Shoes.app do
|
|
7
7
|
eles << shape(left: 200, top: 150, width: 300, height: 300, rotate: [45, 300, 300]){
|
8
8
|
move_to 200, 200
|
9
9
|
line_to 200, 100
|
10
|
-
|
10
|
+
curve_to 100, 100, 20, 200, 50, 150
|
11
11
|
line_to 20, 100
|
12
12
|
}
|
13
13
|
eles << line(100, 100, 480, 480)
|
data/samples/simple-calc.rb
CHANGED
@@ -0,0 +1,238 @@
|
|
1
|
+
# Size module
|
2
|
+
# Change these constants to change the size of the board.
|
3
|
+
module SIZE
|
4
|
+
PADDING = 10
|
5
|
+
TIC_SIZE = 60
|
6
|
+
B_RADIUS = 5
|
7
|
+
WIDTH = HEIGHT = (PADDING * 4) + (TIC_SIZE * 5)
|
8
|
+
end
|
9
|
+
|
10
|
+
class Tic
|
11
|
+
attr_reader :x, :y, :checked, :rect, :player
|
12
|
+
|
13
|
+
def initialize(tic)
|
14
|
+
@rect = tic[0]
|
15
|
+
@x = tic[1]
|
16
|
+
@y = tic[2]
|
17
|
+
@player = false
|
18
|
+
@checked = false
|
19
|
+
end
|
20
|
+
|
21
|
+
def check
|
22
|
+
@checked = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset
|
26
|
+
@player = false
|
27
|
+
@checked = false
|
28
|
+
@rect.style fill: '#000000'
|
29
|
+
end
|
30
|
+
|
31
|
+
def player=(symbol)
|
32
|
+
@player = symbol
|
33
|
+
if symbol == 'X'
|
34
|
+
@rect.style fill: '#00FFFF'
|
35
|
+
else
|
36
|
+
@rect.style fill: '#FFFF44'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# Mostly keeps track of the Player.
|
44
|
+
# 'class Player' would imply two.
|
45
|
+
class Game
|
46
|
+
|
47
|
+
def initialize(player_label)
|
48
|
+
@player = false
|
49
|
+
@label = player_label
|
50
|
+
end
|
51
|
+
|
52
|
+
def restart
|
53
|
+
@player = true and toggle_player # English syntax!
|
54
|
+
end
|
55
|
+
|
56
|
+
def toggle_player
|
57
|
+
@player = !@player
|
58
|
+
@label.text = player_turn
|
59
|
+
end
|
60
|
+
|
61
|
+
def player_symbol
|
62
|
+
@player ? 'X' : 'O'
|
63
|
+
end
|
64
|
+
|
65
|
+
def player_color
|
66
|
+
@player ? "Yellow" : "Blue"
|
67
|
+
end
|
68
|
+
|
69
|
+
def player_turn
|
70
|
+
"#{player_color}'s Turn"
|
71
|
+
end
|
72
|
+
|
73
|
+
def player_win
|
74
|
+
@player =! @player
|
75
|
+
"#{player_color} won!"
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
# Organizes the Tics and
|
82
|
+
# checks for winning configurations
|
83
|
+
class Board
|
84
|
+
attr_reader :game
|
85
|
+
|
86
|
+
def initialize(tics, player_label)
|
87
|
+
@tics = []
|
88
|
+
@over = false
|
89
|
+
@game = Game.new player_label
|
90
|
+
|
91
|
+
tics.each do |tic| # Each tic in this array is of the format: [rect, x, y]
|
92
|
+
@tics << Tic.new(tic)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
# Actions for each of the tic's rectangle
|
98
|
+
def set_tic_actions
|
99
|
+
@tics.each do |tic|
|
100
|
+
tic.rect.click do
|
101
|
+
unless tic.checked or @over
|
102
|
+
@game.toggle_player
|
103
|
+
tic.player = @game.player_symbol
|
104
|
+
tic.check
|
105
|
+
if self.check_if_over
|
106
|
+
show_screen(game.player_win)
|
107
|
+
elsif self.full?
|
108
|
+
show_screen("Cat's Game!")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def check_if_over
|
116
|
+
(1..3).any? { |i| all_checked?(row(i)) || all_checked?(column(i)) } ||
|
117
|
+
all_checked?(diagonal1) ||
|
118
|
+
all_checked?(diagonal2)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Takes an array and tells if each Tic has been checked by the same player
|
122
|
+
def all_checked?(array)
|
123
|
+
if array[0].checked
|
124
|
+
return array[0].player == array[1].player && array[1].player == array[2].player
|
125
|
+
else
|
126
|
+
return false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
# In this case, the screen is the
|
132
|
+
# end screen, including the transparent
|
133
|
+
# black panel and its buttons.
|
134
|
+
def set_screen(screen)
|
135
|
+
@screen = screen
|
136
|
+
end
|
137
|
+
|
138
|
+
def clear_screen
|
139
|
+
@screen.each do |item|
|
140
|
+
item.hide
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def show_screen(title)
|
145
|
+
@over = true
|
146
|
+
@screen.each do |item|
|
147
|
+
item.show
|
148
|
+
end
|
149
|
+
@screen[0].text = title
|
150
|
+
end
|
151
|
+
|
152
|
+
def restart
|
153
|
+
clear_screen
|
154
|
+
@over = false
|
155
|
+
@tics.each do |tic|
|
156
|
+
tic.reset
|
157
|
+
end
|
158
|
+
game.restart
|
159
|
+
end
|
160
|
+
|
161
|
+
def row(x)
|
162
|
+
@tics.select { |tic| tic.x == x }
|
163
|
+
end
|
164
|
+
|
165
|
+
def column(y)
|
166
|
+
@tics.select { |tic| tic.y == y }
|
167
|
+
end
|
168
|
+
|
169
|
+
def diagonal1
|
170
|
+
tics = []
|
171
|
+
(1..3).each do |i|
|
172
|
+
tics.concat(@tics.select { |tic| tic.x == i && tic.y == i })
|
173
|
+
end
|
174
|
+
tics
|
175
|
+
end
|
176
|
+
|
177
|
+
def diagonal2
|
178
|
+
tics = []
|
179
|
+
(1..3).each do |i|
|
180
|
+
tics.concat(@tics.select { |tic| tic.x == i && tic.y == (4 - i) })
|
181
|
+
end
|
182
|
+
tics
|
183
|
+
end
|
184
|
+
|
185
|
+
def full?
|
186
|
+
@tics.select { |tic| tic.checked }.length == 9
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
# Main GUI App
|
192
|
+
Shoes.app width: SIZE::WIDTH, height: SIZE::HEIGHT, title: 'Tic Tac Toe' do
|
193
|
+
background gradient(slategray, slateblue)
|
194
|
+
|
195
|
+
stroke white
|
196
|
+
|
197
|
+
title 'Tic Tac Toe', align: 'center', family: 'Lacuna', top: 10
|
198
|
+
|
199
|
+
flow bottom: 10 do
|
200
|
+
@player_label = para "Blue's Turn", size: 20, align: 'center'
|
201
|
+
end
|
202
|
+
|
203
|
+
stroke black
|
204
|
+
|
205
|
+
# The making of the Tic rectangles, along with a record of their coordinates.
|
206
|
+
tics = []
|
207
|
+
(1..3).each do |i|
|
208
|
+
(1..3).each do |j|
|
209
|
+
rectangle = rect((SIZE::PADDING + SIZE::TIC_SIZE) * i, (SIZE::PADDING + SIZE::TIC_SIZE) * j, SIZE::TIC_SIZE, SIZE::TIC_SIZE, SIZE::B_RADIUS)
|
210
|
+
tics << [rectangle, i, j]
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
|
215
|
+
stroke black
|
216
|
+
|
217
|
+
board = Board.new(tics, @player_label) # player_label is passed on to the game.
|
218
|
+
|
219
|
+
board.set_tic_actions
|
220
|
+
|
221
|
+
# End Screen
|
222
|
+
black_screen = rect 0,0,SIZE::WIDTH,SIZE::WIDTH, fill: app.rgb(0,0,0,0.5)
|
223
|
+
flow align: 'center' do
|
224
|
+
# Positioned oddly because 'align: "center"' appears not to work on buttons
|
225
|
+
@quit_button = button 'Quit', top: 174, left: (SIZE::WIDTH/2 - 34) do
|
226
|
+
exit
|
227
|
+
end
|
228
|
+
# Positioned oddly because 'align: "center"' appears not to work on buttons
|
229
|
+
@restart_button = button 'Restart', top: 140, align: 'center', left: (SIZE::WIDTH/2 - 43) do
|
230
|
+
board.restart
|
231
|
+
end
|
232
|
+
end
|
233
|
+
alert_title = title "Cat's Game!", stroke: white, top: 90, align: 'center', size: 34
|
234
|
+
exit_screen = [alert_title, black_screen, @quit_button, @restart_button]
|
235
|
+
|
236
|
+
board.set_screen(exit_screen) # Passes pre-made gui on for later use
|
237
|
+
board.clear_screen # Clears it to begin with
|
238
|
+
end
|