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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b9718ed09ba01941d92b7d59dabf07b88e4fe6d44c39f8d3d10e06b8467c7ca
4
- data.tar.gz: f86e29857ba48e2b9108058674517106b74acd5bcdb55438ad50e71ade537ace
3
+ metadata.gz: e9c4a4721041e88aef40cb7c21004642868062c0893f9d580b0becc061754e1e
4
+ data.tar.gz: 7c297a0dc4c4333610a0073ee3ebeef372cdaed9ca14078d518de5cb17e55507
5
5
  SHA512:
6
- metadata.gz: acc7c66f028e73ab48b15367a933c0fc10c6d41839ea495646578281ba659e4146e10fb74159aad703a2955511b37ed2009a69dcfef274cbf9c4d70d0558179a
7
- data.tar.gz: 65c9e78ac89080304c0315ffe36699658aa43321a12ef8847a6a697db9dc86ba2d8ad4c93ee40b27e103458174aef880e86a17d10999f3d23095403db4d17935
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 | "Default"
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| 'gray'
224
- |activeColor|The color of the box when focused | 'green'
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] || '#01042A'
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
@@ -12,7 +12,7 @@ module Savio
12
12
  @size = args[:size] || 10
13
13
  @enabled = args[:enabled] || true
14
14
 
15
- @displayName = args[:displayName] || "Default"
15
+ @displayName = args[:displayName] || ""
16
16
 
17
17
  @draggingEnabled = args[:draggingEnabled] || false
18
18
  @dragType = args[:dragType] || "move"
@@ -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] || 'gray'
30
- @activeColor = args[:activeColor] || 'green'
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
- @knob.x = x
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 = @knob.x
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
- @knob.x = knobX
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
- @knob = Circle.new(
125
- x: @x, y: @y,
126
- radius: @size * 1.2,
127
- color: @knobColor,
128
- z: @z+1
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
@@ -1,3 +1,3 @@
1
1
  module Savio
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TheRealSavi