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 "ui/views/controls/label.h" | 5 #include "ui/views/controls/label.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <vector> | 10 #include <vector> |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 return gfx::Rect(origin, text_size); | 504 return gfx::Rect(origin, text_size); |
505 } | 505 } |
506 | 506 |
507 int Label::ComputeDrawStringFlags() const { | 507 int Label::ComputeDrawStringFlags() const { |
508 int flags = 0; | 508 int flags = 0; |
509 | 509 |
510 // We can't use subpixel rendering if the background is non-opaque. | 510 // We can't use subpixel rendering if the background is non-opaque. |
511 if (SkColorGetA(background_color_) != 0xFF || !subpixel_rendering_enabled_) | 511 if (SkColorGetA(background_color_) != 0xFF || !subpixel_rendering_enabled_) |
512 flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; | 512 flags |= gfx::Canvas::NO_SUBPIXEL_RENDERING; |
513 | 513 |
514 base::i18n::TextDirection direction = | |
515 base::i18n::GetFirstStrongCharacterDirection(layout_text_); | |
516 if (direction == base::i18n::RIGHT_TO_LEFT) | |
517 flags |= gfx::Canvas::FORCE_RTL_DIRECTIONALITY; | |
518 else | |
519 flags |= gfx::Canvas::FORCE_LTR_DIRECTIONALITY; | |
520 | |
521 switch (GetHorizontalAlignment()) { | 514 switch (GetHorizontalAlignment()) { |
522 case gfx::ALIGN_LEFT: | 515 case gfx::ALIGN_LEFT: |
523 flags |= gfx::Canvas::TEXT_ALIGN_LEFT; | 516 flags |= gfx::Canvas::TEXT_ALIGN_LEFT; |
524 break; | 517 break; |
525 case gfx::ALIGN_CENTER: | 518 case gfx::ALIGN_CENTER: |
526 flags |= gfx::Canvas::TEXT_ALIGN_CENTER; | 519 flags |= gfx::Canvas::TEXT_ALIGN_CENTER; |
527 break; | 520 break; |
528 case gfx::ALIGN_RIGHT: | 521 case gfx::ALIGN_RIGHT: |
529 flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; | 522 flags |= gfx::Canvas::TEXT_ALIGN_RIGHT; |
530 break; | 523 break; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 } | 596 } |
604 | 597 |
605 bool Label::ShouldShowDefaultTooltip() const { | 598 bool Label::ShouldShowDefaultTooltip() const { |
606 const gfx::Size text_size = GetTextSize(); | 599 const gfx::Size text_size = GetTextSize(); |
607 const gfx::Size size = GetContentsBounds().size(); | 600 const gfx::Size size = GetContentsBounds().size(); |
608 return !obscured() && (text_size.width() > size.width() || | 601 return !obscured() && (text_size.width() > size.width() || |
609 (multi_line_ && text_size.height() > size.height())); | 602 (multi_line_ && text_size.height() > size.height())); |
610 } | 603 } |
611 | 604 |
612 } // namespace views | 605 } // namespace views |
OLD | NEW |