xoreos  0.0.5
tooltip.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_NWN_GUI_WIDGETS_TOOLTIP_H
26 #define ENGINES_NWN_GUI_WIDGETS_TOOLTIP_H
27 
28 #include <vector>
29 
30 #include "src/common/scopedptr.h"
31 #include "src/common/ptrvector.h"
32 #include "src/common/ustring.h"
33 #include "src/common/mutex.h"
34 
36 
37 #include "src/events/notifyable.h"
38 
39 #include "src/events/timerman.h"
40 
41 namespace Engines {
42 
43 class Widget;
44 
45 namespace NWN {
46 
47 class Portrait;
48 
50 class Tooltip : public Events::Notifyable {
51 public:
52  enum Type {
56  };
57 
58  Tooltip(Type type);
59  Tooltip(Type type, Widget &parent);
60  Tooltip(Type type, Graphics::Aurora::Model &parent);
61  ~Tooltip();
62 
63  void clearLines();
64  void clearPortrait();
65 
66  void addLine(const Common::UString &text, float r, float g, float b, float a);
67  void setPortrait(const Common::UString &image);
68 
69  void setAlign(float align);
70 
71  void updatePosition();
72  void setPosition(float x, float y, float z);
73 
83  void show(uint32 delay, uint32 timeOut = 0);
85  void hide();
86 
88  static uint32 getDefaultDelay();
89 
90 
91 protected:
92  void notifyCameraMoved();
93 
94 
95 private:
96  struct Line {
97  float r, g, b, a;
99  };
100 
102 
105 
106  bool _empty;
107  bool _visible;
108 
109  float _align;
110 
111  bool _showText;
114 
116 
118 
119  std::vector<Line> _lines;
121 
123 
124  float _x;
125  float _y;
126  float _z;
127 
128  float _lineHeight;
130 
131  float _width;
132  float _height;
133 
135 
138 
141 
143 
144 
145  void getSize(float &width, float &height);
146 
147  void checkEmpty();
148  void redoLines(bool force = false);
149  void redoBubble();
150  void redoLayout();
151 
152  bool createTexts(float width, size_t maxLines = 0);
153  void deleteTexts();
154 
155  uint32 doShow(uint32 oldInterval);
156  uint32 doHide(uint32 oldInterval);
157 
158  void doShow();
159  void doHide();
160 
161  void getFeedbackMode(bool &showBubble, bool &showText, bool &showPortrait) const;
162 
163  bool getParentPosition(float &x, float &y, float &z) const;
164 
165  static Common::UString getFontName();
166  static Common::UString getBubbleModel(uint32 lines, float width);
167 };
168 
169 } // End of namespace NWN
170 
171 } // End of namespace Engines
172 
173 #endif // ENGINES_NWN_GUI_WIDGETS_TOOLTIP_H
Help string when mousing over a GUI widget.
Definition: tooltip.h:53
void setAlign(float align)
Definition: tooltip.cpp:136
Events::TimerHandle _timerShow
Definition: tooltip.h:136
void hide()
Hide the tooltip again.
Definition: tooltip.cpp:275
Common::UString _font
Definition: tooltip.h:134
void getFeedbackMode(bool &showBubble, bool &showText, bool &showPortrait) const
Definition: tooltip.cpp:476
A class holding an UTF-8 string.
Definition: ustring.h:48
Graphics::Aurora::Model * _parentModel
Definition: tooltip.h:104
Widget * _parentWidget
Definition: tooltip.h:103
void getSize(float &width, float &height)
Definition: tooltip.cpp:289
Common::UString line
Definition: tooltip.h:98
A scripted speech line on an object.
Definition: tooltip.h:55
A simple scoped smart pointer template.
static Common::UString getFontName()
Definition: tooltip.cpp:499
std::vector< Line > _lines
Definition: tooltip.h:119
A mutex.
Definition: mutex.h:40
Basic Aurora graphics types.
static uint32 getDefaultDelay()
Returns the configured default delay, in ms, before a tooltip appears.
Definition: tooltip.cpp:539
void setPosition(float x, float y, float z)
Definition: tooltip.cpp:248
bool getParentPosition(float &x, float &y, float &z) const
Definition: tooltip.cpp:147
A class that can be notified by the NotificationManager.
A vector storing pointer to objects, with automatic deletion.
Common::Mutex _mutex
Definition: tooltip.h:142
void show(uint32 delay, uint32 timeOut=0)
Show the tooltip.
Definition: tooltip.cpp:258
Events::TimerHandle _timerHide
Definition: tooltip.h:137
Unicode string handling.
Thread mutex classes.
A tooltip.
Definition: tooltip.h:50
void redoLines(bool force=false)
Definition: tooltip.cpp:334
bool createTexts(float width, size_t maxLines=0)
Definition: tooltip.cpp:313
Common::ScopedPtr< Graphics::Aurora::Model > _bubble
Definition: tooltip.h:115
Name and/or portrait of an object in the 3D world.
Definition: tooltip.h:54
A widget in a GUI.
Definition: widget.h:40
void setPortrait(const Common::UString &image)
Definition: tooltip.cpp:125
uint32_t uint32
Definition: types.h:204
The global timer manager.
Tooltip(Type type)
Definition: tooltip.cpp:49
Common::PtrVector< Graphics::Aurora::Text > _texts
Definition: tooltip.h:120
Common::ScopedPtr< Portrait > _portrait
Definition: tooltip.h:117
static Common::UString getBubbleModel(uint32 lines, float width)
Definition: tooltip.cpp:503
void addLine(const Common::UString &text, float r, float g, float b, float a)
Definition: tooltip.cpp:101