BsGUIWindowFrame.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "GUI/BsGUIWindowFrame.h"
  4. #include "GUI/BsGUISkin.h"
  5. #include "GUI/BsGUIDimensions.h"
  6. namespace bs
  7. {
  8. const String& GUIWindowFrame::getGUITypeName()
  9. {
  10. static String name = "WindowFrame";
  11. return name;
  12. }
  13. GUIWindowFrame::GUIWindowFrame(const String& styleName, const GUIDimensions& dimensions)
  14. :GUITexture(styleName, HSpriteTexture(), TextureScaleMode::StretchToFit, true, dimensions)
  15. {
  16. }
  17. GUIWindowFrame::~GUIWindowFrame()
  18. { }
  19. GUIWindowFrame* GUIWindowFrame::create(const String& styleName)
  20. {
  21. return new (bs_alloc<GUIWindowFrame>()) GUIWindowFrame(getStyleName<GUIWindowFrame>(styleName), GUIDimensions::create());
  22. }
  23. GUIWindowFrame* GUIWindowFrame::create(const GUIOptions& options, const String& styleName)
  24. {
  25. return new (bs_alloc<GUIWindowFrame>()) GUIWindowFrame(getStyleName<GUIWindowFrame>(styleName), GUIDimensions::create(options));
  26. }
  27. void GUIWindowFrame::setFocused(bool focused)
  28. {
  29. Vector2I origSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;
  30. if(focused)
  31. mActiveTexture = _getStyle()->focused.texture;
  32. else
  33. mActiveTexture = _getStyle()->normal.texture;
  34. Vector2I newSize = mDimensions.calculateSizeRange(_getOptimalSize()).optimal;
  35. if (origSize != newSize)
  36. _markLayoutAsDirty();
  37. else
  38. _markContentAsDirty();
  39. }
  40. }