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_colordisplay.hpp"
18
19#include "video/drawing_context.hpp"
20
21ItemColorDisplay::ItemColorDisplay(Color* color, int id_) :
22 MenuItem("", id_),
23 old_color(*color),
24 new_color(color)
25{
26}
27
28void
29ItemColorDisplay::draw(DrawingContext& context, const Vector& pos, int menu_width, bool active) {
30 float m = static_cast<float>(menu_width) / 2.0f;
31 context.color().draw_filled_rect(Rectf(pos + Vector(16, -8), pos + Vector(m, 8.0f)),
32 old_color, 0.0f, LAYER_GUI-1);
33 context.color().draw_filled_rect(Rectf(pos + Vector(m, -8), pos + Vector(static_cast<float>(menu_width) - 16.0f, 8.0f)),
34 *new_color, 0.0f, LAYER_GUI-1);
35}
36
37int
38ItemColorDisplay::get_width() const {
39 return 0;
40}
41
42/* EOF */
43