rect_part.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #pragma once
  8. #include "base/flags.h"
  9. enum class RectPart {
  10. None = 0,
  11. TopLeft = (1 << 0),
  12. Top = (1 << 1),
  13. TopRight = (1 << 2),
  14. Left = (1 << 3),
  15. Center = (1 << 4),
  16. Right = (1 << 5),
  17. BottomLeft = (1 << 6),
  18. Bottom = (1 << 7),
  19. BottomRight = (1 << 8),
  20. FullTop = TopLeft | Top | TopRight,
  21. NoTopBottom = Left | Center | Right,
  22. FullBottom = BottomLeft | Bottom | BottomRight,
  23. NoTop = NoTopBottom | FullBottom,
  24. NoBottom = FullTop | NoTopBottom,
  25. FullLeft = TopLeft | Left | BottomLeft,
  26. NoLeftRight = Top | Center | Bottom,
  27. FullRight = TopRight | Right | BottomRight,
  28. NoLeft = NoLeftRight | FullRight,
  29. NoRight = FullLeft | NoLeftRight,
  30. AllCorners = TopLeft | TopRight | BottomLeft | BottomRight,
  31. AllSides = Top | Bottom | Left | Right,
  32. Full = FullTop | NoTop,
  33. };
  34. using RectParts = base::flags<RectPart>;
  35. inline constexpr auto is_flag_type(RectPart) { return true; };
  36. inline bool IsTopCorner(RectPart corner) {
  37. return (corner == RectPart::TopLeft) || (corner == RectPart::TopRight);
  38. }
  39. inline bool IsBottomCorner(RectPart corner) {
  40. return (corner == RectPart::BottomLeft) || (corner == RectPart::BottomRight);
  41. }
  42. inline bool IsLeftCorner(RectPart corner) {
  43. return (corner == RectPart::TopLeft) || (corner == RectPart::BottomLeft);
  44. }
  45. inline bool IsRightCorner(RectPart corner) {
  46. return (corner == RectPart::TopRight) || (corner == RectPart::BottomRight);
  47. }