luit 0.1.1 → 0.1.2
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/luit.rb +26 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a098ee7bfa46b0e484c5da472f6a37f1e741b282
|
4
|
+
data.tar.gz: 92535e1563b72d5fb8e5ec3a34559ea71997249f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9be6cee94a24e2c5b0b17577f16e638f153a6d57997b6cb0177eed1990dc0522df013072e4cc2c50db881ca5c89a903a879c36beff8c5d9f9e528c46dfb61d52
|
7
|
+
data.tar.gz: cf0e40d2fe57639716e73b108e8a817dd7fddb91ecda21b61972c5be9ea891bdf00f60c5218675724dc53ac732ac638d23765eaa8b781cb81ec193f9b675dc13
|
data/lib/luit.rb
CHANGED
@@ -29,7 +29,7 @@ module LUIT
|
|
29
29
|
def self.mY
|
30
30
|
@window.mouse_y
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
#Raspberry pi touchscreen hack
|
34
34
|
def self.updateTouch()
|
35
35
|
if @touchDown
|
@@ -62,7 +62,7 @@ module LUIT
|
|
62
62
|
def draw_rel(x = 0, y = 0)
|
63
63
|
draw(x - (@w/2), y - (@h/2))
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
def updateHover(x, y)
|
67
67
|
@hover = LUIT.mX.between?(x, x + @w) && LUIT.mY.between?(y, y + @h)
|
68
68
|
end
|
@@ -109,7 +109,7 @@ module LUIT
|
|
109
109
|
end
|
110
110
|
|
111
111
|
class TextArea < LUITElement
|
112
|
-
attr_reader :
|
112
|
+
attr_reader :field
|
113
113
|
def initialize(holder, id, x, y, maxChar, h)
|
114
114
|
h = [10, h].max
|
115
115
|
@font = Gosu::Font.new(h)
|
@@ -139,7 +139,7 @@ module LUIT
|
|
139
139
|
def draw(x = 0, y = 0)
|
140
140
|
x = x + @x
|
141
141
|
y = y + @y
|
142
|
-
Gosu::draw_rect(x, y, @w, @h, @typing ?
|
142
|
+
Gosu::draw_rect(x, y, @w, @h, @typing ? 0xffffffff : LUIT.uiColor, LUIT.z)
|
143
143
|
@font.draw(@field.text, x + 10, y + 10, LUIT.z + 1, 1, 1, 0xff000000)
|
144
144
|
end
|
145
145
|
|
@@ -165,28 +165,29 @@ module LUIT
|
|
165
165
|
end
|
166
166
|
|
167
167
|
class ScannerInput
|
168
|
-
attr_reader :
|
169
|
-
def initialize(holder, id
|
168
|
+
attr_reader :scnning
|
169
|
+
def initialize(holder, id)
|
170
170
|
@field = Gosu::TextInput.new
|
171
|
-
@window = window
|
171
|
+
@window = LUIT.window
|
172
172
|
@holder = holder
|
173
173
|
@id = id
|
174
174
|
end
|
175
175
|
|
176
176
|
def update
|
177
|
-
if Gosu::button_down?(Gosu::KbReturn) && @
|
177
|
+
if Gosu::button_down?(Gosu::KbReturn) && @scaning
|
178
178
|
@holder.onScan(@field.text)
|
179
179
|
@field.text = ""
|
180
|
+
stop
|
180
181
|
end
|
181
182
|
end
|
182
183
|
|
183
184
|
def stop
|
184
|
-
@
|
185
|
+
@scaning = false
|
185
186
|
@window.text_input = nil if @window.text_input == @field
|
186
187
|
end
|
187
188
|
|
188
189
|
def scan
|
189
|
-
@
|
190
|
+
@scaning = true
|
190
191
|
@window.text_input = @field
|
191
192
|
end
|
192
193
|
end
|
@@ -244,7 +245,7 @@ module LUIT
|
|
244
245
|
Gosu::draw_rect(@x + x, @y + y + 10, @w, 10, @buttonColor, LUIT.z)
|
245
246
|
Gosu::draw_rect(@x + x + @value, @y + y, 10, @h, @buttonColor, LUIT.z + 1)
|
246
247
|
end
|
247
|
-
|
248
|
+
|
248
249
|
def updateHover(x, y)
|
249
250
|
@hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20)
|
250
251
|
end
|
@@ -278,11 +279,11 @@ module LUIT
|
|
278
279
|
Gosu::draw_rect(@x + x + 10, @y + y, 10, @h, @buttonColor, LUIT.z)
|
279
280
|
Gosu::draw_rect(@x + x, @y + y + @value, @w, 10, @buttonColor, LUIT.z + 1)
|
280
281
|
end
|
281
|
-
|
282
|
+
|
282
283
|
def updateHover(x, y)
|
283
284
|
@hover = LUIT.mX.between?(x - 10, x + @w + 20) && LUIT.mY.between?(y - 10, y + @h + 20)
|
284
285
|
end
|
285
|
-
|
286
|
+
|
286
287
|
def update(x = 0, y = 0)
|
287
288
|
x += @x
|
288
289
|
y += @y
|
@@ -423,9 +424,9 @@ if __FILE__ == $0
|
|
423
424
|
class Test < Gosu::Window
|
424
425
|
def initialize
|
425
426
|
super(1000, 1000, false)
|
426
|
-
|
427
|
+
|
427
428
|
LUIT.config(window: self)
|
428
|
-
|
429
|
+
|
429
430
|
@LUITElements = []
|
430
431
|
@LUITElements << LUIT::Button.new(self, 1, 0, 0, "Test")
|
431
432
|
@LUITElements << LUIT::Button.new(self, 2, 111, 111, "Big button", 200, 70)
|
@@ -443,6 +444,7 @@ if __FILE__ == $0
|
|
443
444
|
@list << LUIT::Button.new(self, 1, 0, 0, "Test", 0, 50)
|
444
445
|
end
|
445
446
|
@font = Gosu::Font.new(30)
|
447
|
+
@scanner = LUIT::ScannerInput.new(self, "dik")
|
446
448
|
end
|
447
449
|
|
448
450
|
def draw
|
@@ -452,14 +454,22 @@ if __FILE__ == $0
|
|
452
454
|
|
453
455
|
def update
|
454
456
|
@LUITElements.each {|e| e.update}
|
457
|
+
@scanner.update
|
455
458
|
end
|
456
459
|
|
457
460
|
def button_down(id)
|
458
|
-
|
461
|
+
case id
|
462
|
+
when Gosu::KbSpace
|
459
463
|
@list << LUIT::Button.new(self, 1, 0, 0, "Test", 0, 50)
|
464
|
+
when Gosu::KbX
|
465
|
+
@scanner.scan
|
460
466
|
end
|
461
467
|
end
|
462
468
|
|
469
|
+
def onScan(text)
|
470
|
+
puts text
|
471
|
+
end
|
472
|
+
|
463
473
|
def onClick(id)
|
464
474
|
puts id
|
465
475
|
if id == "text"
|