| OLD | NEW | 
|---|
| 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 "third_party/skia/include/core/SkColor.h" |  | 
| 9 #include "ui/gfx/image/image_skia.h" | 8 #include "ui/gfx/image/image_skia.h" | 
| 10 #include "ui/gfx/vector_icons_public.h" |  | 
| 11 #include "ui/views/view.h" | 9 #include "ui/views/view.h" | 
| 12 | 10 | 
| 13 namespace gfx { | 11 namespace gfx { | 
| 14 class Canvas; | 12 class Canvas; | 
| 15 } | 13 } | 
| 16 | 14 | 
| 17 namespace views { | 15 namespace views { | 
| 18 | 16 | 
| 19 class Painter; | 17 class Painter; | 
| 20 | 18 | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 47 | 45 | 
| 48   // Set the image that should be displayed from a pointer. Reset the image | 46   // Set the image that should be displayed from a pointer. Reset the image | 
| 49   // if the pointer is NULL. The pointer contents is copied in the receiver's | 47   // if the pointer is NULL. The pointer contents is copied in the receiver's | 
| 50   // image. | 48   // image. | 
| 51   void SetImage(const gfx::ImageSkia* image_skia); | 49   void SetImage(const gfx::ImageSkia* image_skia); | 
| 52 | 50 | 
| 53   // Returns the image currently displayed or NULL of none is currently set. | 51   // Returns the image currently displayed or NULL of none is currently set. | 
| 54   // The returned image is still owned by the ImageView. | 52   // The returned image is still owned by the ImageView. | 
| 55   const gfx::ImageSkia& GetImage(); | 53   const gfx::ImageSkia& GetImage(); | 
| 56 | 54 | 
| 57   // Tells the view to draw a monochrome vector image identified by |id| using |  | 
| 58   // |color|. The size of the view and the image will be set to |image_size|. |  | 
| 59   void SetVectorIcon(gfx::VectorIconId id, |  | 
| 60                      SkColor color, |  | 
| 61                      const gfx::Size& image_size); |  | 
| 62 |  | 
| 63   // Set the desired image size for the receiving ImageView. | 55   // Set the desired image size for the receiving ImageView. | 
| 64   void SetImageSize(const gfx::Size& image_size); | 56   void SetImageSize(const gfx::Size& image_size); | 
| 65 | 57 | 
|  | 58   // Return the preferred size for the receiving view. Returns false if the | 
|  | 59   // preferred size is not defined, which means that the view uses the image | 
|  | 60   // size. | 
|  | 61   bool GetImageSize(gfx::Size* image_size) const; | 
|  | 62 | 
| 66   // Returns the actual bounds of the visible image inside the view. | 63   // Returns the actual bounds of the visible image inside the view. | 
| 67   gfx::Rect GetImageBounds() const; | 64   gfx::Rect GetImageBounds() const; | 
| 68 | 65 | 
| 69   // Reset the image size to the current image dimensions. | 66   // Reset the image size to the current image dimensions. | 
| 70   void ResetImageSize(); | 67   void ResetImageSize(); | 
| 71 | 68 | 
| 72   // Set / Get the horizontal alignment. | 69   // Set / Get the horizontal alignment. | 
| 73   void SetHorizontalAlignment(Alignment ha); | 70   void SetHorizontalAlignment(Alignment ha); | 
| 74   Alignment GetHorizontalAlignment() const; | 71   Alignment GetHorizontalAlignment() const; | 
| 75 | 72 | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 92   void OnPaint(gfx::Canvas* canvas) override; | 89   void OnPaint(gfx::Canvas* canvas) override; | 
| 93   void GetAccessibleState(ui::AXViewState* state) override; | 90   void GetAccessibleState(ui::AXViewState* state) override; | 
| 94   const char* GetClassName() const override; | 91   const char* GetClassName() const override; | 
| 95   bool GetTooltipText(const gfx::Point& p, | 92   bool GetTooltipText(const gfx::Point& p, | 
| 96                       base::string16* tooltip) const override; | 93                       base::string16* tooltip) const override; | 
| 97   bool CanProcessEventsWithinSubtree() const override; | 94   bool CanProcessEventsWithinSubtree() const override; | 
| 98 | 95 | 
| 99  private: | 96  private: | 
| 100   void OnPaintImage(gfx::Canvas* canvas); | 97   void OnPaintImage(gfx::Canvas* canvas); | 
| 101 | 98 | 
| 102   void OnPaintVectorIcon(gfx::Canvas* canvas); |  | 
| 103 |  | 
| 104   // Returns true if |img| is the same as the last image we painted. This is | 99   // Returns true if |img| is the same as the last image we painted. This is | 
| 105   // intended to be a quick check, not exhaustive. In other words it's possible | 100   // intended to be a quick check, not exhaustive. In other words it's possible | 
| 106   // for this to return false even though the images are in fact equal. | 101   // for this to return false even though the images are in fact equal. | 
| 107   bool IsImageEqual(const gfx::ImageSkia& img) const; | 102   bool IsImageEqual(const gfx::ImageSkia& img) const; | 
| 108 | 103 | 
| 109   // Compute the image origin given the desired size and the receiver alignment | 104   // Compute the image origin given the desired size and the receiver alignment | 
| 110   // properties. | 105   // properties. | 
| 111   gfx::Point ComputeImageOrigin(const gfx::Size& image_size) const; | 106   gfx::Point ComputeImageOrigin(const gfx::Size& image_size) const; | 
| 112 | 107 | 
| 113   // Whether the image size is set. | 108   // Whether the image size is set. | 
| 114   bool image_size_set_; | 109   bool image_size_set_; | 
| 115 | 110 | 
| 116   // The actual image size. | 111   // The actual image size. | 
| 117   gfx::Size image_size_; | 112   gfx::Size image_size_; | 
| 118 | 113 | 
| 119   // The underlying image. | 114   // The underlying image. | 
| 120   gfx::ImageSkia image_; | 115   gfx::ImageSkia image_; | 
| 121 | 116 | 
| 122   // The ID of the vector icon that should be drawn, or gfx::VECTOR_ICON_NONE. |  | 
| 123   // This is drawn in addition to |image_|, but in most cases you probably want |  | 
| 124   // one or the other and not both. |  | 
| 125   gfx::VectorIconId vector_id_; |  | 
| 126 |  | 
| 127   // The color to use when drawing the vector icon. |  | 
| 128   SkColor vector_color_; |  | 
| 129 |  | 
| 130   // Horizontal alignment. | 117   // Horizontal alignment. | 
| 131   Alignment horiz_alignment_; | 118   Alignment horiz_alignment_; | 
| 132 | 119 | 
| 133   // Vertical alignment. | 120   // Vertical alignment. | 
| 134   Alignment vert_alignment_; | 121   Alignment vert_alignment_; | 
| 135 | 122 | 
| 136   // The current tooltip text. | 123   // The current tooltip text. | 
| 137   base::string16 tooltip_text_; | 124   base::string16 tooltip_text_; | 
| 138 | 125 | 
| 139   // A flag controlling hit test handling for interactivity. | 126   // A flag controlling hit test handling for interactivity. | 
| 140   bool interactive_; | 127   bool interactive_; | 
| 141 | 128 | 
| 142   // Scale last painted at. | 129   // Scale last painted at. | 
| 143   float last_paint_scale_; | 130   float last_paint_scale_; | 
| 144 | 131 | 
| 145   // Address of bytes we last painted. This is used only for comparison, so its | 132   // Address of bytes we last painted. This is used only for comparison, so its | 
| 146   // safe to cache. | 133   // safe to cache. | 
| 147   void* last_painted_bitmap_pixels_; | 134   void* last_painted_bitmap_pixels_; | 
| 148 | 135 | 
| 149   scoped_ptr<views::Painter> focus_painter_; | 136   scoped_ptr<views::Painter> focus_painter_; | 
| 150 | 137 | 
| 151   DISALLOW_COPY_AND_ASSIGN(ImageView); | 138   DISALLOW_COPY_AND_ASSIGN(ImageView); | 
| 152 }; | 139 }; | 
| 153 | 140 | 
| 154 }  // namespace views | 141 }  // namespace views | 
| 155 | 142 | 
| 156 #endif  // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ | 143 #endif  // UI_VIEWS_CONTROLS_IMAGE_VIEW_H_ | 
| OLD | NEW | 
|---|