1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef VibrancyManager_h
8 #define VibrancyManager_h
10 #include "mozilla/EnumeratedArray.h"
20 enum class VibrancyType
{
22 // Add new values here, or update MaxEnumValue below if you add them after.
27 struct MaxContiguousEnumValue
<VibrancyType
> {
28 static constexpr auto value
= VibrancyType::Titlebar
;
32 * VibrancyManager takes care of updating the vibrant regions of a window.
33 * Vibrancy is a visual look that was introduced on OS X starting with 10.10.
34 * An app declares vibrant window regions to the window server, and the window
35 * server will display a blurred rendering of the screen contents from behind
36 * the window in these areas, behind the actual window contents. Consequently,
37 * the effect is only visible in areas where the window contents are not
38 * completely opaque. Usually this is achieved by clearing the background of
39 * the window prior to drawing in the vibrant areas. This is possible even if
40 * the window is declared as opaque.
42 class VibrancyManager
{
45 * Create a new VibrancyManager instance and provide it with an NSView
46 * to attach NSVisualEffectViews to.
48 * @param aCoordinateConverter The nsChildView to use for converting
49 * nsIntRect device pixel coordinates into Cocoa NSRect coordinates. Must
50 * outlive this VibrancyManager instance.
51 * @param aContainerView The view that's going to be the superview of the
52 * NSVisualEffectViews which will be created for vibrant regions.
54 VibrancyManager(const nsChildView
& aCoordinateConverter
,
55 NSView
* aContainerView
);
60 * Update the placement of the NSVisualEffectViews inside the container
61 * NSView so that they cover aRegion, and create new NSVisualEffectViews
62 * or remove existing ones as needed.
63 * @param aType The vibrancy type to use in the region.
64 * @param aRegion The vibrant area, in device pixels.
65 * @return Whether the region changed.
67 bool UpdateVibrantRegion(VibrancyType aType
,
68 const LayoutDeviceIntRegion
& aRegion
);
73 const nsChildView
& mCoordinateConverter
;
74 NSView
* mContainerView
;
75 EnumeratedArray
<VibrancyType
, UniquePtr
<ViewRegion
>> mVibrantRegions
;
78 } // namespace mozilla
80 #endif // VibrancyManager_h