BsGUIWindowFrame.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "BsGUIWindowFrame.h"
  2. #include "BsGUISkin.h"
  3. #include "BsGUIDimensions.h"
  4. namespace BansheeEngine
  5. {
  6. const String& GUIWindowFrame::getGUITypeName()
  7. {
  8. static String name = "WindowFrame";
  9. return name;
  10. }
  11. GUIWindowFrame::GUIWindowFrame(const String& styleName, const GUIDimensions& dimensions)
  12. :GUITexture(styleName, HSpriteTexture(), GUIImageScaleMode::StretchToFit, true, dimensions)
  13. {
  14. }
  15. GUIWindowFrame::~GUIWindowFrame()
  16. { }
  17. GUIWindowFrame* GUIWindowFrame::create(const String& styleName)
  18. {
  19. return new (bs_alloc<GUIWindowFrame>()) GUIWindowFrame(getStyleName<GUIWindowFrame>(styleName), GUIDimensions::create());
  20. }
  21. GUIWindowFrame* GUIWindowFrame::create(const GUIOptions& options, const String& styleName)
  22. {
  23. return new (bs_alloc<GUIWindowFrame>()) GUIWindowFrame(getStyleName<GUIWindowFrame>(styleName), GUIDimensions::create(options));
  24. }
  25. void GUIWindowFrame::setFocused(bool focused)
  26. {
  27. Vector2I origSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;
  28. if(focused)
  29. mActiveTexture = _getStyle()->focused.texture;
  30. else
  31. mActiveTexture = _getStyle()->normal.texture;
  32. Vector2I newSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;
  33. if (origSize != newSize)
  34. _markLayoutAsDirty();
  35. else
  36. _markContentAsDirty();
  37. }
  38. }