| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/extensions/extension_action.h" | 5 #include "chrome/common/extensions/extension_action.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 badge_width += 1; | 130 badge_width += 1; |
| 131 badge_width = std::max(kBadgeHeight, badge_width); | 131 badge_width = std::max(kBadgeHeight, badge_width); |
| 132 | 132 |
| 133 // Paint the badge background color in the right location. It is usually | 133 // Paint the badge background color in the right location. It is usually |
| 134 // right-aligned, but it can also be center-aligned if it is large. | 134 // right-aligned, but it can also be center-aligned if it is large. |
| 135 SkRect rect; | 135 SkRect rect; |
| 136 rect.fBottom = SkIntToScalar(bounds.bottom() - kBottomMargin); | 136 rect.fBottom = SkIntToScalar(bounds.bottom() - kBottomMargin); |
| 137 rect.fTop = rect.fBottom - SkIntToScalar(kBadgeHeight); | 137 rect.fTop = rect.fBottom - SkIntToScalar(kBadgeHeight); |
| 138 if (badge_width >= kCenterAlignThreshold) { | 138 if (badge_width >= kCenterAlignThreshold) { |
| 139 rect.fLeft = SkIntToScalar( | 139 rect.fLeft = SkIntToScalar( |
| 140 SkScalarFloor(SkIntToScalar(bounds.width() / 2.0) - | 140 SkScalarFloor(SkIntToScalar(bounds.x()) + |
| 141 SkIntToScalar(badge_width / 2.0))); | 141 SkIntToScalar(bounds.width() / 2.0) - |
| 142 SkIntToScalar(badge_width / 2.0); |
| 142 rect.fRight = rect.fLeft + SkIntToScalar(badge_width); | 143 rect.fRight = rect.fLeft + SkIntToScalar(badge_width); |
| 143 } else { | 144 } else { |
| 144 rect.fRight = SkIntToScalar(bounds.right()); | 145 rect.fRight = SkIntToScalar(bounds.right()); |
| 145 rect.fLeft = rect.fRight - badge_width; | 146 rect.fLeft = rect.fRight - badge_width; |
| 146 } | 147 } |
| 147 | 148 |
| 148 SkPaint rect_paint; | 149 SkPaint rect_paint; |
| 149 rect_paint.setStyle(SkPaint::kFill_Style); | 150 rect_paint.setStyle(SkPaint::kFill_Style); |
| 150 rect_paint.setAntiAlias(true); | 151 rect_paint.setAntiAlias(true); |
| 151 rect_paint.setColor(background_color); | 152 rect_paint.setColor(background_color); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 174 // text was too large. | 175 // text was too large. |
| 175 rect.fLeft += kPadding; | 176 rect.fLeft += kPadding; |
| 176 rect.fRight -= kPadding; | 177 rect.fRight -= kPadding; |
| 177 canvas->clipRect(rect); | 178 canvas->clipRect(rect); |
| 178 canvas->drawText(text.c_str(), text.size(), | 179 canvas->drawText(text.c_str(), text.size(), |
| 179 rect.fLeft + (rect.width() - text_width) / 2, | 180 rect.fLeft + (rect.width() - text_width) / 2, |
| 180 rect.fTop + kTextSize + kTopTextPadding, | 181 rect.fTop + kTextSize + kTopTextPadding, |
| 181 *text_paint); | 182 *text_paint); |
| 182 canvas->restore(); | 183 canvas->restore(); |
| 183 } | 184 } |
| OLD | NEW |