1 | // SuperTux |
2 | // Copyright (C) 2015 Hume2 <teratux.mail@gmail.com> |
3 | // |
4 | // This program is free software: you can redistribute it and/or modify |
5 | // it under the terms of the GNU General Public License as published by |
6 | // the Free Software Foundation, either version 3 of the License, or |
7 | // (at your option) any later version. |
8 | // |
9 | // This program is distributed in the hope that it will be useful, |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | // GNU General Public License for more details. |
13 | // |
14 | // You should have received a copy of the GNU General Public License |
15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | |
17 | #include "gui/item_label.hpp" |
18 | |
19 | #include "supertux/colorscheme.hpp" |
20 | #include "supertux/resources.hpp" |
21 | #include "video/drawing_context.hpp" |
22 | |
23 | ItemLabel::ItemLabel(const std::string& text_) : |
24 | MenuItem(text_) |
25 | { |
26 | } |
27 | |
28 | void |
29 | ItemLabel::draw(DrawingContext& context, const Vector& pos, int , bool active) { |
30 | context.color().draw_text(Resources::big_font, get_text(), |
31 | Vector(pos.x + static_cast<float>(menu_width) / 2.0f, |
32 | pos.y - Resources::big_font->get_height() / 2.0f ), |
33 | ALIGN_CENTER, LAYER_GUI, get_color()); |
34 | } |
35 | |
36 | Color |
37 | ItemLabel::get_color() const { |
38 | return ColorScheme::Menu::label_color; |
39 | } |
40 | |
41 | int |
42 | ItemLabel::get_width() const { |
43 | return static_cast<int>(Resources::big_font->get_text_width(get_text())) + 16; |
44 | } |
45 | |
46 | /* EOF */ |
47 | |