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

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

Issue 792243002: ui: Bubble fix (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | 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 "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // Draw the bubble's shadow. 393 // Draw the bubble's shadow.
394 int width = popup_bounds.width(); 394 int width = popup_bounds.width();
395 int height = popup_bounds.height(); 395 int height = popup_bounds.height();
396 gfx::Rect rect(gfx::Rect(popup_bounds.size())); 396 gfx::Rect rect(gfx::Rect(popup_bounds.size()));
397 SkPaint shadow_paint; 397 SkPaint shadow_paint;
398 shadow_paint.setAntiAlias(true); 398 shadow_paint.setAntiAlias(true);
399 shadow_paint.setColor(kShadowColor); 399 shadow_paint.setColor(kShadowColor);
400 400
401 SkRRect rrect; 401 SkRRect rrect;
402 rrect.setRectRadii(RectToSkRect(rect), (const SkVector*)rad); 402 rrect.setRectRadii(RectToSkRect(rect), (const SkVector*)rad);
403 canvas->sk_canvas()->drawRRect(rrect, paint); 403 canvas->sk_canvas()->drawRRect(rrect, shadow_paint);
404 404
405 const int shadow_size = 2 * kShadowThickness;
405 // Draw the bubble. 406 // Draw the bubble.
406 rect.SetRect(SkIntToScalar(kShadowThickness), 407 rect.SetRect(SkIntToScalar(kShadowThickness), SkIntToScalar(kShadowThickness),
407 SkIntToScalar(kShadowThickness), 408 SkIntToScalar(width - shadow_size),
408 SkIntToScalar(width), 409 SkIntToScalar(height - shadow_size));
409 SkIntToScalar(height));
410 rrect.setRectRadii(RectToSkRect(rect), (const SkVector*)rad); 410 rrect.setRectRadii(RectToSkRect(rect), (const SkVector*)rad);
411 canvas->sk_canvas()->drawRRect(rrect, paint); 411 canvas->sk_canvas()->drawRRect(rrect, paint);
412 412
413 // Draw highlight text and then the text body. In order to make sure the text 413 // Draw highlight text and then the text body. In order to make sure the text
414 // is aligned to the right on RTL UIs, we mirror the text bounds if the 414 // is aligned to the right on RTL UIs, we mirror the text bounds if the
415 // locale is RTL. 415 // locale is RTL.
416 const gfx::FontList font_list; 416 const gfx::FontList font_list;
417 int text_width = std::min( 417 int text_width =
418 gfx::GetStringWidth(text_, font_list), 418 std::min(gfx::GetStringWidth(text_, font_list),
419 width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); 419 width - shadow_size - kTextPositionX - kTextHorizPadding);
420 int text_height = height - (kShadowThickness * 2); 420 int text_height = height - shadow_size;
421 gfx::Rect body_bounds(kShadowThickness + kTextPositionX, 421 gfx::Rect body_bounds(kShadowThickness + kTextPositionX,
422 kShadowThickness, 422 kShadowThickness,
423 std::max(0, text_width), 423 std::max(0, text_width),
424 std::max(0, text_height)); 424 std::max(0, text_height));
425 body_bounds.set_x(GetMirroredXForRect(body_bounds)); 425 body_bounds.set_x(GetMirroredXForRect(body_bounds));
426 SkColor text_color = 426 SkColor text_color =
427 theme_service_->GetColor(ThemeProperties::COLOR_STATUS_BAR_TEXT); 427 theme_service_->GetColor(ThemeProperties::COLOR_STATUS_BAR_TEXT);
428 canvas->DrawStringRect(text_, font_list, text_color, body_bounds); 428 canvas->DrawStringRect(text_, font_list, text_color, body_bounds);
429 } 429 }
430 430
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698