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 "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 text_rect); | 495 text_rect); |
496 } | 496 } |
497 | 497 |
498 | 498 |
499 // StatusBubbleViews::StatusViewAnimation -------------------------------------- | 499 // StatusBubbleViews::StatusViewAnimation -------------------------------------- |
500 | 500 |
501 StatusBubbleViews::StatusViewAnimation::StatusViewAnimation( | 501 StatusBubbleViews::StatusViewAnimation::StatusViewAnimation( |
502 StatusView* status_view, | 502 StatusView* status_view, |
503 float opacity_start, | 503 float opacity_start, |
504 float opacity_end) | 504 float opacity_end) |
505 : gfx::LinearAnimation(kFramerate, this), | 505 : gfx::LinearAnimation(this, kFramerate), |
506 status_view_(status_view), | 506 status_view_(status_view), |
507 opacity_start_(opacity_start), | 507 opacity_start_(opacity_start), |
508 opacity_end_(opacity_end) {} | 508 opacity_end_(opacity_end) {} |
509 | 509 |
510 StatusBubbleViews::StatusViewAnimation::~StatusViewAnimation() { | 510 StatusBubbleViews::StatusViewAnimation::~StatusViewAnimation() { |
511 // Remove ourself as a delegate so that we don't get notified when | 511 // Remove ourself as a delegate so that we don't get notified when |
512 // animations end as a result of destruction. | 512 // animations end as a result of destruction. |
513 set_delegate(NULL); | 513 set_delegate(NULL); |
514 } | 514 } |
515 | 515 |
(...skipping 14 matching lines...) Expand all Loading... |
530 } | 530 } |
531 | 531 |
532 // StatusBubbleViews::StatusViewExpander --------------------------------------- | 532 // StatusBubbleViews::StatusViewExpander --------------------------------------- |
533 // | 533 // |
534 // Manages the expansion and contraction of the status bubble as it accommodates | 534 // Manages the expansion and contraction of the status bubble as it accommodates |
535 // URLs too long to fit in the standard bubble. Changes are passed through the | 535 // URLs too long to fit in the standard bubble. Changes are passed through the |
536 // StatusView to paint. | 536 // StatusView to paint. |
537 class StatusBubbleViews::StatusViewExpander : public gfx::LinearAnimation, | 537 class StatusBubbleViews::StatusViewExpander : public gfx::LinearAnimation, |
538 public gfx::AnimationDelegate { | 538 public gfx::AnimationDelegate { |
539 public: | 539 public: |
540 StatusViewExpander(StatusBubbleViews* status_bubble, | 540 StatusViewExpander(StatusBubbleViews* status_bubble, StatusView* status_view) |
541 StatusView* status_view) | 541 : gfx::LinearAnimation(this, kFramerate), |
542 : gfx::LinearAnimation(kFramerate, this), | |
543 status_bubble_(status_bubble), | 542 status_bubble_(status_bubble), |
544 status_view_(status_view), | 543 status_view_(status_view), |
545 expansion_start_(0), | 544 expansion_start_(0), |
546 expansion_end_(0) { | 545 expansion_end_(0) {} |
547 } | |
548 | 546 |
549 // Manage the expansion of the bubble. | 547 // Manage the expansion of the bubble. |
550 void StartExpansion(const base::string16& expanded_text, | 548 void StartExpansion(const base::string16& expanded_text, |
551 int current_width, | 549 int current_width, |
552 int expansion_end); | 550 int expansion_end); |
553 | 551 |
554 private: | 552 private: |
555 // Animation functions. | 553 // Animation functions. |
556 int GetCurrentBubbleWidth(); | 554 int GetCurrentBubbleWidth(); |
557 void SetBubbleWidth(int width); | 555 void SetBubbleWidth(int width); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 void StatusBubbleViews::SetBubbleWidth(int width) { | 948 void StatusBubbleViews::SetBubbleWidth(int width) { |
951 size_.set_width(width); | 949 size_.set_width(width); |
952 SetBounds(original_position_.x(), original_position_.y(), | 950 SetBounds(original_position_.x(), original_position_.y(), |
953 size_.width(), size_.height()); | 951 size_.width(), size_.height()); |
954 } | 952 } |
955 | 953 |
956 void StatusBubbleViews::CancelExpandTimer() { | 954 void StatusBubbleViews::CancelExpandTimer() { |
957 if (expand_timer_factory_.HasWeakPtrs()) | 955 if (expand_timer_factory_.HasWeakPtrs()) |
958 expand_timer_factory_.InvalidateWeakPtrs(); | 956 expand_timer_factory_.InvalidateWeakPtrs(); |
959 } | 957 } |
OLD | NEW |