OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_ANDROID_RESOURCES_NINE_PATCH_RESOURCE_H_ | 5 #ifndef UI_ANDROID_RESOURCES_NINE_PATCH_RESOURCE_H_ |
6 #define UI_ANDROID_RESOURCES_NINE_PATCH_RESOURCE_H_ | 6 #define UI_ANDROID_RESOURCES_NINE_PATCH_RESOURCE_H_ |
7 | 7 |
8 #include "ui/android/resources/resource.h" | 8 #include "ui/android/resources/resource.h" |
9 #include "ui/android/ui_android_export.h" | 9 #include "ui/android/ui_android_export.h" |
10 #include "ui/gfx/geometry/insets_f.h" | 10 #include "ui/gfx/geometry/insets_f.h" |
| 11 #include "ui/gfx/geometry/point_f.h" |
| 12 |
| 13 namespace cc { |
| 14 class NinePatchLayer; |
| 15 } |
11 | 16 |
12 namespace ui { | 17 namespace ui { |
13 | 18 |
14 class UI_ANDROID_EXPORT NinePatchResource final : public Resource { | 19 class UI_ANDROID_EXPORT NinePatchResource final : public Resource { |
15 public: | 20 public: |
16 static NinePatchResource* From(Resource* resource); | 21 static NinePatchResource* From(Resource* resource); |
17 | 22 |
18 NinePatchResource(gfx::Rect padding, gfx::Rect aperture); | 23 NinePatchResource(gfx::Rect padding, gfx::Rect aperture); |
19 ~NinePatchResource() override; | 24 ~NinePatchResource() override; |
20 | 25 |
21 std::unique_ptr<Resource> CreateForCopy() override; | 26 std::unique_ptr<Resource> CreateForCopy() override; |
22 | 27 |
| 28 // Returns the drawing size that the resource will take for padding content |
| 29 // of size |content_size|. |
| 30 gfx::Size DrawSize(const gfx::Size& content_size) const; |
| 31 |
| 32 // Returns the position where the resource should be drawn to account for |
| 33 // margins, given the |content_position| in the parent's coordinate space. |
| 34 gfx::PointF DrawPosition(const gfx::Point& content_position) const; |
| 35 |
| 36 // Updates draw properties on |layer| used to draw this resource. The |
| 37 // |content_location| is the rect of the content to be fit inside the resource |
| 38 // in the parent's coordinate space. |
| 39 void UpdateNinePatchLayer(cc::NinePatchLayer* layer, |
| 40 const gfx::Rect& content_location) const; |
| 41 |
23 gfx::Rect Border(const gfx::Size& bounds) const; | 42 gfx::Rect Border(const gfx::Size& bounds) const; |
24 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale) const; | 43 gfx::Rect Border(const gfx::Size& bounds, const gfx::InsetsF& scale) const; |
25 | 44 |
26 gfx::Rect padding() const { return padding_; } | 45 gfx::Rect padding() const { return padding_; } |
27 gfx::Rect aperture() const { return aperture_; } | 46 gfx::Rect aperture() const { return aperture_; } |
28 | 47 |
29 private: | 48 private: |
30 const gfx::Rect padding_; | 49 const gfx::Rect padding_; |
31 const gfx::Rect aperture_; | 50 const gfx::Rect aperture_; |
32 }; | 51 }; |
33 | 52 |
34 } // namespace ui | 53 } // namespace ui |
35 | 54 |
36 #endif // UI_ANDROID_RESOURCES_NINE_PATCH_RESOURCE_H_ | 55 #endif // UI_ANDROID_RESOURCES_NINE_PATCH_RESOURCE_H_ |
OLD | NEW |