Sha256: f5f854d974553c7eba8e2415a005243b85f3ad508a4ddbe4f3d837e94c9bc2fd

Contents?: true

Size: 683 Bytes

Versions: 7

Compression:

Stored size: 683 Bytes

Contents

module Luck
class Control
  attr_accessor :pane, :display, :x1, :y1, :x2, :y2
  
  def initialize pane, x1, y1, x2, y2, &blck
    @pane = pane
    @display = pane.display
    @x1, @y1 = x1, y1
    @x2, @y2 = x2, y2
    
    instance_eval &blck if blck
  end
  
  def focus!
    @display.active_control = self
  end
  
  def x1
    @pane.x1 + ((@x1 < 0) ? (@pane.width + @x1) : @x1)
  end
  def y1
    @pane.y1 + ((@y1 < 0) ? (@pane.height + @y1) : @y1)
  end
  
  def x2
    @pane.x1 + ((@x2 < 0) ? (@pane.width + @x2 + 1) : @x2)
  end
  def y2
    @pane.y1 + ((@y2 < 0) ? (@pane.height + @y2 + 1) : @y2)
  end
  
  def width
    x2 - x1
  end
  def height
    y2 - y1
  end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
luck-0.1.6 lib/luck/control.rb
luck-0.1.5 lib/luck/control.rb
luck-0.1.4 lib/luck/control.rb
luck-0.1.3 lib/luck/control.rb
luck-0.1.2 lib/luck/control.rb
luck-0.1.1 lib/luck/control.rb
luck-0.1.0 lib/luck/control.rb