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
@@ -1,34 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Common
|
3
|
-
# Changeable elements are elements that receive `change' events.
|
4
|
-
# These are ListBox, EditBox and EditLine. To have your code respond
|
5
|
-
# to these events, either pass a block in when creating the element,
|
6
|
-
# or call #change on the element with a block.
|
7
|
-
module Changeable
|
8
|
-
# Add an extra change event listener block
|
9
|
-
#
|
10
|
-
# @yield The block to execute on a change event
|
11
|
-
def change(&blk)
|
12
|
-
add_change_listener(blk)
|
13
|
-
end
|
14
|
-
|
15
|
-
# The GUI backend needs to call this when an actual change happens in
|
16
|
-
# the backend.
|
17
|
-
def call_change_listeners
|
18
|
-
change_listeners.each do |listener|
|
19
|
-
listener.call(self)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def change_listeners
|
26
|
-
@change_listeners ||= []
|
27
|
-
end
|
28
|
-
|
29
|
-
def add_change_listener(callable)
|
30
|
-
change_listeners << callable
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
class Shoes
|
3
|
-
# Methods common to Shoes gui elements.
|
4
|
-
#
|
5
|
-
# Classes that include this module must expose:
|
6
|
-
#
|
7
|
-
# gui_container - the "real" framework implementation object
|
8
|
-
module CommonMethods
|
9
|
-
|
10
|
-
# Hides the element, so that it can't be seen. See also #show and #toggle.
|
11
|
-
def hide
|
12
|
-
@hidden = false
|
13
|
-
toggle
|
14
|
-
end
|
15
|
-
|
16
|
-
def hidden?
|
17
|
-
@hidden
|
18
|
-
end
|
19
|
-
|
20
|
-
alias_method :hidden, :hidden?
|
21
|
-
|
22
|
-
def visible?
|
23
|
-
!hidden?
|
24
|
-
end
|
25
|
-
|
26
|
-
# Reveals the element, if it is hidden. See also #hide and #toggle.
|
27
|
-
def show
|
28
|
-
@hidden = true
|
29
|
-
toggle
|
30
|
-
end
|
31
|
-
|
32
|
-
# Hides an element if it is shown. Or shows the element, if it is hidden.
|
33
|
-
# See also #hide and #show.
|
34
|
-
def toggle
|
35
|
-
@hidden = !@hidden
|
36
|
-
@gui.toggle
|
37
|
-
self
|
38
|
-
end
|
39
|
-
|
40
|
-
# Moves an element to a specific pixel position. The element is still in the slot,
|
41
|
-
# but will no longer be stacked or flowed with the other stuff in the slot.
|
42
|
-
def move(left, top)
|
43
|
-
self.left = left
|
44
|
-
self.top = top
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
48
|
-
# NOT part of the public interface e.g. no Shoes APP should use this
|
49
|
-
# however we need it from the Slot code to position elements
|
50
|
-
def _position left, top
|
51
|
-
self.absolute_left = left
|
52
|
-
self.absolute_top = top
|
53
|
-
@gui.update_position if @gui && @gui.respond_to?(:update_position)
|
54
|
-
end
|
55
|
-
|
56
|
-
def remove
|
57
|
-
@parent.contents.delete self if @parent
|
58
|
-
@gui.clear if @gui
|
59
|
-
end
|
60
|
-
|
61
|
-
# displace(left: a number, top: a number) » self
|
62
|
-
# Displacing an element moves it. But without changing the layout around it.
|
63
|
-
def displace(left, top)
|
64
|
-
self.displace_left = left
|
65
|
-
self.displace_top = top
|
66
|
-
gui.update_position
|
67
|
-
self
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
data/lib/shoes/common/fill.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Common
|
3
|
-
# Methods for objects with fill
|
4
|
-
#
|
5
|
-
# @note Including classes must provide `#style`
|
6
|
-
module Fill
|
7
|
-
DEFAULTS = {
|
8
|
-
:fill => Shoes::COLORS[:black]
|
9
|
-
}
|
10
|
-
|
11
|
-
def fill
|
12
|
-
style[:fill]
|
13
|
-
end
|
14
|
-
|
15
|
-
def fill=(color)
|
16
|
-
style[:fill] = color
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
@@ -1,33 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Common
|
3
|
-
module Registration
|
4
|
-
def apps
|
5
|
-
@apps ||= []
|
6
|
-
@apps.dup
|
7
|
-
end
|
8
|
-
|
9
|
-
def register(app)
|
10
|
-
register_main_app app
|
11
|
-
apps && @apps << app
|
12
|
-
end
|
13
|
-
|
14
|
-
def unregister(app)
|
15
|
-
apps && @apps.delete(app)
|
16
|
-
end
|
17
|
-
|
18
|
-
def unregister_all
|
19
|
-
@main_app = nil
|
20
|
-
@apps = []
|
21
|
-
end
|
22
|
-
|
23
|
-
def main_app
|
24
|
-
@main_app
|
25
|
-
end
|
26
|
-
|
27
|
-
# Registers the first app as the main app
|
28
|
-
def register_main_app(app)
|
29
|
-
@main_app ||= app
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/shoes/common/state.rb
DELETED
data/lib/shoes/common/stroke.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Common
|
3
|
-
# Methods for objects with stroke
|
4
|
-
#
|
5
|
-
# @note Including classes must provide `#style`
|
6
|
-
module Stroke
|
7
|
-
DEFAULTS = {
|
8
|
-
:stroke => Shoes::COLORS[:black]
|
9
|
-
}
|
10
|
-
|
11
|
-
def stroke
|
12
|
-
style[:stroke]
|
13
|
-
end
|
14
|
-
|
15
|
-
def stroke=(color)
|
16
|
-
style[:stroke] = color
|
17
|
-
end
|
18
|
-
|
19
|
-
def strokewidth
|
20
|
-
style[:strokewidth]
|
21
|
-
end
|
22
|
-
|
23
|
-
def strokewidth=(width)
|
24
|
-
style[:strokewidth] = width
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/lib/shoes/common/style.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Common
|
3
|
-
# Style methods.
|
4
|
-
#
|
5
|
-
# Including classes must have instance variable `@style`
|
6
|
-
module Style
|
7
|
-
# Adds style, or just returns current style if no argument
|
8
|
-
#
|
9
|
-
# Returns the updated style
|
10
|
-
def style(new_styles = nil)
|
11
|
-
update_style(new_styles) if need_to_update_style?(new_styles)
|
12
|
-
@style
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def update_style(new_styles)
|
17
|
-
normalized_style = StyleNormalizer.new.normalize new_styles
|
18
|
-
@style.merge! normalized_style
|
19
|
-
end
|
20
|
-
|
21
|
-
def need_to_update_style?(new_styles)
|
22
|
-
new_styles && style_changed?(new_styles)
|
23
|
-
end
|
24
|
-
|
25
|
-
# check necessary because update_style trigger a redraw in the redrawing
|
26
|
-
# aspect and we want to avoid unnecessary redraws
|
27
|
-
def style_changed?(new_styles)
|
28
|
-
new_styles.each_pair.any? do |key, value|
|
29
|
-
@style[key] != value
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
module Common
|
3
|
-
class StyleNormalizer
|
4
|
-
include Color::DSLHelpers
|
5
|
-
def normalize(orig_style)
|
6
|
-
normalized_style = {}
|
7
|
-
[:fill, :stroke].each do |s|
|
8
|
-
if orig_style[s]
|
9
|
-
normalized_style[s] = pattern(orig_style[s])
|
10
|
-
end
|
11
|
-
end
|
12
|
-
orig_style.merge(normalized_style)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/shoes/configuration.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Configuration
|
3
|
-
class << self
|
4
|
-
def reset
|
5
|
-
@logger = nil
|
6
|
-
@logger_instance = nil
|
7
|
-
end
|
8
|
-
|
9
|
-
def backend
|
10
|
-
@backend ||= Shoes.load_backend(backend_name)
|
11
|
-
end
|
12
|
-
|
13
|
-
def backend_name
|
14
|
-
@backend_name ||= ENV.fetch('SHOES_BACKEND', default_backend).to_sym
|
15
|
-
end
|
16
|
-
|
17
|
-
def default_backend
|
18
|
-
if caller.any? {|path| path =~ /rspec/}
|
19
|
-
:mock
|
20
|
-
else
|
21
|
-
:swt
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
# The Shoes backend to use. Can only be set once.
|
26
|
-
#
|
27
|
-
# @param [Symbol] backend The backend's name
|
28
|
-
# @return [Module] The backend's root module
|
29
|
-
# @example
|
30
|
-
# Shoes::Configuration.backend = :swt # => Shoes::Swt
|
31
|
-
def backend=(name)
|
32
|
-
unless @backend.nil?
|
33
|
-
raise "Can't switch backend to Shoes::#{name.capitalize}, Shoes::#{backend_name.capitalize} backend already loaded."
|
34
|
-
end
|
35
|
-
@backend_name ||= name
|
36
|
-
end
|
37
|
-
|
38
|
-
# Finds the appropriate backend class for the given Shoes object
|
39
|
-
#
|
40
|
-
# @param [Object] shoes_object A Shoes object
|
41
|
-
# @return [Object] An appropriate backend class
|
42
|
-
# @example
|
43
|
-
# Shoes.configuration.backend_class(shoes_button) # => Shoes::Swt::Button
|
44
|
-
def backend_class(shoes_object)
|
45
|
-
class_name = shoes_object.class.name.split("::").last
|
46
|
-
raise ArgumentError, "#{shoes_object} does not have a backend class defined for #{backend}" unless self.backend.const_defined?(class_name)
|
47
|
-
self.backend.const_get(class_name)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Creates an appropriate backend object, passing along additional arguments
|
51
|
-
#
|
52
|
-
# @param [Object] shoes_object A Shoes object
|
53
|
-
# @return [Object] An appropriate backend object
|
54
|
-
# @example
|
55
|
-
# Shoes.configuration.backend_for(button, args) # => <Shoes::Swt::Button:0x12345678>
|
56
|
-
def backend_for(shoes_object, *args)
|
57
|
-
backend_factory(shoes_object).call(shoes_object, *args)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Experimental replacement for #backend_for
|
61
|
-
def backend_with_app_for(shoes_object, *args, &blk)
|
62
|
-
backend_factory(shoes_object).call(shoes_object, shoes_object.app.gui, *args, &blk)
|
63
|
-
end
|
64
|
-
|
65
|
-
def backend_factory(shoes_object)
|
66
|
-
klass = backend_class(shoes_object)
|
67
|
-
klass.respond_to?(:create) ? klass.method(:create) : klass.method(:new)
|
68
|
-
end
|
69
|
-
|
70
|
-
def logger=(value)
|
71
|
-
@logger = value
|
72
|
-
@logger_instance = nil
|
73
|
-
end
|
74
|
-
|
75
|
-
def logger
|
76
|
-
@logger ||= :ruby
|
77
|
-
end
|
78
|
-
|
79
|
-
def logger_instance
|
80
|
-
@logger_instance ||= Shoes::Logger.get(self.logger).new
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def Shoes.configuration
|
87
|
-
Shoes::Configuration
|
88
|
-
end
|
89
|
-
|
90
|
-
def Shoes.backend_for(shoes_object, *args, &blk)
|
91
|
-
Shoes::Configuration.backend_with_app_for(shoes_object, *args, &blk)
|
92
|
-
end
|
93
|
-
|
94
|
-
def Shoes.backend
|
95
|
-
Shoes.configuration.backend
|
96
|
-
end
|
data/lib/shoes/dialog.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Dialog
|
3
|
-
def initialize
|
4
|
-
@gui = Shoes.backend::Dialog.new
|
5
|
-
end
|
6
|
-
|
7
|
-
def alert(msg = '')
|
8
|
-
@gui.alert msg
|
9
|
-
end
|
10
|
-
|
11
|
-
def confirm(msg = '')
|
12
|
-
@gui.confirm msg
|
13
|
-
end
|
14
|
-
|
15
|
-
def dialog_chooser title, folder=false
|
16
|
-
@gui.dialog_chooser title, folder
|
17
|
-
end
|
18
|
-
|
19
|
-
def ask msg, args
|
20
|
-
@gui.ask msg, args
|
21
|
-
end
|
22
|
-
|
23
|
-
def ask_color title
|
24
|
-
@gui.ask_color title
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/shoes/dimension.rb
DELETED
@@ -1,237 +0,0 @@
|
|
1
|
-
class Shoes
|
2
|
-
class Dimension
|
3
|
-
attr_reader :parent
|
4
|
-
attr_accessor :absolute_start
|
5
|
-
protected :parent # we shall not mess with parent,see #495
|
6
|
-
|
7
|
-
# in case you wonder about the -1... it is used to adjust the right and
|
8
|
-
# bottom values. Because right is not left + width but rather left + width -1
|
9
|
-
# Let me give you an example:
|
10
|
-
# Say left is 20 and we have a width of 100 then the right must be 119,
|
11
|
-
# because you have to take pixel number 20 into account so 20..119 is 100
|
12
|
-
# while 20..120 is 101. E.g.:
|
13
|
-
# (20..119).size => 100
|
14
|
-
PIXEL_COUNTING_ADJUSTMENT = -1
|
15
|
-
|
16
|
-
def initialize(parent = nil, start_as_center = false)
|
17
|
-
@parent = parent
|
18
|
-
@start_as_center = start_as_center
|
19
|
-
end
|
20
|
-
|
21
|
-
def start
|
22
|
-
value = basic_start_value
|
23
|
-
value = adjust_start_for_center(value) if start_as_center?
|
24
|
-
value
|
25
|
-
end
|
26
|
-
|
27
|
-
def end
|
28
|
-
@end || report_relative_to_parent_end
|
29
|
-
end
|
30
|
-
|
31
|
-
def extent
|
32
|
-
result = @extent
|
33
|
-
if @parent
|
34
|
-
result = calculate_relative(result) if is_relative?(result)
|
35
|
-
result = calculate_negative(result) if is_negative?(result)
|
36
|
-
end
|
37
|
-
result
|
38
|
-
end
|
39
|
-
|
40
|
-
def extent=(value)
|
41
|
-
@extent = value
|
42
|
-
@extent = parse_from_string @extent if is_string? @extent
|
43
|
-
@extent
|
44
|
-
end
|
45
|
-
|
46
|
-
def absolute_end
|
47
|
-
return absolute_start if extent.nil?
|
48
|
-
absolute_start + extent + PIXEL_COUNTING_ADJUSTMENT
|
49
|
-
end
|
50
|
-
|
51
|
-
def element_extent
|
52
|
-
my_extent = extent
|
53
|
-
if my_extent.nil?
|
54
|
-
nil
|
55
|
-
else
|
56
|
-
extent - (margin_start + margin_end)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def element_extent=(value)
|
61
|
-
self.extent = if value.nil?
|
62
|
-
nil
|
63
|
-
else
|
64
|
-
margin_start + value + margin_end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def element_start
|
69
|
-
return nil if absolute_start.nil?
|
70
|
-
absolute_start + margin_start + displace_start
|
71
|
-
end
|
72
|
-
|
73
|
-
def element_end
|
74
|
-
return nil if element_start.nil? || element_extent.nil?
|
75
|
-
element_start + element_extent + PIXEL_COUNTING_ADJUSTMENT
|
76
|
-
end
|
77
|
-
|
78
|
-
def absolute_start_position?
|
79
|
-
not @start.nil?
|
80
|
-
end
|
81
|
-
|
82
|
-
def absolute_end_position?
|
83
|
-
not @end.nil?
|
84
|
-
end
|
85
|
-
|
86
|
-
def absolute_position?
|
87
|
-
absolute_start_position? || absolute_end_position?
|
88
|
-
end
|
89
|
-
|
90
|
-
def positioned?
|
91
|
-
absolute_start
|
92
|
-
end
|
93
|
-
|
94
|
-
def in_bounds?(value)
|
95
|
-
(absolute_start <= value) && (value <= absolute_end)
|
96
|
-
end
|
97
|
-
|
98
|
-
# For... reasons it is important to have the value of the instance variable
|
99
|
-
# set to nil if it's not modified and then return a default value on the
|
100
|
-
# getter... reason being that for ParentDimensions we need to be able to
|
101
|
-
# figure out if a value has been modified or if we should consulte the
|
102
|
-
# parent value - see ParentDimension implementation
|
103
|
-
[:margin_start, :margin_end, :displace_start].each do |method|
|
104
|
-
define_method method do
|
105
|
-
instance_variable_name = '@' + method.to_s
|
106
|
-
instance_variable_get(instance_variable_name) || 0
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def self.define_int_parsing_writer(name)
|
111
|
-
define_method "#{name}=" do |value|
|
112
|
-
instance_variable_set("@#{name}", parse_int_value(value))
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
%w(start end margin_start margin_end displace_start).each do |method|
|
117
|
-
define_int_parsing_writer method
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
def basic_start_value
|
122
|
-
value = @start
|
123
|
-
value = calculate_relative value if is_relative?(value)
|
124
|
-
value = report_relative_to_parent_start if value.nil?
|
125
|
-
value
|
126
|
-
end
|
127
|
-
|
128
|
-
def is_relative?(result)
|
129
|
-
# as the value is relative to the parent values bigger than one don't
|
130
|
-
# make much sense and are problematic. E.g. through calculations users
|
131
|
-
# might end up with values like 5.14 meaning 5 pixel which would get
|
132
|
-
# interpreted as 514% of the parent
|
133
|
-
# Also check for existance of parent because otherwise relative
|
134
|
-
# calculation makes no sense
|
135
|
-
result.is_a?(Float) && result <= 1 && @parent
|
136
|
-
end
|
137
|
-
|
138
|
-
def calculate_relative(result)
|
139
|
-
(result * @parent.element_extent).to_i
|
140
|
-
end
|
141
|
-
|
142
|
-
def is_string?(result)
|
143
|
-
result.is_a?(String)
|
144
|
-
end
|
145
|
-
|
146
|
-
def is_negative?(result)
|
147
|
-
result && result < 0
|
148
|
-
end
|
149
|
-
|
150
|
-
def calculate_negative(result)
|
151
|
-
@parent.element_extent + result
|
152
|
-
end
|
153
|
-
|
154
|
-
PERCENT_REGEX = /(-?\d+(\.\d+)*)%/
|
155
|
-
|
156
|
-
def parse_from_string(result)
|
157
|
-
match = result.gsub(/\s+/, "").match(PERCENT_REGEX)
|
158
|
-
if match
|
159
|
-
match[1].to_f / 100.0
|
160
|
-
elsif valid_integer_string?(result)
|
161
|
-
int_from_string(result)
|
162
|
-
else
|
163
|
-
nil
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def parse_int_value(input)
|
168
|
-
if input.is_a?(Integer) || input.is_a?(Float)
|
169
|
-
input
|
170
|
-
elsif valid_integer_string?(input)
|
171
|
-
int_from_string(input)
|
172
|
-
else
|
173
|
-
nil
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def int_from_string(result)
|
178
|
-
(result.gsub(' ', '')).to_i
|
179
|
-
end
|
180
|
-
|
181
|
-
NUMBER_REGEX = /^-?\s*\d+/
|
182
|
-
|
183
|
-
def valid_integer_string?(input)
|
184
|
-
input.is_a?(String) && input.match(NUMBER_REGEX)
|
185
|
-
end
|
186
|
-
|
187
|
-
def report_relative_to_parent_start
|
188
|
-
if element_start && parent.element_start
|
189
|
-
element_start - parent.element_start
|
190
|
-
else
|
191
|
-
nil
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def report_relative_to_parent_end
|
196
|
-
if element_end && parent.element_end
|
197
|
-
parent.element_end - element_end
|
198
|
-
else
|
199
|
-
nil
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
def start_as_center?
|
204
|
-
@start_as_center
|
205
|
-
end
|
206
|
-
|
207
|
-
def adjust_start_for_center(value)
|
208
|
-
my_extent = extent
|
209
|
-
if my_extent && my_extent > 0
|
210
|
-
value - my_extent / 2
|
211
|
-
else
|
212
|
-
nil
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
class ParentDimension < Dimension
|
218
|
-
SIMPLE_DELEGATE_METHODS = [:extent, :absolute_start, :margin_start,
|
219
|
-
:margin_end, :start]
|
220
|
-
|
221
|
-
SIMPLE_DELEGATE_METHODS.each do |method|
|
222
|
-
define_method method do
|
223
|
-
if value_modified? method
|
224
|
-
super
|
225
|
-
else
|
226
|
-
parent.public_send(method)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
private
|
232
|
-
def value_modified?(method)
|
233
|
-
instance_variable = ('@' + method.to_s).to_sym
|
234
|
-
instance_variable_get(instance_variable)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|