| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.setAntiAlias(true); | 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); | |
| 137 const float dsf = canvas->UndoDeviceScaleFactor(); | |
| 138 circle_center.Scale(dsf); | |
| 139 | 136 |
| 140 cc::PaintFlags fg_flags; | 137 { |
| 141 fg_flags.setAntiAlias(true); | 138 gfx::ScopedCanvas scoped_canvas(canvas); |
| 142 fg_flags.setStyle(cc::PaintFlags::kStroke_Style); | 139 const float dsf = canvas->UndoDeviceScaleFactor(); |
| 143 fg_flags.setColor(kShelfIconColor); | 140 circle_center.Scale(dsf); |
| 144 const float thickness = std::ceil(kRingThicknessDp * dsf); | 141 |
| 145 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; | 142 cc::PaintFlags fg_flags; |
| 146 fg_flags.setStrokeWidth(thickness); | 143 fg_flags.setAntiAlias(true); |
| 147 // Make sure the center of the circle lands on pixel centers. | 144 fg_flags.setStyle(cc::PaintFlags::kStroke_Style); |
| 148 canvas->DrawCircle(circle_center, radius, fg_flags); | 145 fg_flags.setColor(kShelfIconColor); |
| 146 const float thickness = std::ceil(kRingThicknessDp * dsf); |
| 147 const float radius = std::ceil(kRingOuterRadiusDp * dsf) - thickness / 2; |
| 148 fg_flags.setStrokeWidth(thickness); |
| 149 // Make sure the center of the circle lands on pixel centers. |
| 150 canvas->DrawCircle(circle_center, radius, fg_flags); |
| 151 } |
| 149 | 152 |
| 150 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); | 153 views::Painter::PaintFocusPainter(this, canvas, focus_painter()); |
| 151 } | 154 } |
| 152 | 155 |
| 153 void AppListButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { | 156 void AppListButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 154 node_data->role = ui::AX_ROLE_BUTTON; | 157 node_data->role = ui::AX_ROLE_BUTTON; |
| 155 node_data->SetName(shelf_view_->GetTitleForView(this)); | 158 node_data->SetName(shelf_view_->GetTitleForView(this)); |
| 156 } | 159 } |
| 157 | 160 |
| 158 std::unique_ptr<views::InkDropRipple> AppListButton::CreateInkDropRipple() | 161 std::unique_ptr<views::InkDropRipple> AppListButton::CreateInkDropRipple() |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return gfx::Point(x_mid, x_mid); | 210 return gfx::Point(x_mid, x_mid); |
| 208 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 211 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
| 209 return gfx::Point(y_mid, y_mid); | 212 return gfx::Point(y_mid, y_mid); |
| 210 } else { | 213 } else { |
| 211 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); | 214 DCHECK_EQ(alignment, SHELF_ALIGNMENT_LEFT); |
| 212 return gfx::Point(width() - y_mid, y_mid); | 215 return gfx::Point(width() - y_mid, y_mid); |
| 213 } | 216 } |
| 214 } | 217 } |
| 215 | 218 |
| 216 } // namespace ash | 219 } // namespace ash |
| OLD | NEW |