Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

juce_Displays.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. Manages details about connected display devices.
  18. @tags{GUI}
  19. */
  20. class JUCE_API Displays
  21. {
  22. private:
  23. Displays (Desktop&);
  24. public:
  25. /** Represents a connected display device. */
  26. struct Display
  27. {
  28. /** This will be true if this is the user's main display device. */
  29. bool isMain;
  30. /** The total area of this display in logical pixels including any OS-dependent objects
  31. like the taskbar, menu bar, etc. */
  32. Rectangle<int> totalArea;
  33. /** The total area of this display in logical pixels which isn't covered by OS-dependent
  34. objects like the taskbar, menu bar, etc.
  35. */
  36. Rectangle<int> userArea;
  37. /** The top-left of this display in physical coordinates. */
  38. Point<int> topLeftPhysical;
  39. /** The scale factor of this display.
  40. For higher-resolution displays, or displays with a user-defined scale factor set,
  41. this may be a value other than 1.0.
  42. This value is used to convert between physical and logical pixels. For example, a Component
  43. with size 10x10 will use 20x20 physical pixels on a display with a scale factor of 2.0.
  44. */
  45. double scale;
  46. /** The DPI of the display.
  47. This is the number of physical pixels per inch. To get the number of logical
  48. pixels per inch, divide this by the Display::scale value.
  49. */
  50. double dpi;
  51. };
  52. /** Converts a Rectangle from physical to logical pixels.
  53. If useScaleFactorOfDisplay is not null then its scale factor will be used for the conversion
  54. regardless of the display that the Rectangle to be converted is on.
  55. */
  56. Rectangle<int> physicalToLogical (Rectangle<int>, const Display* useScaleFactorOfDisplay = nullptr) const noexcept;
  57. /** Converts a Rectangle from logical to physical pixels.
  58. If useScaleFactorOfDisplay is not null then its scale factor will be used for the conversion
  59. regardless of the display that the Rectangle to be converted is on.
  60. */
  61. Rectangle<int> logicalToPhysical (Rectangle<int>, const Display* useScaleFactorOfDisplay = nullptr) const noexcept;
  62. /** Converts a Point from physical to logical pixels. */
  63. template <typename ValueType>
  64. Point<ValueType> physicalToLogical (Point<ValueType>, const Display* useScaleFactorOfDisplay = nullptr) const noexcept;
  65. /** Converts a Point from logical to physical pixels. */
  66. template <typename ValueType>
  67. Point<ValueType> logicalToPhysical (Point<ValueType>, const Display* useScaleFactorOfDisplay = nullptr) const noexcept;
  68. /** Returns the Display object representing the display containing a given Rectangle (either
  69. in logical or physical pixels).
  70. If the Rectangle lies outside all the displays then the nearest one will be returned.
  71. */
  72. const Display& findDisplayForRect (Rectangle<int>, bool isPhysical = false) const noexcept;
  73. /** Returns the Display object representing the display containing a given Point (either
  74. in logical or physical pixels).
  75. If the Point lies outside all the displays then the nearest one will be returned.
  76. */
  77. const Display& findDisplayForPoint (Point<int>, bool isPhysical = false) const noexcept;
  78. /** Returns the Display object representing the display acting as the user's main screen. */
  79. const Display& getMainDisplay() const noexcept;
  80. /** Returns a RectangleList made up of all the displays in LOGICAL pixels. */
  81. RectangleList<int> getRectangleList (bool userAreasOnly) const;
  82. /** Returns the smallest bounding box which contains all the displays in LOGICAL pixels. */
  83. Rectangle<int> getTotalBounds (bool userAreasOnly) const;
  84. /** An Array containing the Display objects for all of the connected displays. */
  85. Array<Display> displays;
  86. #ifndef DOXYGEN
  87. /** @internal */
  88. void refresh();
  89. /** @internal */
  90. ~Displays() = default;
  91. // This method has been deprecated - use the findDisplayForPoint() or findDisplayForRect() methods instead
  92. // as they can deal with converting between logical and physical pixels
  93. JUCE_DEPRECATED (const Display& getDisplayContaining (Point<int> position) const noexcept);
  94. #endif
  95. private:
  96. friend class Desktop;
  97. void init (Desktop&);
  98. void findDisplays (float masterScale);
  99. void updateToLogical();
  100. };
  101. } // namespace juce