DecoratorUtilities.cpp 783 B

12345678910111213141516171819202122232425262728293031
  1. #include "DecoratorUtilities.h"
  2. #include "../../Include/RmlUi/Core/Property.h"
  3. namespace Rml {
  4. Vector2Numeric ComputePosition(Array<const Property*, 2> p_position)
  5. {
  6. Vector2Numeric position;
  7. for (int dimension = 0; dimension < 2; dimension++)
  8. {
  9. NumericValue& value = position[dimension];
  10. const Property& property = *p_position[dimension];
  11. if (property.unit == Unit::KEYWORD)
  12. {
  13. enum { TOP_LEFT, CENTER, BOTTOM_RIGHT };
  14. switch (property.Get<int>())
  15. {
  16. case TOP_LEFT: value = NumericValue(0.f, Unit::PERCENT); break;
  17. case CENTER: value = NumericValue(50.f, Unit::PERCENT); break;
  18. case BOTTOM_RIGHT: value = NumericValue(100.f, Unit::PERCENT); break;
  19. }
  20. }
  21. else
  22. {
  23. value = property.GetNumericValue();
  24. }
  25. }
  26. return position;
  27. }
  28. } // namespace Rml