1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-28 12:39:50 +03:00
gmenu2x/src/buttonbox.cpp
Maarten ter Huurne 428a316bc1 Removed GMenu2X pointer from ButtonBox
It was only used to fetch resY, so I replaced that by taking the
y-coordinate as an argument. That is also more consistent with the
x-coordinate which was already an argument.

The x-coordinate was changed to a signed int, since that is the norm
for paint coordinates. It can be useful for drawing widgets that are
partially off screen, for example during a (dis)appear animation.

In InputDialog, the ButtonBox field was changed from a pointer to
a plain data member. There was no need to dynamically allocate it.
2014-08-16 05:52:25 +02:00

35 lines
547 B
C++

#include "buttonbox.h"
#include "gmenu2x.h"
#include "iconbutton.h"
using std::unique_ptr;
using std::move;
void ButtonBox::add(unique_ptr<IconButton> button)
{
buttons.push_back(move(button));
}
void ButtonBox::clear()
{
buttons.clear();
}
void ButtonBox::paint(Surface& s, int x, int y)
{
for (auto& button : buttons) {
auto rect = button->getRect();
button->setPosition(x, y - rect.h);
button->paint(s);
x += button->getRect().w + 6;
}
}
void ButtonBox::handleTS()
{
for (auto& button : buttons) {
button->handleTS();
}
}