SuperTuxKart
Loading...
Searching...
No Matches
rating_bar_widget.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2009-2015 Marianne Gagnon
3// 2013 Glenn De Jonghe
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19
20
21#ifndef HEADER_RATING_BAR_HPP
22#define HEADER_RATING_BAR_HPP
23
24#include <irrString.h>
25
26#include "guiengine/widget.hpp"
27#include "utils/leak_check.hpp"
28#include "utils/ptr_vector.hpp"
29
30namespace GUIEngine
31{
36 class RatingBarWidget : public Widget
37 {
38 private:
39 float m_rating;
40 float m_hover_rating;
41 int m_stars;
42 int m_steps;
43 std::vector<int> m_star_values;
44 bool m_hovering;
45 bool m_allow_voting;
46
47 void setStepValues(float rating);
48
49 public:
50
51 LEAK_CHECK()
52
54 virtual ~RatingBarWidget() {}
55
56
57
58 void add();
59
61 void setRating(float rating);
62
64 float getRating() {return m_rating; };
65
67 void setStarNumber(int star_number) { m_stars = star_number; };
68
70 int getStarNumber() {return m_stars; };
71
72 int getStepsOfStar(int index);
73
74 void setStepValuesByMouse(const core::position2di & mouse_position, const core::recti & stars_rect);
75
76 virtual EventPropagation onClick();
77
78 void allowVoting() { m_allow_voting = true; }
79 };
80}
81
82#endif
A rating bar widget.
Definition: rating_bar_widget.hpp:37
void add()
Create and add the irrLicht widget(s) associated with this object.
Definition: rating_bar_widget.cpp:48
void setStarNumber(int star_number)
Change the number of stars of the widget.
Definition: rating_bar_widget.hpp:67
int getStepsOfStar(int index)
Get the current step of the star.
Definition: rating_bar_widget.cpp:63
virtual EventPropagation onClick()
Gets called when the widget is active and got clicked.
Definition: rating_bar_widget.cpp:115
void setRating(float rating)
Change the rating value of the widget.
Definition: rating_bar_widget.cpp:89
int getStarNumber()
Get the current number of stars of the widget.
Definition: rating_bar_widget.hpp:70
float getRating()
Get the current value of the widget.
Definition: rating_bar_widget.hpp:64
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:143
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33