summary refs log tree commit diff stats
path: root/src/menu.cpp
blob: cfb0dd6c1dcb809b7ae6e6285bbe4fe219a4a265 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "menu.h"

Menu::Menu(const std::vector<MenuBuilder>& builders) {
  items_.reserve(builders.size());

  for (const MenuBuilder& builder : builders) {
    items_.push_back(builder.Build());
  }
}

void Menu::moveCursorUp() {
  cursor_--;

  if (cursor_ < 0) {
    cursor_ = items_.size() - 1;
  }
}

void Menu::moveCursorDown() {
  cursor_++;

  if (cursor_ >= items_.size()) {
    cursor_ = 0;
  }
}