| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include <gdk/gdk.h> | 9 #include <gdk/gdk.h> |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // value on the disappearing bubble; ideally we'd have a way to cancel the | 141 // value on the disappearing bubble; ideally we'd have a way to cancel the |
| 142 // fade and show the bubble at full opacity for another | 142 // fade and show the bubble at full opacity for another |
| 143 // kBubbleShowTimeoutMs. | 143 // kBubbleShowTimeoutMs. |
| 144 } else { | 144 } else { |
| 145 DCHECK(view_); | 145 DCHECK(view_); |
| 146 hide_timer_.Stop(); | 146 hide_timer_.Stop(); |
| 147 view_->SetIcon(icon); | 147 view_->SetIcon(icon); |
| 148 view_->SetEnabled(enabled); | 148 view_->SetEnabled(enabled); |
| 149 } | 149 } |
| 150 | 150 |
| 151 hide_timer_.Start(FROM_HERE, | 151 hide_timer_.Start(base::TimeDelta::FromMilliseconds(kBubbleShowTimeoutMs), |
| 152 base::TimeDelta::FromMilliseconds(kBubbleShowTimeoutMs), | |
| 153 this, &SettingLevelBubble::OnHideTimeout); | 152 this, &SettingLevelBubble::OnHideTimeout); |
| 154 } | 153 } |
| 155 | 154 |
| 156 void SettingLevelBubble::HideBubble() { | 155 void SettingLevelBubble::HideBubble() { |
| 157 if (bubble_) | 156 if (bubble_) |
| 158 bubble_->Close(); | 157 bubble_->Close(); |
| 159 } | 158 } |
| 160 | 159 |
| 161 void SettingLevelBubble::UpdateWithoutShowingBubble(double percent, | 160 void SettingLevelBubble::UpdateWithoutShowingBubble(double percent, |
| 162 bool enabled) { | 161 bool enabled) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // animation. This makes us automatically adapt to the repeat rate if a key | 225 // animation. This makes us automatically adapt to the repeat rate if a key |
| 227 // is being held down to change a setting (which prevents us from lagging | 226 // is being held down to change a setting (which prevents us from lagging |
| 228 // behind when the key is finally released). | 227 // behind when the key is finally released). |
| 229 int64 duration_ms = kInitialAnimationDurationMs; | 228 int64 duration_ms = kInitialAnimationDurationMs; |
| 230 if (!last_target_update_time_.is_null()) | 229 if (!last_target_update_time_.is_null()) |
| 231 duration_ms = min(kInitialAnimationDurationMs, | 230 duration_ms = min(kInitialAnimationDurationMs, |
| 232 (now - last_target_update_time_).InMilliseconds()); | 231 (now - last_target_update_time_).InMilliseconds()); |
| 233 target_time_ = now + TimeDelta::FromMilliseconds(duration_ms); | 232 target_time_ = now + TimeDelta::FromMilliseconds(duration_ms); |
| 234 | 233 |
| 235 if (!is_animating_) { | 234 if (!is_animating_) { |
| 236 animation_timer_.Start(FROM_HERE, | 235 animation_timer_.Start(TimeDelta::FromMilliseconds(kAnimationIntervalMs), |
| 237 TimeDelta::FromMilliseconds(kAnimationIntervalMs), | |
| 238 this, | 236 this, |
| 239 &SettingLevelBubble::OnAnimationTimeout); | 237 &SettingLevelBubble::OnAnimationTimeout); |
| 240 is_animating_ = true; | 238 is_animating_ = true; |
| 241 last_animation_update_time_ = now; | 239 last_animation_update_time_ = now; |
| 242 } | 240 } |
| 243 } | 241 } |
| 244 | 242 |
| 245 last_target_update_time_ = now; | 243 last_target_update_time_ = now; |
| 246 } | 244 } |
| 247 | 245 |
| 248 void SettingLevelBubble::StopAnimation() { | 246 void SettingLevelBubble::StopAnimation() { |
| 249 animation_timer_.Stop(); | 247 animation_timer_.Stop(); |
| 250 is_animating_ = false; | 248 is_animating_ = false; |
| 251 } | 249 } |
| 252 | 250 |
| 253 } // namespace chromeos | 251 } // namespace chromeos |
| OLD | NEW |