shoes-core 4.0.0.pre6 → 4.0.0.pre7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/shoes-picker +1 -1
- data/lib/shoes/app.rb +3 -3
- data/lib/shoes/arc.rb +6 -5
- data/lib/shoes/arrow.rb +31 -0
- data/lib/shoes/background.rb +1 -1
- data/lib/shoes/border.rb +1 -1
- data/lib/shoes/builtin_methods.rb +1 -1
- data/lib/shoes/color.rb +3 -3
- data/lib/shoes/color/dsl_helpers.rb +10 -7
- data/lib/shoes/color/hex_converter.rb +1 -1
- data/lib/shoes/common/attachable.rb +11 -0
- data/lib/shoes/common/background_element.rb +8 -0
- data/lib/shoes/common/hover.rb +7 -17
- data/lib/shoes/common/link_finder.rb +12 -0
- data/lib/shoes/common/positioning.rb +1 -1
- data/lib/shoes/common/state.rb +1 -1
- data/lib/shoes/common/style.rb +9 -4
- data/lib/shoes/common/translate.rb +24 -0
- data/lib/shoes/common/ui_element.rb +1 -0
- data/lib/shoes/common/visibility.rb +1 -1
- data/lib/shoes/configuration.rb +2 -2
- data/lib/shoes/core/version.rb +3 -1
- data/lib/shoes/dimensions.rb +6 -2
- data/lib/shoes/dsl.rb +34 -14
- data/lib/shoes/font.rb +1 -1
- data/lib/shoes/gradient.rb +2 -1
- data/lib/shoes/image.rb +2 -2
- data/lib/shoes/input_box.rb +2 -2
- data/lib/shoes/internal_app.rb +8 -8
- data/lib/shoes/line.rb +7 -6
- data/lib/shoes/link.rb +5 -6
- data/lib/shoes/list_box.rb +2 -2
- data/lib/shoes/logger.rb +2 -1
- data/lib/shoes/mock.rb +1 -0
- data/lib/shoes/mock/arrow.rb +15 -0
- data/lib/shoes/mock/rect.rb +2 -1
- data/lib/shoes/mock/slot.rb +5 -1
- data/lib/shoes/mock/star.rb +2 -1
- data/lib/shoes/oval.rb +5 -4
- data/lib/shoes/point.rb +2 -1
- data/lib/shoes/progress.rb +1 -1
- data/lib/shoes/rect.rb +3 -2
- data/lib/shoes/shape.rb +14 -9
- data/lib/shoes/slot.rb +54 -25
- data/lib/shoes/slot_contents.rb +1 -3
- data/lib/shoes/star.rb +4 -3
- data/lib/shoes/text.rb +5 -0
- data/lib/shoes/text_block.rb +9 -9
- data/lib/shoes/ui/picker.rb +5 -5
- data/lib/shoes/version.rb +3 -1
- data/lib/shoes/widget.rb +2 -2
- data/lib/shoes/window.rb +6 -0
- data/spec/shoes/app_spec.rb +16 -16
- data/spec/shoes/arc_spec.rb +1 -1
- data/spec/shoes/arrow_spec.rb +28 -0
- data/spec/shoes/background_spec.rb +2 -2
- data/spec/shoes/border_spec.rb +3 -3
- data/spec/shoes/builtin_methods_spec.rb +2 -2
- data/spec/shoes/button_spec.rb +4 -2
- data/spec/shoes/color_spec.rb +12 -12
- data/spec/shoes/common/attachable_spec.rb +32 -0
- data/spec/shoes/common/inspect_spec.rb +4 -4
- data/spec/shoes/common/remove_spec.rb +5 -5
- data/spec/shoes/common/rotate_spec.rb +1 -1
- data/spec/shoes/common/style_normalizer_spec.rb +4 -4
- data/spec/shoes/common/style_spec.rb +15 -11
- data/spec/shoes/common/translate_spec.rb +27 -0
- data/spec/shoes/dimension_spec.rb +111 -100
- data/spec/shoes/dimensions_spec.rb +344 -303
- data/spec/shoes/download_spec.rb +17 -17
- data/spec/shoes/flow_spec.rb +2 -2
- data/spec/shoes/framework_learning_spec.rb +3 -1
- data/spec/shoes/helpers/fake_absolute_element.rb +3 -2
- data/spec/shoes/helpers/fake_element.rb +3 -2
- data/spec/shoes/input_box_spec.rb +2 -2
- data/spec/shoes/internal_app_spec.rb +14 -14
- data/spec/shoes/link_spec.rb +18 -19
- data/spec/shoes/list_box_spec.rb +9 -8
- data/spec/shoes/oval_spec.rb +1 -1
- data/spec/shoes/point_spec.rb +3 -3
- data/spec/shoes/renamed_delegate_spec.rb +2 -2
- data/spec/shoes/shape_spec.rb +20 -20
- data/spec/shoes/shared_examples/common_methods.rb +2 -2
- data/spec/shoes/shared_examples/dsl.rb +2 -2
- data/spec/shoes/shared_examples/dsl/flow.rb +1 -1
- data/spec/shoes/shared_examples/dsl/pattern.rb +2 -2
- data/spec/shoes/shared_examples/dsl/rgb.rb +2 -2
- data/spec/shoes/shared_examples/dsl/shape.rb +11 -7
- data/spec/shoes/shared_examples/dsl/star.rb +44 -44
- data/spec/shoes/shared_examples/dsl/style.rb +1 -1
- data/spec/shoes/shared_examples/dsl/text_elements.rb +6 -3
- data/spec/shoes/shared_examples/dsl/video.rb +1 -1
- data/spec/shoes/shared_examples/dsl_app_context.rb +6 -5
- data/spec/shoes/shared_examples/hover.rb +2 -2
- data/spec/shoes/shared_examples/shared_element_method.rb +2 -2
- data/spec/shoes/shared_examples/slot.rb +32 -21
- data/spec/shoes/shared_examples/style.rb +1 -1
- data/spec/shoes/slot_spec.rb +24 -7
- data/spec/shoes/span_spec.rb +5 -5
- data/spec/shoes/spec_helper.rb +1 -1
- data/spec/shoes/stack_spec.rb +5 -5
- data/spec/shoes/text_block_dimensions_spec.rb +6 -3
- data/spec/shoes/text_block_spec.rb +13 -7
- data/spec/shoes/text_spec.rb +22 -0
- data/spec/shoes/ui/picker_spec.rb +3 -3
- data/spec/shoes/url_spec.rb +4 -4
- data/spec/shoes/widget_spec.rb +1 -1
- data/spec/shoes_spec.rb +3 -3
- data/spec/spec_helper.rb +8 -1
- metadata +17 -4
- data/bin/shoes +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24b91fee87f3e41db5ff2dfea086583143fa478f
|
4
|
+
data.tar.gz: 90f1c1286744dec7e681972691c6f14abb838573
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34d82bc1902bd05f440d69cc8b56cac7f30be8367edbca11e8870996691307bd402084a09e0c9dbfc33b87abcf9b8d8d24e6c230c8c5392a043e7b882ac537b
|
7
|
+
data.tar.gz: 699dd3055e4bfdbcf0498af1be251f88835d870591e6019e04e9a82bdd9f40c87c2189000fcce042f85f1e873833c57cde925cab0ff49be7df04799bb95baf3c
|
data/bin/shoes-picker
CHANGED
data/lib/shoes/app.rb
CHANGED
@@ -66,7 +66,7 @@ class Shoes
|
|
66
66
|
@__app__.quit
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
alias close quit
|
70
70
|
|
71
71
|
def parent
|
72
72
|
@__app__.current_slot.parent
|
@@ -80,7 +80,7 @@ class Shoes
|
|
80
80
|
|
81
81
|
def_delegators :@__app__, *delegated_to_internal_app
|
82
82
|
|
83
|
-
|
83
|
+
alias fullscreen? fullscreen
|
84
84
|
|
85
85
|
def eval_with_additional_context(context, &blk)
|
86
86
|
@__additional_context__ = context
|
@@ -107,7 +107,7 @@ class Shoes
|
|
107
107
|
inspect_details
|
108
108
|
end
|
109
109
|
|
110
|
-
DELEGATE_BLACKLIST = [:parent, :app]
|
110
|
+
DELEGATE_BLACKLIST = [:parent, :app].freeze
|
111
111
|
|
112
112
|
# class definitions are evaluated top to bottom, want to have all of them
|
113
113
|
# so define at bottom
|
data/lib/shoes/arc.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Arc
|
3
3
|
include Common::UIElement
|
4
|
+
include Common::Clickable
|
5
|
+
include Common::Hover
|
4
6
|
include Common::Fill
|
5
7
|
include Common::Stroke
|
6
8
|
include Common::Style
|
7
|
-
include Common::
|
8
|
-
include Common::Hover
|
9
|
+
include Common::Translate
|
9
10
|
|
10
11
|
style_with :angle1, :angle2, :art_styles, :center, :common_styles, :dimensions, :radius, :wedge
|
11
|
-
STYLES = { wedge: false }
|
12
|
+
STYLES = { wedge: false }.freeze
|
12
13
|
|
13
|
-
def before_initialize(styles,
|
14
|
+
def before_initialize(styles, _left, _top, _width, _height, angle1, angle2)
|
14
15
|
styles[:angle1] = angle1
|
15
16
|
styles[:angle2] = angle2
|
16
17
|
end
|
17
18
|
|
18
|
-
def create_dimensions(left, top, width, height,
|
19
|
+
def create_dimensions(left, top, width, height, _angle1, _angle2)
|
19
20
|
@dimensions = Dimensions.new parent, left, top, width, height, @style
|
20
21
|
end
|
21
22
|
|
data/lib/shoes/arrow.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class Shoes
|
2
|
+
class Arrow
|
3
|
+
include Common::UIElement
|
4
|
+
include Common::Clickable
|
5
|
+
include Common::Fill
|
6
|
+
include Common::Hover
|
7
|
+
include Common::Stroke
|
8
|
+
include Common::Style
|
9
|
+
include Common::Translate
|
10
|
+
|
11
|
+
style_with :angle, :art_styles, :curve, :common_styles, :dimensions
|
12
|
+
STYLES = { angle: 0, fill: Shoes::COLORS[:black] }.freeze
|
13
|
+
|
14
|
+
def create_dimensions(left, top, width)
|
15
|
+
left ||= @style[:left] || 0
|
16
|
+
top ||= @style[:top] || 0
|
17
|
+
width ||= @style[:width] || 0
|
18
|
+
|
19
|
+
@dimensions = AbsoluteDimensions.new left, top, width, width, @style
|
20
|
+
end
|
21
|
+
|
22
|
+
def needs_rotate?
|
23
|
+
rotate && rotate.nonzero?
|
24
|
+
end
|
25
|
+
|
26
|
+
def width=(*_)
|
27
|
+
super
|
28
|
+
gui.update_position
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/shoes/background.rb
CHANGED
data/lib/shoes/border.rb
CHANGED
data/lib/shoes/color.rb
CHANGED
@@ -24,7 +24,7 @@ Must be one of:
|
|
24
24
|
- #{self.class}.new(red, green, blue)
|
25
25
|
- #{self.class}.new(red, green, blue, alpha)
|
26
26
|
EOS
|
27
|
-
|
27
|
+
raise ArgumentError, message
|
28
28
|
end
|
29
29
|
alpha ||= OPAQUE
|
30
30
|
@red = normalize_rgb(red)
|
@@ -56,7 +56,7 @@ EOS
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def black?
|
59
|
-
@red
|
59
|
+
@red.zero? && @green.zero? && @blue.zero?
|
60
60
|
end
|
61
61
|
|
62
62
|
def <=>(other)
|
@@ -86,7 +86,7 @@ EOS
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def normalize_rgb(value)
|
89
|
-
rgb = value.is_a?(
|
89
|
+
rgb = value.is_a?(Integer) ? value : (255 * value).round
|
90
90
|
return 255 if rgb > 255
|
91
91
|
return 0 if rgb < 0
|
92
92
|
rgb
|
@@ -14,7 +14,7 @@ class Shoes
|
|
14
14
|
when Shoes::ImagePattern
|
15
15
|
arg
|
16
16
|
else
|
17
|
-
|
17
|
+
raise ArgumentError, "Bad pattern: #{arg.inspect}"
|
18
18
|
end
|
19
19
|
else
|
20
20
|
gradient(*args)
|
@@ -50,16 +50,19 @@ class Shoes
|
|
50
50
|
arg = args[0]
|
51
51
|
case arg
|
52
52
|
when Gradient
|
53
|
-
min
|
53
|
+
min = arg.color1
|
54
|
+
max = arg.color2
|
54
55
|
when Range
|
55
|
-
min
|
56
|
+
min = arg.first
|
57
|
+
max = arg.last
|
56
58
|
else
|
57
|
-
|
59
|
+
raise ArgumentError, "Can't make gradient out of #{arg.inspect}"
|
58
60
|
end
|
59
61
|
when 2
|
60
|
-
min
|
62
|
+
min = args[0]
|
63
|
+
max = args[1]
|
61
64
|
else
|
62
|
-
|
65
|
+
raise ArgumentError, "Wrong number of arguments (#{args.length} for 1 or 2)"
|
63
66
|
end
|
64
67
|
Shoes::Gradient.new(color(min), color(max))
|
65
68
|
end
|
@@ -68,7 +71,7 @@ class Shoes
|
|
68
71
|
Shoes::Color.new(level, level, level, alpha)
|
69
72
|
end
|
70
73
|
|
71
|
-
|
74
|
+
alias grey gray
|
72
75
|
|
73
76
|
private
|
74
77
|
|
@@ -2,7 +2,7 @@ class Shoes
|
|
2
2
|
class Color
|
3
3
|
class HexConverter
|
4
4
|
def initialize(hex)
|
5
|
-
@hex = validate(hex) ||
|
5
|
+
@hex = validate(hex) || raise(ArgumentError, "Bad hex color: #{hex}")
|
6
6
|
@red, @green, @blue = hex_to_rgb(pad_if_necessary(@hex))
|
7
7
|
end
|
8
8
|
|
data/lib/shoes/common/hover.rb
CHANGED
@@ -23,10 +23,6 @@ class Shoes
|
|
23
23
|
@hovered
|
24
24
|
end
|
25
25
|
|
26
|
-
def eval_in_parent?
|
27
|
-
false
|
28
|
-
end
|
29
|
-
|
30
26
|
def hover_class
|
31
27
|
return @hover_class if @hover_class
|
32
28
|
|
@@ -40,7 +36,7 @@ class Shoes
|
|
40
36
|
@hovered = true
|
41
37
|
|
42
38
|
apply_style_from_hover_class
|
43
|
-
|
39
|
+
eval_hover_block(@hover_blk)
|
44
40
|
end
|
45
41
|
|
46
42
|
def mouse_left
|
@@ -49,37 +45,31 @@ class Shoes
|
|
49
45
|
@hovered = false
|
50
46
|
|
51
47
|
apply_style_from_pre_hover
|
52
|
-
|
48
|
+
eval_hover_block(@leave_blk)
|
53
49
|
end
|
54
50
|
|
55
51
|
def add_mouse_hover_control
|
56
52
|
app.add_mouse_hover_control(self)
|
57
53
|
end
|
58
54
|
|
59
|
-
def target
|
60
|
-
target = self
|
61
|
-
target = parent if eval_in_parent?
|
62
|
-
target
|
63
|
-
end
|
64
|
-
|
65
55
|
def eval_hover_block(blk)
|
66
56
|
blk.call(self) if blk
|
67
57
|
end
|
68
58
|
|
69
59
|
def apply_style_from_hover_class
|
70
|
-
hover_style = @app.element_styles[
|
60
|
+
hover_style = @app.element_styles[hover_class]
|
71
61
|
return unless hover_style
|
72
62
|
|
73
|
-
@pre_hover_style = hover_style.
|
74
|
-
memo[key] =
|
63
|
+
@pre_hover_style = hover_style.each_with_object({}) do |(key, _), memo|
|
64
|
+
memo[key] = style[key]
|
75
65
|
memo
|
76
66
|
end
|
77
67
|
|
78
|
-
|
68
|
+
style(hover_style)
|
79
69
|
end
|
80
70
|
|
81
71
|
def apply_style_from_pre_hover
|
82
|
-
|
72
|
+
style(@pre_hover_style) if @pre_hover_style
|
83
73
|
@pre_hover_style = nil
|
84
74
|
end
|
85
75
|
end
|
@@ -17,7 +17,7 @@ class Shoes
|
|
17
17
|
gui.update_position if gui && gui.respond_to?(:update_position)
|
18
18
|
end
|
19
19
|
|
20
|
-
# displace(left: a number, top: a number)
|
20
|
+
# displace(left: a number, top: a number) >> self
|
21
21
|
# Displacing an element moves it. But without changing the layout around it.
|
22
22
|
def displace(left, top)
|
23
23
|
self.displace_left = left
|
data/lib/shoes/common/state.rb
CHANGED
data/lib/shoes/common/style.rb
CHANGED
@@ -23,7 +23,7 @@ class Shoes
|
|
23
23
|
:justify, :kerning, :leading, :rise, :size, :stretch,
|
24
24
|
:strikecolor, :strikethrough, :stroke, :undercolor,
|
25
25
|
:underline, :weight, :wrap],
|
26
|
-
}
|
26
|
+
}.freeze
|
27
27
|
|
28
28
|
# Adds styles, or just returns current style if no argument
|
29
29
|
def style(new_styles = nil)
|
@@ -85,7 +85,7 @@ class Shoes
|
|
85
85
|
|
86
86
|
def define_reader_methods
|
87
87
|
needs_readers = @supported_styles.reject do |style|
|
88
|
-
|
88
|
+
method_defined?(style)
|
89
89
|
end
|
90
90
|
|
91
91
|
needs_readers.map(&:to_sym).each do |style|
|
@@ -97,7 +97,7 @@ class Shoes
|
|
97
97
|
|
98
98
|
def define_writer_methods
|
99
99
|
needs_writers = @supported_styles.reject do |style|
|
100
|
-
|
100
|
+
method_defined?("#{style}=")
|
101
101
|
end
|
102
102
|
|
103
103
|
needs_writers.map(&:to_sym).each do |style_key|
|
@@ -126,6 +126,7 @@ class Shoes
|
|
126
126
|
set_visibility(new_styles)
|
127
127
|
set_coloring(new_styles)
|
128
128
|
set_hovers(new_styles)
|
129
|
+
set_translate(new_styles)
|
129
130
|
click(&new_styles[:click]) if new_styles.key?(:click)
|
130
131
|
@style.merge! normalized_style
|
131
132
|
end
|
@@ -153,9 +154,13 @@ class Shoes
|
|
153
154
|
leave(&new_styles[:leave]) if new_styles.include?(:leave)
|
154
155
|
end
|
155
156
|
|
157
|
+
def set_translate(new_styles)
|
158
|
+
clear_translate if new_styles.include?(:translate)
|
159
|
+
end
|
160
|
+
|
156
161
|
def update_dimensions # so that @style hash matches actual values
|
157
162
|
STYLE_GROUPS[:dimensions].each do |style|
|
158
|
-
if
|
163
|
+
if respond_to?(style)
|
159
164
|
value = send(style)
|
160
165
|
@style[style] = value if value
|
161
166
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Shoes
|
2
|
+
module Common
|
3
|
+
module Translate
|
4
|
+
def translate_left
|
5
|
+
@translate_left ||= begin
|
6
|
+
left, _ = translate
|
7
|
+
left || 0
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def translate_top
|
12
|
+
@translate_top ||= begin
|
13
|
+
_, top = translate
|
14
|
+
top || 0
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def clear_translate
|
19
|
+
@translate_left = nil
|
20
|
+
@translate_top = nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/shoes/configuration.rb
CHANGED
@@ -32,7 +32,7 @@ class Shoes
|
|
32
32
|
return if @backend_name == name
|
33
33
|
|
34
34
|
unless @backend.nil?
|
35
|
-
|
35
|
+
raise "Can't switch backend to Shoes::#{name.capitalize}, Shoes::#{backend_name.capitalize} backend already loaded."
|
36
36
|
end
|
37
37
|
@backend_name ||= name
|
38
38
|
end
|
@@ -48,7 +48,7 @@ class Shoes
|
|
48
48
|
class_name = klazz.name.split("::").last
|
49
49
|
# Lookup with false to not consult modules higher in the chain Object
|
50
50
|
# because Shoes::Swt.const_defined? 'Range' => true
|
51
|
-
|
51
|
+
raise ArgumentError, "#{object} does not have a backend class defined for #{backend}" unless backend.const_defined?(class_name, false)
|
52
52
|
backend.const_get(class_name, false)
|
53
53
|
end
|
54
54
|
|