1 // Copyright (c) 2012 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.
5 #ifndef ASH_WM_SCREEN_DIMMER_H_
6 #define ASH_WM_SCREEN_DIMMER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/aura/window_observer.h"
20 // ScreenDimmer displays a partially-opaque layer above everything
21 // else in the root window to darken the display. It shouldn't be used
22 // for long-term brightness adjustments due to performance
23 // considerations -- it's only intended for cases where we want to
24 // briefly dim the screen (e.g. to indicate to the user that we're
25 // about to suspend a machine that lacks an internal backlight that
27 class ASH_EXPORT ScreenDimmer
: public aura::WindowObserver
{
31 explicit TestApi(ScreenDimmer
* dimmer
) : dimmer_(dimmer
) {}
33 ui::Layer
* layer() { return dimmer_
->dimming_layer_
.get(); }
36 ScreenDimmer
* dimmer_
; // not owned
38 DISALLOW_COPY_AND_ASSIGN(TestApi
);
41 explicit ScreenDimmer(aura::Window
* root_window
);
42 virtual ~ScreenDimmer();
44 // Dim or undim the root window.
45 void SetDimming(bool should_dim
);
47 // aura::WindowObserver overrides:
48 virtual void OnWindowBoundsChanged(aura::Window
* root_window
,
49 const gfx::Rect
& old_bounds
,
50 const gfx::Rect
& new_bounds
) OVERRIDE
;
55 aura::Window
* root_window_
;
57 // Partially-opaque layer that's stacked above all of the root window's
58 // children and used to dim the screen. NULL until the first time we dim.
59 scoped_ptr
<ui::Layer
> dimming_layer_
;
61 // Are we currently dimming the screen?
62 bool currently_dimming_
;
64 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer
);
69 #endif // ASH_WM_SCREEN_DIMMER_H_