19 #ifndef HEADER_SKIN_HPP
20 #define HEADER_SKIN_HPP
27 #include <dimension2d.h>
31 namespace video {
class ITexture; }
32 namespace gui {
class IGUIElement;
class IGUIFont;
class IGUISpriteBank; }
38 #include "utils/leak_check.hpp"
39 #include "utils/ptr_vector.hpp"
144 int m_skin_x, m_skin_y, m_skin_w, m_skin_h;
146 bool m_skin_dest_areas_inited;
147 bool m_skin_dest_areas_yflip_inited;
148 int m_skin_dest_x, m_skin_dest_y, m_skin_dest_x2, m_skin_dest_y2;
152 core::rect<s32> m_skin_dest_area_left;
153 core::rect<s32> m_skin_dest_area_center;
154 core::rect<s32> m_skin_dest_area_right;
156 core::rect<s32> m_skin_dest_area_top;
157 core::rect<s32> m_skin_dest_area_bottom;
159 core::rect<s32> m_skin_dest_area_top_left;
160 core::rect<s32> m_skin_dest_area_top_right;
161 core::rect<s32> m_skin_dest_area_bottom_left;
162 core::rect<s32> m_skin_dest_area_bottom_right;
165 core::rect<s32> m_skin_dest_area_left_yflip;
166 core::rect<s32> m_skin_dest_area_center_yflip;
167 core::rect<s32> m_skin_dest_area_right_yflip;
169 core::rect<s32> m_skin_dest_area_top_yflip;
170 core::rect<s32> m_skin_dest_area_bottom_yflip;
172 core::rect<s32> m_skin_dest_area_top_left_yflip;
173 core::rect<s32> m_skin_dest_area_top_right_yflip;
174 core::rect<s32> m_skin_dest_area_bottom_left_yflip;
175 core::rect<s32> m_skin_dest_area_bottom_right_yflip;
177 short m_skin_r, m_skin_g, m_skin_b;
183 m_skin_dest_areas_inited =
false;
184 m_skin_dest_areas_yflip_inited =
false;
197 if (m_next !=
nullptr)
215 video::ITexture* m_image;
219 int m_left_border, m_right_border, m_top_border, m_bottom_border;
220 bool m_preserve_h_aspect_ratios;
221 float m_hborder_out_portion, m_vborder_out_portion;
222 float m_horizontal_inner_padding, m_vertical_inner_padding;
223 float m_horizontal_margin, m_vertical_margin;
227 bool m_vertical_flip;
232 static const int BODY = 1;
233 static const int LEFT = 2;
234 static const int RIGHT = 4;
235 static const int TOP = 8;
236 static const int BOTTOM = 16;
237 static const int ALL = BODY+LEFT+RIGHT+TOP+BOTTOM;
239 core::rect<s32> m_source_area_left;
240 core::rect<s32> m_source_area_center;
241 core::rect<s32> m_source_area_right;
243 core::rect<s32> m_source_area_top;
244 core::rect<s32> m_source_area_bottom;
246 core::rect<s32> m_source_area_top_left;
247 core::rect<s32> m_source_area_top_right;
248 core::rect<s32> m_source_area_bottom_left;
249 core::rect<s32> m_source_area_bottom_right;
253 core::rect<s32> m_source_area_left_yflip;
254 core::rect<s32> m_source_area_center_yflip;
255 core::rect<s32> m_source_area_right_yflip;
257 core::rect<s32> m_source_area_top_yflip;
258 core::rect<s32> m_source_area_bottom_yflip;
260 core::rect<s32> m_source_area_top_left_yflip;
261 core::rect<s32> m_source_area_top_right_yflip;
262 core::rect<s32> m_source_area_bottom_left_yflip;
263 core::rect<s32> m_source_area_bottom_right_yflip;
266 void setTexture(video::ITexture* image);
267 void calculateYFlipIfNeeded();
279 class Skin :
public gui::IGUISkin
281 gui::IGUISkin* m_fallback_skin;
283 video::ITexture* m_bg_image;
284 std::vector<Widget*> m_tooltips;
285 std::vector<bool> m_tooltip_at_mouse;
288 std::vector<std::string> m_skin_paths;
293 const core::rect< s32 > &dest,
295 bool deactivated=
false,
296 const core::rect<s32>* clipRect=NULL);
300 void process3DPane(gui::IGUIElement *element,
301 const core::rect< s32 > &rect,
const bool pressed);
302 void drawButton(
Widget* w,
const core::rect< s32 > &rect,
303 const bool pressed,
const bool focused);
304 void drawProgress(
Widget* w,
const core::rect< s32 > &rect,
305 const bool pressed,
const bool focused);
306 void drawRatingBar(
Widget* w,
const core::rect< s32 > &rect,
307 const bool pressed,
const bool focused);
308 void drawRibbon(
const core::rect< s32 > &rect,
Widget* widget,
309 const bool pressed,
bool focused);
310 void drawRibbonChild(
const core::rect< s32 > &rect,
Widget* widget,
311 const bool pressed,
bool focused);
312 void drawSpinnerChild(
const core::rect< s32 > &rect,
Widget* widget,
313 const bool pressed,
bool focused);
314 void drawSpinnerBody(
const core::rect< s32 > &rect,
Widget* widget,
315 const bool pressed,
bool focused);
316 void drawGauge(
const core::rect< s32 > &rect,
Widget* widget,
318 void drawGaugeFill(
const core::rect< s32 > &rect,
Widget* widget,
320 void drawCheckBox(
const core::rect< s32 > &rect,
Widget* widget,
322 void drawList(
const core::rect< s32 > &rect,
Widget* widget,
324 void drawListHeader(
const core::rect< s32 > &rect,
Widget* widget);
325 void drawListSelection(
const core::rect< s32 > &rect,
Widget* widget,
326 bool focused,
const core::rect< s32 > *clip);
327 void drawIconButton(
const core::rect< s32 > &rect,
Widget* widget,
328 const bool pressed,
bool focused);
329 void drawScrollbarBackground(
const core::rect< s32 > &rect);
330 void drawScrollbarThumb(
const core::rect< s32 > &rect);
331 void drawScrollbarButton(
const core::rect< s32 > &rect,
332 const bool pressed,
const bool bottomArrow);
334 void drawTooltip(
Widget* widget,
bool atMouse);
335 irr::video::SColorf getPlayerColor(
int player_id);
346 Skin(gui::IGUISkin* fallback_skin);
350 void chainLoad(std::string skin_id);
351 void resetBackgroundImage() { m_bg_image = NULL; }
352 static video::SColor getColor(
const std::string &name);
355 void drawBGFadeColor();
356 void drawBadgeOn(
const Widget* widget,
const core::rect<s32>& rect);
358 const core::rect< s32 > &rect,
359 float progress,
bool deactivated =
false);
362 virtual void draw2DRectangle (gui::IGUIElement *element,
363 const video::SColor &color,
364 const core::rect< s32 > &pos,
365 const core::rect< s32 > *clip);
366 virtual void draw3DButtonPanePressed(gui::IGUIElement *element,
367 const core::rect< s32 > &rect,
368 const core::rect< s32 > *clip);
369 virtual void draw3DButtonPaneStandard(gui::IGUIElement *element,
370 const core::rect< s32 > &rect,
371 const core::rect< s32 > *clip);
372 virtual void draw3DMenuPane (gui::IGUIElement *element,
373 const core::rect< s32 > &rect,
374 const core::rect< s32 > *clip);
375 virtual void draw3DSunkenPane (gui::IGUIElement *element,
376 video::SColor bgcolor,
377 bool flat,
bool fillBackGround,
378 const core::rect< s32 > &rect,
379 const core::rect< s32 > *clip);
380 virtual void draw3DTabBody (gui::IGUIElement *element,
bool border,
382 const core::rect< s32 > &rect,
383 const core::rect< s32 > *clip,
385 gui::EGUI_ALIGNMENT alignment=
386 gui::EGUIA_UPPERLEFT);
387 virtual void draw3DTabButton (gui::IGUIElement *element,
389 const core::rect< s32 > &rect,
390 const core::rect< s32 > *clip,
391 gui::EGUI_ALIGNMENT alignment=
392 gui::EGUIA_UPPERLEFT);
393 virtual void draw3DToolBar (gui::IGUIElement *element,
394 const core::rect< s32 > &rect,
395 const core::rect< s32 > *clip);
396 virtual core::rect< s32 >
397 draw3DWindowBackground(gui::IGUIElement *element,
399 video::SColor titleBarColor,
400 const core::rect< s32 > &rect,
401 const core::rect< s32 > *clip,
402 core::rect<s32>* checkClientArea=0);
404 virtual void draw2DImage(
const video::ITexture* texture,
const core::rect<s32>& destRect,
405 const core::rect<s32>& sourceRect,
const core::rect<s32>* clipRect,
406 const video::SColor*
const colors,
bool useAlphaChannelOfTexture);
408 virtual void drawIcon (gui::IGUIElement *element,
409 gui::EGUI_DEFAULT_ICON icon,
410 const core::position2di position,
411 u32 starttime, u32 currenttime,
413 const core::rect< s32 > *clip=NULL);
414 virtual video::SColor getColor (gui::EGUI_DEFAULT_COLOR color)
const;
415 virtual const wchar_t*
416 getDefaultText(gui::EGUI_DEFAULT_TEXT text)
const;
417 virtual gui::IGUIFont*
getFont(gui::EGUI_DEFAULT_FONT which=
418 gui::EGDF_DEFAULT)
const;
419 virtual u32 getIcon (gui::EGUI_DEFAULT_ICON icon)
const;
420 virtual s32 getSize (gui::EGUI_DEFAULT_SIZE size)
const;
422 virtual gui::IGUISpriteBank * getSpriteBank ()
const;
423 virtual void setColor (gui::EGUI_DEFAULT_COLOR which,
424 video::SColor newColor);
425 virtual void setDefaultText (gui::EGUI_DEFAULT_TEXT which,
426 const wchar_t* newText);
427 virtual void setFont (gui::IGUIFont *font,
428 gui::EGUI_DEFAULT_FONT which=gui::EGDF_DEFAULT);
429 virtual void setIcon (gui::EGUI_DEFAULT_ICON icon, u32 index);
430 virtual void setSize (gui::EGUI_DEFAULT_SIZE which, s32 size);
431 virtual void setSpriteBank (gui::IGUISpriteBank *bank);
435 const std::string &type);
437 video::ITexture* getImage(
const char* name);
439 gui::IGUISkin* getFallbackSkin() {
return m_fallback_skin; }
441 bool hasIconTheme()
const;
443 bool hasFont()
const;
445 const std::vector<std::string>& getNormalTTF()
const;
447 const std::vector<std::string>& getDigitTTF()
const;
449 const std::string& getColorEmojiTTF()
const;
451 std::string getThemedIcon(
const std::string& relative_path)
const;
453 float getScalingFactor(std::string params,
float height);
472 float getInnerPadding(
int wtype,
int rtype,
int axis);
473 float getValue(
int value_type,
int widget_type,
int ribbon_type,
int axis);
class containing render params for the 'drawBoxFromStretchableTexture' function see Overview of GUI s...
Definition: skin.hpp:214
int areas
bitmap containing which areas to render
Definition: skin.hpp:230
video::ITexture * getImage()
Returns the image for this BoxRenderParams.
Definition: skin.hpp:270
Object used to render the GUI widgets see Overview of GUI skin for more information about skinning in...
Definition: skin.hpp:280
Definition: ptr_vector.hpp:44
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
irr::gui::ScalableFont * getFont()
Definition: engine.hpp:146
Small utility to read config file info from a XML file.
Definition: skin.cpp:65