| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/views/status_bubble_views.h" | 5 #include "chrome/browser/ui/views/status_bubble_views.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 public: | 74 public: |
| 75 StatusViewAnimation(StatusView* status_view, | 75 StatusViewAnimation(StatusView* status_view, |
| 76 double opacity_start, | 76 double opacity_start, |
| 77 double opacity_end); | 77 double opacity_end); |
| 78 virtual ~StatusViewAnimation(); | 78 virtual ~StatusViewAnimation(); |
| 79 | 79 |
| 80 double GetCurrentOpacity(); | 80 double GetCurrentOpacity(); |
| 81 | 81 |
| 82 private: | 82 private: |
| 83 // gfx::LinearAnimation: | 83 // gfx::LinearAnimation: |
| 84 virtual void AnimateToState(double state) OVERRIDE; | 84 virtual void AnimateToState(double state) override; |
| 85 | 85 |
| 86 // gfx::AnimationDelegate: | 86 // gfx::AnimationDelegate: |
| 87 virtual void AnimationEnded(const Animation* animation) OVERRIDE; | 87 virtual void AnimationEnded(const Animation* animation) override; |
| 88 | 88 |
| 89 StatusView* status_view_; | 89 StatusView* status_view_; |
| 90 | 90 |
| 91 // Start and end opacities for the current transition - note that as a | 91 // Start and end opacities for the current transition - note that as a |
| 92 // fade-in can easily turn into a fade out, opacity_start_ is sometimes | 92 // fade-in can easily turn into a fade out, opacity_start_ is sometimes |
| 93 // a value between 0 and 1. | 93 // a value between 0 and 1. |
| 94 double opacity_start_; | 94 double opacity_start_; |
| 95 double opacity_end_; | 95 double opacity_end_; |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(StatusViewAnimation); | 97 DISALLOW_COPY_AND_ASSIGN(StatusViewAnimation); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void OnTimer(); | 159 void OnTimer(); |
| 160 void CancelTimer(); | 160 void CancelTimer(); |
| 161 void RestartTimer(base::TimeDelta delay); | 161 void RestartTimer(base::TimeDelta delay); |
| 162 | 162 |
| 163 // Manage the fades and starting and stopping the animations correctly. | 163 // Manage the fades and starting and stopping the animations correctly. |
| 164 void StartFade(double start, double end, int duration); | 164 void StartFade(double start, double end, int duration); |
| 165 void StartHiding(); | 165 void StartHiding(); |
| 166 void StartShowing(); | 166 void StartShowing(); |
| 167 | 167 |
| 168 // views::View: | 168 // views::View: |
| 169 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 169 virtual void OnPaint(gfx::Canvas* canvas) override; |
| 170 | 170 |
| 171 BubbleState state_; | 171 BubbleState state_; |
| 172 BubbleStyle style_; | 172 BubbleStyle style_; |
| 173 | 173 |
| 174 base::WeakPtrFactory<StatusBubbleViews::StatusView> timer_factory_; | 174 base::WeakPtrFactory<StatusBubbleViews::StatusView> timer_factory_; |
| 175 | 175 |
| 176 scoped_ptr<StatusViewAnimation> animation_; | 176 scoped_ptr<StatusViewAnimation> animation_; |
| 177 | 177 |
| 178 // Handle to the widget that contains us. | 178 // Handle to the widget that contains us. |
| 179 views::Widget* popup_; | 179 views::Widget* popup_; |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 int current_width, | 484 int current_width, |
| 485 int expansion_end); | 485 int expansion_end); |
| 486 | 486 |
| 487 // Set width of fully expanded bubble. | 487 // Set width of fully expanded bubble. |
| 488 void SetExpandedWidth(int expanded_width); | 488 void SetExpandedWidth(int expanded_width); |
| 489 | 489 |
| 490 private: | 490 private: |
| 491 // Animation functions. | 491 // Animation functions. |
| 492 int GetCurrentBubbleWidth(); | 492 int GetCurrentBubbleWidth(); |
| 493 void SetBubbleWidth(int width); | 493 void SetBubbleWidth(int width); |
| 494 virtual void AnimateToState(double state) OVERRIDE; | 494 virtual void AnimateToState(double state) override; |
| 495 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 495 virtual void AnimationEnded(const gfx::Animation* animation) override; |
| 496 | 496 |
| 497 // Manager that owns us. | 497 // Manager that owns us. |
| 498 StatusBubbleViews* status_bubble_; | 498 StatusBubbleViews* status_bubble_; |
| 499 | 499 |
| 500 // Change the bounds and text of this view. | 500 // Change the bounds and text of this view. |
| 501 StatusView* status_view_; | 501 StatusView* status_view_; |
| 502 | 502 |
| 503 // Text elided (if needed) to fit maximum status bar width. | 503 // Text elided (if needed) to fit maximum status bar width. |
| 504 base::string16 expanded_text_; | 504 base::string16 expanded_text_; |
| 505 | 505 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 void StatusBubbleViews::SetBubbleWidth(int width) { | 864 void StatusBubbleViews::SetBubbleWidth(int width) { |
| 865 size_.set_width(width); | 865 size_.set_width(width); |
| 866 SetBounds(original_position_.x(), original_position_.y(), | 866 SetBounds(original_position_.x(), original_position_.y(), |
| 867 size_.width(), size_.height()); | 867 size_.width(), size_.height()); |
| 868 } | 868 } |
| 869 | 869 |
| 870 void StatusBubbleViews::CancelExpandTimer() { | 870 void StatusBubbleViews::CancelExpandTimer() { |
| 871 if (expand_timer_factory_.HasWeakPtrs()) | 871 if (expand_timer_factory_.HasWeakPtrs()) |
| 872 expand_timer_factory_.InvalidateWeakPtrs(); | 872 expand_timer_factory_.InvalidateWeakPtrs(); |
| 873 } | 873 } |
| OLD | NEW |