Chromium Code Reviews| 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/ash_constants.h" | 7 #include "ash/common/ash_constants.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/shelf/ink_drop_button_listener.h" | 9 #include "ash/common/shelf/ink_drop_button_listener.h" |
| 10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 | 159 |
| 160 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); | 160 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void AppListButton::PaintMd(gfx::Canvas* canvas) { | 163 void AppListButton::PaintMd(gfx::Canvas* canvas) { |
| 164 gfx::PointF circle_center(GetCenterPoint()); | 164 gfx::PointF circle_center(GetCenterPoint()); |
| 165 | 165 |
| 166 // Paint the circular background. | 166 // Paint the circular background. |
| 167 cc::PaintFlags bg_flags; | 167 cc::PaintFlags bg_flags; |
| 168 bg_flags.setColor(background_color_); | 168 bg_flags.setColor(background_color_); |
| 169 bg_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 169 bg_flags.setAntiAlias(true); |
|
enne (OOO)
2017/02/27 05:20:52
Antialiasing is the only use of setFlags, so am cl
| |
| 170 bg_flags.setStyle(cc::PaintFlags::kFill_Style); | 170 bg_flags.setStyle(cc::PaintFlags::kFill_Style); |
| 171 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_flags); | 171 canvas->DrawCircle(circle_center, kAppListButtonRadius, bg_flags); |
| 172 | 172 |
| 173 // Paint a white ring as the foreground. The ceil/dsf math assures that the | 173 // Paint a white ring as the foreground. The ceil/dsf math assures that the |
| 174 // ring draws sharply and is centered at all scale factors. | 174 // ring draws sharply and is centered at all scale factors. |
| 175 const float kRingOuterRadiusDp = 7.f; | 175 const float kRingOuterRadiusDp = 7.f; |
| 176 const float kRingThicknessDp = 1.5f; | 176 const float kRingThicknessDp = 1.5f; |
| 177 gfx::ScopedCanvas scoped_canvas(canvas); | 177 gfx::ScopedCanvas scoped_canvas(canvas); |
| 178 const float dsf = canvas->UndoDeviceScaleFactor(); | 178 const float dsf = canvas->UndoDeviceScaleFactor(); |
| 179 circle_center.Scale(dsf); | 179 circle_center.Scale(dsf); |
| 180 | 180 |
| 181 cc::PaintFlags fg_flags; | 181 cc::PaintFlags fg_flags; |
| 182 fg_flags.setFlags(cc::PaintFlags::kAntiAlias_Flag); | 182 fg_flags.setAntiAlias(true); |
| 183 fg_flags.setStyle(cc::PaintFlags::kStroke_Style); | 183 fg_flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 184 fg_flags.setColor(kShelfIconColor); | 184 fg_flags.setColor(kShelfIconColor); |
| 185 const float thickness = std::ceil(kRingThicknessDp * dsf); | 185 const float thickness = std::ceil(kRingThicknessDp * dsf); |
| 186 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; | 186 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; |
| 187 fg_flags.setStrokeWidth(thickness); | 187 fg_flags.setStrokeWidth(thickness); |
| 188 // Make sure the center of the circle lands on pixel centers. | 188 // Make sure the center of the circle lands on pixel centers. |
| 189 canvas->DrawCircle(circle_center, radius, fg_flags); | 189 canvas->DrawCircle(circle_center, radius, fg_flags); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void AppListButton::PaintAppListButton(gfx::Canvas* canvas, | 192 void AppListButton::PaintAppListButton(gfx::Canvas* canvas, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 return gfx::Point(x_mid, x_mid); | 303 return gfx::Point(x_mid, x_mid); |
| 304 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 304 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
| 305 return gfx::Point(y_mid, y_mid); | 305 return gfx::Point(y_mid, y_mid); |
| 306 } else { | 306 } else { |
| 307 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); | 307 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); |
| 308 return gfx::Point(width() - y_mid, y_mid); | 308 return gfx::Point(width() - y_mid, y_mid); |
| 309 } | 309 } |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace ash | 312 } // namespace ash |
| OLD | NEW |