Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ui/views/controls/image_view.h

Issue 2713993005: Clean up ImageView. (Closed)
Patch Set: revert errant changes Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/label_button.cc ('k') | ui/views/controls/image_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_IMAGE_VIEW_H_ 5 #ifndef UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
6 #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ 6 #define UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/gfx/image/image_skia.h" 9 #include "ui/gfx/image/image_skia.h"
11 #include "ui/views/view.h" 10 #include "ui/views/view.h"
12 11
13 namespace gfx { 12 namespace gfx {
14 class Canvas; 13 class Canvas;
15 } 14 }
16 15
17 namespace views { 16 namespace views {
18 17
19 class Painter;
20
21 ///////////////////////////////////////////////////////////////////////////// 18 /////////////////////////////////////////////////////////////////////////////
22 // 19 //
23 // ImageView class. 20 // ImageView class.
24 // 21 //
25 // An ImageView can display an image from an ImageSkia. If a size is provided, 22 // An ImageView can display an image from an ImageSkia. If a size is provided,
26 // the ImageView will resize the provided image to fit if it is too big or will 23 // the ImageView will resize the provided image to fit if it is too big or will
27 // center the image if smaller. Otherwise, the preferred size matches the 24 // center the image if smaller. Otherwise, the preferred size matches the
28 // provided image size. 25 // provided image size.
29 // 26 //
30 ///////////////////////////////////////////////////////////////////////////// 27 /////////////////////////////////////////////////////////////////////////////
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Alignment GetHorizontalAlignment() const; 65 Alignment GetHorizontalAlignment() const;
69 66
70 // Set / Get the vertical alignment. 67 // Set / Get the vertical alignment.
71 void SetVerticalAlignment(Alignment va); 68 void SetVerticalAlignment(Alignment va);
72 Alignment GetVerticalAlignment() const; 69 Alignment GetVerticalAlignment() const;
73 70
74 // Set / Get the tooltip text. 71 // Set / Get the tooltip text.
75 void SetTooltipText(const base::string16& tooltip); 72 void SetTooltipText(const base::string16& tooltip);
76 base::string16 GetTooltipText() const; 73 base::string16 GetTooltipText() const;
77 74
78 void set_interactive(bool interactive) { interactive_ = interactive; }
79
80 void SetFocusPainter(std::unique_ptr<Painter> focus_painter);
81
82 // Overriden from View: 75 // Overriden from View:
83 gfx::Size GetPreferredSize() const override; 76 gfx::Size GetPreferredSize() const override;
84 void OnFocus() override;
85 void OnBlur() override;
86 void OnPaint(gfx::Canvas* canvas) override; 77 void OnPaint(gfx::Canvas* canvas) override;
87 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 78 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
88 const char* GetClassName() const override; 79 const char* GetClassName() const override;
89 bool GetTooltipText(const gfx::Point& p, 80 bool GetTooltipText(const gfx::Point& p,
90 base::string16* tooltip) const override; 81 base::string16* tooltip) const override;
91 bool CanProcessEventsWithinSubtree() const override;
92 82
93 private: 83 private:
94 void OnPaintImage(gfx::Canvas* canvas); 84 void OnPaintImage(gfx::Canvas* canvas);
95 85
96 // Returns true if |img| is the same as the last image we painted. This is 86 // Returns true if |img| is the same as the last image we painted. This is
97 // intended to be a quick check, not exhaustive. In other words it's possible 87 // intended to be a quick check, not exhaustive. In other words it's possible
98 // for this to return false even though the images are in fact equal. 88 // for this to return false even though the images are in fact equal.
99 bool IsImageEqual(const gfx::ImageSkia& img) const; 89 bool IsImageEqual(const gfx::ImageSkia& img) const;
100 90
101 // Returns the size the image will be painted. 91 // Returns the size the image will be painted.
(...skipping 14 matching lines...) Expand all
116 106
117 // Horizontal alignment. 107 // Horizontal alignment.
118 Alignment horiz_alignment_; 108 Alignment horiz_alignment_;
119 109
120 // Vertical alignment. 110 // Vertical alignment.
121 Alignment vert_alignment_; 111 Alignment vert_alignment_;
122 112
123 // The current tooltip text. 113 // The current tooltip text.
124 base::string16 tooltip_text_; 114 base::string16 tooltip_text_;
125 115
126 // A flag controlling hit test handling for interactivity.
127 bool interactive_;
128
129 // Scale last painted at. 116 // Scale last painted at.
130 float last_paint_scale_; 117 float last_paint_scale_;
131 118
132 // Address of bytes we last painted. This is used only for comparison, so its 119 // Address of bytes we last painted. This is used only for comparison, so its
133 // safe to cache. 120 // safe to cache.
134 void* last_painted_bitmap_pixels_; 121 void* last_painted_bitmap_pixels_;
135 122
136 std::unique_ptr<views::Painter> focus_painter_;
137
138 DISALLOW_COPY_AND_ASSIGN(ImageView); 123 DISALLOW_COPY_AND_ASSIGN(ImageView);
139 }; 124 };
140 125
141 } // namespace views 126 } // namespace views
142 127
143 #endif // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ 128 #endif // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/controls/button/label_button.cc ('k') | ui/views/controls/image_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698