| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ |
| 7 | 7 |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/gfx/canvas_skia.h" | 9 #include "ui/gfx/canvas_skia.h" |
| 10 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // Empty constructor. | 35 // Empty constructor. |
| 36 RoundedView() {} | 36 RoundedView() {} |
| 37 | 37 |
| 38 // Constructors. | 38 // Constructors. |
| 39 template<typename D> | 39 template<typename D> |
| 40 explicit RoundedView(const D &value) : C(value) {} | 40 explicit RoundedView(const D &value) : C(value) {} |
| 41 template<typename D1, typename D2> | 41 template<typename D1, typename D2> |
| 42 RoundedView(const D1& val1, const D2& val2) : C(val1, val2) {} | 42 RoundedView(const D1& val1, const D2& val2) : C(val1, val2) {} |
| 43 | 43 |
| 44 // Overrides views::View. | 44 // Overrides views::View. |
| 45 virtual void ProcessPaint(gfx::Canvas* canvas); | 45 virtual void Paint(gfx::Canvas* canvas); |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 // Returns the path that will be used for a clip. | 48 // Returns the path that will be used for a clip. |
| 49 virtual SkPath GetClipPath() const; | 49 virtual SkPath GetClipPath() const; |
| 50 | 50 |
| 51 // Returns maximal rectangle in the view. | 51 // Returns maximal rectangle in the view. |
| 52 virtual SkRect GetViewRect() const; | 52 virtual SkRect GetViewRect() const; |
| 53 | 53 |
| 54 // Draws custom frame for the view. | 54 // Draws custom frame for the view. |
| 55 virtual void DrawFrame(gfx::Canvas* canvas); | 55 virtual void DrawFrame(gfx::Canvas* canvas); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // RoundedView implementation. | 58 // RoundedView implementation. |
| 59 | 59 |
| 60 template <typename C> | 60 template <typename C> |
| 61 void RoundedView<C>::ProcessPaint(gfx::Canvas* canvas) { | 61 void RoundedView<C>::Paint(gfx::Canvas* canvas) { |
| 62 // Setup clip region. | 62 // Setup clip region. |
| 63 canvas->Save(); | 63 canvas->Save(); |
| 64 canvas->AsCanvasSkia()->clipPath(GetClipPath()); | 64 canvas->AsCanvasSkia()->clipPath(GetClipPath()); |
| 65 // Do original painting. | 65 // Do original painting. |
| 66 C::ProcessPaint(canvas); | 66 C::Paint(canvas); |
| 67 canvas->Restore(); | 67 canvas->Restore(); |
| 68 // Add frame. | 68 // Add frame. |
| 69 DrawFrame(canvas); | 69 DrawFrame(canvas); |
| 70 } | 70 } |
| 71 | 71 |
| 72 template <typename C> | 72 template <typename C> |
| 73 SkPath RoundedView<C>::GetClipPath() const { | 73 SkPath RoundedView<C>::GetClipPath() const { |
| 74 SkPath round_view; | 74 SkPath round_view; |
| 75 SkRect view_rect = GetViewRect(); | 75 SkRect view_rect = GetViewRect(); |
| 76 view_rect.inset(2 * rounded_view::kStrokeWidth, | 76 view_rect.inset(2 * rounded_view::kStrokeWidth, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 view_rect.offset(rounded_view::kStrokeWidth - kDelta, | 124 view_rect.offset(rounded_view::kStrokeWidth - kDelta, |
| 125 rounded_view::kStrokeWidth - kDelta); | 125 rounded_view::kStrokeWidth - kDelta); |
| 126 paint.setColor(rounded_view::kOuterFrameColor); | 126 paint.setColor(rounded_view::kOuterFrameColor); |
| 127 canvas->AsCanvasSkia()->drawRoundRect(view_rect, rounded_view::kCornerRadius, | 127 canvas->AsCanvasSkia()->drawRoundRect(view_rect, rounded_view::kCornerRadius, |
| 128 rounded_view::kCornerRadius, paint); | 128 rounded_view::kCornerRadius, paint); |
| 129 } | 129 } |
| 130 | 130 |
| 131 } | 131 } |
| 132 | 132 |
| 133 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ | 133 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_ROUNDED_VIEW_H_ |
| OLD | NEW |