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_controlfield.hpp" |
18 | |
19 | #include "supertux/colorscheme.hpp" |
20 | #include "supertux/resources.hpp" |
21 | #include "video/drawing_context.hpp" |
22 | |
23 | ItemControlField::ItemControlField(const std::string& text, const std::string& input_, int id) : |
24 | MenuItem(text, id), |
25 | input(input_) |
26 | { |
27 | } |
28 | |
29 | void |
30 | ItemControlField::draw(DrawingContext& context, const Vector& pos, int , bool active) |
31 | { |
32 | context.color().draw_text(Resources::normal_font, input, |
33 | Vector(pos.x + static_cast<float>(menu_width) - 16.0f, |
34 | pos.y - static_cast<float>(int(Resources::normal_font->get_height()/2))), |
35 | ALIGN_RIGHT, LAYER_GUI, ColorScheme::Menu::field_color); |
36 | context.color().draw_text(Resources::normal_font, get_text(), |
37 | Vector(pos.x + 16.0f, |
38 | pos.y - static_cast<float>(int(Resources::normal_font->get_height()/2))), |
39 | ALIGN_LEFT, LAYER_GUI, active ? ColorScheme::Menu::active_color : get_color()); |
40 | } |
41 | |
42 | int |
43 | ItemControlField::get_width() const { |
44 | return static_cast<int>(Resources::normal_font->get_text_width(get_text()) + Resources::normal_font->get_text_width(input) + 16.0f); |
45 | } |
46 | |
47 | /* EOF */ |
48 | |