browser_header_painter_ash.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright 2014 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 CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
6#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
7
8#include "ash/frame/header_painter.h"
9#include "base/basictypes.h"
10#include "base/compiler_specific.h"  // OVERRIDE
11#include "base/memory/scoped_ptr.h"
12#include "ui/gfx/animation/animation_delegate.h"
13
14class BrowserView;
15
16namespace ash {
17class FrameCaptionButtonContainerView;
18}
19
20namespace gfx {
21class ImageSkia;
22class Rect;
23class SlideAnimation;
24}
25namespace views {
26class View;
27class Widget;
28}
29
30// Helper class for painting the browser window header.
31class BrowserHeaderPainterAsh : public ash::HeaderPainter,
32                                public gfx::AnimationDelegate {
33 public:
34  BrowserHeaderPainterAsh();
35  virtual ~BrowserHeaderPainterAsh();
36
37  // BrowserHeaderPainterAsh does not take ownership of any of the parameters.
38  void Init(
39    views::Widget* frame,
40    BrowserView* browser_view,
41    views::View* header_view,
42    views::View* window_icon,
43    ash::FrameCaptionButtonContainerView* caption_button_container);
44
45  // ash::HeaderPainter overrides:
46  virtual int GetMinimumHeaderWidth() const OVERRIDE;
47  virtual void PaintHeader(gfx::Canvas* canvas, Mode mode) OVERRIDE;
48  virtual void LayoutHeader() OVERRIDE;
49  virtual int GetHeaderHeightForPainting() const OVERRIDE;
50  virtual void SetHeaderHeightForPainting(int height) OVERRIDE;
51  virtual void SchedulePaintForTitle() OVERRIDE;
52
53 private:
54  // gfx::AnimationDelegate override:
55  virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
56
57  // Paints highlight around the edge of the header for restored windows.
58  void PaintHighlightForRestoredWindow(gfx::Canvas* canvas);
59
60  // Paints the title bar, primarily the title string.
61  void PaintTitleBar(gfx::Canvas* canvas);
62
63  // Sets |frame_image| and |frame_overlay_image| to the frame image and the
64  // frame overlay image respectivately which should be used to paint the
65  // header.
66  void GetFrameImages(Mode mode,
67                      gfx::ImageSkia* frame_image,
68                      gfx::ImageSkia* frame_overlay_image) const;
69
70  // Sets |frame_image| and |frame_overlay_image| to the frame image and the
71  // frame overlay image respectively that should be used to paint the header
72  // for tabbed browser windows.
73  void GetFrameImagesForTabbedBrowser(
74      Mode mode,
75      gfx::ImageSkia* frame_image,
76      gfx::ImageSkia* frame_overlay_image) const;
77
78  // Returns the frame image which should be used to paint the header for popup
79  // browser windows and for hosted app windows which show the toolbar.
80  gfx::ImageSkia GetFrameImageForNonTabbedBrowser(Mode mode) const;
81
82  // Updates the images used for the minimize, restore and close buttons.
83  void UpdateCaptionButtonImages();
84
85  // Returns bounds of the region in |view_| which is painted with the header
86  // images. The region is assumed to start at the top left corner of |view_|
87  // and to have the same width as |view_|.
88  gfx::Rect GetPaintedBounds() const;
89
90  // Returns the bounds for the title.
91  gfx::Rect GetTitleBounds() const;
92
93  views::Widget* frame_;
94
95  // Whether the header is for a tabbed browser window.
96  bool is_tabbed_;
97
98  // Whether the header is for an incognito browser window.
99  bool is_incognito_;
100
101  // The header view.
102  views::View* view_;
103
104  views::View* window_icon_;
105  ash::FrameCaptionButtonContainerView* caption_button_container_;
106  int painted_height_;
107
108  // Whether the header is painted for the first time.
109  bool initial_paint_;
110
111  // Whether the header should be painted as active.
112  Mode mode_;
113
114  scoped_ptr<gfx::SlideAnimation> activation_animation_;
115
116  DISALLOW_COPY_AND_ASSIGN(BrowserHeaderPainterAsh);
117};
118
119#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
120