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/lib/shoes/mock/timer.rb
DELETED
data/lib/shoes/oval.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Oval
|
3
|
-
include CommonMethods
|
4
|
-
include Common::Fill
|
5
|
-
include Common::Stroke
|
6
|
-
include Common::Style
|
7
|
-
include Common::Clickable
|
8
|
-
include DimensionsDelegations
|
9
|
-
|
10
|
-
attr_reader :app, :dimensions, :angle, :gui, :parent
|
11
|
-
|
12
|
-
def initialize(app, parent, left, top, width, height, opts = {}, &blk)
|
13
|
-
@app = app
|
14
|
-
@dimensions = AbsoluteDimensions.new left, top, width, height, opts
|
15
|
-
@style = Shoes::Common::Fill::DEFAULTS.merge(
|
16
|
-
Shoes::Common::Stroke::DEFAULTS).merge(opts)
|
17
|
-
@style[:strokewidth] ||= 1
|
18
|
-
@angle = opts[:angle]
|
19
|
-
@parent = parent
|
20
|
-
|
21
|
-
@parent.add_child self
|
22
|
-
|
23
|
-
@gui = Shoes.backend_for(self, &blk)
|
24
|
-
|
25
|
-
clickable_options(opts)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/shoes/point.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Point
|
3
|
-
def initialize(x, y)
|
4
|
-
@x, @y = x, y
|
5
|
-
end
|
6
|
-
|
7
|
-
attr_reader :x, :y
|
8
|
-
|
9
|
-
# @param [Shoes::Point] other the other point
|
10
|
-
# @return [Integer] if this is further left, this.x; otherwise other.x
|
11
|
-
def left(other = self)
|
12
|
-
[self.x, other.x].min
|
13
|
-
end
|
14
|
-
|
15
|
-
# @param [Shoes::Point] other the other point
|
16
|
-
# @return [Integer] if this is higher, this.y; otherwise other.y
|
17
|
-
def top(other = self)
|
18
|
-
[self.y, other.y].min
|
19
|
-
end
|
20
|
-
|
21
|
-
# Creates a new point at an offset of (x,y) from this point. Positive
|
22
|
-
# offsets move right and down; negative offsets move left and up.
|
23
|
-
#
|
24
|
-
# @param [Integer] x the x-component of the offset
|
25
|
-
# @param [Integer] y the y-component of the offset
|
26
|
-
# @return [Shoes::Point] a new point at offset (x,y) from this point
|
27
|
-
def to(x, y)
|
28
|
-
Shoes::Point.new(@x + x, @y + y)
|
29
|
-
end
|
30
|
-
|
31
|
-
def width(other = self)
|
32
|
-
(@x - other.x).abs
|
33
|
-
end
|
34
|
-
|
35
|
-
def height(other = self)
|
36
|
-
(@y - other.y).abs
|
37
|
-
end
|
38
|
-
|
39
|
-
def ==(other)
|
40
|
-
return other.respond_to?(:x) && @x == other.x && other.respond_to?(:y) && @y == other.y
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
data/lib/shoes/progress.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Progress
|
3
|
-
include CommonMethods
|
4
|
-
include DimensionsDelegations
|
5
|
-
|
6
|
-
attr_reader :app, :parent, :blk, :gui, :opts, :dimensions, :fraction
|
7
|
-
|
8
|
-
def initialize(app, parent, opts = {}, blk = nil)
|
9
|
-
@app = app
|
10
|
-
@parent = parent
|
11
|
-
@opts = opts
|
12
|
-
@blk = blk
|
13
|
-
@dimensions = Dimensions.new parent, opts
|
14
|
-
@gui = Shoes.configuration.backend_for(self, @parent.gui)
|
15
|
-
|
16
|
-
@parent.add_child self
|
17
|
-
|
18
|
-
@fraction = 0.0
|
19
|
-
end
|
20
|
-
|
21
|
-
def fraction=(value)
|
22
|
-
@fraction = value
|
23
|
-
@gui.fraction = @fraction
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/shoes/radio.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Radio < CheckButton
|
3
|
-
attr_accessor :group
|
4
|
-
|
5
|
-
def initialize(app, parent, group, opts = {}, blk = nil)
|
6
|
-
@group = group
|
7
|
-
super(app, parent, opts, blk)
|
8
|
-
end
|
9
|
-
|
10
|
-
def group=(value)
|
11
|
-
self.gui.group = value
|
12
|
-
@group = value
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/shoes/rect.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Rect
|
3
|
-
include CommonMethods
|
4
|
-
include Common::Style
|
5
|
-
include Common::Fill
|
6
|
-
include Common::Stroke
|
7
|
-
include Common::Clickable
|
8
|
-
include DimensionsDelegations
|
9
|
-
|
10
|
-
attr_reader :app, :gui, :corners, :dimensions, :angle, :parent
|
11
|
-
|
12
|
-
def initialize(app, parent, left, top, width, height, opts = {}, &blk)
|
13
|
-
@app = app
|
14
|
-
@dimensions = AbsoluteDimensions.new left, top, width, height, opts
|
15
|
-
@corners = opts[:curve] || 0
|
16
|
-
@angle = opts[:angle] || app.rotate
|
17
|
-
@style = Common::Fill::DEFAULTS.merge(
|
18
|
-
Common::Stroke::DEFAULTS).merge(opts)
|
19
|
-
@style[:strokewidth] ||= 1
|
20
|
-
@parent = parent
|
21
|
-
|
22
|
-
@parent.add_child self
|
23
|
-
|
24
|
-
@gui = Shoes.backend_for(self, opts, &blk)
|
25
|
-
clickable_options(opts)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module RenamedDelegate
|
2
|
-
include Forwardable
|
3
|
-
|
4
|
-
def renamed_delegate_to(getter, methods, renamings)
|
5
|
-
methods.each do |method|
|
6
|
-
method_name = method.to_s
|
7
|
-
renamed_method_name = renamings.inject(method_name) do |name, (word, sub)|
|
8
|
-
name.gsub word, sub
|
9
|
-
end
|
10
|
-
if renamed_method_name != method_name
|
11
|
-
def_delegator getter, method_name, renamed_method_name
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/lib/shoes/shape.rb
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Shape
|
3
|
-
include Shoes::CommonMethods
|
4
|
-
include Shoes::Common::Fill
|
5
|
-
include Shoes::Common::Stroke
|
6
|
-
include Shoes::Common::Style
|
7
|
-
include Shoes::Common::Clickable
|
8
|
-
|
9
|
-
# Creates a new Shoes::Shape
|
10
|
-
#
|
11
|
-
def initialize(app, opts = {}, blk = nil)
|
12
|
-
@app = app
|
13
|
-
@style = Shoes::Common::Fill::DEFAULTS.merge(Shoes::Common::Stroke::DEFAULTS).merge(opts)
|
14
|
-
@style[:strokewidth] ||= @app.style[:strokewidth] || 1
|
15
|
-
@blk = blk
|
16
|
-
|
17
|
-
@displace_left = 0
|
18
|
-
@displace_top = 0
|
19
|
-
|
20
|
-
# GUI
|
21
|
-
@gui = Shoes.backend_for(self, @style)
|
22
|
-
|
23
|
-
instance_eval &@blk unless @blk.nil?
|
24
|
-
|
25
|
-
clickable_options(opts)
|
26
|
-
end
|
27
|
-
|
28
|
-
attr_reader :app, :blk, :gui, :hidden
|
29
|
-
attr_reader :x, :y
|
30
|
-
attr_accessor :displace_left, :displace_top
|
31
|
-
|
32
|
-
def left
|
33
|
-
@left || 0
|
34
|
-
end
|
35
|
-
|
36
|
-
def top
|
37
|
-
@top || 0
|
38
|
-
end
|
39
|
-
|
40
|
-
alias_method :absolute_left, :left
|
41
|
-
alias_method :absolute_top, :top
|
42
|
-
alias_method :element_left, :left
|
43
|
-
alias_method :element_top, :top
|
44
|
-
|
45
|
-
|
46
|
-
def right
|
47
|
-
@right || left
|
48
|
-
end
|
49
|
-
|
50
|
-
def bottom
|
51
|
-
@bottom || top
|
52
|
-
end
|
53
|
-
|
54
|
-
def width
|
55
|
-
@app.width
|
56
|
-
end
|
57
|
-
|
58
|
-
def height
|
59
|
-
@app.height
|
60
|
-
end
|
61
|
-
|
62
|
-
alias_method :element_width, :width
|
63
|
-
alias_method :element_height, :height
|
64
|
-
|
65
|
-
def needs_to_be_positioned?
|
66
|
-
true
|
67
|
-
end
|
68
|
-
|
69
|
-
def takes_up_space?
|
70
|
-
true
|
71
|
-
end
|
72
|
-
|
73
|
-
def positioned?
|
74
|
-
absolute_left && absolute_top
|
75
|
-
end
|
76
|
-
|
77
|
-
# Moves the shape
|
78
|
-
#
|
79
|
-
# @param [Integer] left The new left value
|
80
|
-
# @param [Integer] top The new top value
|
81
|
-
# @return [Shoes::Shape] This shape
|
82
|
-
def move(left, top)
|
83
|
-
@right += offset(@left, left) if @right
|
84
|
-
@bottom += offset(@top, top) if @bottom
|
85
|
-
@left = left
|
86
|
-
@top = top
|
87
|
-
@gui.update_position
|
88
|
-
self
|
89
|
-
end
|
90
|
-
|
91
|
-
# Draws a line from the current position to the given point
|
92
|
-
#
|
93
|
-
# @param [Integer] x The new point's x-value
|
94
|
-
# @param [Integer] y The new point's y-value
|
95
|
-
# @return [Shoes::Shape] This shape
|
96
|
-
def line_to(x, y)
|
97
|
-
update_bounds_rect(@x, @y, x, y)
|
98
|
-
@x, @y = x, y
|
99
|
-
@gui.line_to(x, y)
|
100
|
-
self
|
101
|
-
end
|
102
|
-
|
103
|
-
# Moves the drawing "pen" to the given point
|
104
|
-
#
|
105
|
-
# @param [Integer] x The new point's x-value
|
106
|
-
# @param [Integer] y The new point's y-value
|
107
|
-
# @return [Shoes::Shape] self This shape
|
108
|
-
def move_to(x, y)
|
109
|
-
@x, @y = x, y
|
110
|
-
@gui.move_to(x, y)
|
111
|
-
self
|
112
|
-
end
|
113
|
-
|
114
|
-
def quad_to *args
|
115
|
-
@gui.quad_to *args
|
116
|
-
end
|
117
|
-
|
118
|
-
def curve_to(cx1, cy1, cx2, cy2, x, y)
|
119
|
-
update_bounds([@x, cx1, cx2, x], [@y, cy1, cy2, y])
|
120
|
-
@gui.curve_to(cx1, cy1, cx2, cy2, x, y)
|
121
|
-
self
|
122
|
-
end
|
123
|
-
|
124
|
-
def arc(x, y, width, height, start_angle, arc_angle)
|
125
|
-
@x, @y = x, y
|
126
|
-
update_bounds_rect(x-width/2, y-height/2, x+width/2, y+height/2)
|
127
|
-
@gui.arc(x, y, width, height, start_angle, arc_angle)
|
128
|
-
end
|
129
|
-
|
130
|
-
private
|
131
|
-
# Gives the relative offset of the new position from original position.
|
132
|
-
# This calculation is for a single coordinate value, e.g. an x or a y.
|
133
|
-
#
|
134
|
-
# @param [Integer] original The original position
|
135
|
-
# @param [Integer] new The new position
|
136
|
-
# @return [Integer] A value that should be added to the current position in order to
|
137
|
-
# move to the new position.
|
138
|
-
def offset(original, new)
|
139
|
-
return 0 unless original && new
|
140
|
-
relative = (new - original).abs
|
141
|
-
relative = -relative if new < original
|
142
|
-
relative
|
143
|
-
end
|
144
|
-
|
145
|
-
# Updates the bounds of this shape to include the rectangle described by
|
146
|
-
# (x1, y1) and (x2, y2)
|
147
|
-
#
|
148
|
-
# @param [Integer] x1 The x-value of the first coordinate
|
149
|
-
# @param [Integer] y1 The y-value of the first coordinate
|
150
|
-
# @param [Integer] x2 The x-value of the second coordinate
|
151
|
-
# @param [Integer] y2 The y-value of the second coordinate
|
152
|
-
# @return nil
|
153
|
-
def update_bounds_rect(x1, y1, x2, y2)
|
154
|
-
update_bounds( [x1, x2], [y1, y2] )
|
155
|
-
end
|
156
|
-
|
157
|
-
# Updates the bounds of this shape to the rectangle covering all
|
158
|
-
# the given coordinates.
|
159
|
-
#
|
160
|
-
# @param [Array<Integer>] xs Array of X coordinates
|
161
|
-
# @param [Array<Integer>] ys Array of Y coordinates
|
162
|
-
# @return nil
|
163
|
-
def update_bounds(xs, ys)
|
164
|
-
x_min = xs.min
|
165
|
-
x_max = xs.max
|
166
|
-
y_min = ys.min
|
167
|
-
y_max = ys.max
|
168
|
-
@left = x_min unless @left && x_min > @left
|
169
|
-
@top = y_min unless @top && y_min > @top
|
170
|
-
@right = x_max unless @right && x_max < @right
|
171
|
-
@bottom = y_max unless @bottom && y_max < @bottom
|
172
|
-
nil
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
data/lib/shoes/slot.rb
DELETED
@@ -1,232 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Slot
|
3
|
-
include Common::Clickable
|
4
|
-
include CommonMethods
|
5
|
-
include DimensionsDelegations
|
6
|
-
|
7
|
-
NEXT_ELEMENT_ON_SAME_LINE_OFFSET = Point.new(1, 0)
|
8
|
-
NEXT_ELEMENT_ON_NEXT_LINE_OFFSET = Point.new(0, 1)
|
9
|
-
|
10
|
-
attr_reader :parent, :gui, :contents, :blk, :dimensions, :hover_proc,
|
11
|
-
:leave_proc
|
12
|
-
|
13
|
-
def initialize(app, parent, opts={}, &blk)
|
14
|
-
init_attributes(app, parent, opts, blk)
|
15
|
-
@parent.add_child self
|
16
|
-
|
17
|
-
@gui = Shoes.configuration.backend_for(self, @parent.gui)
|
18
|
-
eval_block blk
|
19
|
-
contents_alignment
|
20
|
-
end
|
21
|
-
|
22
|
-
def init_attributes(app, parent, opts, blk)
|
23
|
-
@app = app
|
24
|
-
@parent = parent
|
25
|
-
@contents = SlotContents.new
|
26
|
-
@blk = blk
|
27
|
-
@dimensions = Dimensions.new parent, opts
|
28
|
-
@fixed_height = height || false
|
29
|
-
set_default_dimension_values
|
30
|
-
end
|
31
|
-
|
32
|
-
def set_default_dimension_values
|
33
|
-
self.width ||= 1.0
|
34
|
-
self.height ||= 0
|
35
|
-
self.absolute_left ||= 0
|
36
|
-
self.absolute_top ||= 0
|
37
|
-
end
|
38
|
-
|
39
|
-
def clear(&blk)
|
40
|
-
contents.clear
|
41
|
-
eval_block blk
|
42
|
-
end
|
43
|
-
|
44
|
-
def eval_block blk
|
45
|
-
@app.current_slot = self
|
46
|
-
blk.call if blk
|
47
|
-
@app.current_slot = parent
|
48
|
-
end
|
49
|
-
|
50
|
-
def add_child(element)
|
51
|
-
contents.add_element element
|
52
|
-
end
|
53
|
-
|
54
|
-
def append(&blk)
|
55
|
-
eval_block blk
|
56
|
-
end
|
57
|
-
|
58
|
-
def prepend(&blk)
|
59
|
-
contents.prepend do
|
60
|
-
eval_block blk
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def contents_alignment(_=nil)
|
65
|
-
last_position = position_contents
|
66
|
-
determine_slot_height(last_position)
|
67
|
-
end
|
68
|
-
|
69
|
-
def hovered?
|
70
|
-
@hovered
|
71
|
-
end
|
72
|
-
|
73
|
-
def hover(blk)
|
74
|
-
@hover_proc = blk
|
75
|
-
@app.add_mouse_hover_control self
|
76
|
-
end
|
77
|
-
|
78
|
-
def leave(blk)
|
79
|
-
@leave_proc = blk
|
80
|
-
@app.add_mouse_hover_control self
|
81
|
-
end
|
82
|
-
|
83
|
-
def mouse_hovered
|
84
|
-
@hovered = true
|
85
|
-
end
|
86
|
-
|
87
|
-
def mouse_left
|
88
|
-
@hovered = false
|
89
|
-
end
|
90
|
-
|
91
|
-
def app
|
92
|
-
@app.app #return the Shoes::App not the internal app
|
93
|
-
end
|
94
|
-
|
95
|
-
def inspect
|
96
|
-
"#<#{self.class}:0x#{hash.to_s(16)} @contents=#{@contents.inspect} and so much stuff literally breaks the memory limit. Look at it selectively.>"
|
97
|
-
end
|
98
|
-
|
99
|
-
protected
|
100
|
-
CurrentPosition = Struct.new(:x, :y, :next_line_start)
|
101
|
-
|
102
|
-
def position_contents
|
103
|
-
current_position = CurrentPosition.new element_left,
|
104
|
-
element_top,
|
105
|
-
element_top
|
106
|
-
|
107
|
-
contents.each do |element|
|
108
|
-
next if element.hidden?
|
109
|
-
current_position = positioning(element, current_position)
|
110
|
-
end
|
111
|
-
current_position
|
112
|
-
end
|
113
|
-
|
114
|
-
def positioning(element, current_position)
|
115
|
-
return current_position unless element.needs_to_be_positioned?
|
116
|
-
position_modifier = position_element element, current_position
|
117
|
-
element.contents_alignment(current_position) if element.respond_to? :contents_alignment
|
118
|
-
if element.takes_up_space?
|
119
|
-
update_current_position(current_position, element, position_modifier)
|
120
|
-
else
|
121
|
-
current_position
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def position_element(element, current_position)
|
126
|
-
raise 'position_element is a subclass responsibility'
|
127
|
-
end
|
128
|
-
|
129
|
-
def position_in_current_line(element, current_position)
|
130
|
-
position_element_at element,
|
131
|
-
position_x(current_position.x, element),
|
132
|
-
position_y(current_position.y, element)
|
133
|
-
NEXT_ELEMENT_ON_SAME_LINE_OFFSET
|
134
|
-
end
|
135
|
-
|
136
|
-
def move_to_next_line(element, current_position)
|
137
|
-
position_element_at element,
|
138
|
-
position_x(self.element_left, element),
|
139
|
-
position_y(current_position.next_line_start, element)
|
140
|
-
NEXT_ELEMENT_ON_NEXT_LINE_OFFSET
|
141
|
-
end
|
142
|
-
|
143
|
-
def position_element_at(element, x, y)
|
144
|
-
return if element_did_not_move?(element, x, y)
|
145
|
-
element._position x, y
|
146
|
-
end
|
147
|
-
|
148
|
-
def element_did_not_move?(element, x, y)
|
149
|
-
element.absolute_left == x && element.absolute_top == y
|
150
|
-
end
|
151
|
-
|
152
|
-
def update_current_position(current_position, element, position_modifier)
|
153
|
-
return current_position if element.absolutely_positioned?
|
154
|
-
current_position.x = element.absolute_right + position_modifier.x
|
155
|
-
current_position.y = element.absolute_top + position_modifier.y
|
156
|
-
if current_position.next_line_start < element.absolute_bottom + 1
|
157
|
-
current_position.next_line_start = element.absolute_bottom + 1
|
158
|
-
end
|
159
|
-
current_position
|
160
|
-
end
|
161
|
-
|
162
|
-
def position_x(relative_x, element)
|
163
|
-
if element.absolute_x_position?
|
164
|
-
absolute_x_position(element)
|
165
|
-
else
|
166
|
-
relative_x
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def absolute_x_position(element)
|
171
|
-
if element.absolute_left_position?
|
172
|
-
self.absolute_left + element.left
|
173
|
-
elsif element.absolute_right_position?
|
174
|
-
self.absolute_right - (element.right + element.width)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def position_y(relative_y, element)
|
179
|
-
if element.absolute_y_position?
|
180
|
-
absolute_y_position(element)
|
181
|
-
else
|
182
|
-
relative_y
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
def absolute_y_position(element)
|
187
|
-
if element.absolute_top_position?
|
188
|
-
self.absolute_top + element.top
|
189
|
-
elsif element.absolute_bottom_position?
|
190
|
-
# TODO: slots grow... to really position it relative to the bottom
|
191
|
-
# we probably need to position it after everything has been positioned
|
192
|
-
self.absolute_bottom - (element.bottom + element.height)
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
def fits_on_the_same_line?(element, current_x)
|
197
|
-
fitting_width = element.width
|
198
|
-
fitting_width = element.fitting_width if element.respond_to?(:fitting_width)
|
199
|
-
current_x + fitting_width - 1 <= element_right
|
200
|
-
end
|
201
|
-
|
202
|
-
def determine_slot_height(last_position)
|
203
|
-
content_height = compute_content_height(last_position)
|
204
|
-
self.height = content_height if has_variable_height?
|
205
|
-
content_height
|
206
|
-
end
|
207
|
-
|
208
|
-
def compute_content_height(last_position)
|
209
|
-
last_position.next_line_start - self.absolute_top
|
210
|
-
end
|
211
|
-
|
212
|
-
def has_variable_height?
|
213
|
-
not @fixed_height
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
class Flow < Slot
|
218
|
-
def position_element(element, current_position)
|
219
|
-
if fits_on_the_same_line?(element, current_position.x)
|
220
|
-
position_in_current_line(element, current_position)
|
221
|
-
else
|
222
|
-
move_to_next_line(element, current_position)
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
class Stack < Slot
|
228
|
-
def position_element(element, current_position)
|
229
|
-
move_to_next_line(element, current_position)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|