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/setting_level_bubble.h" | 5 #include "chrome/browser/chromeos/setting_level_bubble.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 | 8 |
9 #include "base/timer.h" | 9 #include "base/timer.h" |
10 #include "chrome/browser/chromeos/login/background_view.h" | 10 #include "chrome/browser/chromeos/login/background_view.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DCHECK(view_ == NULL); | 105 DCHECK(view_ == NULL); |
106 view_ = new SettingLevelBubbleView; | 106 view_ = new SettingLevelBubbleView; |
107 view_->Init(icon, previous_percent_); | 107 view_->Init(icon, previous_percent_); |
108 // Calculate position of the bubble. | 108 // Calculate position of the bubble. |
109 gfx::Rect bounds = widget->GetClientAreaScreenBounds(); | 109 gfx::Rect bounds = widget->GetClientAreaScreenBounds(); |
110 const gfx::Size view_size = view_->GetPreferredSize(); | 110 const gfx::Size view_size = view_->GetPreferredSize(); |
111 // Note that (x, y) is the point of the center of the bubble. | 111 // Note that (x, y) is the point of the center of the bubble. |
112 const int x = view_size.width() / 2 + | 112 const int x = view_size.width() / 2 + |
113 kBubbleXRatio * (bounds.width() - view_size.width()); | 113 kBubbleXRatio * (bounds.width() - view_size.width()); |
114 const int y = bounds.height() - view_size.height() / 2 - kBubbleBottomGap; | 114 const int y = bounds.height() - view_size.height() / 2 - kBubbleBottomGap; |
| 115 |
| 116 // ShowFocusless doesn't set ESC accelerator. The Esc key is handled in |
| 117 // SystemKeyEventListener instead. |
115 bubble_ = Bubble::ShowFocusless(widget, // parent | 118 bubble_ = Bubble::ShowFocusless(widget, // parent |
116 gfx::Rect(x, y, 0, 20), | 119 gfx::Rect(x, y, 0, 20), |
117 BubbleBorder::FLOAT, | 120 BubbleBorder::FLOAT, |
118 view_, // contents | 121 view_, // contents |
119 this, // delegate | 122 this, // delegate |
120 true); // show while screen is locked | 123 true); // show while screen is locked |
121 } else { | 124 } else { |
122 DCHECK(view_); | 125 DCHECK(view_); |
123 timeout_timer_.Stop(); | 126 timeout_timer_.Stop(); |
124 view_->SetIcon(icon); | 127 view_->SetIcon(icon); |
125 } | 128 } |
126 if (animation_.is_animating()) | 129 if (animation_.is_animating()) |
127 animation_.End(); | 130 animation_.End(); |
128 animation_.Reset(); | 131 animation_.Reset(); |
129 animation_.Show(); | 132 animation_.Show(); |
130 timeout_timer_.Start(base::TimeDelta::FromSeconds(kBubbleShowTimeoutSec), | 133 timeout_timer_.Start(base::TimeDelta::FromSeconds(kBubbleShowTimeoutSec), |
131 this, &SettingLevelBubble::OnTimeout); | 134 this, &SettingLevelBubble::OnTimeout); |
132 } | 135 } |
133 | 136 |
134 void SettingLevelBubble::HideBubble() { | 137 void SettingLevelBubble::HideBubble() { |
135 if (bubble_) | 138 if (bubble_) |
136 bubble_->Close(); | 139 bubble_->Close(); |
137 } | 140 } |
138 | 141 |
| 142 bool SettingLevelBubble::IsShown() const { |
| 143 return bubble_ != NULL; |
| 144 } |
| 145 |
139 void SettingLevelBubble::UpdateWithoutShowingBubble(int percent) { | 146 void SettingLevelBubble::UpdateWithoutShowingBubble(int percent) { |
140 percent = LimitPercent(percent); | 147 percent = LimitPercent(percent); |
141 | 148 |
142 previous_percent_ = | 149 previous_percent_ = |
143 animation_.is_animating() ? | 150 animation_.is_animating() ? |
144 animation_.GetCurrentValue() : | 151 animation_.GetCurrentValue() : |
145 current_percent_; | 152 current_percent_; |
146 if (previous_percent_ < 0) | 153 if (previous_percent_ < 0) |
147 previous_percent_ = percent; | 154 previous_percent_ = percent; |
148 current_percent_ = percent; | 155 current_percent_ = percent; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void SettingLevelBubble::AnimationProgressed(const ui::Animation* animation) { | 187 void SettingLevelBubble::AnimationProgressed(const ui::Animation* animation) { |
181 if (view_) { | 188 if (view_) { |
182 view_->Update( | 189 view_->Update( |
183 ui::Tween::ValueBetween(animation->GetCurrentValue(), | 190 ui::Tween::ValueBetween(animation->GetCurrentValue(), |
184 previous_percent_, | 191 previous_percent_, |
185 current_percent_)); | 192 current_percent_)); |
186 } | 193 } |
187 } | 194 } |
188 | 195 |
189 } // namespace chromeos | 196 } // namespace chromeos |
OLD | NEW |