BsGUIVector4Field.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "BsGUIVector4Field.h"
  2. #include "BsGUIArea.h"
  3. #include "BsGUILayout.h"
  4. #include "BsGUILabel.h"
  5. #include "BsGUIFloatField.h"
  6. #include "BsBuiltinResources.h"
  7. #include "BsGUIWidget.h"
  8. #include "BsGUIMouseEvent.h"
  9. #include "BsGUIWidget.h"
  10. using namespace CamelotFramework;
  11. using namespace BansheeEngine;
  12. namespace BansheeEditor
  13. {
  14. const UINT32 GUIVector4Field::ELEMENT_LABEL_WIDTH = 10;
  15. GUIVector4Field::GUIVector4Field(const PrivatelyConstruct& dummy, GUIWidget& parent, const GUIContent& labelContent,
  16. CM::UINT32 labelWidth, GUIElementStyle* labelStyle, GUIElementStyle* inputBoxStyle, const GUILayoutOptions& layoutOptions, bool withLabel)
  17. :TGUIField(dummy, parent, labelContent, labelWidth, labelStyle, layoutOptions, withLabel), mFieldX(nullptr), mFieldY(nullptr)
  18. {
  19. mFieldX = GUIFloatField::create(parent, HString(L"X"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
  20. mFieldY = GUIFloatField::create(parent, HString(L"Y"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
  21. mFieldZ = GUIFloatField::create(parent, HString(L"Z"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
  22. mFieldW = GUIFloatField::create(parent, HString(L"W"), ELEMENT_LABEL_WIDTH, labelStyle, inputBoxStyle);
  23. mLayout->removeElement(mLabel);
  24. GUILayout* layout = &mLayout->addLayoutY();
  25. layout->addElement(mLabel);
  26. GUILayout* elementLayout = &layout->addLayoutX();
  27. elementLayout->addElement(mFieldX);
  28. elementLayout->addElement(mFieldY);
  29. elementLayout->addElement(mFieldZ);
  30. elementLayout->addElement(mFieldW);
  31. }
  32. Vector4 GUIVector4Field::getValue() const
  33. {
  34. Vector4 value;
  35. value.x = mFieldX->getValue();
  36. value.y = mFieldY->getValue();
  37. value.z = mFieldZ->getValue();
  38. value.w = mFieldW->getValue();
  39. return value;
  40. }
  41. void GUIVector4Field::setValue(const Vector4& value)
  42. {
  43. mFieldX->setValue(value.x);
  44. mFieldY->setValue(value.y);
  45. mFieldZ->setValue(value.z);
  46. mFieldW->setValue(value.w);
  47. }
  48. const String& GUIVector4Field::getGUITypeName()
  49. {
  50. static String typeName = "GUIVector4Field";
  51. return typeName;
  52. }
  53. }