size.cpp 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #if defined(Hiro_Size)
  2. Size::Size() {
  3. setSize(0, 0);
  4. }
  5. Size::Size(float width, float height) {
  6. setSize(width, height);
  7. }
  8. Size::operator bool() const {
  9. return state.width || state.height;
  10. }
  11. auto Size::operator==(const Size& source) const -> bool {
  12. return width() == source.width() && height() == source.height();
  13. }
  14. auto Size::operator!=(const Size& source) const -> bool {
  15. return !operator==(source);
  16. }
  17. auto Size::height() const -> float {
  18. return state.height;
  19. }
  20. auto Size::reset() -> type& {
  21. return setSize(0, 0);
  22. }
  23. auto Size::setHeight(float height) -> type& {
  24. state.height = height;
  25. return *this;
  26. }
  27. auto Size::setSize(Size size) -> type& {
  28. return setSize(size.width(), size.height());
  29. }
  30. auto Size::setSize(float width, float height) -> type& {
  31. state.width = width;
  32. state.height = height;
  33. return *this;
  34. }
  35. auto Size::setWidth(float width) -> type& {
  36. state.width = width;
  37. return *this;
  38. }
  39. auto Size::width() const -> float {
  40. return state.width;
  41. }
  42. #endif