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