Class: Test

Inherits:
Gosu::Window
  • Object
show all
Defined in:
lib/luit.rb

Instance Method Summary collapse

Constructor Details

#initializeTest



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/luit.rb', line 425

def initialize
  super(1000, 1000, false)

  LUIT.config(window: self)

  @LUITElements = []
  @LUITElements << LUIT::Button.new(self, 1, 0, 0, "Test")
  @LUITElements << LUIT::Button.new(self, 2, 111, 111, "Big button", 200, 70)
  @LUITElements << LUIT::Slider.new(self, 3, 300, 300, 300)
  @vslider = LUIT::VerticalSlider.new(self, 3, 250, 250, 300)
  @LUITElements << @vslider
  @LUITElements << LUIT::Toggle.new(self, 4, 500, 500)
  @LUITElements << LUIT::ClickArea.new(self, "click", 900, 900, 100, 100)
  @texter = LUIT::TextArea.new(self, "text", 300, 100, 32, 20)
  @LUITElements << @texter
  @LUITElements << LUIT::TextArea.new(self, "text2", 300, 200, 32, 20)
  @list = LUIT::List.new(self, "list", 0, 200, 300, 0)
  @LUITElements << @list
  20.times do
    @list << LUIT::Button.new(self, 1, 0, 0, "Test", 0, 50)
  end
  @font = Gosu::Font.new(30)
  @scanner = LUIT::ScannerInput.new(self, "dik")
end

Instance Method Details

#button_down(id) ⇒ Object



460
461
462
463
464
465
466
467
# File 'lib/luit.rb', line 460

def button_down(id)
  case id
  when Gosu::KbSpace
    @list << LUIT::Button.new(self, 1, 0, 0, "Test", 0, 50)
  when Gosu::KbX
    @scanner.scan
  end
end

#drawObject



450
451
452
453
# File 'lib/luit.rb', line 450

def draw
  @LUITElements.each {|e| e.draw}
  @font.draw(LUIT::to_roman(@vslider.value), 600, 250, 2)
end

#needs_cursor?Boolean



480
481
482
# File 'lib/luit.rb', line 480

def needs_cursor?
  return true
end

#onClick(id) ⇒ Object



473
474
475
476
477
478
# File 'lib/luit.rb', line 473

def onClick(id)
  puts id
  if id == "text"
    puts @texter.text
  end
end

#onScan(text) ⇒ Object



469
470
471
# File 'lib/luit.rb', line 469

def onScan(text)
  puts text
end

#updateObject



455
456
457
458
# File 'lib/luit.rb', line 455

def update
  @LUITElements.each {|e| e.update}
  @scanner.update
end