Navigable menu
This commit is contained in:
parent
570319627a
commit
34ad81e3fc
3 changed files with 20 additions and 1 deletions
|
@ -7,6 +7,8 @@ module Widgets
|
|||
|
||||
@logo = Logo.new x, y, nil, nil
|
||||
@items = Items.new x, @logo.height, @logo.width, nil
|
||||
|
||||
self.focus = @items
|
||||
end
|
||||
|
||||
def children
|
||||
|
|
|
@ -19,6 +19,15 @@ module Widgets
|
|||
@active = 0
|
||||
end
|
||||
|
||||
def trigger(event)
|
||||
case event
|
||||
when Events::Panel::Up
|
||||
up
|
||||
when Events::Panel::Down
|
||||
down
|
||||
end
|
||||
end
|
||||
|
||||
def draw
|
||||
ITEMS.each_with_index do |item, index|
|
||||
draw_item index, item
|
||||
|
@ -37,6 +46,14 @@ module Widgets
|
|||
Curses.addstr ' ' * (width - 2 * SIDE_PADDING)
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
@active -= 1 if active.positive?
|
||||
end
|
||||
|
||||
def down
|
||||
@active += 1 if active < ITEMS.count - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Widgets
|
|||
@menu = Widgets::Menu.new 0, 0, nil, Curses.stdscr.maxy
|
||||
@messenger = Widgets::Messenger.new @menu.width, 0, Curses.stdscr.maxx - @menu.width, Curses.stdscr.maxy
|
||||
|
||||
self.focus = @messenger
|
||||
self.focus = @menu
|
||||
end
|
||||
|
||||
def children
|
||||
|
|
Reference in a new issue