BsGUIFieldBase.cpp 1.1 KB

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