OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/brightness_bubble.h" | 5 #include "chrome/browser/chromeos/brightness_bubble.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "views/bubble/bubble_view.h" | |
msw
2011/10/20 19:36:13
merge and remove bubble_view.h
alicet1
2011/10/20 22:36:30
Done.
| |
11 #include "views/widget/widget.h" | |
10 | 12 |
11 namespace chromeos { | 13 namespace chromeos { |
12 | 14 |
13 BrightnessBubble::BrightnessBubble() | 15 BrightnessBubble::BrightnessBubble() : widget_(NULL) {} |
14 : SettingLevelBubble( | 16 |
15 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 17 BrightnessBubble::~BrightnessBubble() { |
18 if (widget_) | |
19 delete widget_; | |
Daniel Erat
2011/10/20 15:43:39
nit: deleting a null pointer is fine, so you can r
alicet1
2011/10/20 22:36:30
Done.
| |
20 } | |
21 | |
22 void BrightnessBubble::ShowBubble(double percent, bool enabled) { | |
23 if (!widget_) { | |
24 widget_= SettingLevelBubble::CreateSettingLevelBubble( | |
25 ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
26 IDR_BRIGHTNESS_BUBBLE_ICON), | |
27 ResourceBundle::GetSharedInstance().GetBitmapNamed( | |
16 IDR_BRIGHTNESS_BUBBLE_ICON), | 28 IDR_BRIGHTNESS_BUBBLE_ICON), |
17 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 29 ResourceBundle::GetSharedInstance().GetBitmapNamed( |
18 IDR_BRIGHTNESS_BUBBLE_ICON), | 30 IDR_BRIGHTNESS_BUBBLE_ICON), |
19 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 31 percent, |
20 IDR_BRIGHTNESS_BUBBLE_ICON)) { | 32 enabled); |
33 } else { | |
34 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) | |
35 ->UpdateSetting(percent, enabled); | |
36 } | |
37 // Starts a new fade out animation and show. | |
38 widget_->client_view()->AsBubbleView()->StartFade(/*fade_in=*/false); | |
Daniel Erat
2011/10/20 15:43:39
nit: comment style i've seen more frequently for p
Daniel Erat
2011/10/20 15:43:39
does this mean that we start fading the bubble out
alicet1
2011/10/20 22:36:30
Done.
alicet1
2011/10/20 22:36:30
yup, changed.
| |
39 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) | |
40 ->StartHideTimer(); | |
41 } | |
42 | |
43 void BrightnessBubble::UpdateWithoutShowingBubble(int level, bool enabled) { | |
44 if (widget_) | |
45 static_cast<SettingLevelBubble*>(widget_->widget_delegate()) | |
46 ->UpdateWithoutShowingBubble(level, enabled); | |
47 } | |
48 | |
49 void BrightnessBubble::HideBubble() { | |
msw
2011/10/20 19:36:13
Is this called anywhere?
alicet1
2011/10/20 22:36:30
yeah, in SystemKeyEventListener::ShowVolumeBubble,
| |
50 if (widget_) | |
51 widget_->Close(); | |
21 } | 52 } |
22 | 53 |
23 // static | 54 // static |
24 BrightnessBubble* BrightnessBubble::GetInstance() { | 55 BrightnessBubble* BrightnessBubble::GetInstance() { |
25 return Singleton<BrightnessBubble>::get(); | 56 return Singleton<BrightnessBubble>::get(); |
26 } | 57 } |
27 | 58 |
28 } // namespace chromeos | 59 } // namespace chromeos |
OLD | NEW |