savio 0.1.2 → 0.1.3
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/README.md +6 -3
- data/lib/savio/Button.rb +3 -1
- data/lib/savio/IORenderable.rb +1 -1
- data/lib/savio/InputBox.rb +20 -3
- data/lib/savio/Slider.rb +43 -9
- data/lib/savio/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9c4a4721041e88aef40cb7c21004642868062c0893f9d580b0becc061754e1e
|
4
|
+
data.tar.gz: 7c297a0dc4c4333610a0073ee3ebeef372cdaed9ca14078d518de5cb17e55507
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d58b069df4a6556b7b0c4a931e50eb0e0a730e32b00d39cbeb5453003e9ff2a125387e53a102bc9bc81b92d53ba4b67298992cf2f848bc89fb8141db3cff910
|
7
|
+
data.tar.gz: 4307f4a3119b6328e4724a4e555a6f767c5e51a16ca1ba89e667157bb594b13b2f2598a183fb4f362aa3961a33645419852e4fb03083256838030ea5ba46b7f9
|
data/README.md
CHANGED
@@ -57,7 +57,7 @@ all SavIO object's parameters are optional, if it is not defined then it will us
|
|
57
57
|
| z | The z Position | 1
|
58
58
|
| size | The scaling value | 10
|
59
59
|
| enabled | If the object can be interacted with by the user | true
|
60
|
-
| displayName | The name of the object | "
|
60
|
+
| displayName | The name of the object | ""
|
61
61
|
| draggingEnabled | If the object itself can be moved around the window | false
|
62
62
|
| dragType | "move" or "duplicate" If draggingEnabled is true, this is what happens when it drags | "move"
|
63
63
|
| shown | If the object is shown or not | true
|
@@ -86,6 +86,7 @@ all SavIO object's parameters are optional, if it is not defined then it will us
|
|
86
86
|
|min | The minimum value of the slider | 0
|
87
87
|
|max | The maximum value of the slider | 100
|
88
88
|
|value| The value of the slider | Random between min and max
|
89
|
+
|style|'knob' or 'fill' changes the style the slider is shown with|'knob' |
|
89
90
|
|showValue| If the value label should be shown| true
|
90
91
|
|labelColor| The color of the labels| '#F5F5F5'
|
91
92
|
|sliderColor| Color of the slider line | '#757575'
|
@@ -220,8 +221,10 @@ A **ButtonManager** is a simple and easy way to **manage a group of multiple but
|
|
220
221
|
|displayName | The value shown in the text field when nothing is in it. AKA the default value. if a value was specified, this will be overwritten with it. | **@value** or "Default"
|
221
222
|
|length| The length of the text box | **@size** * 10
|
222
223
|
|width| The width of the text box| **@size** * 1.2
|
223
|
-
|color| The color of the box when not focused| '
|
224
|
-
|activeColor|The color of the box when focused | '
|
224
|
+
|color| The color of the box when not focused| '#F5F5F5'
|
225
|
+
|activeColor|The color of the box when focused | '#5BB36A'
|
226
|
+
|activeTextColor| The color of the text when focused | '#F5F5F5'
|
227
|
+
|inactiveTextColor| The color of the text when not focused | '#757575'
|
225
228
|
|
226
229
|
### Example:
|
227
230
|
|
data/lib/savio/Button.rb
CHANGED
@@ -41,7 +41,7 @@ module Savio
|
|
41
41
|
|
42
42
|
if @style == 'box'
|
43
43
|
@size *= 2
|
44
|
-
@labelColor = args[:baseColor] || '#
|
44
|
+
@labelColor = args[:baseColor] || '#757575'
|
45
45
|
end
|
46
46
|
@length = args[:length] || @size * 10
|
47
47
|
@height = args[:height] || @size * 1.2
|
@@ -219,6 +219,8 @@ module Savio
|
|
219
219
|
color: @labelColor,
|
220
220
|
z: @z+2
|
221
221
|
)
|
222
|
+
@nameLabel.x = @baseCircle.x + @baseCircle.width / 2 - @nameLabel.width / 2
|
223
|
+
@nameLabel.y = @baseCircle.y + @baseCircle.height / 2 - @nameLabel.height / 2
|
222
224
|
end
|
223
225
|
|
224
226
|
if @buttonManager == nil
|
data/lib/savio/IORenderable.rb
CHANGED
@@ -12,7 +12,7 @@ module Savio
|
|
12
12
|
@size = args[:size] || 10
|
13
13
|
@enabled = args[:enabled] || true
|
14
14
|
|
15
|
-
@displayName = args[:displayName] || "
|
15
|
+
@displayName = args[:displayName] || ""
|
16
16
|
|
17
17
|
@draggingEnabled = args[:draggingEnabled] || false
|
18
18
|
@dragType = args[:dragType] || "move"
|
data/lib/savio/InputBox.rb
CHANGED
@@ -26,8 +26,11 @@ module Savio
|
|
26
26
|
@length = args[:length] || @size * 10
|
27
27
|
@height = args[:height] || @size * 1.2
|
28
28
|
|
29
|
-
@color = args[:color] || '
|
30
|
-
@activeColor = args[:activeColor] || '
|
29
|
+
@color = args[:color] || '#F5F5F5'
|
30
|
+
@activeColor = args[:activeColor] || '#5BB36A'
|
31
|
+
|
32
|
+
@activeTextColor = args[:activeTextColor] || '#F5F5F5'
|
33
|
+
@inactiveTextColor = args[:inactiveTextColor] || '#757575'
|
31
34
|
|
32
35
|
build()
|
33
36
|
end
|
@@ -52,6 +55,14 @@ module Savio
|
|
52
55
|
@activeColor = color
|
53
56
|
rebuild()
|
54
57
|
end
|
58
|
+
def activeTextcolor=(color)
|
59
|
+
@activeTextcolor = color
|
60
|
+
rebuild()
|
61
|
+
end
|
62
|
+
def inactiveTextColor=(color)
|
63
|
+
@inactiveTextColor = color
|
64
|
+
rebuild()
|
65
|
+
end
|
55
66
|
def length=(length)
|
56
67
|
@length = length
|
57
68
|
rebuild()
|
@@ -114,6 +125,7 @@ module Savio
|
|
114
125
|
end
|
115
126
|
|
116
127
|
@display.text = @value + "|"
|
128
|
+
@display.color = @activeTextColor
|
117
129
|
@container.color = @activeColor
|
118
130
|
end
|
119
131
|
|
@@ -125,6 +137,7 @@ module Savio
|
|
125
137
|
end
|
126
138
|
|
127
139
|
@display.text = @value
|
140
|
+
@display.color = @inactiveTextColor
|
128
141
|
@container.color = @color
|
129
142
|
end
|
130
143
|
|
@@ -139,8 +152,12 @@ module Savio
|
|
139
152
|
def build()
|
140
153
|
@shown = true
|
141
154
|
|
142
|
-
@display = Text.new(@value,x: @x,y: @y,z: @z + 1, size: @size)
|
155
|
+
@display = Text.new(@value,x: @x,y: @y,z: @z + 1, size: @size, color: @inactiveTextColor)
|
156
|
+
@height = @display.height * 1.1
|
157
|
+
|
143
158
|
@container = Rectangle.new(x: @x, y: @y, z: @z, height: @height, width: @length, color: @color)
|
159
|
+
|
160
|
+
@display.y = @container.y + @container.height / 2 - @display.height / 2
|
144
161
|
end
|
145
162
|
end
|
146
163
|
end
|
data/lib/savio/Slider.rb
CHANGED
@@ -17,6 +17,11 @@ module Savio
|
|
17
17
|
@min = args[:min] || 0
|
18
18
|
@max = args[:max] || 100
|
19
19
|
|
20
|
+
@style = args[:style] || 'knob'
|
21
|
+
if @style != 'knob' && @style != 'fill'
|
22
|
+
@style = 'knob'
|
23
|
+
end
|
24
|
+
|
20
25
|
@value = args[:value] || rand(@min..@max)
|
21
26
|
@showValue = args[:showValue] || true
|
22
27
|
|
@@ -27,6 +32,12 @@ module Savio
|
|
27
32
|
build()
|
28
33
|
end
|
29
34
|
|
35
|
+
def style=(style)
|
36
|
+
if style == 'knob' || style == 'fill'
|
37
|
+
@style = style
|
38
|
+
rebuild()
|
39
|
+
end
|
40
|
+
end
|
30
41
|
def length=(length)
|
31
42
|
@length = length.clamp(1, Window.width-@x)
|
32
43
|
rebuild()
|
@@ -56,15 +67,26 @@ module Savio
|
|
56
67
|
setValue(@value)
|
57
68
|
end
|
58
69
|
|
70
|
+
def renderKnobTo(x)
|
71
|
+
if x.between?(@x, @x+@length)
|
72
|
+
case @style
|
73
|
+
when 'knob'
|
74
|
+
@knob.x = x
|
75
|
+
when 'fill'
|
76
|
+
@knob.width = x - @x
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
59
81
|
def moveKnob(x)
|
60
82
|
if x.between?(@x, @x+@length)
|
61
|
-
|
83
|
+
renderKnobTo(x)
|
62
84
|
|
63
85
|
to_max = @max
|
64
86
|
to_min = @min
|
65
87
|
from_max = @x + @length
|
66
88
|
from_min = @x
|
67
|
-
pos =
|
89
|
+
pos = x
|
68
90
|
@value = (((to_max - to_min) * (pos - from_min)) / (from_max - from_min) + to_min)
|
69
91
|
if @showValue == true
|
70
92
|
@label.text = @value.round(2).to_s
|
@@ -88,7 +110,7 @@ module Savio
|
|
88
110
|
if @showValue == true
|
89
111
|
@label.text = @value.round(2).to_s
|
90
112
|
end
|
91
|
-
|
113
|
+
renderKnobTo(knobX)
|
92
114
|
else
|
93
115
|
setValue(@min)
|
94
116
|
end
|
@@ -121,12 +143,22 @@ module Savio
|
|
121
143
|
z: @z
|
122
144
|
)
|
123
145
|
|
124
|
-
@
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
146
|
+
case @style
|
147
|
+
when 'knob'
|
148
|
+
@knob = Circle.new(
|
149
|
+
x: @x, y: @y,
|
150
|
+
radius: @size * 1.2,
|
151
|
+
color: @knobColor,
|
152
|
+
z: @z+1
|
153
|
+
)
|
154
|
+
when 'fill'
|
155
|
+
@knob = Rectangle.new(
|
156
|
+
x: @x, y: @y,
|
157
|
+
width: 0 , height: @size,
|
158
|
+
color: @knobColor,
|
159
|
+
z: @z+1
|
160
|
+
)
|
161
|
+
end
|
130
162
|
|
131
163
|
@label = Text.new(
|
132
164
|
@value.to_s,
|
@@ -136,6 +168,8 @@ module Savio
|
|
136
168
|
z: @z+1
|
137
169
|
)
|
138
170
|
|
171
|
+
@label.y = @y + @sliderLine.width / 2 - @label.height / 2
|
172
|
+
|
139
173
|
@nameLabel = Text.new(
|
140
174
|
@displayName.to_s,
|
141
175
|
x: @x, y: @y - @size * 3 - @size,
|
data/lib/savio/version.rb
CHANGED