OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/status_bubble_views.h" | 5 #include "chrome/browser/views/status_bubble_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/linear_animation.h" | 9 #include "app/linear_animation.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
12 #include "app/text_elider.h" | 12 #include "app/text_elider.h" |
13 #include "base/i18n/rtl.h" | 13 #include "base/i18n/rtl.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "chrome/browser/browser_theme_provider.h" | 16 #include "chrome/browser/browser_theme_provider.h" |
17 #include "gfx/canvas_skia.h" | 17 #include "gfx/canvas.h" |
18 #include "gfx/point.h" | 18 #include "gfx/point.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
23 #include "third_party/skia/include/core/SkPaint.h" | 23 #include "third_party/skia/include/core/SkPaint.h" |
24 #include "third_party/skia/include/core/SkPath.h" | 24 #include "third_party/skia/include/core/SkPath.h" |
25 #include "third_party/skia/include/core/SkRect.h" | 25 #include "third_party/skia/include/core/SkRect.h" |
26 #include "views/controls/label.h" | 26 #include "views/controls/label.h" |
27 #include "views/controls/scrollbar/native_scroll_bar.h" | 27 #include "views/controls/scrollbar/native_scroll_bar.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 int height = popup_bounds.height(); | 407 int height = popup_bounds.height(); |
408 SkRect rect; | 408 SkRect rect; |
409 rect.set(0, 0, | 409 rect.set(0, 0, |
410 SkIntToScalar(width), | 410 SkIntToScalar(width), |
411 SkIntToScalar(height)); | 411 SkIntToScalar(height)); |
412 SkPath shadow_path; | 412 SkPath shadow_path; |
413 shadow_path.addRoundRect(rect, rad, SkPath::kCW_Direction); | 413 shadow_path.addRoundRect(rect, rad, SkPath::kCW_Direction); |
414 SkPaint shadow_paint; | 414 SkPaint shadow_paint; |
415 shadow_paint.setFlags(SkPaint::kAntiAlias_Flag); | 415 shadow_paint.setFlags(SkPaint::kAntiAlias_Flag); |
416 shadow_paint.setColor(kShadowColor); | 416 shadow_paint.setColor(kShadowColor); |
417 canvas->AsCanvasSkia()->drawPath(shadow_path, shadow_paint); | 417 canvas->drawPath(shadow_path, shadow_paint); |
418 | 418 |
419 // Draw the bubble. | 419 // Draw the bubble. |
420 rect.set(SkIntToScalar(kShadowThickness), | 420 rect.set(SkIntToScalar(kShadowThickness), |
421 SkIntToScalar(kShadowThickness), | 421 SkIntToScalar(kShadowThickness), |
422 SkIntToScalar(width - kShadowThickness), | 422 SkIntToScalar(width - kShadowThickness), |
423 SkIntToScalar(height - kShadowThickness)); | 423 SkIntToScalar(height - kShadowThickness)); |
424 SkPath path; | 424 SkPath path; |
425 path.addRoundRect(rect, rad, SkPath::kCW_Direction); | 425 path.addRoundRect(rect, rad, SkPath::kCW_Direction); |
426 canvas->AsCanvasSkia()->drawPath(path, paint); | 426 canvas->drawPath(path, paint); |
427 | 427 |
428 // Draw highlight text and then the text body. In order to make sure the text | 428 // Draw highlight text and then the text body. In order to make sure the text |
429 // is aligned to the right on RTL UIs, we mirror the text bounds if the | 429 // is aligned to the right on RTL UIs, we mirror the text bounds if the |
430 // locale is RTL. | 430 // locale is RTL. |
431 int text_width = std::min(views::Label::font().GetStringWidth(text_), | 431 int text_width = std::min(views::Label::font().GetStringWidth(text_), |
432 width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); | 432 width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); |
433 int text_height = height - (kShadowThickness * 2); | 433 int text_height = height - (kShadowThickness * 2); |
434 gfx::Rect body_bounds(kShadowThickness + kTextPositionX, | 434 gfx::Rect body_bounds(kShadowThickness + kTextPositionX, |
435 kShadowThickness, | 435 kShadowThickness, |
436 std::max(0, text_width), | 436 std::max(0, text_width), |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 835 |
836 void StatusBubbleViews::SetBubbleWidth(int width) { | 836 void StatusBubbleViews::SetBubbleWidth(int width) { |
837 size_.set_width(width); | 837 size_.set_width(width); |
838 SetBounds(position_.x(), position_.y(), size_.width(), size_.height()); | 838 SetBounds(position_.x(), position_.y(), size_.width(), size_.height()); |
839 } | 839 } |
840 | 840 |
841 void StatusBubbleViews::CancelExpandTimer() { | 841 void StatusBubbleViews::CancelExpandTimer() { |
842 if (!expand_timer_factory_.empty()) | 842 if (!expand_timer_factory_.empty()) |
843 expand_timer_factory_.RevokeAll(); | 843 expand_timer_factory_.RevokeAll(); |
844 } | 844 } |
OLD | NEW |