Archived
1
0
Fork 0

Add class Widgets::Menu::Items

This commit is contained in:
Braiden Vasco 2017-07-22 14:51:07 +00:00
parent cab2881d02
commit 92bc971b5f
3 changed files with 33 additions and 23 deletions

View file

@ -17,6 +17,7 @@ require 'widgets/messenger'
require 'widgets/menu' require 'widgets/menu'
require 'widgets/menu/logo' require 'widgets/menu/logo'
require 'widgets/menu/items'
require 'widgets/peers' require 'widgets/peers'
require 'widgets/peers/list' require 'widgets/peers/list'

View file

@ -2,35 +2,16 @@
module Widgets module Widgets
class Menu < Base class Menu < Base
ITEMS = [
'Foo menu item',
'Bar Car menu item',
'Hello, World!',
].freeze
def initialize(x, y, _width, height) def initialize(x, y, _width, height)
super x, y, Logo::WIDTH, height super x, y, Logo::WIDTH, height
@logo = Logo.new x, y, nil, nil @logo = Logo.new x, y, nil, nil
@items = Items.new x, @logo.height, @logo.width, nil
end end
def draw def draw
@logo.draw @logo.render
@items.render
ITEMS.each_with_index do |item, index|
item_y = @logo.height + index * 4
Style.default.menu_item do
setpos 2, item_y + 0
Curses.addstr ' ' * (width - 4)
setpos 2, item_y + 1
Curses.addstr " #{item}".ljust width - 4
setpos 2, item_y + 2
Curses.addstr ' ' * (width - 4)
end
end
end end
end end
end end

28
lib/widgets/menu/items.rb Normal file
View file

@ -0,0 +1,28 @@
# frozen_string_literal: true
module Widgets
class Menu < Base
class Items < Base
ITEMS = [
'Foo menu item',
'Bar Car menu item',
'Hello, World!',
].freeze
def draw
ITEMS.each_with_index do |item, index|
Style.default.menu_item do
setpos 2, 4 * index + 0
Curses.addstr ' ' * (width - 4)
setpos 2, 4 * index + 1
Curses.addstr " #{item}".ljust width - 4
setpos 2, 4 * index + 2
Curses.addstr ' ' * (width - 4)
end
end
end
end
end
end