shoes-core 4.0.0.pre8 → 4.0.0.pre9
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 -0
- data/lib/shoes.rb +1 -0
- data/lib/shoes/animation.rb +1 -0
- data/lib/shoes/app.rb +7 -1
- data/lib/shoes/arc.rb +2 -3
- data/lib/shoes/arrow.rb +2 -3
- data/lib/shoes/background.rb +2 -2
- data/lib/shoes/border.rb +2 -2
- data/lib/shoes/builtin_methods.rb +2 -2
- data/lib/shoes/button.rb +2 -2
- data/lib/shoes/check_button.rb +2 -2
- data/lib/shoes/color.rb +1 -0
- data/lib/shoes/color/dsl.rb +1 -0
- data/lib/shoes/color/dsl_helpers.rb +1 -0
- data/lib/shoes/color/hex_converter.rb +1 -0
- data/lib/shoes/common/art_element.rb +6 -9
- data/lib/shoes/common/attachable.rb +1 -0
- data/lib/shoes/common/background_element.rb +2 -11
- data/lib/shoes/common/changeable.rb +1 -0
- data/lib/shoes/common/clickable.rb +1 -0
- data/lib/shoes/common/fill.rb +1 -0
- data/lib/shoes/common/hover.rb +2 -1
- data/lib/shoes/common/inspect.rb +1 -0
- data/lib/shoes/common/link_finder.rb +1 -0
- data/lib/shoes/common/positioning.rb +1 -0
- data/lib/shoes/common/registration.rb +1 -0
- data/lib/shoes/common/remove.rb +1 -0
- data/lib/shoes/common/rotate.rb +1 -0
- data/lib/shoes/common/safely_evaluate.rb +13 -0
- data/lib/shoes/common/state.rb +4 -10
- data/lib/shoes/common/stroke.rb +1 -0
- data/lib/shoes/common/style.rb +13 -3
- data/lib/shoes/common/style_normalizer.rb +1 -0
- data/lib/shoes/common/translate.rb +1 -0
- data/lib/shoes/common/ui_element.rb +67 -5
- data/lib/shoes/common/visibility.rb +7 -6
- data/lib/shoes/configuration.rb +5 -16
- data/lib/shoes/console.rb +91 -0
- data/lib/shoes/core.rb +1 -1
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/dialog.rb +1 -0
- data/lib/shoes/dimension.rb +1 -0
- data/lib/shoes/dimensions.rb +1 -0
- data/lib/shoes/download.rb +1 -0
- data/lib/shoes/dsl.rb +28 -588
- data/lib/shoes/dsl/animate.rb +51 -0
- data/lib/shoes/dsl/art.rb +256 -0
- data/lib/shoes/dsl/element.rb +56 -0
- data/lib/shoes/dsl/interaction.rb +76 -0
- data/lib/shoes/dsl/media.rb +38 -0
- data/lib/shoes/dsl/setup.rb +42 -0
- data/lib/shoes/dsl/style.rb +81 -0
- data/lib/shoes/dsl/text.rb +50 -0
- data/lib/shoes/file_not_found_error.rb +1 -0
- data/lib/shoes/font.rb +2 -1
- data/lib/shoes/gradient.rb +1 -0
- data/lib/shoes/image.rb +2 -2
- data/lib/shoes/image_pattern.rb +1 -0
- data/lib/shoes/input_box.rb +11 -2
- data/lib/shoes/internal_app.rb +16 -3
- data/lib/shoes/key_event.rb +1 -0
- data/lib/shoes/line.rb +2 -3
- data/lib/shoes/link.rb +2 -0
- data/lib/shoes/list_box.rb +3 -3
- data/lib/shoes/logger_collection.rb +38 -0
- data/lib/shoes/mock.rb +1 -0
- data/lib/shoes/mock/animation.rb +1 -0
- data/lib/shoes/mock/app.rb +1 -0
- data/lib/shoes/mock/arc.rb +1 -0
- data/lib/shoes/mock/arrow.rb +1 -0
- data/lib/shoes/mock/background.rb +1 -0
- data/lib/shoes/mock/border.rb +1 -0
- data/lib/shoes/mock/button.rb +1 -0
- data/lib/shoes/mock/check.rb +1 -0
- data/lib/shoes/mock/clickable.rb +1 -0
- data/lib/shoes/mock/common_methods.rb +1 -0
- data/lib/shoes/mock/dialog.rb +1 -0
- data/lib/shoes/mock/download.rb +1 -0
- data/lib/shoes/mock/font.rb +1 -0
- data/lib/shoes/mock/image.rb +1 -0
- data/lib/shoes/mock/image_pattern.rb +1 -0
- data/lib/shoes/mock/input_box.rb +4 -0
- data/lib/shoes/mock/keypress.rb +1 -0
- data/lib/shoes/mock/keyrelease.rb +1 -0
- data/lib/shoes/mock/line.rb +1 -0
- data/lib/shoes/mock/link.rb +1 -0
- data/lib/shoes/mock/list_box.rb +1 -0
- data/lib/shoes/mock/oval.rb +1 -0
- data/lib/shoes/mock/packager.rb +3 -0
- data/lib/shoes/mock/progress.rb +1 -0
- data/lib/shoes/mock/radio.rb +1 -0
- data/lib/shoes/mock/rect.rb +1 -0
- data/lib/shoes/mock/shape.rb +1 -0
- data/lib/shoes/mock/slot.rb +1 -0
- data/lib/shoes/mock/sound.rb +1 -0
- data/lib/shoes/mock/star.rb +1 -0
- data/lib/shoes/mock/text_block.rb +1 -0
- data/lib/shoes/mock/timer.rb +1 -0
- data/lib/shoes/not_implemented_error.rb +1 -0
- data/lib/shoes/oval.rb +2 -3
- data/lib/shoes/packager.rb +13 -0
- data/lib/shoes/point.rb +1 -0
- data/lib/shoes/progress.rb +2 -3
- data/lib/shoes/radio.rb +1 -0
- data/lib/shoes/rect.rb +2 -3
- data/lib/shoes/renamed_delegate.rb +1 -0
- data/lib/shoes/shape.rb +2 -4
- data/lib/shoes/slot.rb +3 -3
- data/lib/shoes/slot_contents.rb +1 -0
- data/lib/shoes/sound.rb +1 -0
- data/lib/shoes/span.rb +1 -0
- data/lib/shoes/standard_logger.rb +14 -0
- data/lib/shoes/star.rb +2 -3
- data/lib/shoes/text.rb +1 -0
- data/lib/shoes/text_block.rb +4 -4
- data/lib/shoes/text_block_dimensions.rb +1 -0
- data/lib/shoes/timer.rb +1 -0
- data/lib/shoes/ui/cli.rb +5 -0
- data/lib/shoes/ui/picker.rb +2 -1
- data/lib/shoes/url.rb +1 -0
- data/lib/shoes/version.rb +1 -1
- data/lib/shoes/widget.rb +1 -0
- data/lib/shoes/window.rb +1 -0
- metadata +14 -5
- data/lib/shoes/common/initialization.rb +0 -71
- data/lib/shoes/logger.rb +0 -65
- data/lib/shoes/logger/ruby.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ba64133e02f0c5a97f98f1f9eff7a68b32fba38
|
4
|
+
data.tar.gz: c3ee4b52936eb0125cf87f8c21b318ada8ca949f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399a8a7dc9fe4057095a926b7fb9a41c442a5bfb96295a6b21122dab8f829968f34841a94e4b836be4927bd197582ef544e0c768383dc57152f46ff38f214e76
|
7
|
+
data.tar.gz: 161b478d23e6949f3c5ce41fd7178c7f75ed3ef6da3a52b1e9f57f6daddfa61d86a3dcdeb2aa9a927b5eae167ea098a7eb880a1d841d41f0019c196bb7eaa5d9
|
data/bin/shoes-picker
CHANGED
data/lib/shoes.rb
CHANGED
data/lib/shoes/animation.rb
CHANGED
data/lib/shoes/app.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
3
|
ICON = File.join(DIR, 'static/shoes-icon.png').freeze
|
3
4
|
|
@@ -61,6 +62,11 @@ class Shoes
|
|
61
62
|
self.class.new(options, &block)
|
62
63
|
end
|
63
64
|
|
65
|
+
# Remember startup block for execution later
|
66
|
+
def start(&blk)
|
67
|
+
@__app__.start_block = blk
|
68
|
+
end
|
69
|
+
|
64
70
|
def quit
|
65
71
|
Shoes.unregister self
|
66
72
|
@__app__.quit
|
@@ -75,7 +81,7 @@ class Shoes
|
|
75
81
|
delegated_to_internal_app = %w(
|
76
82
|
width height owner started? location left top absolute_left
|
77
83
|
absolute_top click release clear fullscreen fullscreen=
|
78
|
-
contents wait_until_closed gui
|
84
|
+
contents wait_until_closed focus open? gui
|
79
85
|
)
|
80
86
|
|
81
87
|
def_delegators :@__app__, *delegated_to_internal_app
|
data/lib/shoes/arc.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
|
-
class Arc
|
3
|
-
include Common::ArtElement
|
4
|
-
|
3
|
+
class Arc < Common::ArtElement
|
5
4
|
style_with :angle1, :angle2, :art_styles, :center, :common_styles, :dimensions, :radius, :wedge
|
6
5
|
STYLES = { wedge: false, fill: Shoes::COLORS[:black] }.freeze
|
7
6
|
|
data/lib/shoes/arrow.rb
CHANGED
data/lib/shoes/background.rb
CHANGED
data/lib/shoes/border.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# The methods defined in this module/file are also available outside of the
|
2
3
|
# Shoes.app block. So they are monkey patched onto the main object.
|
3
4
|
# However they can also be used from the normal Shoes.app block.
|
4
5
|
class Shoes
|
5
6
|
def self.p(message)
|
6
|
-
Shoes
|
7
|
+
Shoes.logger.debug(message.inspect)
|
7
8
|
end
|
8
9
|
|
9
10
|
module BuiltinMethods
|
@@ -19,7 +20,6 @@ class Shoes
|
|
19
20
|
|
20
21
|
%w(info debug warn error).each do |log_level|
|
21
22
|
define_method(log_level) do |message = ''|
|
22
|
-
Shoes::LOG << [log_level, message]
|
23
23
|
Shoes.logger.public_send(log_level, message)
|
24
24
|
end
|
25
25
|
end
|
data/lib/shoes/button.rb
CHANGED
data/lib/shoes/check_button.rb
CHANGED
data/lib/shoes/color.rb
CHANGED
data/lib/shoes/color/dsl.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
3
|
module Common
|
3
|
-
|
4
|
-
include Common::UIElement
|
4
|
+
class ArtElement < UIElement
|
5
5
|
include Common::Clickable
|
6
6
|
include Common::Fill
|
7
7
|
include Common::Rotate
|
8
8
|
include Common::Stroke
|
9
9
|
include Common::Translate
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def self.included(base)
|
16
|
-
base.include Common::Hover
|
17
|
-
base.include Common::Style
|
11
|
+
def self.inherited(child)
|
12
|
+
# Hover's inclusion generates a styling class per child class.
|
13
|
+
# We need to include it at inheritance time to get that behavior.
|
14
|
+
child.include Common::Hover
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -1,16 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
3
|
module Common
|
3
|
-
|
4
|
-
include Common::UIElement
|
5
|
-
|
6
|
-
# Modules that muck with class methods need to be included like this
|
7
|
-
#
|
8
|
-
# We also can't rely on Common::UIElement providing these, as it gets
|
9
|
-
# BackgroundElement, not the destination class to add things to!
|
10
|
-
def self.included(base)
|
11
|
-
base.include Common::Style
|
12
|
-
end
|
13
|
-
|
4
|
+
class BackgroundElement < Common::UIElement
|
14
5
|
def create_dimensions(*_)
|
15
6
|
@dimensions = ParentDimensions.new @parent, @style
|
16
7
|
end
|
data/lib/shoes/common/fill.rb
CHANGED
data/lib/shoes/common/hover.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
3
|
module Common
|
3
4
|
module Hover
|
@@ -53,7 +54,7 @@ class Shoes
|
|
53
54
|
end
|
54
55
|
|
55
56
|
def eval_hover_block(blk)
|
56
|
-
|
57
|
+
safely_evaluate(self, &blk) if blk
|
57
58
|
end
|
58
59
|
|
59
60
|
def apply_style_from_hover_class
|
data/lib/shoes/common/inspect.rb
CHANGED
data/lib/shoes/common/remove.rb
CHANGED
data/lib/shoes/common/rotate.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class Shoes
|
3
|
+
module Common
|
4
|
+
module SafelyEvaluate
|
5
|
+
def safely_evaluate(*args)
|
6
|
+
yield(*args) if block_given?
|
7
|
+
rescue => e
|
8
|
+
Shoes.logger.error(e.message)
|
9
|
+
raise e if Shoes.configuration.fail_fast
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/shoes/common/state.rb
CHANGED
@@ -1,29 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
3
|
module Common
|
3
4
|
module State
|
4
|
-
DISABLED_STATE = "disabled"
|
5
|
+
DISABLED_STATE = "disabled"
|
5
6
|
|
6
7
|
def after_initialize(*_)
|
7
8
|
super
|
8
|
-
|
9
|
+
update_from_state
|
9
10
|
end
|
10
11
|
|
11
12
|
def state=(value)
|
12
13
|
style(state: value)
|
13
|
-
update_enabled
|
14
14
|
end
|
15
15
|
|
16
|
-
def state_options(opts)
|
17
|
-
self.state = opts[:state]
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
16
|
def enabled?
|
23
17
|
!(state.to_s == DISABLED_STATE)
|
24
18
|
end
|
25
19
|
|
26
|
-
def
|
20
|
+
def update_from_state
|
27
21
|
@gui.enabled(enabled?)
|
28
22
|
end
|
29
23
|
end
|
data/lib/shoes/common/stroke.rb
CHANGED
data/lib/shoes/common/style.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# The general Style module handles the many optional styles that may be passed
|
2
3
|
# to shoes elements upon creates as well as the fact that they can later on be
|
3
4
|
# altered through the #style method.
|
@@ -122,13 +123,15 @@ class Shoes
|
|
122
123
|
|
123
124
|
def update_style(new_styles)
|
124
125
|
normalized_style = StyleNormalizer.new.normalize(new_styles)
|
126
|
+
@style.merge! normalized_style
|
127
|
+
|
125
128
|
set_dimensions(new_styles)
|
126
129
|
set_visibility(new_styles)
|
127
130
|
set_coloring(new_styles)
|
128
131
|
set_hovers(new_styles)
|
129
132
|
set_translate(new_styles)
|
130
|
-
|
131
|
-
|
133
|
+
set_click(new_styles)
|
134
|
+
set_state(new_styles)
|
132
135
|
end
|
133
136
|
|
134
137
|
# if dimension is set via style, pass info on to the dimensions setter
|
@@ -140,7 +143,6 @@ class Shoes
|
|
140
143
|
|
141
144
|
def set_visibility(new_styles)
|
142
145
|
return unless new_styles.include?(:hidden)
|
143
|
-
@style[:hidden] = new_styles[:hidden]
|
144
146
|
update_visibility
|
145
147
|
end
|
146
148
|
|
@@ -158,6 +160,14 @@ class Shoes
|
|
158
160
|
clear_translate if new_styles.include?(:translate)
|
159
161
|
end
|
160
162
|
|
163
|
+
def set_click(new_styles)
|
164
|
+
click(&new_styles[:click]) if new_styles.key?(:click)
|
165
|
+
end
|
166
|
+
|
167
|
+
def set_state(new_styles)
|
168
|
+
update_from_state if new_styles.include?(:state)
|
169
|
+
end
|
170
|
+
|
161
171
|
def update_dimensions # so that @style hash matches actual values
|
162
172
|
STYLE_GROUPS[:dimensions].each do |style|
|
163
173
|
if respond_to?(style)
|
@@ -1,17 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Shoes
|
2
3
|
module Common
|
3
|
-
|
4
|
+
class UIElement
|
4
5
|
include Common::Attachable
|
5
|
-
include Common::Initialization
|
6
6
|
include Common::Inspect
|
7
7
|
include Common::Visibility
|
8
8
|
include Common::Positioning
|
9
9
|
include Common::Remove
|
10
10
|
include DimensionsDelegations
|
11
|
+
include Common::SafelyEvaluate
|
12
|
+
include Common::Style
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
attr_reader :app, :parent, :dimensions, :gui
|
15
|
+
|
16
|
+
def initialize(app, parent, *args)
|
17
|
+
blk = args.pop if args.last.is_a?(Proc) || args.last.nil?
|
18
|
+
styles = args.last.is_a?(Hash) ? args.pop : {}
|
19
|
+
|
20
|
+
before_initialize(styles, *args)
|
21
|
+
|
22
|
+
@app = app
|
23
|
+
@parent = parent
|
24
|
+
|
25
|
+
style_init(styles)
|
26
|
+
create_dimensions(*args)
|
27
|
+
update_dimensions if styles_with_dimensions?
|
28
|
+
|
29
|
+
create_backend
|
30
|
+
add_to_parent(*args)
|
31
|
+
|
32
|
+
handle_block(blk)
|
33
|
+
update_visibility
|
34
|
+
|
35
|
+
after_initialize(*args)
|
36
|
+
end
|
37
|
+
|
38
|
+
# This method will get called with the incoming styles hash and the
|
39
|
+
# other arguments passed to initialize.
|
40
|
+
#
|
41
|
+
# It is intended for performing any additions to the styles hash before
|
42
|
+
# that gets sent on to style_init.
|
43
|
+
def before_initialize(_styles, *_)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Set the dimensions for the element. Defaults to using the Dimensions
|
47
|
+
# class, but is expected to be overridden in other types (art elements,
|
48
|
+
# text blocks) that require different dimensioning.
|
49
|
+
def create_dimensions(*_)
|
50
|
+
@dimensions = Dimensions.new @parent, @style
|
51
|
+
end
|
52
|
+
|
53
|
+
# Call to create the backend (aka @gui)
|
54
|
+
def create_backend
|
55
|
+
@gui = Shoes.backend_for self
|
56
|
+
end
|
57
|
+
|
58
|
+
# Calls to add child in parent, after the backend has been created.
|
59
|
+
# Can be overridden for operations that must happen after backend, but
|
60
|
+
# before addition to parent (and hence positioning)
|
61
|
+
def add_to_parent(*_)
|
62
|
+
@parent.add_child self
|
63
|
+
end
|
64
|
+
|
65
|
+
# This method handles the block passed in at creation of the DSL element.
|
66
|
+
# By default it will treat things as clickable, and assumes the
|
67
|
+
# necessary methods are there.
|
68
|
+
#
|
69
|
+
# Override if DSL element uses that block for something else (i.e. slot)
|
70
|
+
def handle_block(blk)
|
71
|
+
register_click blk if respond_to?(:register_click)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Final method called in initialize. Intended for any final setup after
|
75
|
+
# the rest of the object has been set up fully.
|
76
|
+
def after_initialize(*_)
|
15
77
|
end
|
16
78
|
|
17
79
|
# Nobody rotates by default, but we need to let you check
|