savio 0.1.4 → 0.1.7
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/.gitignore +8 -8
- data/Gemfile +6 -6
- data/LICENSE.txt +21 -21
- data/README.md +261 -261
- data/Rakefile +2 -2
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/savio/Button.rb +253 -253
- data/lib/savio/ButtonManager.rb +106 -106
- data/lib/savio/ColorSlider.rb +224 -224
- data/lib/savio/Colors.rb +13 -13
- data/lib/savio/IORenderable.rb +126 -127
- data/lib/savio/InputBox.rb +196 -163
- data/lib/savio/Scene.rb +55 -55
- data/lib/savio/Slider.rb +195 -195
- data/lib/savio/hsv2rgb.rb +78 -78
- data/lib/savio/io.rb +250 -250
- data/lib/savio/version.rb +3 -3
- data/lib/savio.rb +82 -82
- data/savio.gemspec +26 -26
- data/test.rb +9 -9
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04640fc5a9eb1db2e3d0be4e9da7371a5de2a15ff692d2797b351153e6185db9
|
4
|
+
data.tar.gz: 17f0c953565031d21e31861dad64bb6575a944316332df67890f09bbb272e298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ebffa238ec54a95d0ca71c8a2855694912bec3462e46114875cdd74a88e5fe5bdc4779d566ce335a4fe2657081b24c5dbfed14505575394433cb4cdc0b145d9
|
7
|
+
data.tar.gz: 162df8637dde6d13647d8bbd60b013a15290d10b2e621c794bb399a026ae3c639e75f056d9f0797bbd4459839e4fdfc0829d717a30ee0642d87530e60f83ff86
|
data/.gitignore
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/_yardoc/
|
4
|
-
/coverage/
|
5
|
-
/doc/
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/tmp/
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in savio.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem "rake", "~> 12.0"
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in savio.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake", "~> 12.0"
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 TheRealSavi
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 TheRealSavi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,261 +1,261 @@
|
|
1
|
-
# | *Sav***IO**
|
2
|
-
[](https://badge.fury.io/rb/savio)
|
3
|
-
## What is it?
|
4
|
-
|
5
|
-
SavIO is an input/output library created to be used with **Ruby2D**. It adds multiple ways for the user to interact with your application, including :
|
6
|
-
|
7
|
-
- Sliders
|
8
|
-
- Buttons
|
9
|
-
- Text Input
|
10
|
-
- Color Picker (Work In Progress)
|
11
|
-
|
12
|
-
## How to install?
|
13
|
-
|
14
|
-
Easy! do:
|
15
|
-
|
16
|
-
gem install savio
|
17
|
-
|
18
|
-
then in your program do:
|
19
|
-
|
20
|
-
require "savio"
|
21
|
-
|
22
|
-
## How do they work?
|
23
|
-
|
24
|
-
|
25
|
-
Good question! Part of the goal when developing SavIO was to make it as **intuitive** and **simple** as possible, while also being highly **versatile**, **powerful**, and **customizable**.
|
26
|
-
|
27
|
-
# | ALL OBJECTS
|
28
|
-
#### All SavIO objects inherit these basic properties.
|
29
|
-
|
30
|
-
#### You can access an array of all SavIO Objects by using Savio.elements
|
31
|
-
##### Example:
|
32
|
-
|
33
|
-
Savio.elements.each do |element|
|
34
|
-
element.x += 1 #Moves all elements over by 1 pixel
|
35
|
-
end
|
36
|
-
|
37
|
-
##### SavIO Commands:
|
38
|
-
Savio.hide #This will hide all elements
|
39
|
-
Savio.unhide #This will bring them all back
|
40
|
-
Savio.stop #This stops the mouse and keyboard event listeners
|
41
|
-
Savio.listen #Starts the mouse and keyboard event listeners
|
42
|
-
Savio.listening #returns true or false if its listening or not
|
43
|
-
|
44
|
-
|
45
|
-
## **Creation:**
|
46
|
-
|
47
|
-
myAwesomeOBJECT = OBJECTNAME.new(params)
|
48
|
-
|
49
|
-
### Params:
|
50
|
-
|
51
|
-
all SavIO object's parameters are optional, if it is not defined then it will use the default.
|
52
|
-
|
53
|
-
| Variable | Description | Default |
|
54
|
-
|--|--|--|
|
55
|
-
| x | The x position | 0
|
56
|
-
| y | The y Position | 0
|
57
|
-
| z | The z Position | 1
|
58
|
-
| size | The scaling value | 10
|
59
|
-
| enabled | If the object can be interacted with by the user | true
|
60
|
-
| displayName | The name of the object | ""
|
61
|
-
| draggingEnabled | If the object itself can be moved around the window | false
|
62
|
-
| dragType | "move" or "duplicate" If draggingEnabled is true, this is what happens when it drags | "move"
|
63
|
-
| shown | If the object is shown or not | true
|
64
|
-
|
65
|
-
### Example:
|
66
|
-
|
67
|
-
`myAwesomeOBJECT = OBJECTNAME.new(x: 100, y: 30, z:2, size: 13, displayName: "Swag")`
|
68
|
-
|
69
|
-
|
70
|
-
### Methods:
|
71
|
-
----
|
72
|
-
| Method | Description |
|
73
|
-
|--|--|
|
74
|
-
|.remove() | removes the object from the screen |
|
75
|
-
| .add() | adds the object back to the screen |
|
76
|
-
|.rebuild() | rebuilds the object |
|
77
|
-
|.context() | returns a hash with all the variables that make the object |
|
78
|
-
|
79
|
-
# | Sliders:
|
80
|
-
**On top of** all the basic parameters and methods a **Slider** can **also** use these:
|
81
|
-
|
82
|
-
### Params:
|
83
|
-
| Variable | Description | Default |
|
84
|
-
|--|--|--|
|
85
|
-
|length | How long the slider is | 100
|
86
|
-
|min | The minimum value of the slider | 0
|
87
|
-
|max | The maximum value of the slider | 100
|
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' |
|
90
|
-
|showValue| If the value label should be shown| true
|
91
|
-
|labelColor| The color of the labels| '#F5F5F5'
|
92
|
-
|sliderColor| Color of the slider line | '#757575'
|
93
|
-
|knobColor| Color of the sliders knob | '#5BB36A'
|
94
|
-
|
95
|
-
### Example:
|
96
|
-
|
97
|
-
slippyTheSlider = Slider.new(x: 830, y: 40, length: 220, draggingEnabled: true, dragType: "duplicate")
|
98
|
-
|
99
|
-
### Methods:
|
100
|
-
----
|
101
|
-
| Method | Description |
|
102
|
-
|--|--|
|
103
|
-
|.moveKnob(**x**) | Moves the knob to that **x** pixel location on the screen and finds and sets equivalent value for the slider |
|
104
|
-
|.setValue(**value**)|Sets the sliders value to that value and moves the knob there (same as .value=)|
|
105
|
-
| .value = **value** | Sets the sliders value to that **value** and moves the knob there (same as .setValue)|
|
106
|
-
|.onChange| Calls the given proc any time the sliders **value** is updated(see basic usage)|
|
107
|
-
|
108
|
-
### Basic Usage:
|
109
|
-
|
110
|
-
if slippyTheSlider.value == 69
|
111
|
-
puts "nice"
|
112
|
-
end
|
113
|
-
|
114
|
-
-----
|
115
|
-
|
116
|
-
slippyTheSlider.onChange do
|
117
|
-
puts "Value Changed! new value is: " + slippyTheSlider.value.to_s
|
118
|
-
end
|
119
|
-
|
120
|
-
# | Buttons:
|
121
|
-
**On top of** all the basic parameters and methods a **Button** can **also** use these:
|
122
|
-
|
123
|
-
### Params:
|
124
|
-
| Variable | Description | Default |
|
125
|
-
|--|--|--|
|
126
|
-
|selected | Whether the button is selected or not | false
|
127
|
-
|type | Whether the button will act normally('toggle') or instantly deselect itself('clicker') | 'toggle'
|
128
|
-
|style|'box' or 'badge'. Determines the style the button should be rendered with| 'badge'
|
129
|
-
|length|Only used for the 'box' style. Determines the length of the button| @size * 10
|
130
|
-
|height|Only used for the 'box' style. Determines the height of the button| @size * 1.2
|
131
|
-
|cooldownTime|Time needed to wait in seconds until the button may be clicked again| 0.0
|
132
|
-
|buttonManager | The manager that controls this button | nil
|
133
|
-
|enforceManager| When a manager is defined, whether the manager should force this button to follow its rule | true
|
134
|
-
|baseColor| Color shown when the button is deselected| '#F5F5F5'
|
135
|
-
|selectedColor|Color shown when the button is selected | '#00B3EC'
|
136
|
-
|labelColor| Color of the buttons displayName label | '#F5F5F5'
|
137
|
-
|
138
|
-
### Example:
|
139
|
-
|
140
|
-
clickyBob = Button.new(
|
141
|
-
x: 830, y: 90,
|
142
|
-
displayName: "Enable Bob?",
|
143
|
-
selectedColor: "purple",
|
144
|
-
type : 'clicker'
|
145
|
-
)
|
146
|
-
-----
|
147
|
-
anotherButton = Button.new(
|
148
|
-
x: 830, y: 150,
|
149
|
-
displayName: "Enable flux capacitors?",
|
150
|
-
)
|
151
|
-
|
152
|
-
|
153
|
-
### Methods:
|
154
|
-
----
|
155
|
-
| Method | Description |
|
156
|
-
|--|--|
|
157
|
-
|.select(*enforce*) | Selects the button. if left empty *enforce* will be the buttons **@enforceManager** state. when true the manager will enforce its rule on the button. when false, the button will perform as if it were not controlled. |
|
158
|
-
|.deselect(*enforce*) | Deselects the button. *enforce* works the same as .select() *(see above)* |
|
159
|
-
|.toggle(*enforce*) | Toggles the buttons Selection state. *enforce* works the same as .select() *(see above)*
|
160
|
-
|.selected = **bool** | Selects or deselects the button whether given true or false |
|
161
|
-
|.timeLastClicked| returns the unix time of the last click
|
162
|
-
| .onClick | Takes in a proc that will be ran every time the button gets selected (See example and basic usage)|
|
163
|
-
|
164
|
-
### Basic Usage:
|
165
|
-
|
166
|
-
clickyBob.onClick do
|
167
|
-
puts "Bob is now enabled! Hi Bob!"
|
168
|
-
end
|
169
|
-
-----
|
170
|
-
if anotherButton.selected == true do
|
171
|
-
puts "Flux capacitors now enabled"
|
172
|
-
end
|
173
|
-
|
174
|
-
# | ButtonManager:
|
175
|
-
Now I'm sure after reading how a **button** works you're saying, "What in the hell is a **manager**?"
|
176
|
-
|
177
|
-
## Let me explain, it's **very simple**.
|
178
|
-
A **ButtonManager** is a simple and easy way to **manage a group of multiple buttons**. More specifically, it **controls** the state of **all the buttons** in its group **depending on** the state of **all the other buttons** in its group.
|
179
|
-
|
180
|
-
## This is not considered a standard SavIO Object and does not inherit the typical parameters and methods.
|
181
|
-
|
182
|
-
### Creation:
|
183
|
-
|
184
|
-
theSwagMaster = ButtonManager.new(type: "checkbox")
|
185
|
-
|
186
|
-
|
187
|
-
### Params:
|
188
|
-
| Param |Description | Default|
|
189
|
-
|--|--|--|
|
190
|
-
| type | either "radio" or "checkbox" Decides how the manager should control its buttons | "radio"
|
191
|
-
|
192
|
-
### Methods:
|
193
|
-
----
|
194
|
-
| Method | Description |
|
195
|
-
|--|--|
|
196
|
-
|.addButton(**button**) | Adds the **button** to the group of buttons controlled by the manager. This is done automatically when a buttons **@buttonManager** is set to the manager. If called this way however, it will also automatically set the buttons **@buttonManager** to this manager, so they will always be linked.|
|
197
|
-
|.removeButton(**button**, *overwrite*) | Removes the **button** from the group of buttons controlled by the manager. This is done automatically when a buttons **@buttonManager** is changed or removed. *overwrite* is not required and is automatically set to true. When true, this will overwrite the **button**'s **@buttonManager** and set it to nil. When false it will not overwrite the buttons **@buttonManager**. **It is highly recommended not to change this since** it will desynchronize the button and manager and cause issues. It is used internally to prevent recursion when removed the manager from the **button** rather than from the **manager**
|
198
|
-
|.toggle(**button**) | Toggles the **button** according to the rule of the manager. This is done automatically by the **button** when **button**.toggle() is called and this manager is used. This is true also for .select() and .deselect().
|
199
|
-
| .select(**button**) | Selects the **button** according to the rule of the manager.
|
200
|
-
| .deselect(**button**) | Deselects the **button** according to the rule of the manager |
|
201
|
-
|
202
|
-
### Variables :
|
203
|
-
|Variable|Description | Type |
|
204
|
-
|--|--|--|
|
205
|
-
| buttons |an array of all the buttons that are controlled by this manager |array |
|
206
|
-
| selected | an array of all the buttons that are currently selected and in control of this manager | array |
|
207
|
-
|
208
|
-
|
209
|
-
### Basic Usage:
|
210
|
-
|
211
|
-
theSwagMaster.selected.each do |button|
|
212
|
-
puts button.to_s + " Is currently selected!"
|
213
|
-
end
|
214
|
-
--
|
215
|
-
|
216
|
-
if theSwagMaster.selected.include?(button)
|
217
|
-
puts "This button is currently selected!"
|
218
|
-
end
|
219
|
-
|
220
|
-
# | InputBox:
|
221
|
-
**On top of** all the basic parameters and methods an **InputBox** can **also** use these:
|
222
|
-
### Params:
|
223
|
-
| Variable | Description | Default |
|
224
|
-
|--|--|--|
|
225
|
-
|selected | Whether it is currently focused | false
|
226
|
-
|value | The current text input in the field | **@displayName**
|
227
|
-
|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"
|
228
|
-
|length| The length of the text box | **@size** * 10
|
229
|
-
|width| The width of the text box| **@size** * 1.2
|
230
|
-
|color| The color of the box when not focused| '#F5F5F5'
|
231
|
-
|activeColor|The color of the box when focused | '#5BB36A'
|
232
|
-
|activeTextColor| The color of the text when focused | '#F5F5F5'
|
233
|
-
|inactiveTextColor| The color of the text when not focused | '#757575'
|
234
|
-
|
235
|
-
### Example:
|
236
|
-
|
237
|
-
askMeAnything = InputBox.new(
|
238
|
-
x: 830, y: 180, size: 30,
|
239
|
-
activeColor: 'purple',
|
240
|
-
displayName: "What would you like to ask?"
|
241
|
-
)
|
242
|
-
|
243
|
-
### Methods:
|
244
|
-
----
|
245
|
-
| Method | Description |
|
246
|
-
|--|--|
|
247
|
-
|.addKey(**key**) | Simulates a key input of given **key** |
|
248
|
-
| .updateDisplay() | Adds the line follower marker to the text box |
|
249
|
-
|.select() | Focuses the text box and lets you type in it |
|
250
|
-
|.deselect() | Loses focus of the text box and finalizes value|
|
251
|
-
|.toggle() | Toggles the selection value of the text box |
|
252
|
-
|.selected=(**bool**) | Selects or deselects the text box based on the **bool** |
|
253
|
-
|
254
|
-
### Basic Usage:
|
255
|
-
|
256
|
-
if askMeAnything.value == "Favorite Color?"
|
257
|
-
puts "Purple"
|
258
|
-
end
|
259
|
-
|
260
|
-
# | ColorSlider:
|
261
|
-
These technically work but I'm not done with them so for now I wont bother with documentation.
|
1
|
+
# | *Sav***IO**
|
2
|
+
[](https://badge.fury.io/rb/savio)
|
3
|
+
## What is it?
|
4
|
+
|
5
|
+
SavIO is an input/output library created to be used with **Ruby2D**. It adds multiple ways for the user to interact with your application, including :
|
6
|
+
|
7
|
+
- Sliders
|
8
|
+
- Buttons
|
9
|
+
- Text Input
|
10
|
+
- Color Picker (Work In Progress)
|
11
|
+
|
12
|
+
## How to install?
|
13
|
+
|
14
|
+
Easy! do:
|
15
|
+
|
16
|
+
gem install savio
|
17
|
+
|
18
|
+
then in your program do:
|
19
|
+
|
20
|
+
require "savio"
|
21
|
+
|
22
|
+
## How do they work?
|
23
|
+
|
24
|
+
|
25
|
+
Good question! Part of the goal when developing SavIO was to make it as **intuitive** and **simple** as possible, while also being highly **versatile**, **powerful**, and **customizable**.
|
26
|
+
|
27
|
+
# | ALL OBJECTS
|
28
|
+
#### All SavIO objects inherit these basic properties.
|
29
|
+
|
30
|
+
#### You can access an array of all SavIO Objects by using Savio.elements
|
31
|
+
##### Example:
|
32
|
+
|
33
|
+
Savio.elements.each do |element|
|
34
|
+
element.x += 1 #Moves all elements over by 1 pixel
|
35
|
+
end
|
36
|
+
|
37
|
+
##### SavIO Commands:
|
38
|
+
Savio.hide #This will hide all elements
|
39
|
+
Savio.unhide #This will bring them all back
|
40
|
+
Savio.stop #This stops the mouse and keyboard event listeners
|
41
|
+
Savio.listen #Starts the mouse and keyboard event listeners
|
42
|
+
Savio.listening #returns true or false if its listening or not
|
43
|
+
|
44
|
+
|
45
|
+
## **Creation:**
|
46
|
+
|
47
|
+
myAwesomeOBJECT = OBJECTNAME.new(params)
|
48
|
+
|
49
|
+
### Params:
|
50
|
+
|
51
|
+
all SavIO object's parameters are optional, if it is not defined then it will use the default.
|
52
|
+
|
53
|
+
| Variable | Description | Default |
|
54
|
+
|--|--|--|
|
55
|
+
| x | The x position | 0
|
56
|
+
| y | The y Position | 0
|
57
|
+
| z | The z Position | 1
|
58
|
+
| size | The scaling value | 10
|
59
|
+
| enabled | If the object can be interacted with by the user | true
|
60
|
+
| displayName | The name of the object | ""
|
61
|
+
| draggingEnabled | If the object itself can be moved around the window | false
|
62
|
+
| dragType | "move" or "duplicate" If draggingEnabled is true, this is what happens when it drags | "move"
|
63
|
+
| shown | If the object is shown or not | true
|
64
|
+
|
65
|
+
### Example:
|
66
|
+
|
67
|
+
`myAwesomeOBJECT = OBJECTNAME.new(x: 100, y: 30, z:2, size: 13, displayName: "Swag")`
|
68
|
+
|
69
|
+
|
70
|
+
### Methods:
|
71
|
+
----
|
72
|
+
| Method | Description |
|
73
|
+
|--|--|
|
74
|
+
|.remove() | removes the object from the screen |
|
75
|
+
| .add() | adds the object back to the screen |
|
76
|
+
|.rebuild() | rebuilds the object |
|
77
|
+
|.context() | returns a hash with all the variables that make the object |
|
78
|
+
|
79
|
+
# | Sliders:
|
80
|
+
**On top of** all the basic parameters and methods a **Slider** can **also** use these:
|
81
|
+
|
82
|
+
### Params:
|
83
|
+
| Variable | Description | Default |
|
84
|
+
|--|--|--|
|
85
|
+
|length | How long the slider is | 100
|
86
|
+
|min | The minimum value of the slider | 0
|
87
|
+
|max | The maximum value of the slider | 100
|
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' |
|
90
|
+
|showValue| If the value label should be shown| true
|
91
|
+
|labelColor| The color of the labels| '#F5F5F5'
|
92
|
+
|sliderColor| Color of the slider line | '#757575'
|
93
|
+
|knobColor| Color of the sliders knob | '#5BB36A'
|
94
|
+
|
95
|
+
### Example:
|
96
|
+
|
97
|
+
slippyTheSlider = Slider.new(x: 830, y: 40, length: 220, draggingEnabled: true, dragType: "duplicate")
|
98
|
+
|
99
|
+
### Methods:
|
100
|
+
----
|
101
|
+
| Method | Description |
|
102
|
+
|--|--|
|
103
|
+
|.moveKnob(**x**) | Moves the knob to that **x** pixel location on the screen and finds and sets equivalent value for the slider |
|
104
|
+
|.setValue(**value**)|Sets the sliders value to that value and moves the knob there (same as .value=)|
|
105
|
+
| .value = **value** | Sets the sliders value to that **value** and moves the knob there (same as .setValue)|
|
106
|
+
|.onChange| Calls the given proc any time the sliders **value** is updated(see basic usage)|
|
107
|
+
|
108
|
+
### Basic Usage:
|
109
|
+
|
110
|
+
if slippyTheSlider.value == 69
|
111
|
+
puts "nice"
|
112
|
+
end
|
113
|
+
|
114
|
+
-----
|
115
|
+
|
116
|
+
slippyTheSlider.onChange do
|
117
|
+
puts "Value Changed! new value is: " + slippyTheSlider.value.to_s
|
118
|
+
end
|
119
|
+
|
120
|
+
# | Buttons:
|
121
|
+
**On top of** all the basic parameters and methods a **Button** can **also** use these:
|
122
|
+
|
123
|
+
### Params:
|
124
|
+
| Variable | Description | Default |
|
125
|
+
|--|--|--|
|
126
|
+
|selected | Whether the button is selected or not | false
|
127
|
+
|type | Whether the button will act normally('toggle') or instantly deselect itself('clicker') | 'toggle'
|
128
|
+
|style|'box' or 'badge'. Determines the style the button should be rendered with| 'badge'
|
129
|
+
|length|Only used for the 'box' style. Determines the length of the button| @size * 10
|
130
|
+
|height|Only used for the 'box' style. Determines the height of the button| @size * 1.2
|
131
|
+
|cooldownTime|Time needed to wait in seconds until the button may be clicked again| 0.0
|
132
|
+
|buttonManager | The manager that controls this button | nil
|
133
|
+
|enforceManager| When a manager is defined, whether the manager should force this button to follow its rule | true
|
134
|
+
|baseColor| Color shown when the button is deselected| '#F5F5F5'
|
135
|
+
|selectedColor|Color shown when the button is selected | '#00B3EC'
|
136
|
+
|labelColor| Color of the buttons displayName label | '#F5F5F5'
|
137
|
+
|
138
|
+
### Example:
|
139
|
+
|
140
|
+
clickyBob = Button.new(
|
141
|
+
x: 830, y: 90,
|
142
|
+
displayName: "Enable Bob?",
|
143
|
+
selectedColor: "purple",
|
144
|
+
type : 'clicker'
|
145
|
+
)
|
146
|
+
-----
|
147
|
+
anotherButton = Button.new(
|
148
|
+
x: 830, y: 150,
|
149
|
+
displayName: "Enable flux capacitors?",
|
150
|
+
)
|
151
|
+
|
152
|
+
|
153
|
+
### Methods:
|
154
|
+
----
|
155
|
+
| Method | Description |
|
156
|
+
|--|--|
|
157
|
+
|.select(*enforce*) | Selects the button. if left empty *enforce* will be the buttons **@enforceManager** state. when true the manager will enforce its rule on the button. when false, the button will perform as if it were not controlled. |
|
158
|
+
|.deselect(*enforce*) | Deselects the button. *enforce* works the same as .select() *(see above)* |
|
159
|
+
|.toggle(*enforce*) | Toggles the buttons Selection state. *enforce* works the same as .select() *(see above)*
|
160
|
+
|.selected = **bool** | Selects or deselects the button whether given true or false |
|
161
|
+
|.timeLastClicked| returns the unix time of the last click
|
162
|
+
| .onClick | Takes in a proc that will be ran every time the button gets selected (See example and basic usage)|
|
163
|
+
|
164
|
+
### Basic Usage:
|
165
|
+
|
166
|
+
clickyBob.onClick do
|
167
|
+
puts "Bob is now enabled! Hi Bob!"
|
168
|
+
end
|
169
|
+
-----
|
170
|
+
if anotherButton.selected == true do
|
171
|
+
puts "Flux capacitors now enabled"
|
172
|
+
end
|
173
|
+
|
174
|
+
# | ButtonManager:
|
175
|
+
Now I'm sure after reading how a **button** works you're saying, "What in the hell is a **manager**?"
|
176
|
+
|
177
|
+
## Let me explain, it's **very simple**.
|
178
|
+
A **ButtonManager** is a simple and easy way to **manage a group of multiple buttons**. More specifically, it **controls** the state of **all the buttons** in its group **depending on** the state of **all the other buttons** in its group.
|
179
|
+
|
180
|
+
## This is not considered a standard SavIO Object and does not inherit the typical parameters and methods.
|
181
|
+
|
182
|
+
### Creation:
|
183
|
+
|
184
|
+
theSwagMaster = ButtonManager.new(type: "checkbox")
|
185
|
+
|
186
|
+
|
187
|
+
### Params:
|
188
|
+
| Param |Description | Default|
|
189
|
+
|--|--|--|
|
190
|
+
| type | either "radio" or "checkbox" Decides how the manager should control its buttons | "radio"
|
191
|
+
|
192
|
+
### Methods:
|
193
|
+
----
|
194
|
+
| Method | Description |
|
195
|
+
|--|--|
|
196
|
+
|.addButton(**button**) | Adds the **button** to the group of buttons controlled by the manager. This is done automatically when a buttons **@buttonManager** is set to the manager. If called this way however, it will also automatically set the buttons **@buttonManager** to this manager, so they will always be linked.|
|
197
|
+
|.removeButton(**button**, *overwrite*) | Removes the **button** from the group of buttons controlled by the manager. This is done automatically when a buttons **@buttonManager** is changed or removed. *overwrite* is not required and is automatically set to true. When true, this will overwrite the **button**'s **@buttonManager** and set it to nil. When false it will not overwrite the buttons **@buttonManager**. **It is highly recommended not to change this since** it will desynchronize the button and manager and cause issues. It is used internally to prevent recursion when removed the manager from the **button** rather than from the **manager**
|
198
|
+
|.toggle(**button**) | Toggles the **button** according to the rule of the manager. This is done automatically by the **button** when **button**.toggle() is called and this manager is used. This is true also for .select() and .deselect().
|
199
|
+
| .select(**button**) | Selects the **button** according to the rule of the manager.
|
200
|
+
| .deselect(**button**) | Deselects the **button** according to the rule of the manager |
|
201
|
+
|
202
|
+
### Variables :
|
203
|
+
|Variable|Description | Type |
|
204
|
+
|--|--|--|
|
205
|
+
| buttons |an array of all the buttons that are controlled by this manager |array |
|
206
|
+
| selected | an array of all the buttons that are currently selected and in control of this manager | array |
|
207
|
+
|
208
|
+
|
209
|
+
### Basic Usage:
|
210
|
+
|
211
|
+
theSwagMaster.selected.each do |button|
|
212
|
+
puts button.to_s + " Is currently selected!"
|
213
|
+
end
|
214
|
+
--
|
215
|
+
|
216
|
+
if theSwagMaster.selected.include?(button)
|
217
|
+
puts "This button is currently selected!"
|
218
|
+
end
|
219
|
+
|
220
|
+
# | InputBox:
|
221
|
+
**On top of** all the basic parameters and methods an **InputBox** can **also** use these:
|
222
|
+
### Params:
|
223
|
+
| Variable | Description | Default |
|
224
|
+
|--|--|--|
|
225
|
+
|selected | Whether it is currently focused | false
|
226
|
+
|value | The current text input in the field | **@displayName**
|
227
|
+
|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"
|
228
|
+
|length| The length of the text box | **@size** * 10
|
229
|
+
|width| The width of the text box| **@size** * 1.2
|
230
|
+
|color| The color of the box when not focused| '#F5F5F5'
|
231
|
+
|activeColor|The color of the box when focused | '#5BB36A'
|
232
|
+
|activeTextColor| The color of the text when focused | '#F5F5F5'
|
233
|
+
|inactiveTextColor| The color of the text when not focused | '#757575'
|
234
|
+
|
235
|
+
### Example:
|
236
|
+
|
237
|
+
askMeAnything = InputBox.new(
|
238
|
+
x: 830, y: 180, size: 30,
|
239
|
+
activeColor: 'purple',
|
240
|
+
displayName: "What would you like to ask?"
|
241
|
+
)
|
242
|
+
|
243
|
+
### Methods:
|
244
|
+
----
|
245
|
+
| Method | Description |
|
246
|
+
|--|--|
|
247
|
+
|.addKey(**key**) | Simulates a key input of given **key** |
|
248
|
+
| .updateDisplay() | Adds the line follower marker to the text box |
|
249
|
+
|.select() | Focuses the text box and lets you type in it |
|
250
|
+
|.deselect() | Loses focus of the text box and finalizes value|
|
251
|
+
|.toggle() | Toggles the selection value of the text box |
|
252
|
+
|.selected=(**bool**) | Selects or deselects the text box based on the **bool** |
|
253
|
+
|
254
|
+
### Basic Usage:
|
255
|
+
|
256
|
+
if askMeAnything.value == "Favorite Color?"
|
257
|
+
puts "Purple"
|
258
|
+
end
|
259
|
+
|
260
|
+
# | ColorSlider:
|
261
|
+
These technically work but I'm not done with them so for now I wont bother with documentation.
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
task :default => :spec
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
task :default => :spec
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "savio"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "savio"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|