ES-DE/src/components/GuiMenu.cpp

59 lines
1.1 KiB
C++
Raw Normal View History

#include "GuiMenu.h"
#include <iostream>
GuiMenu::GuiMenu(GuiComponent* parent)
{
mParent = parent;
parent->pause();
2012-08-02 04:50:18 +00:00
mList = new GuiList<std::string>(Renderer::getScreenWidth() * 0.5, 20);
addChild(mList);
mSkippedMenuClose = false;
Renderer::registerComponent(this);
InputManager::registerComponent(this);
}
GuiMenu::~GuiMenu()
{
Renderer::unregisterComponent(this);
InputManager::unregisterComponent(this);
delete mList;
mParent->resume();
}
void GuiMenu::onInput(InputManager::InputButton button, bool keyDown)
{
if(button == InputManager::MENU && !keyDown)
{
if(!mSkippedMenuClose)
{
mSkippedMenuClose = true;
}else{
delete this;
return;
}
}
2012-08-02 04:50:18 +00:00
if(button == InputManager::BUTTON1 && keyDown)
{
system(mList->getSelectedObject().c_str());
}
}
void GuiMenu::populateList()
{
2012-08-02 04:50:18 +00:00
mList->clear();
2012-08-02 04:50:18 +00:00
mList->addObject("Nothing", "");
mList->addObject("Shutdown", "sudo shutdown -h now");
}
void GuiMenu::onRender()
{
Renderer::drawRect(Renderer::getScreenWidth() * 0.25, 0, Renderer::getScreenWidth() * 0.5, Renderer::getScreenHeight(), 0xFF00FF);
}