BsGUIFieldBase.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "BsGUIFieldBase.h"
  2. #include "BsGUILabel.h"
  3. #include "BsGUILayoutX.h"
  4. #include "BsGUIWidget.h"
  5. #include "BsGUISkin.h"
  6. #include "BsGUILayoutUtility.h"
  7. namespace BansheeEngine
  8. {
  9. const UINT32 GUIFieldBase::DEFAULT_LABEL_WIDTH = 100;
  10. GUIFieldBase::GUIFieldBase(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  11. const String& style, const GUIDimensions& dimensions, bool withLabel)
  12. :GUIElementContainer(dimensions, style), mLabel(nullptr)
  13. {
  14. mLayout = GUILayoutX::create();
  15. _registerChildElement(mLayout);
  16. if(withLabel)
  17. {
  18. mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(getLabelStyleType()));
  19. mLayout->addElement(mLabel);
  20. }
  21. }
  22. void GUIFieldBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
  23. Rect2I clipRect, UINT8 widgetDepth, INT16 panelDepth, UINT16 panelDepthRangeMin, UINT16 panelDepthRangeMax)
  24. {
  25. mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, panelDepth, panelDepthRangeMin, panelDepthRangeMax);
  26. }
  27. Vector2I GUIFieldBase::_getOptimalSize() const
  28. {
  29. return GUILayoutUtility::calcOptimalSize(mLayout);
  30. }
  31. void GUIFieldBase::styleUpdated()
  32. {
  33. if (mLabel != nullptr)
  34. mLabel->setStyle(getSubStyleName(getLabelStyleType()));
  35. }
  36. }