Root/src/background.cpp

Source at commit 00d3c3b57008bddf8770c51271db9d766acaf854 created 7 years 5 months ago.
By Maarten ter Huurne, Gave Layer class a protected constructor
1// Various authors.
2// License: GPL version 2 or later.
3
4#include "background.h"
5
6#include "gmenu2x.h"
7
8
9Background::Background(GMenu2X& gmenu2x)
10    : gmenu2x(gmenu2x)
11    , battery(gmenu2x.sc)
12{
13}
14
15void Background::paint(Surface& s) {
16    Font& font = *gmenu2x.font;
17    OffscreenSurface& bgmain = *gmenu2x.bgmain;
18
19    bgmain.blit(s, 0, 0);
20
21    font.write(s, clock.getTime(),
22            s.width() / 2, gmenu2x.bottomBarTextY,
23            Font::HAlignCenter, Font::VAlignMiddle);
24
25    auto icon = battery.getIcon();
26    if (icon) {
27        icon->blit(s, s.width() - 19, gmenu2x.bottomBarIconY);
28    }
29}
30
31bool Background::handleButtonPress(InputManager::Button button) {
32    switch (button) {
33        case InputManager::CANCEL:
34            gmenu2x.showHelpPopup();
35            return true;
36        case InputManager::SETTINGS:
37            gmenu2x.showSettings();
38            return true;
39        default:
40            return false;
41    }
42}
43

Archive Download this file



interactive