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/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/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 // is aligned to the right on RTL UIs, we mirror the text bounds if the | 430 // is aligned to the right on RTL UIs, we mirror the text bounds if the |
431 // locale is RTL. | 431 // locale is RTL. |
432 int text_width = std::min( | 432 int text_width = std::min( |
433 views::Label::font().GetStringWidth(text_), | 433 views::Label::font().GetStringWidth(text_), |
434 width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); | 434 width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); |
435 int text_height = height - (kShadowThickness * 2); | 435 int text_height = height - (kShadowThickness * 2); |
436 gfx::Rect body_bounds(kShadowThickness + kTextPositionX, | 436 gfx::Rect body_bounds(kShadowThickness + kTextPositionX, |
437 kShadowThickness, | 437 kShadowThickness, |
438 std::max(0, text_width), | 438 std::max(0, text_width), |
439 std::max(0, text_height)); | 439 std::max(0, text_height)); |
440 body_bounds.set_x(MirroredLeftPointForRect(body_bounds)); | 440 body_bounds.set_x(GetMirroredXForRect(body_bounds)); |
441 SkColor text_color = | 441 SkColor text_color = |
442 theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT); | 442 theme_provider_->GetColor(BrowserThemeProvider::COLOR_TAB_TEXT); |
443 | 443 |
444 // DrawStringInt doesn't handle alpha, so we'll do the blending ourselves. | 444 // DrawStringInt doesn't handle alpha, so we'll do the blending ourselves. |
445 text_color = SkColorSetARGB( | 445 text_color = SkColorSetARGB( |
446 SkColorGetA(text_color), | 446 SkColorGetA(text_color), |
447 (SkColorGetR(text_color) + SkColorGetR(toolbar_color)) / 2, | 447 (SkColorGetR(text_color) + SkColorGetR(toolbar_color)) / 2, |
448 (SkColorGetG(text_color) + SkColorGetR(toolbar_color)) / 2, | 448 (SkColorGetG(text_color) + SkColorGetR(toolbar_color)) / 2, |
449 (SkColorGetB(text_color) + SkColorGetR(toolbar_color)) / 2); | 449 (SkColorGetB(text_color) + SkColorGetR(toolbar_color)) / 2); |
450 canvas->DrawStringInt(text_, | 450 canvas->DrawStringInt(text_, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 586 } |
587 } | 587 } |
588 | 588 |
589 gfx::Size StatusBubbleViews::GetPreferredSize() { | 589 gfx::Size StatusBubbleViews::GetPreferredSize() { |
590 return gfx::Size(0, ResourceBundle::GetSharedInstance().GetFont( | 590 return gfx::Size(0, ResourceBundle::GetSharedInstance().GetFont( |
591 ResourceBundle::BaseFont).GetHeight() + kTotalVerticalPadding); | 591 ResourceBundle::BaseFont).GetHeight() + kTotalVerticalPadding); |
592 } | 592 } |
593 | 593 |
594 void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { | 594 void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { |
595 original_position_.SetPoint(x, y); | 595 original_position_.SetPoint(x, y); |
596 position_.SetPoint(base_view_->MirroredXWithWidthInsideView(x, w), y); | 596 position_.SetPoint(base_view_->GetMirroredXWithWidthInView(x, w), y); |
597 size_.SetSize(w, h); | 597 size_.SetSize(w, h); |
598 Reposition(); | 598 Reposition(); |
599 } | 599 } |
600 | 600 |
601 void StatusBubbleViews::SetStatus(const string16& status_text) { | 601 void StatusBubbleViews::SetStatus(const string16& status_text) { |
602 if (size_.IsEmpty()) | 602 if (size_.IsEmpty()) |
603 return; // We have no bounds, don't attempt to show the popup. | 603 return; // We have no bounds, don't attempt to show the popup. |
604 | 604 |
605 if (status_text_ == status_text && !status_text.empty()) | 605 if (status_text_ == status_text && !status_text.empty()) |
606 return; | 606 return; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 void StatusBubbleViews::SetBubbleWidth(int width) { | 828 void StatusBubbleViews::SetBubbleWidth(int width) { |
829 size_.set_width(width); | 829 size_.set_width(width); |
830 SetBounds(original_position_.x(), original_position_.y(), | 830 SetBounds(original_position_.x(), original_position_.y(), |
831 size_.width(), size_.height()); | 831 size_.width(), size_.height()); |
832 } | 832 } |
833 | 833 |
834 void StatusBubbleViews::CancelExpandTimer() { | 834 void StatusBubbleViews::CancelExpandTimer() { |
835 if (!expand_timer_factory_.empty()) | 835 if (!expand_timer_factory_.empty()) |
836 expand_timer_factory_.RevokeAll(); | 836 expand_timer_factory_.RevokeAll(); |
837 } | 837 } |
OLD | NEW |