BsGUIWindowFrame.cpp 1.5 KB

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