BsGUIFieldBase.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "BsGUIFieldBase.h"
  2. #include "BsGUILabel.h"
  3. #include "BsGUILayout.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 GUILayoutOptions& layoutOptions, bool withLabel)
  12. :GUIElementContainer(layoutOptions, style), mLabel(nullptr)
  13. {
  14. mLayout = &addLayoutXInternal(this);
  15. if(withLabel)
  16. {
  17. mLabel = GUILabel::create(labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), getSubStyleName(getLabelStyleType()));
  18. mLayout->addElement(mLabel);
  19. }
  20. }
  21. void GUIFieldBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
  22. Rect2I clipRect, UINT8 widgetDepth, UINT16 areaDepth)
  23. {
  24. mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
  25. }
  26. Vector2I GUIFieldBase::_getOptimalSize() const
  27. {
  28. return GUILayoutUtility::calcOptimalSize(mLayout);
  29. }
  30. void GUIFieldBase::styleUpdated()
  31. {
  32. if (mLabel != nullptr)
  33. mLabel->setStyle(getSubStyleName(getLabelStyleType()));
  34. }
  35. }