OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef ASH_WM_SCREEN_DIMMER_H_ |
| 6 #define ASH_WM_SCREEN_DIMMER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "ash/ash_export.h" |
| 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/aura/root_window_observer.h" |
| 14 |
| 15 namespace ui { |
| 16 class Layer; |
| 17 } |
| 18 |
| 19 namespace ash { |
| 20 namespace internal { |
| 21 |
| 22 // ScreenDimmer displays a partially-opaque layer above everything else to |
| 23 // darken the screen. It shouldn't be used for long-term brightness adjustments |
| 24 // due to performance considerations -- it's only intended for cases where we |
| 25 // want to briefly dim the screen (e.g. to indicate to the user that we're about |
| 26 // to suspend a machine that lacks an internal backlight that can be adjusted). |
| 27 class ASH_EXPORT ScreenDimmer : public aura::RootWindowObserver { |
| 28 public: |
| 29 class TestApi { |
| 30 public: |
| 31 explicit TestApi(ScreenDimmer* dimmer) : dimmer_(dimmer) {} |
| 32 |
| 33 ui::Layer* layer() { return dimmer_->dimming_layer_.get(); } |
| 34 |
| 35 private: |
| 36 ScreenDimmer* dimmer_; // not owned |
| 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(TestApi); |
| 39 }; |
| 40 |
| 41 ScreenDimmer(); |
| 42 virtual ~ScreenDimmer(); |
| 43 |
| 44 // Dim or undim the screen. |
| 45 void SetDimming(bool should_dim); |
| 46 |
| 47 // aura::RootWindowObserver overrides: |
| 48 virtual void OnRootWindowResized(const aura::RootWindow* root, |
| 49 const gfx::Size& old_size) OVERRIDE; |
| 50 |
| 51 private: |
| 52 friend class TestApi; |
| 53 |
| 54 // Partially-opaque layer that's stacked above all of the root window's |
| 55 // children and used to dim the screen. NULL until the first time we dim. |
| 56 scoped_ptr<ui::Layer> dimming_layer_; |
| 57 |
| 58 // Are we currently dimming the screen? |
| 59 bool currently_dimming_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(ScreenDimmer); |
| 62 }; |
| 63 |
| 64 } // namespace internal |
| 65 } // namespace ash |
| 66 |
| 67 #endif // ASH_WM_SCREEN_DIMMER_H_ |
OLD | NEW |