cyberarm_engine 0.7.1 → 0.8.0
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/lib/cyberarm_engine/ui/border_canvas.rb +8 -8
- data/lib/cyberarm_engine/ui/button.rb +5 -5
- data/lib/cyberarm_engine/ui/check_box.rb +2 -2
- data/lib/cyberarm_engine/ui/container.rb +17 -30
- data/lib/cyberarm_engine/ui/dsl.rb +13 -14
- data/lib/cyberarm_engine/ui/edit_line.rb +5 -11
- data/lib/cyberarm_engine/ui/element.rb +67 -78
- data/lib/cyberarm_engine/ui/image.rb +7 -9
- data/lib/cyberarm_engine/ui/label.rb +4 -10
- data/lib/cyberarm_engine/ui/style.rb +11 -6
- data/lib/cyberarm_engine/ui/theme.rb +1 -1
- data/lib/cyberarm_engine/ui/toggle_button.rb +1 -7
- data/lib/cyberarm_engine/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699e78a7d87b5875ccefeffd1376baa7653b07c29a401381496257f764fcfc25
|
4
|
+
data.tar.gz: 7d577da5ae1d17297b0be0e9be536496717fb7807849ce05451a27ee061ae807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6bcd42a625b081fe5ea5c0d7c5246c3612ed26a1e9c47f74d44a1cab35ebe6a1916afa5d5f0d490134ad9b7aba5ce14d591f4b5c1566af8955b80be9950f102
|
7
|
+
data.tar.gz: 785d8b59ab8404569cd89ad12b0eaeac189d03995c7c2045ee1a5b1be0f5aa50152aba747632c495b193953c12a4bbd7e5af59fcbe83991e7e848459a9689f32
|
@@ -66,31 +66,31 @@ module CyberarmEngine
|
|
66
66
|
@top.z = @element.z
|
67
67
|
|
68
68
|
@top.width = @element.width
|
69
|
-
@top.height = @element.border_thickness_top
|
69
|
+
@top.height = @element.style.border_thickness_top
|
70
70
|
|
71
71
|
# RIGHT
|
72
72
|
@right.x = @element.x + @element.width
|
73
|
-
@right.y = @element.y + @element.border_thickness_top
|
73
|
+
@right.y = @element.y + @element.style.border_thickness_top
|
74
74
|
@right.z = @element.z
|
75
75
|
|
76
|
-
@right.width = -@element.border_thickness_right
|
77
|
-
@right.height = @element.height - @element.border_thickness_top
|
76
|
+
@right.width = -@element.style.border_thickness_right
|
77
|
+
@right.height = @element.height - @element.style.border_thickness_top
|
78
78
|
|
79
79
|
# BOTTOM
|
80
80
|
@bottom.x = @element.x
|
81
81
|
@bottom.y = @element.y + @element.height
|
82
82
|
@bottom.z = @element.z
|
83
83
|
|
84
|
-
@bottom.width = @element.width - @element.border_thickness_right
|
85
|
-
@bottom.height = -@element.border_thickness_bottom
|
84
|
+
@bottom.width = @element.width - @element.style.border_thickness_right
|
85
|
+
@bottom.height = -@element.style.border_thickness_bottom
|
86
86
|
|
87
87
|
# LEFT
|
88
88
|
@left.x = @element.x
|
89
89
|
@left.y = @element.y
|
90
90
|
@left.z = @element.z
|
91
91
|
|
92
|
-
@left.width = @element.border_thickness_left
|
93
|
-
@left.height = @element.height - @element.border_thickness_bottom
|
92
|
+
@left.width = @element.style.border_thickness_left
|
93
|
+
@left.height = @element.height - @element.style.border_thickness_bottom
|
94
94
|
|
95
95
|
@top.update
|
96
96
|
@right.update
|
@@ -3,7 +3,7 @@ module CyberarmEngine
|
|
3
3
|
def initialize(text, options = {}, block = nil)
|
4
4
|
super(text, options, block)
|
5
5
|
|
6
|
-
@background_canvas.background = default(:background)
|
6
|
+
@style.background_canvas.background = default(:background)
|
7
7
|
end
|
8
8
|
|
9
9
|
def render
|
@@ -18,17 +18,17 @@ module CyberarmEngine
|
|
18
18
|
@focus = false unless window.button_down?(Gosu::MsLeft)
|
19
19
|
|
20
20
|
if @focus
|
21
|
-
@background_canvas.background = default(:active, :background)
|
21
|
+
@style.background_canvas.background = default(:active, :background)
|
22
22
|
@text.color = default(:active, :color)
|
23
23
|
else
|
24
|
-
@background_canvas.background = default(:hover, :background)
|
24
|
+
@style.background_canvas.background = default(:hover, :background)
|
25
25
|
@text.color = default(:hover, :color)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
def left_mouse_button(sender, x, y)
|
30
30
|
@focus = true
|
31
|
-
@background_canvas.background = default(:active, :background)
|
31
|
+
@style.background_canvas.background = default(:active, :background)
|
32
32
|
window.current_state.focus = self
|
33
33
|
@text.color = default(:active, :color)
|
34
34
|
end
|
@@ -42,7 +42,7 @@ module CyberarmEngine
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def leave(sender)
|
45
|
-
@background_canvas.background = default(:background)
|
45
|
+
@style.background_canvas.background = default(:background)
|
46
46
|
@text.color = default(:color)
|
47
47
|
end
|
48
48
|
|
@@ -12,8 +12,8 @@ module CyberarmEngine
|
|
12
12
|
add(@toggle_button)
|
13
13
|
add(@label)
|
14
14
|
|
15
|
-
@width = @toggle_button.width + @label.width
|
16
|
-
@height = @toggle_button.height + @label.height
|
15
|
+
@style.width = @toggle_button.width + @label.width
|
16
|
+
@style.height = @toggle_button.height + @label.height
|
17
17
|
end
|
18
18
|
|
19
19
|
def text=(text)
|
@@ -15,12 +15,9 @@ module CyberarmEngine
|
|
15
15
|
@text_color = options[:color]
|
16
16
|
|
17
17
|
@children = []
|
18
|
-
|
19
|
-
@theme = {}
|
20
18
|
end
|
21
19
|
|
22
20
|
def build
|
23
|
-
@theme.merge(@parent.theme) if @parent
|
24
21
|
@block.call(self) if @block
|
25
22
|
|
26
23
|
recalculate
|
@@ -40,14 +37,6 @@ module CyberarmEngine
|
|
40
37
|
@children.each(&:update)
|
41
38
|
end
|
42
39
|
|
43
|
-
def theme
|
44
|
-
@theme
|
45
|
-
end
|
46
|
-
|
47
|
-
def color(color)
|
48
|
-
@theme[:color] = color
|
49
|
-
end
|
50
|
-
|
51
40
|
def hit_element?(x, y)
|
52
41
|
@children.reverse_each do |child|
|
53
42
|
case child
|
@@ -64,25 +53,23 @@ module CyberarmEngine
|
|
64
53
|
end
|
65
54
|
|
66
55
|
def recalculate
|
67
|
-
@current_position = Vector.new(@margin_left + @padding_left, @margin_top + @padding_top)
|
68
|
-
unless
|
69
|
-
|
70
|
-
@height= 0
|
71
|
-
return
|
72
|
-
end
|
56
|
+
@current_position = Vector.new(@style.margin_left + @style.padding_left, @style.margin_top + @style.padding_top)
|
57
|
+
return unless visible?
|
58
|
+
stylize
|
73
59
|
|
74
60
|
layout
|
75
61
|
|
76
|
-
@width = @max_width ? @max_width : (@children.map {|c| c.x + c.outer_width }.max || 0).round
|
77
|
-
@height = @max_height ? @max_height : (@children.map {|c| c.y + c.outer_height}.max || 0).round
|
62
|
+
@style.width = @max_width ? @max_width : (@children.map {|c| c.x + c.outer_width }.max || 0).round
|
63
|
+
@style.height = @max_height ? @max_height : (@children.map {|c| c.y + c.outer_height}.max || 0).round
|
78
64
|
|
79
65
|
# Move child to parent after positioning
|
80
66
|
@children.each do |child|
|
81
67
|
child.x += @x
|
82
68
|
child.y += @y
|
83
|
-
|
84
|
-
|
69
|
+
|
70
|
+
child.stylize
|
85
71
|
child.recalculate
|
72
|
+
child.reposition # TODO: Implement top,bottom,left,center, and right positioning
|
86
73
|
end
|
87
74
|
|
88
75
|
update_background
|
@@ -93,7 +80,7 @@ module CyberarmEngine
|
|
93
80
|
end
|
94
81
|
|
95
82
|
def max_width
|
96
|
-
@max_width ? @max_width : window.width - (@parent ? @parent.margin_right + @margin_right : @margin_right)
|
83
|
+
@max_width ? @max_width : window.width - (@parent ? @parent.style.margin_right + @style.margin_right : @style.margin_right)
|
97
84
|
end
|
98
85
|
|
99
86
|
def fits_on_line?(element) # Flow
|
@@ -102,13 +89,13 @@ module CyberarmEngine
|
|
102
89
|
end
|
103
90
|
|
104
91
|
def position_on_current_line(element) # Flow
|
105
|
-
element.x = element.margin_left + @current_position.x
|
106
|
-
element.y = element.margin_top + @current_position.y
|
92
|
+
element.x = element.style.margin_left + @current_position.x
|
93
|
+
element.y = element.style.margin_top + @current_position.y
|
107
94
|
|
108
95
|
element.recalculate
|
109
96
|
|
110
97
|
@current_position.x += element.outer_width
|
111
|
-
@current_position.x = @margin_left if @current_position.x >= max_width
|
98
|
+
@current_position.x = @style.margin_left if @current_position.x >= max_width
|
112
99
|
end
|
113
100
|
|
114
101
|
def tallest_neighbor(querier, y_position) # Flow
|
@@ -122,11 +109,11 @@ module CyberarmEngine
|
|
122
109
|
end
|
123
110
|
|
124
111
|
def position_on_next_line(child) # Flow
|
125
|
-
@current_position.x = @margin_left
|
112
|
+
@current_position.x = @style.margin_left
|
126
113
|
@current_position.y += tallest_neighbor(child, @current_position.y).outer_height
|
127
114
|
|
128
|
-
child.x = child.margin_left + @current_position.x
|
129
|
-
child.y = child.margin_top + @current_position.y
|
115
|
+
child.x = child.style.margin_left + @current_position.x
|
116
|
+
child.y = child.style.margin_top + @current_position.y
|
130
117
|
|
131
118
|
child.recalculate
|
132
119
|
|
@@ -134,8 +121,8 @@ module CyberarmEngine
|
|
134
121
|
end
|
135
122
|
|
136
123
|
def move_to_next_line(element) # Stack
|
137
|
-
element.x = element.margin_left + @current_position.x
|
138
|
-
element.y = element.margin_top + @current_position.y
|
124
|
+
element.x = element.style.margin_left + @current_position.x
|
125
|
+
element.y = element.style.margin_top + @current_position.y
|
139
126
|
|
140
127
|
element.recalculate
|
141
128
|
|
@@ -2,7 +2,7 @@ module CyberarmEngine
|
|
2
2
|
module DSL
|
3
3
|
def flow(options = {}, &block)
|
4
4
|
options[:parent] = @containers.last
|
5
|
-
options[:theme] =
|
5
|
+
options[:theme] = current_theme
|
6
6
|
_container = Flow.new(options, block)
|
7
7
|
@containers << _container
|
8
8
|
_container.build
|
@@ -14,7 +14,7 @@ module CyberarmEngine
|
|
14
14
|
|
15
15
|
def stack(options = {}, &block)
|
16
16
|
options[:parent] = @containers.last
|
17
|
-
options[:theme] =
|
17
|
+
options[:theme] = current_theme
|
18
18
|
_container = Stack.new(options, block)
|
19
19
|
@containers << _container
|
20
20
|
_container.build
|
@@ -26,7 +26,7 @@ module CyberarmEngine
|
|
26
26
|
|
27
27
|
def label(text, options = {}, &block)
|
28
28
|
options[:parent] = @containers.last
|
29
|
-
options[:theme] =
|
29
|
+
options[:theme] = current_theme
|
30
30
|
_element = Label.new(text, options, block)
|
31
31
|
@containers.last.add(_element)
|
32
32
|
|
@@ -35,7 +35,7 @@ module CyberarmEngine
|
|
35
35
|
|
36
36
|
def button(text, options = {}, &block)
|
37
37
|
options[:parent] = @containers.last
|
38
|
-
options[:theme] =
|
38
|
+
options[:theme] = current_theme
|
39
39
|
_element = Button.new(text, options, block) { if block.is_a?(Proc); block.call; end }
|
40
40
|
@containers.last.add(_element)
|
41
41
|
|
@@ -44,7 +44,7 @@ module CyberarmEngine
|
|
44
44
|
|
45
45
|
def edit_line(text, options = {}, &block)
|
46
46
|
options[:parent] = @containers.last
|
47
|
-
options[:theme] =
|
47
|
+
options[:theme] = current_theme
|
48
48
|
_element = EditLine.new(text, options, block)
|
49
49
|
@containers.last.add(_element)
|
50
50
|
|
@@ -53,7 +53,7 @@ module CyberarmEngine
|
|
53
53
|
|
54
54
|
def toggle_button(options = {}, &block)
|
55
55
|
options[:parent] = @containers.last
|
56
|
-
options[:theme] =
|
56
|
+
options[:theme] = current_theme
|
57
57
|
_element = ToggleButton.new(options, block)
|
58
58
|
@containers.last.add(_element)
|
59
59
|
|
@@ -62,7 +62,7 @@ module CyberarmEngine
|
|
62
62
|
|
63
63
|
def check_box(text, options = {}, &block)
|
64
64
|
options[:parent] = @containers.last
|
65
|
-
options[:theme] =
|
65
|
+
options[:theme] = current_theme
|
66
66
|
_element = CheckBox.new(text, options, block)
|
67
67
|
@containers.last.add(_element)
|
68
68
|
|
@@ -71,7 +71,7 @@ module CyberarmEngine
|
|
71
71
|
|
72
72
|
def image(path, options = {}, &block)
|
73
73
|
options[:parent] = @containers.last
|
74
|
-
options[:theme] =
|
74
|
+
options[:theme] = current_theme
|
75
75
|
_element = Image.new(path, options, block)
|
76
76
|
@containers.last.add(_element)
|
77
77
|
|
@@ -79,16 +79,15 @@ module CyberarmEngine
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def background(color = Gosu::Color::NONE)
|
82
|
-
@containers.last.background = color
|
82
|
+
@containers.last.style.background = color
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
@containers.last.color(color)
|
85
|
+
def theme(theme)
|
86
|
+
@containers.last.options[:theme] = theme
|
88
87
|
end
|
89
88
|
|
90
|
-
def
|
91
|
-
@
|
89
|
+
def current_theme
|
90
|
+
@containers.last.options[:theme]
|
92
91
|
end
|
93
92
|
end
|
94
93
|
end
|
@@ -20,7 +20,7 @@ module CyberarmEngine
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def render
|
23
|
-
Gosu.clip_to(@text.x, @text.y, @width, @text.height) do
|
23
|
+
Gosu.clip_to(@text.x, @text.y, @style.width, @text.height) do
|
24
24
|
draw_text
|
25
25
|
Gosu.draw_rect(caret_position, @text.y, @caret_width, @caret_height, @caret_color, @z + 40) if @focus && @show_caret
|
26
26
|
end
|
@@ -47,10 +47,10 @@ module CyberarmEngine
|
|
47
47
|
|
48
48
|
def enter(sender)
|
49
49
|
if @focus
|
50
|
-
@background_canvas.background = default(:active, :background)
|
50
|
+
@style.background_canvas.background = default(:active, :background)
|
51
51
|
@text.color = default(:active, :color)
|
52
52
|
else
|
53
|
-
@background_canvas.background = default(:hover, :background)
|
53
|
+
@style.background_canvas.background = default(:hover, :background)
|
54
54
|
@text.color = default(:hover, :color)
|
55
55
|
end
|
56
56
|
end
|
@@ -63,7 +63,7 @@ module CyberarmEngine
|
|
63
63
|
|
64
64
|
def blur(sender)
|
65
65
|
@focus = false
|
66
|
-
@background_canvas.background = default(:background)
|
66
|
+
@style.background_canvas.background = default(:background)
|
67
67
|
@text.color = default(:color)
|
68
68
|
window.text_input = nil
|
69
69
|
end
|
@@ -80,13 +80,7 @@ module CyberarmEngine
|
|
80
80
|
def recalculate
|
81
81
|
super
|
82
82
|
|
83
|
-
|
84
|
-
@width = 0
|
85
|
-
@height= 0
|
86
|
-
return
|
87
|
-
end
|
88
|
-
|
89
|
-
@width = default(:width)
|
83
|
+
@style.width = default(:width)
|
90
84
|
update_background
|
91
85
|
end
|
92
86
|
|
@@ -5,13 +5,7 @@ module CyberarmEngine
|
|
5
5
|
include Common
|
6
6
|
|
7
7
|
attr_accessor :x, :y, :z, :enabled
|
8
|
-
attr_reader :
|
9
|
-
|
10
|
-
attr_reader :border_thickness, :border_thickness_left, :border_thickness_right, :border_thickness_top, :border_thickness_bottom
|
11
|
-
attr_reader :border_color, :border_color_left, :border_color_right, :border_color_top, :border_color_bottom
|
12
|
-
|
13
|
-
attr_reader :padding, :padding_left, :padding_right, :padding_top, :padding_bottom
|
14
|
-
attr_reader :margin, :margin_left, :margin_right, :margin_top, :margin_bottom
|
8
|
+
attr_reader :parent, :options, :style, :event_handler, :background_canvas, :border_canvas
|
15
9
|
|
16
10
|
def initialize(options = {}, block = nil)
|
17
11
|
@parent = options[:parent] # parent Container (i.e. flow/stack)
|
@@ -19,86 +13,82 @@ module CyberarmEngine
|
|
19
13
|
@options = options
|
20
14
|
@block = block
|
21
15
|
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
25
|
-
|
16
|
+
@focus = false
|
17
|
+
@enabled = true
|
18
|
+
@visible = true
|
19
|
+
|
20
|
+
@style = Style.new(options)
|
26
21
|
|
27
|
-
@x =
|
28
|
-
@y =
|
29
|
-
@z =
|
22
|
+
@x = @style.x
|
23
|
+
@y = @style.y
|
24
|
+
@z = @style.z
|
30
25
|
|
31
26
|
@fixed_x = @x if @x != 0
|
32
27
|
@fixed_y = @y if @y != 0
|
33
28
|
|
34
|
-
|
35
|
-
@height = default(:height) || $window.height
|
29
|
+
stylize
|
36
30
|
|
37
|
-
|
38
|
-
|
39
|
-
set_padding(default(:padding))
|
31
|
+
default_events
|
32
|
+
end
|
40
33
|
|
41
|
-
|
34
|
+
def stylize
|
35
|
+
@style.width = @style.width || $window.width
|
36
|
+
@style.height = @style.height || $window.height
|
42
37
|
|
43
|
-
|
44
|
-
set_border_color(default(:border_color))
|
38
|
+
set_border_thickness(@style.border_thickness)
|
45
39
|
|
46
|
-
|
47
|
-
raise "#{self.class} 'y' must be a number" unless @y.is_a?(Numeric)
|
48
|
-
raise "#{self.class} 'z' must be a number" unless @z.is_a?(Numeric)
|
49
|
-
raise "#{self.class} 'width' must be a number" unless @width.is_a?(Numeric) || @width.nil?
|
50
|
-
raise "#{self.class} 'height' must be a number" unless @height.is_a?(Numeric) || @height.nil?
|
51
|
-
raise "#{self.class} 'options' must be a Hash" unless @options.is_a?(Hash)
|
40
|
+
set_padding(@style.padding)
|
52
41
|
|
53
|
-
|
42
|
+
set_margin(@style.margin)
|
54
43
|
|
55
|
-
@
|
56
|
-
@
|
44
|
+
@style.background_canvas = Background.new
|
45
|
+
@style.border_canvas = BorderCanvas.new(element: self)
|
57
46
|
|
58
|
-
|
47
|
+
set_background(@style.background)
|
48
|
+
set_border_color(@style.border_color)
|
59
49
|
end
|
60
50
|
|
61
51
|
def set_background(background)
|
62
|
-
@background = background
|
63
|
-
@background_canvas.background = background
|
52
|
+
@style.background = background
|
53
|
+
@style.background_canvas.background = background
|
64
54
|
end
|
65
55
|
|
66
56
|
def set_border_thickness(border_thickness)
|
67
|
-
@border_thickness = border_thickness
|
57
|
+
@style.border_thickness = border_thickness
|
68
58
|
|
69
|
-
@border_thickness_left = default(:border_thickness_left) || @border_thickness
|
70
|
-
@border_thickness_right = default(:border_thickness_right) || @border_thickness
|
71
|
-
@border_thickness_top = default(:border_thickness_top) || @border_thickness
|
72
|
-
@border_thickness_bottom = default(:border_thickness_bottom) || @border_thickness
|
59
|
+
@style.border_thickness_left = default(:border_thickness_left) || @style.border_thickness
|
60
|
+
@style.border_thickness_right = default(:border_thickness_right) || @style.border_thickness
|
61
|
+
@style.border_thickness_top = default(:border_thickness_top) || @style.border_thickness
|
62
|
+
@style.border_thickness_bottom = default(:border_thickness_bottom) || @style.border_thickness
|
73
63
|
end
|
74
64
|
|
75
65
|
def set_border_color(color)
|
76
|
-
@border_color = color
|
66
|
+
@style.border_color = color
|
77
67
|
|
78
|
-
@border_color_left = default(:border_color_left) || @border_color
|
79
|
-
@border_color_right = default(:border_color_right) || @border_color
|
80
|
-
@border_color_top = default(:border_color_top) || @border_color
|
81
|
-
@border_color_bottom = default(:border_color_bottom) || @border_color
|
68
|
+
@style.border_color_left = default(:border_color_left) || @style.border_color
|
69
|
+
@style.border_color_right = default(:border_color_right) || @style.border_color
|
70
|
+
@style.border_color_top = default(:border_color_top) || @style.border_color
|
71
|
+
@style.border_color_bottom = default(:border_color_bottom) || @style.border_color
|
82
72
|
|
83
|
-
@border_canvas.color = color
|
73
|
+
@style.border_canvas.color = color
|
84
74
|
end
|
85
75
|
|
86
76
|
def set_padding(padding)
|
87
|
-
@padding = padding
|
77
|
+
@style.padding = padding
|
88
78
|
|
89
|
-
@padding_left = default(:padding_left) || @padding
|
90
|
-
@padding_right = default(:padding_right) || @padding
|
91
|
-
@padding_top = default(:padding_top) || @padding
|
92
|
-
@padding_bottom = default(:padding_bottom) || @padding
|
79
|
+
@style.padding_left = default(:padding_left) || @style.padding
|
80
|
+
@style.padding_right = default(:padding_right) || @style.padding
|
81
|
+
@style.padding_top = default(:padding_top) || @style.padding
|
82
|
+
@style.padding_bottom = default(:padding_bottom) || @style.padding
|
93
83
|
end
|
94
84
|
|
95
85
|
def set_margin(margin)
|
96
|
-
@margin = margin
|
86
|
+
@style.margin = margin
|
97
87
|
|
98
|
-
@margin_left = default(:margin_left) || @margin
|
99
|
-
@margin_right = default(:margin_right) || @margin
|
100
|
-
@margin_top = default(:margin_top) || @margin
|
101
|
-
@margin_bottom = default(:margin_bottom) || @margin
|
88
|
+
@style.margin_left = default(:margin_left) || @style.margin
|
89
|
+
@style.margin_right = default(:margin_right) || @style.margin
|
90
|
+
@style.margin_top = default(:margin_top) || @style.margin
|
91
|
+
@style.margin_bottom = default(:margin_bottom) || @style.margin
|
102
92
|
end
|
103
93
|
|
104
94
|
def default_events
|
@@ -145,8 +135,8 @@ module CyberarmEngine
|
|
145
135
|
def draw
|
146
136
|
return unless @visible
|
147
137
|
|
148
|
-
@background_canvas.draw
|
149
|
-
@border_canvas.draw
|
138
|
+
@style.background_canvas.draw
|
139
|
+
@style.border_canvas.draw
|
150
140
|
render
|
151
141
|
end
|
152
142
|
|
@@ -168,44 +158,44 @@ module CyberarmEngine
|
|
168
158
|
end
|
169
159
|
|
170
160
|
def width
|
171
|
-
|
161
|
+
if visible?
|
162
|
+
(@style.border_thickness_left + @style.padding_left) + @style.width + (@style.padding_right + @style.border_thickness_right)
|
163
|
+
else
|
164
|
+
0
|
165
|
+
end
|
172
166
|
end
|
173
167
|
|
174
168
|
def outer_width
|
175
|
-
@margin_left + width + @margin_right
|
169
|
+
@style.margin_left + width + @style.margin_right
|
176
170
|
end
|
177
171
|
|
178
172
|
def height
|
179
|
-
|
173
|
+
if visible?
|
174
|
+
(@style.border_thickness_top + @style.padding_top) + @style.height + (@style.padding_bottom + @style.border_thickness_bottom)
|
175
|
+
else
|
176
|
+
0
|
177
|
+
end
|
180
178
|
end
|
181
179
|
|
182
180
|
def outer_height
|
183
|
-
@margin_top + height + @margin_bottom
|
184
|
-
end
|
185
|
-
|
186
|
-
def style(hash)
|
187
|
-
if hash
|
188
|
-
@style.set(hash)
|
189
|
-
else
|
190
|
-
@style.hash
|
191
|
-
end
|
181
|
+
@style.margin_top + height + @style.margin_bottom
|
192
182
|
end
|
193
183
|
|
194
184
|
def background=(_background)
|
195
|
-
@background_canvas.background=(_background)
|
185
|
+
@style.background_canvas.background=(_background)
|
196
186
|
update_background
|
197
187
|
end
|
198
188
|
|
199
189
|
def update_background
|
200
|
-
@background_canvas.x = @x
|
201
|
-
@background_canvas.y = @y
|
202
|
-
@background_canvas.z = @z
|
203
|
-
@background_canvas.width = width
|
204
|
-
@background_canvas.height = height
|
190
|
+
@style.background_canvas.x = @x
|
191
|
+
@style.background_canvas.y = @y
|
192
|
+
@style.background_canvas.z = @z
|
193
|
+
@style.background_canvas.width = width
|
194
|
+
@style.background_canvas.height = height
|
205
195
|
|
206
|
-
@background_canvas.update
|
196
|
+
@style.background_canvas.update
|
207
197
|
|
208
|
-
@border_canvas.update
|
198
|
+
@style.border_canvas.update
|
209
199
|
end
|
210
200
|
|
211
201
|
def root
|
@@ -229,7 +219,6 @@ module CyberarmEngine
|
|
229
219
|
end
|
230
220
|
|
231
221
|
def reposition
|
232
|
-
raise "#{self.class}#reposition was not overridden!"
|
233
222
|
end
|
234
223
|
|
235
224
|
def value
|
@@ -23,7 +23,11 @@ module CyberarmEngine
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def render
|
26
|
-
@image.draw(
|
26
|
+
@image.draw(
|
27
|
+
@style.border_thickness_left + @style.padding_left + @x,
|
28
|
+
@style.border_thickness_top + @style.padding_top + @y,
|
29
|
+
@z + 2,
|
30
|
+
@scale_x, @scale_y) # TODO: Add color support?
|
27
31
|
end
|
28
32
|
|
29
33
|
def clicked_left_mouse_button(sender, x, y)
|
@@ -31,14 +35,8 @@ module CyberarmEngine
|
|
31
35
|
end
|
32
36
|
|
33
37
|
def recalculate
|
34
|
-
|
35
|
-
|
36
|
-
@height= 0
|
37
|
-
return
|
38
|
-
end
|
39
|
-
|
40
|
-
@width = @image.width * @scale_x
|
41
|
-
@height = @image.height * @scale_y
|
38
|
+
@style.width = @image.width * @scale_x
|
39
|
+
@style.height = @image.height * @scale_y
|
42
40
|
end
|
43
41
|
|
44
42
|
def value
|
@@ -17,17 +17,11 @@ module CyberarmEngine
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def recalculate
|
20
|
-
|
21
|
-
|
22
|
-
@height= 0
|
23
|
-
return
|
24
|
-
end
|
20
|
+
@style.width = @text.width.round
|
21
|
+
@style.height= @text.height.round
|
25
22
|
|
26
|
-
@
|
27
|
-
@
|
28
|
-
|
29
|
-
@text.x = @border_thickness_left + @padding_left + @x
|
30
|
-
@text.y = @border_thickness_top + @padding_top + @y
|
23
|
+
@text.x = @style.border_thickness_left + @style.padding_left + @x
|
24
|
+
@text.y = @style.border_thickness_top + @style.padding_top + @y
|
31
25
|
@text.z = @z + 3
|
32
26
|
|
33
27
|
update_background
|
@@ -1,15 +1,20 @@
|
|
1
1
|
module CyberarmEngine
|
2
2
|
class Style
|
3
|
-
def initialize(hash)
|
3
|
+
def initialize(hash = {})
|
4
4
|
@hash = hash
|
5
5
|
end
|
6
6
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
7
|
+
def method_missing(method, *args, &block)
|
8
|
+
if method.to_s.end_with?("=")
|
9
|
+
raise "Did not expect more than 1 argument" if args.size > 1
|
10
|
+
return @hash[method.to_s.sub("=", "").to_sym] = args.first
|
11
|
+
|
12
|
+
elsif args.size == 0
|
13
|
+
return @hash[method]
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
else
|
16
|
+
raise ArgumentError, "Did not expect arguments"
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -13,7 +13,7 @@ module CyberarmEngine
|
|
13
13
|
raise "Error" unless self.class.ancestors.include?(CyberarmEngine::Element)
|
14
14
|
_theme = THEME
|
15
15
|
_theme = _theme.merge(options[:theme]) if options[:theme]
|
16
|
-
|
16
|
+
_theme.delete(:theme) if options[:theme]
|
17
17
|
|
18
18
|
hash = {}
|
19
19
|
class_names = self.class.ancestors
|
@@ -38,13 +38,7 @@ module CyberarmEngine
|
|
38
38
|
def recalculate
|
39
39
|
super
|
40
40
|
|
41
|
-
|
42
|
-
@width = 0
|
43
|
-
@height= 0
|
44
|
-
return
|
45
|
-
end
|
46
|
-
|
47
|
-
@width = @text.textobject.text_width(@options[:checkmark])
|
41
|
+
@style.width = @text.textobject.text_width(@options[:checkmark])
|
48
42
|
update_background
|
49
43
|
end
|
50
44
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyberarm_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyberarm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
131
|
requirements: []
|
132
|
-
rubygems_version: 3.0.
|
132
|
+
rubygems_version: 3.0.4
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Make games quickly and easily with gosu
|