shoes-core 4.0.0.pre6 → 4.0.0.pre7
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/shoes/core/version.rb
CHANGED
data/lib/shoes/dimensions.rb
CHANGED
@@ -191,7 +191,7 @@ class Shoes
|
|
191
191
|
module DimensionsDelegations
|
192
192
|
extend Forwardable
|
193
193
|
|
194
|
-
UNDELEGATED_METHODS = [:to_s]
|
194
|
+
UNDELEGATED_METHODS = [:to_s].freeze
|
195
195
|
CANDIDATE_METHODS = Dimensions.public_instance_methods(false) - UNDELEGATED_METHODS
|
196
196
|
|
197
197
|
WRITER_METHODS = CANDIDATE_METHODS.select { |meth| meth.to_s.end_with?("=") }
|
@@ -205,7 +205,7 @@ class Shoes
|
|
205
205
|
key = meth.to_s.sub("=", "").to_sym
|
206
206
|
define_method(meth) do |value|
|
207
207
|
@style[key] = value if @style
|
208
|
-
|
208
|
+
dimensions.send(meth, value)
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
@@ -219,5 +219,9 @@ class Shoes
|
|
219
219
|
extend Forwardable
|
220
220
|
|
221
221
|
def_delegators :dsl, *DimensionsDelegations::CANDIDATE_METHODS
|
222
|
+
|
223
|
+
def redraw_target
|
224
|
+
@dsl
|
225
|
+
end
|
222
226
|
end
|
223
227
|
end
|
data/lib/shoes/dsl.rb
CHANGED
@@ -74,12 +74,14 @@ require 'shoes/text_block_dimensions'
|
|
74
74
|
|
75
75
|
require 'shoes/color'
|
76
76
|
|
77
|
+
require 'shoes/common/attachable'
|
77
78
|
require 'shoes/common/background_element'
|
78
79
|
require 'shoes/common/changeable'
|
79
80
|
require 'shoes/common/clickable'
|
80
81
|
require 'shoes/common/fill'
|
81
82
|
require 'shoes/common/hover'
|
82
83
|
require 'shoes/common/initialization'
|
84
|
+
require 'shoes/common/link_finder'
|
83
85
|
require 'shoes/common/positioning'
|
84
86
|
require 'shoes/common/remove'
|
85
87
|
require 'shoes/common/rotate'
|
@@ -87,6 +89,7 @@ require 'shoes/common/state'
|
|
87
89
|
require 'shoes/common/stroke'
|
88
90
|
require 'shoes/common/style'
|
89
91
|
require 'shoes/common/style_normalizer'
|
92
|
+
require 'shoes/common/translate'
|
90
93
|
require 'shoes/common/visibility'
|
91
94
|
|
92
95
|
require 'shoes/common/ui_element'
|
@@ -100,6 +103,7 @@ require 'shoes/input_box'
|
|
100
103
|
# please keep this list tidy and alphabetically sorted
|
101
104
|
require 'shoes/animation'
|
102
105
|
require 'shoes/arc'
|
106
|
+
require 'shoes/arrow'
|
103
107
|
require 'shoes/background'
|
104
108
|
require 'shoes/border'
|
105
109
|
require 'shoes/button'
|
@@ -128,6 +132,7 @@ require 'shoes/star'
|
|
128
132
|
require 'shoes/sound'
|
129
133
|
require 'shoes/text_block'
|
130
134
|
require 'shoes/timer'
|
135
|
+
require 'shoes/window'
|
131
136
|
|
132
137
|
class Shoes
|
133
138
|
# Methods for creating and manipulating Shoes elements
|
@@ -303,6 +308,17 @@ class Shoes
|
|
303
308
|
Shoes::Sound.new @__app__, soundfile, opts, &blk
|
304
309
|
end
|
305
310
|
|
311
|
+
# Creates an arrow centered at (left, top)
|
312
|
+
#
|
313
|
+
# @param [Integer] left the x-coordinate of the element center
|
314
|
+
# @param [Integer] top the y-coordinate of the element center
|
315
|
+
# @param [Integer] width width of the arrow
|
316
|
+
# @param [Hash] opts Arrow style options
|
317
|
+
# @option opts [Integer] rotate (false)
|
318
|
+
def arrow(left, top, width, styles = {}, &blk)
|
319
|
+
create Shoes::Arrow, left, top, width, styles, blk
|
320
|
+
end
|
321
|
+
|
306
322
|
# Creates an arc at (left, top)
|
307
323
|
#
|
308
324
|
# @param [Integer] left the x-coordinate of the top-left corner
|
@@ -351,7 +367,7 @@ class Shoes
|
|
351
367
|
# @option styles [Integer] height (0) the height
|
352
368
|
# @option styles [Integer] top (0) the y-coordinate of the top-left corner
|
353
369
|
# @option styles [Boolean] center (false) is (left, top) the center of the oval
|
354
|
-
OVAL_ALLOWED_ARG_SIZES = [0, 3, 4]
|
370
|
+
OVAL_ALLOWED_ARG_SIZES = [0, 3, 4].freeze
|
355
371
|
def oval(*opts, &blk)
|
356
372
|
oval_style = pop_style(opts)
|
357
373
|
oval_style = style_normalizer.normalize(oval_style)
|
@@ -364,7 +380,7 @@ Wrong number of arguments. Must be one of:
|
|
364
380
|
- oval(left, top, width, height, [opts])
|
365
381
|
- oval(styles)
|
366
382
|
EOS
|
367
|
-
|
383
|
+
raise ArgumentError, message unless OVAL_ALLOWED_ARG_SIZES.include? opts.size
|
368
384
|
create Shoes::Oval, left, top, width, height, oval_style, blk
|
369
385
|
end
|
370
386
|
|
@@ -390,7 +406,7 @@ EOS
|
|
390
406
|
# @option styles [Integer] height (0) the height
|
391
407
|
# @option styles [Integer] top (0) the y-coordinate of the top-left corner
|
392
408
|
# @option styles [Boolean] center (false) is (left, top) the center of the rectangle?
|
393
|
-
RECT_ALLOWED_ARG_SIZES = [0, 3, 4, 5]
|
409
|
+
RECT_ALLOWED_ARG_SIZES = [0, 3, 4, 5].freeze
|
394
410
|
def rect(*args, &blk)
|
395
411
|
opts = style_normalizer.normalize pop_style(args)
|
396
412
|
|
@@ -404,7 +420,7 @@ Wrong number of arguments. Must be one of:
|
|
404
420
|
- rect(left, top, width, height, curve, [opts])
|
405
421
|
- rect(styles)
|
406
422
|
EOS
|
407
|
-
|
423
|
+
raise ArgumentError, message unless RECT_ALLOWED_ARG_SIZES.include? args.size
|
408
424
|
create Shoes::Rect, left, top, width, height, style.merge(opts), blk
|
409
425
|
end
|
410
426
|
|
@@ -449,7 +465,7 @@ Wrong number of arguments. Must be one of:
|
|
449
465
|
- star(left, top, points, outer, [styles])
|
450
466
|
- star(left, top, points, outer, inner, [styles])
|
451
467
|
EOS
|
452
|
-
|
468
|
+
raise ArgumentError, message
|
453
469
|
end
|
454
470
|
|
455
471
|
create Shoes::Star, left, top, points, outer, inner, styles, blk
|
@@ -469,7 +485,7 @@ EOS
|
|
469
485
|
# Creates a shape at (0, 0)
|
470
486
|
# @option styles [Integer] left (0) the x-coordinate of the top-left corner
|
471
487
|
# @option styles [Integer] top (0) the y-coordinate of the top-left corner
|
472
|
-
SHAPE_ALLOWED_ARG_SIZES = [0, 2]
|
488
|
+
SHAPE_ALLOWED_ARG_SIZES = [0, 2].freeze
|
473
489
|
def shape(*args, &blk)
|
474
490
|
opts = style_normalizer.normalize pop_style(args)
|
475
491
|
opts[:left], opts[:top] = args if args.length == 2
|
@@ -480,13 +496,13 @@ Wrong number of arguments. Must be one of:
|
|
480
496
|
- shape(left, top, [opts])
|
481
497
|
- shape(styles)
|
482
498
|
EOS
|
483
|
-
|
499
|
+
raise ArgumentError, message unless SHAPE_ALLOWED_ARG_SIZES.include? args.length
|
484
500
|
create Shoes::Shape, style.merge(opts), blk
|
485
501
|
end
|
486
502
|
|
487
503
|
# Define app-level setter methods
|
488
|
-
PATTERN_APP_STYLES = [:fill, :stroke]
|
489
|
-
OTHER_APP_STYLES = [:cap, :rotate, :strokewidth, :transform
|
504
|
+
PATTERN_APP_STYLES = [:fill, :stroke].freeze
|
505
|
+
OTHER_APP_STYLES = [:cap, :rotate, :strokewidth, :transform].freeze
|
490
506
|
|
491
507
|
PATTERN_APP_STYLES.each do |style|
|
492
508
|
define_method style do |val|
|
@@ -500,6 +516,10 @@ EOS
|
|
500
516
|
end
|
501
517
|
end
|
502
518
|
|
519
|
+
def translate(left, top)
|
520
|
+
@__app__.style[:translate] = [left, top]
|
521
|
+
end
|
522
|
+
|
503
523
|
def nostroke
|
504
524
|
@__app__.style[:stroke] = nil
|
505
525
|
end
|
@@ -524,7 +544,7 @@ EOS
|
|
524
544
|
sub: { rise: -10, size_modifier: 0.8 },
|
525
545
|
sup: { rise: 10, size_modifier: 0.8 },
|
526
546
|
strong: { weight: true },
|
527
|
-
}
|
547
|
+
}.freeze
|
528
548
|
|
529
549
|
TEXT_STYLES.keys.each do |method|
|
530
550
|
define_method method do |*texts|
|
@@ -623,10 +643,10 @@ EOS
|
|
623
643
|
end
|
624
644
|
|
625
645
|
def video(*_args)
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
646
|
+
raise Shoes::NotImplementedError,
|
647
|
+
'Sorry video support has been cut from shoes 4!' \
|
648
|
+
' Check out github issue #113 for any changes/updates or if you' \
|
649
|
+
' want to help :)'
|
630
650
|
end
|
631
651
|
end
|
632
652
|
end
|
data/lib/shoes/font.rb
CHANGED
data/lib/shoes/gradient.rb
CHANGED
data/lib/shoes/image.rb
CHANGED
@@ -9,7 +9,7 @@ class Shoes
|
|
9
9
|
|
10
10
|
style_with :art_styles, :common_styles, :dimensions, :file_path
|
11
11
|
|
12
|
-
STYLES = { fill: Shoes::COLORS[:black] }
|
12
|
+
STYLES = { fill: Shoes::COLORS[:black] }.freeze
|
13
13
|
|
14
14
|
def before_initialize(styles, file_path_or_data)
|
15
15
|
styles[:file_path] = normalized_source(file_path_or_data)
|
@@ -42,7 +42,7 @@ class Shoes
|
|
42
42
|
|
43
43
|
def absolute_file_path(path)
|
44
44
|
path = File.join(Dir.pwd, path) unless Pathname(path).absolute?
|
45
|
-
|
45
|
+
raise FileNotFoundError, "#{path} not found." unless File.exist?(path)
|
46
46
|
path
|
47
47
|
end
|
48
48
|
end
|
data/lib/shoes/input_box.rb
CHANGED
@@ -38,12 +38,12 @@ class Shoes
|
|
38
38
|
|
39
39
|
class EditBox < InputBox
|
40
40
|
style_with :change, :common_styles, :dimensions, :text, :state
|
41
|
-
STYLES = { width: 200, height: 108, text: '' }
|
41
|
+
STYLES = { width: 200, height: 108, text: '' }.freeze
|
42
42
|
end
|
43
43
|
|
44
44
|
class EditLine < InputBox
|
45
45
|
style_with :change, :common_styles, :dimensions, :text, :secret, :state
|
46
|
-
STYLES = { width:
|
46
|
+
STYLES = { width: 200, height: 28, text: '' }.freeze
|
47
47
|
|
48
48
|
def secret?
|
49
49
|
secret
|
data/lib/shoes/internal_app.rb
CHANGED
@@ -14,12 +14,12 @@ class Shoes
|
|
14
14
|
extend Forwardable
|
15
15
|
|
16
16
|
DEFAULT_OPTIONS = {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
width: 600,
|
18
|
+
height: 500,
|
19
|
+
title: "Shoes 4",
|
20
|
+
resizable: true,
|
21
|
+
border: true
|
22
|
+
}.freeze
|
23
23
|
|
24
24
|
def initialize(app, opts, &blk)
|
25
25
|
@app = app
|
@@ -41,7 +41,7 @@ class Shoes
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def ensure_backend_loaded
|
44
|
-
|
44
|
+
unless defined?(Shoes.configuration.backend::App)
|
45
45
|
backend_const = Shoes.load_backend(Shoes.configuration.backend_name)
|
46
46
|
backend_const.initialize_backend
|
47
47
|
end
|
@@ -100,7 +100,7 @@ class Shoes
|
|
100
100
|
|
101
101
|
def_delegators :gui, *delegated_to_gui
|
102
102
|
|
103
|
-
|
103
|
+
alias start_as_fullscreen? start_as_fullscreen
|
104
104
|
|
105
105
|
# Necessary for click/mouse positioning checks
|
106
106
|
def hidden?
|
data/lib/shoes/line.rb
CHANGED
@@ -3,15 +3,16 @@ require 'matrix'
|
|
3
3
|
class Shoes
|
4
4
|
class Line
|
5
5
|
include Common::UIElement
|
6
|
-
include Common::Stroke
|
7
|
-
include Common::Style
|
8
6
|
include Common::Clickable
|
9
7
|
include Common::Hover
|
8
|
+
include Common::Stroke
|
9
|
+
include Common::Style
|
10
|
+
include Common::Translate
|
10
11
|
|
11
12
|
attr_reader :point_a, :point_b
|
12
13
|
|
13
14
|
style_with :angle, :art_styles, :dimensions, :x2, :y2
|
14
|
-
STYLES = { angle: 0, fill: Shoes::COLORS[:black] }
|
15
|
+
STYLES = { angle: 0, fill: Shoes::COLORS[:black] }.freeze
|
15
16
|
|
16
17
|
def create_dimensions(point_a, point_b)
|
17
18
|
@point_a = point_a
|
@@ -37,7 +38,7 @@ class Shoes
|
|
37
38
|
|
38
39
|
if left_c_dot_left_right.between?(0, left_right_dot_left_right)
|
39
40
|
left_c_dot_left_c = left_c.inner_product(left_c)
|
40
|
-
left_right_dot_left_right * left_c_dot_left_c <= boldness
|
41
|
+
left_right_dot_left_right * left_c_dot_left_c <= boldness**2 * left_right_dot_left_right + left_c_dot_left_right**2
|
41
42
|
else
|
42
43
|
false
|
43
44
|
end
|
@@ -64,8 +65,8 @@ class Shoes
|
|
64
65
|
set_point_b(:y, val)
|
65
66
|
end
|
66
67
|
|
67
|
-
|
68
|
-
|
68
|
+
alias x2= right=
|
69
|
+
alias y2= bottom=
|
69
70
|
|
70
71
|
def move(x, y, x2 = nil, y2 = nil)
|
71
72
|
@point_a.x = x
|
data/lib/shoes/link.rb
CHANGED
@@ -7,7 +7,7 @@ class Shoes
|
|
7
7
|
|
8
8
|
attr_reader :app, :gui, :blk
|
9
9
|
style_with :common_styles, :text_block_styles
|
10
|
-
STYLES = { underline: true, stroke: ::Shoes::COLORS[:blue], fill: nil }
|
10
|
+
STYLES = { underline: true, stroke: ::Shoes::COLORS[:blue], fill: nil }.freeze
|
11
11
|
|
12
12
|
def initialize(my_app, texts, styles = {}, blk = nil)
|
13
13
|
@app = my_app
|
@@ -18,11 +18,6 @@ class Shoes
|
|
18
18
|
super texts, @style
|
19
19
|
end
|
20
20
|
|
21
|
-
# Force hovering evaluation up in parent where we have actual dimensions
|
22
|
-
def eval_in_parent?
|
23
|
-
true
|
24
|
-
end
|
25
|
-
|
26
21
|
# Doesn't use Common::Clickable because of URL flavor option clicks
|
27
22
|
def setup_click(blk)
|
28
23
|
if blk.nil?
|
@@ -62,6 +57,10 @@ class Shoes
|
|
62
57
|
text_block_guard && @text_block.visible?
|
63
58
|
end
|
64
59
|
|
60
|
+
def links
|
61
|
+
[self]
|
62
|
+
end
|
63
|
+
|
65
64
|
private
|
66
65
|
|
67
66
|
def text_block_guard
|
data/lib/shoes/list_box.rb
CHANGED
@@ -31,7 +31,7 @@ class Shoes
|
|
31
31
|
include Common::State
|
32
32
|
|
33
33
|
style_with :change, :choose, :common_styles, :dimensions, :items, :state, :text
|
34
|
-
STYLES = { width: 200, height: 20, items: [""] }
|
34
|
+
STYLES = { width: 200, height: 20, items: [""] }.freeze
|
35
35
|
|
36
36
|
def handle_block(blk)
|
37
37
|
change(&blk) if blk
|
@@ -64,6 +64,6 @@ class Shoes
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
alias choose= choose
|
68
68
|
end
|
69
69
|
end
|
data/lib/shoes/logger.rb
CHANGED
data/lib/shoes/mock.rb
CHANGED
data/lib/shoes/mock/rect.rb
CHANGED
data/lib/shoes/mock/slot.rb
CHANGED