| 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 ASH_WM_IMAGE_GRID_H_ | 5 #ifndef ASH_WM_IMAGE_GRID_H_ |
| 6 #define ASH_WM_IMAGE_GRID_H_ | 6 #define ASH_WM_IMAGE_GRID_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 ImageGrid(); | 103 ImageGrid(); |
| 104 ~ImageGrid(); | 104 ~ImageGrid(); |
| 105 | 105 |
| 106 ui::Layer* layer() { return layer_.get(); } | 106 ui::Layer* layer() { return layer_.get(); } |
| 107 int top_image_height() const { return top_image_height_; } | 107 int top_image_height() const { return top_image_height_; } |
| 108 int bottom_image_height() const { return bottom_image_height_; } | 108 int bottom_image_height() const { return bottom_image_height_; } |
| 109 int left_image_width() const { return left_image_width_; } | 109 int left_image_width() const { return left_image_width_; } |
| 110 int right_image_width() const { return right_image_width_; } | 110 int right_image_width() const { return right_image_width_; } |
| 111 | 111 |
| 112 // Initializes the grid to display the passed-in images (any of which can be | 112 // Sets the grid to display the passed-in images (any of which can be NULL). |
| 113 // NULL). Ownership of the images remains with the caller. | 113 // Ownership of the images remains with the caller. May be called more than |
| 114 void Init(const gfx::Image* top_left_image, | 114 // once to switch images. |
| 115 const gfx::Image* top_image, | 115 void SetImages(const gfx::Image* top_left_image, |
| 116 const gfx::Image* top_right_image, | 116 const gfx::Image* top_image, |
| 117 const gfx::Image* left_image, | 117 const gfx::Image* top_right_image, |
| 118 const gfx::Image* center_image, | 118 const gfx::Image* left_image, |
| 119 const gfx::Image* right_image, | 119 const gfx::Image* center_image, |
| 120 const gfx::Image* bottom_left_image, | 120 const gfx::Image* right_image, |
| 121 const gfx::Image* bottom_image, | 121 const gfx::Image* bottom_left_image, |
| 122 const gfx::Image* bottom_right_image); | 122 const gfx::Image* bottom_image, |
| 123 const gfx::Image* bottom_right_image); |
| 123 | 124 |
| 124 void SetSize(const gfx::Size& size); | 125 void SetSize(const gfx::Size& size); |
| 125 | 126 |
| 126 private: | 127 private: |
| 127 // Delegate responsible for painting a specific image on a layer. | 128 // Delegate responsible for painting a specific image on a layer. |
| 128 class ImagePainter : public ui::LayerDelegate { | 129 class ImagePainter : public ui::LayerDelegate { |
| 129 public: | 130 public: |
| 130 ImagePainter(const gfx::Image* image) : image_(image) {} | 131 ImagePainter(const gfx::Image* image) : image_(image) {} |
| 131 virtual ~ImagePainter() {} | 132 virtual ~ImagePainter() {} |
| 132 | 133 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 146 | 147 |
| 147 DISALLOW_COPY_AND_ASSIGN(ImagePainter); | 148 DISALLOW_COPY_AND_ASSIGN(ImagePainter); |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 // Returns the dimensions of |image| if non-NULL or gfx::Size(0, 0) otherwise. | 151 // Returns the dimensions of |image| if non-NULL or gfx::Size(0, 0) otherwise. |
| 151 static gfx::Size GetImageSize(const gfx::Image* image); | 152 static gfx::Size GetImageSize(const gfx::Image* image); |
| 152 | 153 |
| 153 // Returns true if |layer|'s bounds don't fit within |size|. | 154 // Returns true if |layer|'s bounds don't fit within |size|. |
| 154 static bool LayerExceedsSize(const ui::Layer* layer, const gfx::Size& size); | 155 static bool LayerExceedsSize(const ui::Layer* layer, const gfx::Size& size); |
| 155 | 156 |
| 156 // Initializes |layer_ptr| and |painter_ptr| to display |image|. | 157 // Sets |layer_ptr| and |painter_ptr| to display |image| and adds the |
| 157 // Also adds the passed-in layer to |layer_|. | 158 // passed-in layer to |layer_|. If image is NULL resets |layer_ptr| and |
| 158 void InitImage(const gfx::Image* image, | 159 // |painter_ptr| and removes any existing layer from |layer_|. |
| 159 scoped_ptr<ui::Layer>* layer_ptr, | 160 void SetImage(const gfx::Image* image, |
| 160 scoped_ptr<ImagePainter>* painter_ptr); | 161 scoped_ptr<ui::Layer>* layer_ptr, |
| 162 scoped_ptr<ImagePainter>* painter_ptr); |
| 161 | 163 |
| 162 // Layer that contains all of the image layers. | 164 // Layer that contains all of the image layers. |
| 163 scoped_ptr<ui::Layer> layer_; | 165 scoped_ptr<ui::Layer> layer_; |
| 164 | 166 |
| 165 // The grid's dimensions. | 167 // The grid's dimensions. |
| 166 gfx::Size size_; | 168 gfx::Size size_; |
| 167 | 169 |
| 168 // Heights and widths of the images displayed by |top_layer_|, | 170 // Heights and widths of the images displayed by |top_layer_|, |
| 169 // |bottom_layer_|, |left_layer_|, and |right_layer_|. | 171 // |bottom_layer_|, |left_layer_|, and |right_layer_|. |
| 170 int top_image_height_; | 172 int top_image_height_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 scoped_ptr<ImagePainter> bottom_painter_; | 205 scoped_ptr<ImagePainter> bottom_painter_; |
| 204 scoped_ptr<ImagePainter> bottom_right_painter_; | 206 scoped_ptr<ImagePainter> bottom_right_painter_; |
| 205 | 207 |
| 206 DISALLOW_COPY_AND_ASSIGN(ImageGrid); | 208 DISALLOW_COPY_AND_ASSIGN(ImageGrid); |
| 207 }; | 209 }; |
| 208 | 210 |
| 209 } // namespace internal | 211 } // namespace internal |
| 210 } // namespace ash | 212 } // namespace ash |
| 211 | 213 |
| 212 #endif // ASH_WM_IMAGE_GRID_H_ | 214 #endif // ASH_WM_IMAGE_GRID_H_ |
| OLD | NEW |