Class: Uh::Layout::Bar
- Inherits:
-
Object
- Object
- Uh::Layout::Bar
- 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
-
#active ⇒ Object
writeonly
Sets the attribute active.
-
#screen ⇒ Object
readonly
Returns the value of attribute screen.
-
#status ⇒ Object
writeonly
Sets the attribute status.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #focus ⇒ Object
-
#initialize(display, screen, colors) ⇒ Bar
constructor
A new instance of Bar.
- #on_update(&block) ⇒ Object
- #redraw ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
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
14 15 16 |
# File 'lib/uh/layout/bar.rb', line 14 def active=(value) @active = value end |
#screen ⇒ Object (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
14 15 16 |
# File 'lib/uh/layout/bar.rb', line 14 def status=(value) @status = value end |
Instance Method Details
#active? ⇒ Boolean
26 27 28 |
# File 'lib/uh/layout/bar.rb', line 26 def active? !!@active end |
#focus ⇒ Object
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 |
#redraw ⇒ Object
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 |
#show ⇒ Object
51 52 53 54 |
# File 'lib/uh/layout/bar.rb', line 51 def show @window.show self end |
#update ⇒ Object
34 35 36 |
# File 'lib/uh/layout/bar.rb', line 34 def update @on_update.call end |