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 VIEWS_CONTROLS_IMAGE_VIEW_H_ | 5 #ifndef VIEWS_CONTROLS_IMAGE_VIEW_H_ |
6 #define VIEWS_CONTROLS_IMAGE_VIEW_H_ | 6 #define VIEWS_CONTROLS_IMAGE_VIEW_H_ |
7 | 7 |
8 #include "third_party/skia/include/core/SkBitmap.h" | 8 #include "third_party/skia/include/core/SkBitmap.h" |
9 #include "views/view.h" | 9 #include "views/view.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 const SkBitmap& GetImage(); | 48 const SkBitmap& GetImage(); |
49 | 49 |
50 // Set the desired image size for the receiving ImageView. | 50 // Set the desired image size for the receiving ImageView. |
51 void SetImageSize(const gfx::Size& image_size); | 51 void SetImageSize(const gfx::Size& image_size); |
52 | 52 |
53 // Return the preferred size for the receiving view. Returns false if the | 53 // Return the preferred size for the receiving view. Returns false if the |
54 // preferred size is not defined, which means that the view uses the image | 54 // preferred size is not defined, which means that the view uses the image |
55 // size. | 55 // size. |
56 bool GetImageSize(gfx::Size* image_size); | 56 bool GetImageSize(gfx::Size* image_size); |
57 | 57 |
| 58 // Returns the actual bounds of the visible image inside the view. |
| 59 gfx::Rect GetImageBounds() const; |
| 60 |
58 // Reset the image size to the current image dimensions. | 61 // Reset the image size to the current image dimensions. |
59 void ResetImageSize(); | 62 void ResetImageSize(); |
60 | 63 |
61 // Set / Get the horizontal alignment. | 64 // Set / Get the horizontal alignment. |
62 void SetHorizontalAlignment(Alignment ha); | 65 void SetHorizontalAlignment(Alignment ha); |
63 Alignment GetHorizontalAlignment(); | 66 Alignment GetHorizontalAlignment(); |
64 | 67 |
65 // Set / Get the vertical alignment. | 68 // Set / Get the vertical alignment. |
66 void SetVerticalAlignment(Alignment va); | 69 void SetVerticalAlignment(Alignment va); |
67 Alignment GetVerticalAlignment(); | 70 Alignment GetVerticalAlignment(); |
68 | 71 |
69 // Set / Get the tooltip text. | 72 // Set / Get the tooltip text. |
70 void SetTooltipText(const std::wstring& tooltip); | 73 void SetTooltipText(const std::wstring& tooltip); |
71 std::wstring GetTooltipText(); | 74 std::wstring GetTooltipText(); |
72 | 75 |
73 // Return whether the image should be centered inside the view. | |
74 // Overriden from View | 76 // Overriden from View |
75 virtual gfx::Size GetPreferredSize(); | 77 virtual gfx::Size GetPreferredSize(); |
76 virtual void Paint(gfx::Canvas* canvas); | 78 virtual void Paint(gfx::Canvas* canvas); |
77 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 79 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
78 | |
79 // Overriden from View. | |
80 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); | 80 virtual bool GetTooltipText(const gfx::Point& p, std::wstring* tooltip); |
81 | 81 |
82 private: | 82 private: |
83 // Compute the image origin given the desired size and the receiver alignment | 83 // Compute the image origin given the desired size and the receiver alignment |
84 // properties. | 84 // properties. |
85 void ComputeImageOrigin(int image_width, int image_height, int *x, int *y); | 85 gfx::Point ComputeImageOrigin(const gfx::Size& image_size) const; |
86 | 86 |
87 // Whether the image size is set. | 87 // Whether the image size is set. |
88 bool image_size_set_; | 88 bool image_size_set_; |
89 | 89 |
90 // The actual image size. | 90 // The actual image size. |
91 gfx::Size image_size_; | 91 gfx::Size image_size_; |
92 | 92 |
93 // The underlying bitmap. | 93 // The underlying bitmap. |
94 SkBitmap image_; | 94 SkBitmap image_; |
95 | 95 |
96 // Horizontal alignment. | 96 // Horizontal alignment. |
97 Alignment horiz_alignment_; | 97 Alignment horiz_alignment_; |
98 | 98 |
99 // Vertical alignment. | 99 // Vertical alignment. |
100 Alignment vert_alignment_; | 100 Alignment vert_alignment_; |
101 | 101 |
102 // The current tooltip text. | 102 // The current tooltip text. |
103 std::wstring tooltip_text_; | 103 std::wstring tooltip_text_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(ImageView); | 105 DISALLOW_COPY_AND_ASSIGN(ImageView); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace views | 108 } // namespace views |
109 | 109 |
110 #endif // VIEWS_CONTROLS_IMAGE_VIEW_H_ | 110 #endif // VIEWS_CONTROLS_IMAGE_VIEW_H_ |
OLD | NEW |