Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/ui/views/status_bubble_views.cc

Issue 10069043: Makes the status bubble less janky on chromeos. Any time the bounds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add null check Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/status_bubble_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 static const int kMinExpansionStepDurationMS = 20; 65 static const int kMinExpansionStepDurationMS = 20;
66 static const int kMaxExpansionStepDurationMS = 150; 66 static const int kMaxExpansionStepDurationMS = 150;
67 67
68 // View ----------------------------------------------------------------------- 68 // View -----------------------------------------------------------------------
69 // StatusView manages the display of the bubble, applying text changes and 69 // StatusView manages the display of the bubble, applying text changes and
70 // fading in or out the bubble as required. 70 // fading in or out the bubble as required.
71 class StatusBubbleViews::StatusView : public views::Label, 71 class StatusBubbleViews::StatusView : public views::Label,
72 public ui::LinearAnimation, 72 public ui::LinearAnimation,
73 public ui::AnimationDelegate { 73 public ui::AnimationDelegate {
74 public: 74 public:
75 StatusView(StatusBubble* status_bubble, views::Widget* popup, 75 StatusView(StatusBubble* status_bubble,
76 views::Widget* popup,
76 ui::ThemeProvider* theme_provider) 77 ui::ThemeProvider* theme_provider)
77 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::LinearAnimation(kFramerate, this)), 78 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::LinearAnimation(kFramerate, this)),
78 stage_(BUBBLE_HIDDEN), 79 stage_(BUBBLE_HIDDEN),
79 style_(STYLE_STANDARD), 80 style_(STYLE_STANDARD),
80 ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)), 81 ALLOW_THIS_IN_INITIALIZER_LIST(timer_factory_(this)),
81 status_bubble_(status_bubble), 82 status_bubble_(status_bubble),
82 popup_(popup), 83 popup_(popup),
83 opacity_start_(0), 84 opacity_start_(0),
84 opacity_end_(0), 85 opacity_end_(0),
85 theme_service_(theme_provider) { 86 theme_service_(theme_provider) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 307 }
307 308
308 // Animation functions. 309 // Animation functions.
309 double StatusBubbleViews::StatusView::GetCurrentOpacity() { 310 double StatusBubbleViews::StatusView::GetCurrentOpacity() {
310 return opacity_start_ + (opacity_end_ - opacity_start_) * 311 return opacity_start_ + (opacity_end_ - opacity_start_) *
311 ui::LinearAnimation::GetCurrentValue(); 312 ui::LinearAnimation::GetCurrentValue();
312 } 313 }
313 314
314 void StatusBubbleViews::StatusView::SetOpacity(double opacity) { 315 void StatusBubbleViews::StatusView::SetOpacity(double opacity) {
315 popup_->SetOpacity(static_cast<unsigned char>(opacity * 255)); 316 popup_->SetOpacity(static_cast<unsigned char>(opacity * 255));
316 SchedulePaint();
317 } 317 }
318 318
319 void StatusBubbleViews::StatusView::AnimateToState(double state) { 319 void StatusBubbleViews::StatusView::AnimateToState(double state) {
320 SetOpacity(GetCurrentOpacity()); 320 SetOpacity(GetCurrentOpacity());
321 } 321 }
322 322
323 void StatusBubbleViews::StatusView::AnimationEnded( 323 void StatusBubbleViews::StatusView::AnimationEnded(
324 const ui::Animation* animation) { 324 const ui::Animation* animation) {
325 SetOpacity(opacity_end_); 325 SetOpacity(opacity_end_);
326 326
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 void StatusBubbleViews::StatusViewExpander::SetBubbleWidth(int width) { 537 void StatusBubbleViews::StatusViewExpander::SetBubbleWidth(int width) {
538 status_bubble_->SetBubbleWidth(width); 538 status_bubble_->SetBubbleWidth(width);
539 status_view_->SchedulePaint(); 539 status_view_->SchedulePaint();
540 } 540 }
541 541
542 // StatusBubble --------------------------------------------------------------- 542 // StatusBubble ---------------------------------------------------------------
543 543
544 const int StatusBubbleViews::kShadowThickness = 1; 544 const int StatusBubbleViews::kShadowThickness = 1;
545 545
546 StatusBubbleViews::StatusBubbleViews(views::View* base_view) 546 StatusBubbleViews::StatusBubbleViews(views::View* base_view)
547 : offset_(0), 547 : contains_mouse_(false),
548 offset_(0),
548 popup_(NULL), 549 popup_(NULL),
549 opacity_(0), 550 opacity_(0),
550 base_view_(base_view), 551 base_view_(base_view),
551 view_(NULL), 552 view_(NULL),
552 download_shelf_is_visible_(false), 553 download_shelf_is_visible_(false),
553 is_expanded_(false), 554 is_expanded_(false),
554 ALLOW_THIS_IN_INITIALIZER_LIST(expand_timer_factory_(this)) { 555 ALLOW_THIS_IN_INITIALIZER_LIST(expand_timer_factory_(this)) {
555 expand_view_.reset(); 556 expand_view_.reset();
556 } 557 }
557 558
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 gfx::Size StatusBubbleViews::GetPreferredSize() { 598 gfx::Size StatusBubbleViews::GetPreferredSize() {
598 return gfx::Size(0, ui::ResourceBundle::GetSharedInstance().GetFont( 599 return gfx::Size(0, ui::ResourceBundle::GetSharedInstance().GetFont(
599 ui::ResourceBundle::BaseFont).GetHeight() + kTotalVerticalPadding); 600 ui::ResourceBundle::BaseFont).GetHeight() + kTotalVerticalPadding);
600 } 601 }
601 602
602 void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { 603 void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {
603 original_position_.SetPoint(x, y); 604 original_position_.SetPoint(x, y);
604 position_.SetPoint(base_view_->GetMirroredXWithWidthInView(x, w), y); 605 position_.SetPoint(base_view_->GetMirroredXWithWidthInView(x, w), y);
605 size_.SetSize(w, h); 606 size_.SetSize(w, h);
606 Reposition(); 607 Reposition();
608 if (popup_.get() && contains_mouse_)
609 AvoidMouse(last_mouse_moved_location_);
607 } 610 }
608 611
609 void StatusBubbleViews::SetStatus(const string16& status_text) { 612 void StatusBubbleViews::SetStatus(const string16& status_text) {
610 if (size_.IsEmpty()) 613 if (size_.IsEmpty())
611 return; // We have no bounds, don't attempt to show the popup. 614 return; // We have no bounds, don't attempt to show the popup.
612 615
613 if (status_text_ == status_text && !status_text.empty()) 616 if (status_text_ == status_text && !status_text.empty())
614 return; 617 return;
615 618
616 if (!IsFrameVisible()) 619 if (!IsFrameVisible())
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 688
686 void StatusBubbleViews::Hide() { 689 void StatusBubbleViews::Hide() {
687 status_text_ = string16(); 690 status_text_ = string16();
688 url_text_ = string16(); 691 url_text_ = string16();
689 if (view_) 692 if (view_)
690 view_->Hide(); 693 view_->Hide();
691 } 694 }
692 695
693 void StatusBubbleViews::MouseMoved(const gfx::Point& location, 696 void StatusBubbleViews::MouseMoved(const gfx::Point& location,
694 bool left_content) { 697 bool left_content) {
698 contains_mouse_ = !left_content;
695 if (left_content) 699 if (left_content)
696 return; 700 return;
701 last_mouse_moved_location_ = location;
697 702
698 if (view_) { 703 if (view_) {
699 view_->ResetTimer(); 704 view_->ResetTimer();
700 705
701 if (view_->GetState() != StatusView::BUBBLE_HIDDEN && 706 if (view_->GetState() != StatusView::BUBBLE_HIDDEN &&
702 view_->GetState() != StatusView::BUBBLE_HIDING_FADE && 707 view_->GetState() != StatusView::BUBBLE_HIDING_FADE &&
703 view_->GetState() != StatusView::BUBBLE_HIDING_TIMER) { 708 view_->GetState() != StatusView::BUBBLE_HIDING_TIMER) {
704 AvoidMouse(location); 709 AvoidMouse(location);
705 } 710 }
706 } 711 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 void StatusBubbleViews::SetBubbleWidth(int width) { 840 void StatusBubbleViews::SetBubbleWidth(int width) {
836 size_.set_width(width); 841 size_.set_width(width);
837 SetBounds(original_position_.x(), original_position_.y(), 842 SetBounds(original_position_.x(), original_position_.y(),
838 size_.width(), size_.height()); 843 size_.width(), size_.height());
839 } 844 }
840 845
841 void StatusBubbleViews::CancelExpandTimer() { 846 void StatusBubbleViews::CancelExpandTimer() {
842 if (expand_timer_factory_.HasWeakPtrs()) 847 if (expand_timer_factory_.HasWeakPtrs())
843 expand_timer_factory_.InvalidateWeakPtrs(); 848 expand_timer_factory_.InvalidateWeakPtrs();
844 } 849 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/status_bubble_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698