| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_VIEWS_CONTROLS_FOCUSABLE_BORDER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_FOCUSABLE_BORDER_H_ |
| 6 #define UI_VIEWS_CONTROLS_FOCUSABLE_BORDER_H_ | 6 #define UI_VIEWS_CONTROLS_FOCUSABLE_BORDER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/optional.h" |
| 11 #include "ui/native_theme/native_theme.h" |
| 10 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
| 11 #include "ui/views/view.h" | 13 #include "ui/views/view.h" |
| 12 | 14 |
| 13 namespace gfx { | 15 namespace gfx { |
| 14 class Canvas; | 16 class Canvas; |
| 15 class Insets; | 17 class Insets; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace views { | 20 namespace views { |
| 19 | 21 |
| 20 // A Border class to draw a focused border around a field (e.g textfield). | 22 // A Border class to draw a focused border around a field (e.g textfield). |
| 21 class VIEWS_EXPORT FocusableBorder : public Border { | 23 class VIEWS_EXPORT FocusableBorder : public Border { |
| 22 public: | 24 public: |
| 23 static constexpr float kCornerRadiusDp = 2.f; | 25 static constexpr float kCornerRadiusDp = 2.f; |
| 24 | 26 |
| 25 FocusableBorder(); | 27 FocusableBorder(); |
| 26 ~FocusableBorder() override; | 28 ~FocusableBorder() override; |
| 27 | 29 |
| 28 // Sets the insets of the border. | 30 // Sets the insets of the border. |
| 29 void SetInsets(int top, int left, int bottom, int right); | 31 void SetInsets(int top, int left, int bottom, int right); |
| 30 | 32 |
| 31 // Sets the color of this border. | 33 // Sets the color id to use for this border. When unsupplied, the color will |
| 32 void SetColor(SkColor color); | 34 // depend on the focus state. |
| 33 // Reverts the color of this border to the system default. | 35 void SetColorId(const base::Optional<ui::NativeTheme::ColorId>& color_id); |
| 34 void UseDefaultColor(); | |
| 35 | 36 |
| 36 // Overridden from Border: | 37 // Overridden from Border: |
| 37 void Paint(const View& view, gfx::Canvas* canvas) override; | 38 void Paint(const View& view, gfx::Canvas* canvas) override; |
| 38 gfx::Insets GetInsets() const override; | 39 gfx::Insets GetInsets() const override; |
| 39 gfx::Size GetMinimumSize() const override; | 40 gfx::Size GetMinimumSize() const override; |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 SkColor GetCurrentColor(const View& view) const; | 43 SkColor GetCurrentColor(const View& view) const; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 gfx::Insets insets_; | 46 gfx::Insets insets_; |
| 46 | 47 |
| 47 // The color to paint the border when |use_default_color_| is false. | 48 base::Optional<ui::NativeTheme::ColorId> override_color_id_; |
| 48 SkColor override_color_; | |
| 49 | |
| 50 // Whether the system border color should be used. True unless SetColor has | |
| 51 // been called. | |
| 52 bool use_default_color_; | |
| 53 | 49 |
| 54 DISALLOW_COPY_AND_ASSIGN(FocusableBorder); | 50 DISALLOW_COPY_AND_ASSIGN(FocusableBorder); |
| 55 }; | 51 }; |
| 56 | 52 |
| 57 } // namespace views | 53 } // namespace views |
| 58 | 54 |
| 59 #endif // UI_VIEWS_CONTROLS_FOCUSABLE_BORDER_H_ | 55 #endif // UI_VIEWS_CONTROLS_FOCUSABLE_BORDER_H_ |
| OLD | NEW |