Home | History | Annotate | Download | only in window
      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 
     12 namespace gfx {
     13 class Canvas;
     14 class ImageSkia;
     15 }
     16 
     17 namespace views {
     18 
     19 class 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!
     24 class 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   // Only used if we have an overlay image for the theme.
     48   void set_theme_background_y(int y) { theme_background_y_ = y; }
     49 
     50   // Vertical offset for theme image when drawing maximized.
     51   void set_maximized_top_offset(int offset) { maximized_top_offset_ = offset; }
     52 
     53   // Sets images used when drawing the sides of the frame.
     54   // Caller owns the memory.
     55   void SetSideImages(const gfx::ImageSkia* left,
     56                      const gfx::ImageSkia* top,
     57                      const gfx::ImageSkia* right,
     58                      const gfx::ImageSkia* bottom);
     59 
     60   // Sets images used when drawing the corners of the frame.
     61   // Caller owns the memory.
     62   void SetCornerImages(const gfx::ImageSkia* top_left,
     63                        const gfx::ImageSkia* top_right,
     64                        const gfx::ImageSkia* bottom_left,
     65                        const gfx::ImageSkia* bottom_right);
     66 
     67   // Paints the border for a standard, non-maximized window.  Also paints the
     68   // background of the title bar area, since the top frame border and the
     69   // title bar background are a contiguous component.
     70   void PaintRestored(gfx::Canvas* canvas, View* view) const;
     71 
     72   // Paints the border for a maximized window, which does not include the
     73   // window edges.
     74   void PaintMaximized(gfx::Canvas* canvas, View* view) const;
     75 
     76  private:
     77   // Fills the frame area with the frame color.
     78   void PaintFrameColor(gfx::Canvas* canvas, View* view) const;
     79 
     80   SkColor frame_color_;
     81   const gfx::ImageSkia* theme_image_;
     82   gfx::ImageSkia* theme_overlay_image_;
     83   int top_area_height_;
     84 
     85   // Images for the sides of the frame.
     86   const gfx::ImageSkia* left_edge_;
     87   const gfx::ImageSkia* top_edge_;
     88   const gfx::ImageSkia* right_edge_;
     89   const gfx::ImageSkia* bottom_edge_;
     90 
     91   // Images for the corners of the frame.
     92   const gfx::ImageSkia* top_left_corner_;
     93   const gfx::ImageSkia* top_right_corner_;
     94   const gfx::ImageSkia* bottom_left_corner_;
     95   const gfx::ImageSkia* bottom_right_corner_;
     96 
     97   // Attributes for maximized window painting.
     98   // TODO(jamescook): Remove all these.
     99   gfx::ImageSkia* maximized_top_left_;
    100   gfx::ImageSkia* maximized_top_right_;
    101   int maximized_top_offset_;
    102   int theme_background_y_;
    103 
    104   DISALLOW_COPY_AND_ASSIGN(FrameBackground);
    105 };
    106 
    107 }  // namespace views
    108 
    109 #endif  // UI_VIEWS_WINDOW_FRAME_BACKGROUND_H_
    110