resize_utils.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_GEOMETRY_RESIZE_UTILS_H_
  5. #define UI_GFX_GEOMETRY_RESIZE_UTILS_H_
  6. #include "third_party/abseil-cpp/absl/types/optional.h"
  7. #include "ui/gfx/geometry/geometry_export.h"
  8. namespace gfx {
  9. class Rect;
  10. class Size;
  11. enum class ResizeEdge {
  12. kBottom,
  13. kBottomLeft,
  14. kBottomRight,
  15. kLeft,
  16. kRight,
  17. kTop,
  18. kTopLeft,
  19. kTopRight
  20. };
  21. // Updates |rect| to adhere to the |aspect_ratio| of the window, if it has
  22. // been set. |resize_edge| refers to the edge of the window being sized.
  23. // |min_window_size| and |max_window_size| are expected to adhere to the
  24. // given aspect ratio.
  25. // |aspect_ratio| must be valid and is found using width / height.
  26. void GEOMETRY_EXPORT SizeRectToAspectRatio(ResizeEdge resize_edge,
  27. float aspect_ratio,
  28. const Size& min_window_size,
  29. absl::optional<Size> max_window_size,
  30. Rect* rect);
  31. } // namespace gfx
  32. #endif // UI_GFX_GEOMETRY_RESIZE_UTILS_H_