| 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_WINDOW_FRAME_BACKGROUND_H_ | 5 #ifndef UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_ |
| 6 #define UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_ | 6 #define UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "ui/views/views_export.h" | 11 #include "ui/views/views_export.h" |
| 12 | 12 |
| 13 class SkBitmap; | |
| 14 namespace gfx { | 13 namespace gfx { |
| 15 class Canvas; | 14 class Canvas; |
| 15 class ImageSkia; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 class View; | 20 class View; |
| 21 | 21 |
| 22 // FrameBackground handles painting for all the various window frames we | 22 // FrameBackground handles painting for all the various window frames we |
| 23 // support in Chrome. It intends to consolidate paint code that historically | 23 // support in Chrome. It intends to consolidate paint code that historically |
| 24 // was copied. One frame to rule them all! | 24 // was copied. One frame to rule them all! |
| 25 class VIEWS_EXPORT FrameBackground { | 25 class VIEWS_EXPORT FrameBackground { |
| 26 public: | 26 public: |
| 27 FrameBackground(); | 27 FrameBackground(); |
| 28 ~FrameBackground(); | 28 ~FrameBackground(); |
| 29 | 29 |
| 30 // Sets the color to draw under the frame bitmaps. | 30 // Sets the color to draw under the frame images. |
| 31 void set_frame_color(SkColor color) { frame_color_ = color; } | 31 void set_frame_color(SkColor color) { frame_color_ = color; } |
| 32 | 32 |
| 33 // Sets the theme bitmap for the top of the window. May be NULL. | 33 // Sets the theme image for the top of the window. May be NULL. |
| 34 // Memory is owned by the caller. | 34 // Memory is owned by the caller. |
| 35 void set_theme_bitmap(const SkBitmap* bitmap) { theme_bitmap_ = bitmap; } | 35 void set_theme_image(const gfx::ImageSkia* image) { theme_image_ = image; } |
| 36 | 36 |
| 37 // Sets an image that overlays the top window bitmap. Usually used to add | 37 // Sets an image that overlays the top window image. Usually used to add |
| 38 // edge highlighting to provide the illusion of depth. May be NULL. | 38 // edge highlighting to provide the illusion of depth. May be NULL. |
| 39 // Memory is owned by the caller. | 39 // Memory is owned by the caller. |
| 40 void set_theme_overlay_bitmap(SkBitmap* bitmap) { | 40 void set_theme_overlay_image(gfx::ImageSkia* image) { |
| 41 theme_overlay_bitmap_ = bitmap; | 41 theme_overlay_image_ = image; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Sets the height of the top area to fill with the default frame color, | 44 // Sets the height of the top area to fill with the default frame color, |
| 45 // which must extend behind the tab strip. | 45 // which must extend behind the tab strip. |
| 46 void set_top_area_height(int height) { top_area_height_ = height; } | 46 void set_top_area_height(int height) { top_area_height_ = height; } |
| 47 | 47 |
| 48 // Only used if we have an overlay image for the theme. | 48 // Only used if we have an overlay image for the theme. |
| 49 void set_theme_background_y(int y) { theme_background_y_ = y; } | 49 void set_theme_background_y(int y) { theme_background_y_ = y; } |
| 50 | 50 |
| 51 // Vertical offset for theme image when drawing maximized. | 51 // Vertical offset for theme image when drawing maximized. |
| 52 void set_maximized_top_offset(int offset) { maximized_top_offset_ = offset; } | 52 void set_maximized_top_offset(int offset) { maximized_top_offset_ = offset; } |
| 53 | 53 |
| 54 // Sets images used when drawing the sides of the frame. | 54 // Sets images used when drawing the sides of the frame. |
| 55 // Caller owns the memory. | 55 // Caller owns the memory. |
| 56 void SetSideImages(const SkBitmap* left, | 56 void SetSideImages(const gfx::ImageSkia* left, |
| 57 const SkBitmap* top, | 57 const gfx::ImageSkia* top, |
| 58 const SkBitmap* right, | 58 const gfx::ImageSkia* right, |
| 59 const SkBitmap* bottom); | 59 const gfx::ImageSkia* bottom); |
| 60 | 60 |
| 61 // Sets images used when drawing the corners of the frame. | 61 // Sets images used when drawing the corners of the frame. |
| 62 // Caller owns the memory. | 62 // Caller owns the memory. |
| 63 void SetCornerImages(const SkBitmap* top_left, | 63 void SetCornerImages(const gfx::ImageSkia* top_left, |
| 64 const SkBitmap* top_right, | 64 const gfx::ImageSkia* top_right, |
| 65 const SkBitmap* bottom_left, | 65 const gfx::ImageSkia* bottom_left, |
| 66 const SkBitmap* bottom_right); | 66 const gfx::ImageSkia* bottom_right); |
| 67 | 67 |
| 68 // Paints the border for a standard, non-maximized window. Also paints the | 68 // Paints the border for a standard, non-maximized window. Also paints the |
| 69 // background of the title bar area, since the top frame border and the | 69 // background of the title bar area, since the top frame border and the |
| 70 // title bar background are a contiguous component. | 70 // title bar background are a contiguous component. |
| 71 void PaintRestored(gfx::Canvas* canvas, View* view) const; | 71 void PaintRestored(gfx::Canvas* canvas, View* view) const; |
| 72 | 72 |
| 73 // Paints the border for a maximized window, which does not include the | 73 // Paints the border for a maximized window, which does not include the |
| 74 // window edges. | 74 // window edges. |
| 75 void PaintMaximized(gfx::Canvas* canvas, View* view) const; | 75 void PaintMaximized(gfx::Canvas* canvas, View* view) const; |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 // Fills the frame area with the frame color. | 78 // Fills the frame area with the frame color. |
| 79 void PaintFrameColor(gfx::Canvas* canvas, View* view) const; | 79 void PaintFrameColor(gfx::Canvas* canvas, View* view) const; |
| 80 | 80 |
| 81 SkColor frame_color_; | 81 SkColor frame_color_; |
| 82 const SkBitmap* theme_bitmap_; | 82 const gfx::ImageSkia* theme_image_; |
| 83 SkBitmap* theme_overlay_bitmap_; | 83 gfx::ImageSkia* theme_overlay_image_; |
| 84 int top_area_height_; | 84 int top_area_height_; |
| 85 | 85 |
| 86 // Images for the sides of the frame. | 86 // Images for the sides of the frame. |
| 87 const SkBitmap* left_edge_; | 87 const gfx::ImageSkia* left_edge_; |
| 88 const SkBitmap* top_edge_; | 88 const gfx::ImageSkia* top_edge_; |
| 89 const SkBitmap* right_edge_; | 89 const gfx::ImageSkia* right_edge_; |
| 90 const SkBitmap* bottom_edge_; | 90 const gfx::ImageSkia* bottom_edge_; |
| 91 | 91 |
| 92 // Images for the corners of the frame. | 92 // Images for the corners of the frame. |
| 93 const SkBitmap* top_left_corner_; | 93 const gfx::ImageSkia* top_left_corner_; |
| 94 const SkBitmap* top_right_corner_; | 94 const gfx::ImageSkia* top_right_corner_; |
| 95 const SkBitmap* bottom_left_corner_; | 95 const gfx::ImageSkia* bottom_left_corner_; |
| 96 const SkBitmap* bottom_right_corner_; | 96 const gfx::ImageSkia* bottom_right_corner_; |
| 97 | 97 |
| 98 // Attributes for maximized window painting. | 98 // Attributes for maximized window painting. |
| 99 // TODO(jamescook): Remove all these. | 99 // TODO(jamescook): Remove all these. |
| 100 SkBitmap* maximized_top_left_; | 100 gfx::ImageSkia* maximized_top_left_; |
| 101 SkBitmap* maximized_top_right_; | 101 gfx::ImageSkia* maximized_top_right_; |
| 102 int maximized_top_offset_; | 102 int maximized_top_offset_; |
| 103 int theme_background_y_; | 103 int theme_background_y_; |
| 104 | 104 |
| 105 DISALLOW_COPY_AND_ASSIGN(FrameBackground); | 105 DISALLOW_COPY_AND_ASSIGN(FrameBackground); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 } // namespace views | 108 } // namespace views |
| 109 | 109 |
| 110 #endif // UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_ | 110 #endif // UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_ |
| OLD | NEW |