Class: Uh::Layout::Bar

Inherits:
Object
  • Object
show all
Includes:
GeoAccessors
Defined in:
lib/uh/layout/bar.rb

Constant Summary collapse

TEXT_PADDING_X =
3
TEXT_PADDING_Y =
1
BORDER_HEIGHT =
2
BORDER_PADDING_Y =
0
COLUMN_PADDING_X =
1
VIEW_PADDING_X =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(display, screen, colors) ⇒ Bar

Returns a new instance of Bar.



16
17
18
19
20
21
22
23
24
# File 'lib/uh/layout/bar.rb', line 16

def initialize display, screen, colors
  @display    = display
  @screen     = screen
  @geo        = build_geo @screen.geo
  @window     = @display.create_subwindow @geo
  @pixmap     = @display.create_pixmap width, height
  @colors     = Hash[colors.map { |k, v| [k, @display.color_by_name(v)] }]
  @on_update  = proc { }
end

Instance Attribute Details

#active=(value) ⇒ Object (writeonly)

Sets the attribute active

Parameters:

  • value

    the value to set the attribute active to.



14
15
16
# File 'lib/uh/layout/bar.rb', line 14

def active=(value)
  @active = value
end

#screenObject (readonly)

Returns the value of attribute screen.



13
14
15
# File 'lib/uh/layout/bar.rb', line 13

def screen
  @screen
end

#status=(value) ⇒ Object (writeonly)

Sets the attribute status

Parameters:

  • value

    the value to set the attribute status to.



14
15
16
# File 'lib/uh/layout/bar.rb', line 14

def status=(value)
  @status = value
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/uh/layout/bar.rb', line 26

def active?
  !!@active
end

#focusObject



56
57
58
59
# File 'lib/uh/layout/bar.rb', line 56

def focus
  @window.focus
  self
end

#on_update(&block) ⇒ Object



30
31
32
# File 'lib/uh/layout/bar.rb', line 30

def on_update &block
  @on_update = block
end

#redrawObject



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/uh/layout/bar.rb', line 38

def redraw
  draw_background
  draw_columns BORDER_HEIGHT + BORDER_PADDING_Y,
    @screen.current_view.columns, @screen.current_view.current_column
  draw_views BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
    @screen.views, @screen.current_view
  if @status
    draw_status BORDER_HEIGHT + BORDER_PADDING_Y + text_line_height,
      @status
  end
  blit
end

#showObject



51
52
53
54
# File 'lib/uh/layout/bar.rb', line 51

def show
  @window.show
  self
end

#updateObject



34
35
36
# File 'lib/uh/layout/bar.rb', line 34

def update
  @on_update.call
end