| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_FRAME_DEFAULT_HEADER_PAINTER_H_ | 5 #ifndef ASH_FRAME_DEFAULT_HEADER_PAINTER_H_ |
| 6 #define ASH_FRAME_DEFAULT_HEADER_PAINTER_H_ | 6 #define ASH_FRAME_DEFAULT_HEADER_PAINTER_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "ash/frame/header_painter.h" | 9 #include "ash/frame/header_painter.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // Helper class for painting the default window header. | 30 // Helper class for painting the default window header. |
| 31 class ASH_EXPORT DefaultHeaderPainter : public HeaderPainter, | 31 class ASH_EXPORT DefaultHeaderPainter : public HeaderPainter, |
| 32 public gfx::AnimationDelegate { | 32 public gfx::AnimationDelegate { |
| 33 public: | 33 public: |
| 34 DefaultHeaderPainter(); | 34 DefaultHeaderPainter(); |
| 35 virtual ~DefaultHeaderPainter(); | 35 virtual ~DefaultHeaderPainter(); |
| 36 | 36 |
| 37 // DefaultHeaderPainter does not take ownership of any of the parameters. | 37 // DefaultHeaderPainter does not take ownership of any of the parameters. |
| 38 void Init(views::Widget* frame, | 38 void Init(views::Widget* frame, |
| 39 views::View* header_view, | 39 views::View* header_view, |
| 40 views::View* window_icon, | |
| 41 FrameCaptionButtonContainerView* caption_button_container); | 40 FrameCaptionButtonContainerView* caption_button_container); |
| 42 | 41 |
| 43 // HeaderPainter overrides: | 42 // HeaderPainter overrides: |
| 44 virtual int GetMinimumHeaderWidth() const OVERRIDE; | 43 virtual int GetMinimumHeaderWidth() const OVERRIDE; |
| 45 virtual void PaintHeader(gfx::Canvas* canvas, Mode mode) OVERRIDE; | 44 virtual void PaintHeader(gfx::Canvas* canvas, Mode mode) OVERRIDE; |
| 46 virtual void LayoutHeader() OVERRIDE; | 45 virtual void LayoutHeader() OVERRIDE; |
| 47 virtual int GetHeaderHeightForPainting() const OVERRIDE; | 46 virtual int GetHeaderHeightForPainting() const OVERRIDE; |
| 48 virtual void SetHeaderHeightForPainting(int height) OVERRIDE; | 47 virtual void SetHeaderHeightForPainting(int height) OVERRIDE; |
| 49 virtual void SchedulePaintForTitle() OVERRIDE; | 48 virtual void SchedulePaintForTitle() OVERRIDE; |
| 49 virtual void UpdateLeftViewXInset(int left_view_x_inset) OVERRIDE; |
| 50 | 50 |
| 51 // Sets the window icon for the header. Passing NULL removes the window icon. | 51 // Sets the left header view for the header. Passing NULL removes the view. |
| 52 void UpdateWindowIcon(views::View* window_icon, int icon_size); | 52 void UpdateLeftHeaderView(views::View* left_header_view); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 FRIEND_TEST_ALL_PREFIXES(DefaultHeaderPainterTest, TitleIconAlignment); | 55 FRIEND_TEST_ALL_PREFIXES(DefaultHeaderPainterTest, TitleIconAlignment); |
| 56 | 56 |
| 57 // gfx::AnimationDelegate override: | 57 // gfx::AnimationDelegate override: |
| 58 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 58 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 59 | 59 |
| 60 // Paints highlight around the edge of the header for inactive restored | 60 // Paints highlight around the edge of the header for inactive restored |
| 61 // windows. | 61 // windows. |
| 62 void PaintHighlightForInactiveRestoredWindow(gfx::Canvas* canvas); | 62 void PaintHighlightForInactiveRestoredWindow(gfx::Canvas* canvas); |
| 63 | 63 |
| 64 // Paints the title bar, primarily the title string. | 64 // Paints the title bar, primarily the title string. |
| 65 void PaintTitleBar(gfx::Canvas* canvas); | 65 void PaintTitleBar(gfx::Canvas* canvas); |
| 66 | 66 |
| 67 // Paints the header/content separator. | 67 // Paints the header/content separator. |
| 68 void PaintHeaderContentSeparator(gfx::Canvas* canvas); | 68 void PaintHeaderContentSeparator(gfx::Canvas* canvas); |
| 69 | 69 |
| 70 // Layout the left header view. |
| 71 void LayoutLeftHeaderView(); |
| 72 |
| 70 // Returns the header bounds in the coordinates of |view_|. The header is | 73 // Returns the header bounds in the coordinates of |view_|. The header is |
| 71 // assumed to be positioned at the top left corner of |view_| and to have the | 74 // assumed to be positioned at the top left corner of |view_| and to have the |
| 72 // same width as |view_|. | 75 // same width as |view_|. |
| 73 gfx::Rect GetLocalBounds() const; | 76 gfx::Rect GetLocalBounds() const; |
| 74 | 77 |
| 75 // Returns the bounds for the title. | 78 // Returns the bounds for the title. |
| 76 gfx::Rect GetTitleBounds() const; | 79 gfx::Rect GetTitleBounds() const; |
| 77 | 80 |
| 78 // Returns the frame color to use when |frame_| is inactive. | 81 // Returns the frame color to use when |frame_| is inactive. |
| 79 SkColor GetInactiveFrameColor() const; | 82 SkColor GetInactiveFrameColor() const; |
| 80 | 83 |
| 81 views::Widget* frame_; | 84 views::Widget* frame_; |
| 82 views::View* view_; | 85 views::View* view_; |
| 83 views::View* window_icon_; // May be NULL. | 86 views::View* left_header_view_; // May be NULL. |
| 84 int window_icon_size_; | 87 int left_view_x_inset_; |
| 85 FrameCaptionButtonContainerView* caption_button_container_; | 88 FrameCaptionButtonContainerView* caption_button_container_; |
| 86 | 89 |
| 87 // The height of the header including the header/content separator. | 90 // The height of the header including the header/content separator. |
| 88 int height_; | 91 int height_; |
| 89 | 92 |
| 90 // Whether the header should be painted as active. | 93 // Whether the header should be painted as active. |
| 91 Mode mode_; | 94 Mode mode_; |
| 92 | 95 |
| 93 // Whether the header is painted for the first time. | 96 // Whether the header is painted for the first time. |
| 94 bool initial_paint_; | 97 bool initial_paint_; |
| 95 | 98 |
| 96 scoped_ptr<gfx::SlideAnimation> activation_animation_; | 99 scoped_ptr<gfx::SlideAnimation> activation_animation_; |
| 97 | 100 |
| 98 DISALLOW_COPY_AND_ASSIGN(DefaultHeaderPainter); | 101 DISALLOW_COPY_AND_ASSIGN(DefaultHeaderPainter); |
| 99 }; | 102 }; |
| 100 | 103 |
| 101 } // namespace ash | 104 } // namespace ash |
| 102 | 105 |
| 103 #endif // ASH_FRAME_DEFAULT_HEADER_PAINTER_H_ | 106 #endif // ASH_FRAME_DEFAULT_HEADER_PAINTER_H_ |
| OLD | NEW |