OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/views/controls/focusable_rounded_border_mac.h" | |
6 | |
7 #include "ui/gfx/canvas.h" | |
8 #include "ui/native_theme/native_theme_mac.h" | |
9 | |
10 namespace { | |
11 | |
12 const int kThickness = 1; | |
13 | |
14 } // namespace | |
15 | |
16 namespace views { | |
17 | |
18 FocusableRoundedBorder::FocusableRoundedBorder() { | |
19 // TODO(ellyjones): These insets seem like they shouldn't be big enough, but | |
20 // they are, and insetting by corner_radius_ instead produces gargantuan | |
21 // padding. Why is that? | |
22 SetInsets(kThickness, kThickness, kThickness, kThickness); | |
23 } | |
24 | |
25 FocusableRoundedBorder::~FocusableRoundedBorder() {} | |
26 | |
27 // For now, this is similar to RoundedRectBorder::Paint(), but this method will | |
28 // likely diverge in future. | |
29 // TODO(ellyjones): Diverge it by adding soft focus rings. | |
30 void FocusableRoundedBorder::Paint(const View& view, gfx::Canvas* canvas) { | |
31 cc::PaintFlags flags; | |
32 flags.setStyle(cc::PaintFlags::kStroke_Style); | |
33 flags.setStrokeWidth(kThickness); | |
34 flags.setColor(GetCurrentColor(view)); | |
35 flags.setAntiAlias(true); | |
36 | |
37 float half_thickness = kThickness / 2.0f; | |
38 gfx::RectF bounds(view.GetLocalBounds()); | |
39 bounds.Inset(half_thickness, half_thickness); | |
40 canvas->DrawRoundRect(bounds, ui::NativeThemeMac::kButtonCornerRadius, flags); | |
41 } | |
42 | |
43 } // namespace views | |
OLD | NEW |