Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / frame / default_header_painter.h
bloba79f3d5f47092a9d00b820a6dc7242430102ef60
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 GetHeaderHeight() const override;
47 int GetHeaderHeightForPainting() const override;
48 void SetHeaderHeightForPainting(int height) override;
49 void SchedulePaintForTitle() override;
50 void UpdateLeftViewXInset(int left_view_x_inset) override;
52 // Sets the left header view for the header. Passing NULL removes the view.
53 void UpdateLeftHeaderView(views::View* left_header_view);
55 // Sets the active and inactive frame colors. Note the inactive frame color
56 // will have some transparency added when the frame is drawn.
57 void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
59 private:
60 FRIEND_TEST_ALL_PREFIXES(DefaultHeaderPainterTest, TitleIconAlignment);
61 FRIEND_TEST_ALL_PREFIXES(DefaultHeaderPainterTest, LightIcons);
63 // gfx::AnimationDelegate override:
64 void AnimationProgressed(const gfx::Animation* animation) override;
66 // Paints highlight around the edge of the header for inactive restored
67 // windows.
68 void PaintHighlightForInactiveRestoredWindow(gfx::Canvas* canvas);
70 // Paints the title bar, primarily the title string.
71 void PaintTitleBar(gfx::Canvas* canvas);
73 // Paints the header/content separator.
74 void PaintHeaderContentSeparator(gfx::Canvas* canvas);
76 // Layout the left header view.
77 void LayoutLeftHeaderView();
79 // Whether light caption images should be used. This is the case when the
80 // background of the frame is dark.
81 bool ShouldUseLightImages();
83 // Update all the images in the caption buttons.
84 void UpdateAllButtonImages();
86 // Updates the size button's images.
87 void UpdateSizeButtonImages(bool use_light_images);
89 // Returns the header bounds in the coordinates of |view_|. The header is
90 // assumed to be positioned at the top left corner of |view_| and to have the
91 // same width as |view_|.
92 gfx::Rect GetLocalBounds() const;
94 // Returns the bounds for the title.
95 gfx::Rect GetTitleBounds() const;
97 // Returns whether the frame uses custom frame coloring.
98 bool UsesCustomFrameColors() const;
100 views::Widget* frame_;
101 views::View* view_;
102 views::View* left_header_view_; // May be NULL.
103 int left_view_x_inset_;
104 SkColor active_frame_color_;
105 SkColor inactive_frame_color_;
106 FrameCaptionButtonContainerView* caption_button_container_;
108 // The height of the header to paint.
109 int painted_height_;
111 // Whether the header should be painted as active.
112 Mode mode_;
114 // Whether the header is painted for the first time.
115 bool initial_paint_;
117 scoped_ptr<gfx::SlideAnimation> activation_animation_;
119 DISALLOW_COPY_AND_ASSIGN(DefaultHeaderPainter);
122 } // namespace ash
124 #endif // ASH_FRAME_DEFAULT_HEADER_PAINTER_H_