Now launching WebRTC-AppRTC test with Collider.
[chromium-blink-merge.git] / ash / frame / default_header_painter.h
blob4c875c04978cc4d65fa992f27a85c4eb318918fd
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.
5 #ifndef ASH_FRAME_DEFAULT_HEADER_PAINTER_H_
6 #define ASH_FRAME_DEFAULT_HEADER_PAINTER_H_
8 #include "ash/ash_export.h"
9 #include "ash/frame/header_painter.h"
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" // override
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/animation/animation_delegate.h"
17 namespace gfx {
18 class ImageSkia;
19 class Rect;
20 class SlideAnimation;
22 namespace views {
23 class View;
24 class Widget;
27 namespace ash {
28 class FrameCaptionButtonContainerView;
30 // Helper class for painting the default window header.
31 class ASH_EXPORT DefaultHeaderPainter : public HeaderPainter,
32 public gfx::AnimationDelegate {
33 public:
34 DefaultHeaderPainter();
35 ~DefaultHeaderPainter() override;
37 // DefaultHeaderPainter does not take ownership of any of the parameters.
38 void Init(views::Widget* frame,
39 views::View* header_view,
40 FrameCaptionButtonContainerView* caption_button_container);
42 // HeaderPainter overrides:
43 int GetMinimumHeaderWidth() const override;
44 void PaintHeader(gfx::Canvas* canvas, Mode mode) override;
45 void LayoutHeader() override;
46 int GetHeaderHeightForPainting() const override;
47 void SetHeaderHeightForPainting(int height) override;
48 void SchedulePaintForTitle() override;
49 void UpdateLeftViewXInset(int left_view_x_inset) override;
51 // Sets the left header view for the header. Passing NULL removes the view.
52 void UpdateLeftHeaderView(views::View* left_header_view);
54 // Sets the active and inactive frame colors. Note the inactive frame color
55 // will have some transparency added when the frame is drawn.
56 void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
58 private:
59 FRIEND_TEST_ALL_PREFIXES(DefaultHeaderPainterTest, TitleIconAlignment);
61 // gfx::AnimationDelegate override:
62 void AnimationProgressed(const gfx::Animation* animation) override;
64 // Paints highlight around the edge of the header for inactive restored
65 // windows.
66 void PaintHighlightForInactiveRestoredWindow(gfx::Canvas* canvas);
68 // Paints the title bar, primarily the title string.
69 void PaintTitleBar(gfx::Canvas* canvas);
71 // Paints the header/content separator.
72 void PaintHeaderContentSeparator(gfx::Canvas* canvas);
74 // Layout the left header view.
75 void LayoutLeftHeaderView();
77 // Updates the size button's images.
78 void UpdateSizeButtonImages();
80 // Returns the header bounds in the coordinates of |view_|. The header is
81 // assumed to be positioned at the top left corner of |view_| and to have the
82 // same width as |view_|.
83 gfx::Rect GetLocalBounds() const;
85 // Returns the bounds for the title.
86 gfx::Rect GetTitleBounds() const;
88 // Returns the frame color to use when |frame_| is inactive.
89 SkColor GetInactiveFrameColor() const;
91 views::Widget* frame_;
92 views::View* view_;
93 views::View* left_header_view_; // May be NULL.
94 int left_view_x_inset_;
95 SkColor active_frame_color_;
96 SkColor inactive_frame_color_;
97 FrameCaptionButtonContainerView* caption_button_container_;
99 // The height of the header including the header/content separator.
100 int height_;
102 // Whether the header should be painted as active.
103 Mode mode_;
105 // Whether the header is painted for the first time.
106 bool initial_paint_;
108 scoped_ptr<gfx::SlideAnimation> activation_animation_;
110 DISALLOW_COPY_AND_ASSIGN(DefaultHeaderPainter);
113 } // namespace ash
115 #endif // ASH_FRAME_DEFAULT_HEADER_PAINTER_H_