SuperTuxKart
Loading...
Searching...
No Matches
bubble_widget.hpp
1// SuperTuxKart - a fun racing game with go-kart
2// Copyright (C) 2010-2015 Marianne Gagnon
3//
4// This program is free software; you can redistribute it and/or
5// modify it under the terms of the GNU General Public License
6// as published by the Free Software Foundation; either version 3
7// of the License, or (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, write to the Free Software
16// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18#ifndef __BUBBLE_WIDGET_HPP__
19#define __BUBBLE_WIDGET_HPP__
20
21#include <rect.h>
22#include <irrString.h>
23
24#include "guiengine/widget.hpp"
25#include "utils/leak_check.hpp"
26
27namespace GUIEngine
28{
29 const int BUBBLE_MARGIN_ON_RIGHT = 15;
30
35 class BubbleWidget : public Widget
36 {
37 friend class Skin;
38
42 irr::core::rect<irr::s32> m_shrinked_size;
43
47 irr::core::rect<irr::s32> m_expanded_size;
48
50 irr::core::stringw m_shrinked_text;
51
53 float m_zoom;
54
56 void replaceText();
57
58 public:
59
60 LEAK_CHECK()
61
63
64 virtual void add();
65
66 virtual EventPropagation focused(const int playerID);
67
68 void updateSize();
69
70 void setText(const irr::core::stringw &s);
71
72 virtual int getHeightNeededAroundLabel() const { return 10; }
73 };
74
75}
76
77#endif
A text widget that can expand when focused.
Definition: bubble_widget.hpp:36
virtual int getHeightNeededAroundLabel() const
When inferring widget size from its label length, this method will be called to if/how much space mus...
Definition: bubble_widget.hpp:72
irr::core::rect< irr::s32 > m_shrinked_size
shrinked size of this widget (size allowed in layout; internal text may be bigger than that).
Definition: bubble_widget.hpp:42
float m_zoom
For the skin to create the zooming effect.
Definition: bubble_widget.hpp:53
irr::core::rect< irr::s32 > m_expanded_size
Expanded size of this widget (size to see all text inside the bubble).
Definition: bubble_widget.hpp:47
irr::core::stringw m_shrinked_text
Text shrinked to fit into the allowed layout space (will be same as m_text if all text fits)
Definition: bubble_widget.hpp:50
virtual void add()
Create and add the irrLicht widget(s) associated with this object.
Definition: bubble_widget.cpp:44
void setText(const irr::core::stringw &s)
Sets the text of a widget from a wchar_t.
Definition: bubble_widget.cpp:117
void replaceText()
Will add/replace text in the bubble.
Definition: bubble_widget.cpp:77
virtual EventPropagation focused(const int playerID)
override in children if you need to know when the widget is focused.
Definition: bubble_widget.cpp:151
Object used to render the GUI widgets see Overview of GUI skin for more information about skinning in...
Definition: skin.hpp:269
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