BsGUIFieldBase.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "BsGUIFieldBase.h"
  2. #include "BsGUILabel.h"
  3. #include "BsGUILayout.h"
  4. #include "BsGUIWidget.h"
  5. #include "BsGUISkin.h"
  6. using namespace CamelotFramework;
  7. using namespace BansheeEngine;
  8. namespace BansheeEditor
  9. {
  10. const UINT32 GUIFieldBase::DEFAULT_LABEL_WIDTH = 100;
  11. GUIFieldBase::GUIFieldBase(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent, UINT32 labelWidth,
  12. GUIElementStyle* labelStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
  13. :GUIElementContainer(parent, layoutOptions)
  14. {
  15. mLayout = &addLayoutXInternal(this);
  16. if(withLabel)
  17. {
  18. const GUIElementStyle* curLabelStyle = labelStyle;
  19. if(curLabelStyle == nullptr)
  20. curLabelStyle = parent.getSkin().getStyle("Label");
  21. mLabel = BS::GUILabel::create(parent, labelContent, GUIOptions(GUIOption::fixedWidth(labelWidth)), curLabelStyle);
  22. mLayout->addElement(mLabel);
  23. }
  24. }
  25. void GUIFieldBase::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
  26. RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
  27. {
  28. mLayout->_updateLayoutInternal(x, y, width, height, clipRect, widgetDepth, areaDepth);
  29. }
  30. Vector2I GUIFieldBase::_getOptimalSize() const
  31. {
  32. return mLayout->_getOptimalSize();
  33. }
  34. }