| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 ASH_MUS_FRAME_DEFAULT_HEADER_PAINTER_H_ | |
| 6 #define ASH_MUS_FRAME_DEFAULT_HEADER_PAINTER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "ash/mus/frame/header_painter.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "third_party/skia/include/core/SkColor.h" | |
| 13 #include "ui/gfx/animation/animation_delegate.h" | |
| 14 | |
| 15 namespace gfx { | |
| 16 class ImageSkia; | |
| 17 class Rect; | |
| 18 class SlideAnimation; | |
| 19 } | |
| 20 namespace views { | |
| 21 class View; | |
| 22 class Widget; | |
| 23 } | |
| 24 | |
| 25 namespace ash { | |
| 26 namespace mus { | |
| 27 | |
| 28 class FrameCaptionButtonContainerView; | |
| 29 | |
| 30 // Helper class for painting the default window header. | |
| 31 class DefaultHeaderPainter : public HeaderPainter, | |
| 32 public gfx::AnimationDelegate { | |
| 33 public: | |
| 34 DefaultHeaderPainter(); | |
| 35 ~DefaultHeaderPainter() override; | |
| 36 | |
| 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); | |
| 41 | |
| 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 | |
| 51 // Sets the left header view for the header. Passing NULL removes the view. | |
| 52 void UpdateLeftHeaderView(views::View* left_header_view); | |
| 53 | |
| 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); | |
| 57 | |
| 58 private: | |
| 59 // gfx::AnimationDelegate override: | |
| 60 void AnimationProgressed(const gfx::Animation* animation) override; | |
| 61 | |
| 62 // Paints highlight around the edge of the header for inactive restored | |
| 63 // windows. | |
| 64 void PaintHighlightForInactiveRestoredWindow(gfx::Canvas* canvas); | |
| 65 | |
| 66 // Paints the title bar, primarily the title string. | |
| 67 void PaintTitleBar(gfx::Canvas* canvas); | |
| 68 | |
| 69 // Paints the header/content separator. | |
| 70 void PaintHeaderContentSeparator(gfx::Canvas* canvas); | |
| 71 | |
| 72 // Whether light caption images should be used. This is the case when the | |
| 73 // background of the frame is dark. | |
| 74 bool ShouldUseLightImages(); | |
| 75 | |
| 76 // Update all the images in the caption buttons. | |
| 77 void UpdateAllButtonImages(); | |
| 78 | |
| 79 // Updates the size button's images. | |
| 80 void UpdateSizeButtonImages(bool use_light_images); | |
| 81 | |
| 82 // Returns the header bounds in the coordinates of |view_|. The header is | |
| 83 // assumed to be positioned at the top left corner of |view_| and to have the | |
| 84 // same width as |view_|. | |
| 85 gfx::Rect GetLocalBounds() const; | |
| 86 | |
| 87 // Returns the bounds for the title. | |
| 88 gfx::Rect GetTitleBounds() const; | |
| 89 | |
| 90 // Returns whether the frame uses custom frame coloring. | |
| 91 bool UsesCustomFrameColors() const; | |
| 92 | |
| 93 views::Widget* frame_; | |
| 94 views::View* view_; | |
| 95 views::View* left_header_view_; // May be NULL. | |
| 96 SkColor active_frame_color_; | |
| 97 SkColor inactive_frame_color_; | |
| 98 FrameCaptionButtonContainerView* caption_button_container_; | |
| 99 | |
| 100 // The height of the header to paint. | |
| 101 int painted_height_; | |
| 102 | |
| 103 // Whether the header should be painted as active. | |
| 104 Mode mode_; | |
| 105 | |
| 106 // Whether the header is painted for the first time. | |
| 107 bool initial_paint_; | |
| 108 | |
| 109 std::unique_ptr<gfx::SlideAnimation> activation_animation_; | |
| 110 | |
| 111 DISALLOW_COPY_AND_ASSIGN(DefaultHeaderPainter); | |
| 112 }; | |
| 113 | |
| 114 } // namespace mus | |
| 115 } // namespace ash | |
| 116 | |
| 117 #endif // ASH_MUS_FRAME_DEFAULT_HEADER_PAINTER_H_ | |
| OLD | NEW |