diff --git a/lib/main.rb b/lib/main.rb index 55804c5..64bb10b 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -20,7 +20,6 @@ require 'widgets/main' require 'widgets/menu' require 'widgets/menu/logo' -require 'widgets/menu/items' require 'widgets/peers' require 'widgets/peers/list' diff --git a/lib/widgets/menu/items.rb b/lib/widgets/menu/items.rb deleted file mode 100644 index 53fef4e..0000000 --- a/lib/widgets/menu/items.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -module Widgets - class Menu < Container - class Items < Base - ITEMS = [ - 'Foo menu item', - 'Bar Car menu item', - 'Hello, World!', - ].freeze - - SIDE_PADDING = 3 - - attr_reader :active - - def initialize(*) - super - - @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 - end - end - - def draw_item(index, name) - Style.default.public_send(index == active ? :active_menu_item : :menu_item, window) do - setpos SIDE_PADDING, 4 * index + 0 - addstr ' ' * (width - 2 * SIDE_PADDING) - - setpos SIDE_PADDING, 4 * index + 1 - addstr " #{name}".ljust width - 2 * SIDE_PADDING - - setpos SIDE_PADDING, 4 * index + 2 - 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