| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/common/shelf/app_list_button.h" | 5 #include "ash/common/shelf/app_list_button.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/ink_drop_button_listener.h" | 7 #include "ash/common/shelf/ink_drop_button_listener.h" |
| 8 #include "ash/common/shelf/shelf_constants.h" | 8 #include "ash/common/shelf/shelf_constants.h" |
| 9 #include "ash/common/shelf/shelf_view.h" | 9 #include "ash/common/shelf/shelf_view.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 118 |
| 119 void AppListButton::OnPaint(gfx::Canvas* canvas) { | 119 void AppListButton::OnPaint(gfx::Canvas* canvas) { |
| 120 // Call the base class first to paint any background/borders. | 120 // Call the base class first to paint any background/borders. |
| 121 View::OnPaint(canvas); | 121 View::OnPaint(canvas); |
| 122 | 122 |
| 123 gfx::PointF circle_center(GetCenterPoint()); | 123 gfx::PointF circle_center(GetCenterPoint()); |
| 124 | 124 |
| 125 // Paint the circular background. | 125 // Paint the circular background. |
| 126 cc::PaintFlags bg_flags; | 126 cc::PaintFlags bg_flags; |
| 127 bg_flags.setColor(background_color_); | 127 bg_flags.setColor(background_color_); |
| 128 bg_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 128 bg_flags.setAntiAlias(true); |
| 129 bg_flags.setStyle(cc::PaintFlags::kFill_Style); | 129 bg_flags.setStyle(cc::PaintFlags::kFill_Style); |
| 130 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_flags); | 130 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_flags); |
| 131 | 131 |
| 132 // Paint a white ring as the foreground. The ceil/dsf math assures that the | 132 // Paint a white ring as the foreground. The ceil/dsf math assures that the |
| 133 // ring draws sharply and is centered at all scale factors. | 133 // ring draws sharply and is centered at all scale factors. |
| 134 const float kRingOuterRadiusDp = 7.f; | 134 const float kRingOuterRadiusDp = 7.f; |
| 135 const float kRingThicknessDp = 1.5f; | 135 const float kRingThicknessDp = 1.5f; |
| 136 gfx::ScopedCanvas scoped_canvas(canvas); | 136 gfx::ScopedCanvas scoped_canvas(canvas); |
| 137 const float dsf = canvas->UndoDeviceScaleFactor(); | 137 const float dsf = canvas->UndoDeviceScaleFactor(); |
| 138 circle_center.Scale(dsf); | 138 circle_center.Scale(dsf); |
| 139 | 139 |
| 140 cc::PaintFlags fg_flags; | 140 cc::PaintFlags fg_flags; |
| 141 fg_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 141 fg_flags.setAntiAlias(true); |
| 142 fg_flags.setStyle(cc::PaintFlags::kStroke_Style); | 142 fg_flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 143 fg_flags.setColor(kShelfIconColor); | 143 fg_flags.setColor(kShelfIconColor); |
| 144 const float thickness = std::ceil(kRingThicknessDp * dsf); | 144 const float thickness = std::ceil(kRingThicknessDp * dsf); |
| 145 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; | 145 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; |
| 146 fg_flags.setStrokeWidth(thickness); | 146 fg_flags.setStrokeWidth(thickness); |
| 147 // Make sure the center of the circle lands on pixel centers. | 147 // Make sure the center of the circle lands on pixel centers. |
| 148 canvas->DrawCircle(circle_center, radius, fg_flags); | 148 canvas->DrawCircle(circle_center, radius, fg_flags); |
| 149 | 149 |
| 150 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); | 150 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); |
| 151 } | 151 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return gfx::Point(x_mid, x_mid); | 207 return gfx::Point(x_mid, x_mid); |
| 208 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 208 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
| 209 return gfx::Point(y_mid, y_mid); | 209 return gfx::Point(y_mid, y_mid); |
| 210 } else { | 210 } else { |
| 211 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); | 211 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); |
| 212 return gfx::Point(width() - y_mid, y_mid); | 212 return gfx::Point(width() - y_mid, y_mid); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace ash | 216 } // namespace ash |
| OLD | NEW |