| 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 "views/bubble/bubble_border.h" | 5 #include "views/bubble/bubble_border.h" |
| 6 | 6 |
| 7 #include <algorithm> // for std::max | 7 #include <algorithm> // for std::max |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 int y = position_relative_to.y(); | 53 int y = position_relative_to.y(); |
| 54 int w = position_relative_to.width(); | 54 int w = position_relative_to.width(); |
| 55 int h = position_relative_to.height(); | 55 int h = position_relative_to.height(); |
| 56 int arrow_offset = override_arrow_offset_ ? override_arrow_offset_ : | 56 int arrow_offset = override_arrow_offset_ ? override_arrow_offset_ : |
| 57 arrow_offset_; | 57 arrow_offset_; |
| 58 | 58 |
| 59 // Calculate bubble x coordinate. | 59 // Calculate bubble x coordinate. |
| 60 switch (arrow_location_) { | 60 switch (arrow_location_) { |
| 61 case TOP_LEFT: | 61 case TOP_LEFT: |
| 62 case BOTTOM_LEFT: | 62 case BOTTOM_LEFT: |
| 63 x += w / 2 - arrow_offset; | 63 x += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ? w / 2 - arrow_offset : |
| 64 -kArrowOverlap; |
| 64 break; | 65 break; |
| 65 | 66 |
| 66 case TOP_RIGHT: | 67 case TOP_RIGHT: |
| 67 case BOTTOM_RIGHT: | 68 case BOTTOM_RIGHT: |
| 68 x += w / 2 + arrow_offset - border_size.width() + 1; | 69 x += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ? |
| 70 w / 2 + arrow_offset - border_size.width() + 1 : |
| 71 w - border_size.width() + kArrowOverlap; |
| 69 break; | 72 break; |
| 70 | 73 |
| 71 case LEFT_TOP: | 74 case LEFT_TOP: |
| 72 case LEFT_BOTTOM: | 75 case LEFT_BOTTOM: |
| 73 x += w - kArrowOverlap; | 76 x += w - kArrowOverlap; |
| 74 break; | 77 break; |
| 75 | 78 |
| 76 case RIGHT_TOP: | 79 case RIGHT_TOP: |
| 77 case RIGHT_BOTTOM: | 80 case RIGHT_BOTTOM: |
| 78 x += kArrowOverlap - border_size.width(); | 81 x += kArrowOverlap - border_size.width(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 91 y += h - kArrowOverlap; | 94 y += h - kArrowOverlap; |
| 92 break; | 95 break; |
| 93 | 96 |
| 94 case BOTTOM_LEFT: | 97 case BOTTOM_LEFT: |
| 95 case BOTTOM_RIGHT: | 98 case BOTTOM_RIGHT: |
| 96 y += kArrowOverlap - border_size.height(); | 99 y += kArrowOverlap - border_size.height(); |
| 97 break; | 100 break; |
| 98 | 101 |
| 99 case LEFT_TOP: | 102 case LEFT_TOP: |
| 100 case RIGHT_TOP: | 103 case RIGHT_TOP: |
| 101 y += h / 2 - arrow_offset; | 104 y += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ? h / 2 - arrow_offset : |
| 105 -kArrowOverlap; |
| 102 break; | 106 break; |
| 103 | 107 |
| 104 case LEFT_BOTTOM: | 108 case LEFT_BOTTOM: |
| 105 case RIGHT_BOTTOM: | 109 case RIGHT_BOTTOM: |
| 106 y += h / 2 + arrow_offset - border_size.height() + 1; | 110 y += alignment_ == ALIGN_ARROW_TO_MID_ANCHOR ? |
| 111 h / 2 + arrow_offset - border_size.height() + 1 : |
| 112 h - border_size.height() + kArrowOverlap; |
| 107 break; | 113 break; |
| 108 | 114 |
| 109 case NONE: | 115 case NONE: |
| 110 y += h; | 116 y += h; |
| 111 break; | 117 break; |
| 112 | 118 |
| 113 case FLOAT: | 119 case FLOAT: |
| 114 y += h / 2 - border_size.height() / 2; | 120 y += h / 2 - border_size.height() / 2; |
| 115 break; | 121 break; |
| 116 } | 122 } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 gfx::Rect bounds(view->GetContentsBounds()); | 447 gfx::Rect bounds(view->GetContentsBounds()); |
| 442 SkRect rect; | 448 SkRect rect; |
| 443 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), | 449 rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()), |
| 444 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); | 450 SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom())); |
| 445 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); | 451 SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); |
| 446 path.addRoundRect(rect, radius, radius); | 452 path.addRoundRect(rect, radius, radius); |
| 447 canvas->GetSkCanvas()->drawPath(path, paint); | 453 canvas->GetSkCanvas()->drawPath(path, paint); |
| 448 } | 454 } |
| 449 | 455 |
| 450 } // namespace views | 456 } // namespace views |
| OLD | NEW |