Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
guiSkin.h
Go to the documentation of this file.
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __GUI_SKIN_H_INCLUDED__
6#define __GUI_SKIN_H_INCLUDED__
7
8#include "IGUISkin.h"
9#include "irrString.h"
10#include <string>
11#include "ITexture.h"
12
13namespace irr
14{
15namespace video
16{
17 class IVideoDriver;
18}
19namespace gui
20{
21 class GUISkin : public IGUISkin
22 {
23 public:
24
25 GUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver* driver);
26
28 virtual ~GUISkin();
29
31 virtual float getScale() const { return Scale; }
32
34 virtual void setScale(float scale) { Scale = scale; }
35
37 virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const;
38
40 virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor);
41
43 virtual s32 getSize(EGUI_DEFAULT_SIZE size) const;
44
46 virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size);
47
49 virtual IGUIFont* getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const;
50
52 virtual void setFont(IGUIFont* font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT);
53
55 virtual void setSpriteBank(IGUISpriteBank* bank);
56
58 virtual IGUISpriteBank* getSpriteBank() const;
59
61
62 virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const;
63
65
69 virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index);
70
72
74 virtual const wchar_t* getDefaultText(EGUI_DEFAULT_TEXT text) const;
75
77
79 virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t* newText);
80
82
90 virtual void draw3DButtonPaneStandard(IGUIElement* element,
91 const core::rect<s32>& rect,
92 const core::rect<s32>* clip=0)
93 {
94 drawColored3DButtonPaneStandard(element, rect,clip);
95 }
96
97 virtual void drawColored3DButtonPaneStandard(IGUIElement* element,
98 const core::rect<s32>& rect,
99 const core::rect<s32>* clip=0,
100 const video::SColor* colors=0);
101
103
111 virtual void draw3DButtonPanePressed(IGUIElement* element,
112 const core::rect<s32>& rect,
113 const core::rect<s32>* clip=0)
114 {
115 drawColored3DButtonPanePressed(element, rect, clip);
116 }
117
118 virtual void drawColored3DButtonPanePressed(IGUIElement* element,
119 const core::rect<s32>& rect,
120 const core::rect<s32>* clip=0,
121 const video::SColor* colors=0);
122
124
133 virtual void draw3DSunkenPane(IGUIElement* element,
134 video::SColor bgcolor, bool flat,
135 bool fillBackGround,
136 const core::rect<s32>& rect,
137 const core::rect<s32>* clip=0)
138 {
139 drawColored3DSunkenPane(element, bgcolor, flat, fillBackGround, rect, clip);
140 }
141
142 virtual void drawColored3DSunkenPane(IGUIElement* element,
143 video::SColor bgcolor, bool flat,
144 bool fillBackGround,
145 const core::rect<s32>& rect,
146 const core::rect<s32>* clip=0,
147 const video::SColor* colors=0);
148
150
163 virtual core::rect<s32> draw3DWindowBackground(IGUIElement* element,
164 bool drawTitleBar, video::SColor titleBarColor,
165 const core::rect<s32>& rect,
166 const core::rect<s32>* clip,
167 core::rect<s32>* checkClientArea)
168 {
169 return drawColored3DWindowBackground(element, drawTitleBar, titleBarColor,
170 rect, clip, checkClientArea);
171 }
172
173 virtual core::rect<s32> drawColored3DWindowBackground(IGUIElement* element,
174 bool drawTitleBar, video::SColor titleBarColor,
175 const core::rect<s32>& rect,
176 const core::rect<s32>* clip,
177 core::rect<s32>* checkClientArea,
178 const video::SColor* colors=0);
179
181
189 virtual void draw3DMenuPane(IGUIElement* element,
190 const core::rect<s32>& rect,
191 const core::rect<s32>* clip=0)
192 {
193 drawColored3DMenuPane(element, rect, clip);
194 }
195
196 virtual void drawColored3DMenuPane(IGUIElement* element,
197 const core::rect<s32>& rect,
198 const core::rect<s32>* clip=0,
199 const video::SColor* colors=0);
200
202
208 virtual void draw3DToolBar(IGUIElement* element,
209 const core::rect<s32>& rect,
210 const core::rect<s32>* clip=0)
211 {
212 drawColored3DToolBar(element, rect, clip);
213 }
214
215 virtual void drawColored3DToolBar(IGUIElement* element,
216 const core::rect<s32>& rect,
217 const core::rect<s32>* clip=0,
218 const video::SColor* colors=0);
219
221
228 virtual void draw3DTabButton(IGUIElement* element, bool active,
229 const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT)
230 {
231 drawColored3DTabButton(element, active, rect, clip, alignment);
232 }
233
234 virtual void drawColored3DTabButton(IGUIElement* element, bool active,
235 const core::rect<s32>& rect, const core::rect<s32>* clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT,
236 const video::SColor* colors=0);
237
239
246 virtual void draw3DTabBody(IGUIElement* element, bool border, bool background,
247 const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT)
248 {
249 drawColored3DTabBody(element, border, background, rect, clip, tabHeight, alignment);
250 }
251
252 virtual void drawColored3DTabBody(IGUIElement* element, bool border, bool background,
253 const core::rect<s32>& rect, const core::rect<s32>* clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT,
254 const video::SColor* colors=0);
255
257
266 virtual void drawIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
267 const core::position2di position,
268 u32 starttime=0, u32 currenttime=0,
269 bool loop=false, const core::rect<s32>* clip=0)
270 {
271 drawColoredIcon(element, icon, position, starttime, currenttime, loop, clip);
272 }
273
274 virtual void drawColoredIcon(IGUIElement* element, EGUI_DEFAULT_ICON icon,
275 const core::position2di position,
276 u32 starttime=0, u32 currenttime=0,
277 bool loop=false, const core::rect<s32>* clip=0,
278 const video::SColor* colors=0);
279
281
289 virtual void draw2DRectangle(IGUIElement* element, const video::SColor &color,
290 const core::rect<s32>& pos, const core::rect<s32>* clip = 0);
291
292
294 virtual EGUI_SKIN_TYPE getType() const;
295
297 virtual void getColors(video::SColor* colors); // ::PATCH:
298
299 private:
300
301 float Scale = 1.0f;
302 video::SColor Colors[EGDC_COUNT];
303 s32 Sizes[EGDS_COUNT];
304 u32 Icons[EGDI_COUNT];
305 IGUIFont* Fonts[EGDF_COUNT];
306 IGUISpriteBank* SpriteBank;
307 core::stringw Texts[EGDT_COUNT];
308 video::IVideoDriver* Driver;
310
311 EGUI_SKIN_TYPE Type;
312 };
313
314 #define set3DSkinColors(skin, button_color) \
315 { \
316 skin->setColor(EGDC_3D_FACE, button_color); \
317 skin->setColor(EGDC_3D_DARK_SHADOW, button_color, 0.25f); \
318 skin->setColor(EGDC_3D_SHADOW, button_color, 0.5f); \
319 skin->setColor(EGDC_3D_LIGHT, button_color); \
320 skin->setColor(EGDC_3D_HIGH_LIGHT, button_color, 1.5f); \
321 }
322
323 #define getElementSkinColor(color) \
324 { \
325 if (!Colors) \
326 { \
327 IGUISkin* skin = Environment->getSkin(); \
328 if (skin) \
329 return skin->getColor(color); \
330 } \
331 return Colors[color]; \
332 }
333
334 #define setElementSkinColor(which, newColor, shading) \
335 { \
336 if (!Colors) \
337 { \
338 Colors = new video::SColor[EGDC_COUNT]; \
339 GUISkin* skin = (GUISkin *)Environment->getSkin(); \
340 if (skin) \
341 skin->getColors(Colors); \
342 } \
343 Colors[which] = newColor; \
344 setShading(Colors[which],shading); \
345 }
346} // end namespace gui
348inline void setShading(video::SColor &color,f32 s) // :PATCH:
349{
350 if (s < 1.0f)
351 {
352 color.setRed(color.getRed() * s);
353 color.setGreen(color.getGreen() * s);
354 color.setBlue(color.getBlue() * s);
355 }
356 else if (s > 1.0f)
357 {
358 s -= 1.0f;
359
360 color.setRed(color.getRed() + (255 - color.getRed()) * s);
361 color.setGreen(color.getGreen() + (255 - color.getGreen()) * s);
362 color.setBlue(color.getBlue() + (255 - color.getBlue()) * s);
363 }
364}
365} // end namespace irr
366
367#endif
Definition guiSkin.h:22
virtual void draw3DButtonPanePressed(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0)
draws a pressed 3d button pane
Definition guiSkin.h:111
virtual void draw3DToolBar(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0)
draws a standard 3d tool bar
Definition guiSkin.h:208
virtual void drawColored3DToolBar(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, const video::SColor *colors=0)
draws a standard 3d tool bar
Definition guiSkin.cpp:754
IGUIFont * Fonts[EGDF_COUNT]
Definition guiSkin.h:305
float Scale
Definition guiSkin.h:301
virtual void setDefaultText(EGUI_DEFAULT_TEXT which, const wchar_t *newText)
Sets a default text.
Definition guiSkin.cpp:297
virtual core::rect< s32 > draw3DWindowBackground(IGUIElement *element, bool drawTitleBar, video::SColor titleBarColor, const core::rect< s32 > &rect, const core::rect< s32 > *clip, core::rect< s32 > *checkClientArea)
draws a window background
Definition guiSkin.h:163
EGUI_SKIN_TYPE Type
Definition guiSkin.h:311
virtual void drawColored3DSunkenPane(IGUIElement *element, video::SColor bgcolor, bool flat, bool fillBackGround, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, const video::SColor *colors=0)
draws a sunken 3d pane
Definition guiSkin.cpp:426
virtual void drawColored3DTabBody(IGUIElement *element, bool border, bool background, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT, const video::SColor *colors=0)
draws a tab control body
Definition guiSkin.cpp:894
virtual void setSpriteBank(IGUISpriteBank *bank)
sets the sprite bank used for drawing icons
Definition guiSkin.cpp:254
virtual void getColors(video::SColor *colors)
gets the colors
Definition guiSkin.cpp:1028
IGUISpriteBank * SpriteBank
Definition guiSkin.h:306
virtual void drawColored3DTabButton(IGUIElement *element, bool active, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT, const video::SColor *colors=0)
draws a tab button
Definition guiSkin.cpp:807
virtual void drawIcon(IGUIElement *element, EGUI_DEFAULT_ICON icon, const core::position2di position, u32 starttime=0, u32 currenttime=0, bool loop=false, const core::rect< s32 > *clip=0)
draws an icon, usually from the skin's sprite bank
Definition guiSkin.h:266
virtual EGUI_SKIN_TYPE getType() const
get the type of this skin
Definition guiSkin.cpp:1011
virtual void drawColoredIcon(IGUIElement *element, EGUI_DEFAULT_ICON icon, const core::position2di position, u32 starttime=0, u32 currenttime=0, bool loop=false, const core::rect< s32 > *clip=0, const video::SColor *colors=0)
draws an icon, usually from the skin's sprite bank
Definition guiSkin.cpp:992
u32 Icons[EGDI_COUNT]
Definition guiSkin.h:304
s32 Sizes[EGDS_COUNT]
Definition guiSkin.h:303
virtual void draw2DRectangle(IGUIElement *element, const video::SColor &color, const core::rect< s32 > &pos, const core::rect< s32 > *clip=0)
draws a 2d rectangle.
Definition guiSkin.cpp:1018
virtual void drawColored3DButtonPaneStandard(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, const video::SColor *colors=0)
draws a standard 3d button pane
Definition guiSkin.cpp:314
virtual IGUIFont * getFont(EGUI_DEFAULT_FONT which=EGDF_DEFAULT) const
returns the default font
Definition guiSkin.cpp:220
virtual IGUISpriteBank * getSpriteBank() const
gets the sprite bank used for drawing icons
Definition guiSkin.cpp:247
virtual void draw3DButtonPaneStandard(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0)
draws a standard 3d button pane
Definition guiSkin.h:90
virtual void setScale(float scale)
sets display density scaling factor
Definition guiSkin.h:34
GUISkin(EGUI_SKIN_TYPE type, video::IVideoDriver *driver)
Definition guiSkin.cpp:20
virtual void setSize(EGUI_DEFAULT_SIZE which, s32 size)
sets a default size
Definition guiSkin.cpp:212
virtual void setColor(EGUI_DEFAULT_COLOR which, video::SColor newColor)
sets a default color
Definition guiSkin.cpp:194
video::IVideoDriver * Driver
Definition guiSkin.h:308
virtual s32 getSize(EGUI_DEFAULT_SIZE size) const
returns size for the given size type
Definition guiSkin.cpp:202
virtual core::rect< s32 > drawColored3DWindowBackground(IGUIElement *element, bool drawTitleBar, video::SColor titleBarColor, const core::rect< s32 > &rect, const core::rect< s32 > *clip, core::rect< s32 > *checkClientArea, const video::SColor *colors=0)
draws a window background
Definition guiSkin.cpp:515
virtual video::SColor getColor(EGUI_DEFAULT_COLOR color) const
returns default color
Definition guiSkin.cpp:184
virtual void draw3DMenuPane(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0)
draws a standard 3d menu pane
Definition guiSkin.h:189
virtual void setIcon(EGUI_DEFAULT_ICON icon, u32 index)
Sets a default icon.
Definition guiSkin.cpp:277
virtual u32 getIcon(EGUI_DEFAULT_ICON icon) const
Returns a default icon.
Definition guiSkin.cpp:267
virtual void draw3DTabButton(IGUIElement *element, bool active, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT)
draws a tab button
Definition guiSkin.h:228
virtual void draw3DTabBody(IGUIElement *element, bool border, bool background, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, s32 tabHeight=-1, EGUI_ALIGNMENT alignment=EGUIA_UPPERLEFT)
draws a tab control body
Definition guiSkin.h:246
virtual const wchar_t * getDefaultText(EGUI_DEFAULT_TEXT text) const
Returns a default text.
Definition guiSkin.cpp:286
virtual void draw3DSunkenPane(IGUIElement *element, video::SColor bgcolor, bool flat, bool fillBackGround, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0)
draws a sunken 3d pane
Definition guiSkin.h:133
virtual ~GUISkin()
destructor
Definition guiSkin.cpp:170
virtual float getScale() const
returns display density scaling factor
Definition guiSkin.h:31
virtual void drawColored3DButtonPanePressed(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, const video::SColor *colors=0)
draws a pressed 3d button pane
Definition guiSkin.cpp:376
virtual void setFont(IGUIFont *font, EGUI_DEFAULT_FONT which=EGDF_DEFAULT)
sets a default font
Definition guiSkin.cpp:230
core::stringw Texts[EGDT_COUNT]
Definition guiSkin.h:307
bool UseGradient
Definition guiSkin.h:309
video::SColor Colors[EGDC_COUNT]
Definition guiSkin.h:302
virtual void drawColored3DMenuPane(IGUIElement *element, const core::rect< s32 > &rect, const core::rect< s32 > *clip=0, const video::SColor *colors=0)
draws a standard 3d menu pane
Definition guiSkin.cpp:670
Definition core.h:25
void setShading(video::SColor &color, f32 s)
Sets the shading.
Definition guiSkin.h:348