OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_COMMON_FRAME_HEADER_VIEW_H_ | |
6 #define ASH_COMMON_FRAME_HEADER_VIEW_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "ash/common/shell_observer.h" | |
12 #include "ash/shared/immersive_fullscreen_controller_delegate.h" | |
13 #include "base/macros.h" | |
14 #include "third_party/skia/include/core/SkColor.h" | |
15 #include "ui/views/view.h" | |
16 | |
17 namespace views { | |
18 class ImageView; | |
19 class Widget; | |
20 } | |
21 | |
22 namespace ash { | |
23 | |
24 class DefaultHeaderPainter; | |
25 class FrameCaptionButtonContainerView; | |
26 | |
27 // View which paints the frame header (title, caption buttons...). It slides off | |
28 // and on screen in immersive fullscreen. | |
29 class ASH_EXPORT HeaderView : public views::View, | |
30 public ImmersiveFullscreenControllerDelegate, | |
31 public ShellObserver { | |
32 public: | |
33 // |target_widget| is the widget that the caption buttons act on. | |
34 // |target_widget| is not necessarily the same as the widget the header is | |
35 // placed in. For example, in immersive fullscreen this view may be painted in | |
36 // a widget that slides in and out on top of the main app or browser window. | |
37 // However, clicking a caption button should act on the target widget. | |
38 explicit HeaderView(views::Widget* target_widget); | |
39 ~HeaderView() override; | |
40 | |
41 void set_is_immersive_delegate(bool value) { is_immersive_delegate_ = value; } | |
42 | |
43 // Schedules a repaint for the entire title. | |
44 void SchedulePaintForTitle(); | |
45 | |
46 // Tells the window controls to reset themselves to the normal state. | |
47 void ResetWindowControls(); | |
48 | |
49 // Returns the amount of the view's pixels which should be on screen. | |
50 int GetPreferredOnScreenHeight(); | |
51 | |
52 // Returns the view's preferred height. | |
53 int GetPreferredHeight(); | |
54 | |
55 // Returns the view's minimum width. | |
56 int GetMinimumWidth() const; | |
57 | |
58 void UpdateAvatarIcon(); | |
59 | |
60 void SizeConstraintsChanged(); | |
61 | |
62 void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color); | |
63 SkColor GetActiveFrameColor() const; | |
64 SkColor GetInactiveFrameColor() const; | |
65 | |
66 // views::View: | |
67 void Layout() override; | |
68 void OnPaint(gfx::Canvas* canvas) override; | |
69 void ChildPreferredSizeChanged(views::View* child) override; | |
70 | |
71 // ShellObserver: | |
72 void OnOverviewModeStarting() override; | |
73 void OnOverviewModeEnded() override; | |
74 void OnMaximizeModeStarted() override; | |
75 void OnMaximizeModeEnded() override; | |
76 | |
77 FrameCaptionButtonContainerView* caption_button_container() { | |
78 return caption_button_container_; | |
79 } | |
80 | |
81 views::View* avatar_icon() const; | |
82 | |
83 private: | |
84 // ImmersiveFullscreenControllerDelegate: | |
85 void OnImmersiveRevealStarted() override; | |
86 void OnImmersiveRevealEnded() override; | |
87 void OnImmersiveFullscreenExited() override; | |
88 void SetVisibleFraction(double visible_fraction) override; | |
89 std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override; | |
90 | |
91 // The widget that the caption buttons act on. | |
92 views::Widget* target_widget_; | |
93 | |
94 // Helper for painting the header. | |
95 std::unique_ptr<DefaultHeaderPainter> header_painter_; | |
96 | |
97 views::ImageView* avatar_icon_; | |
98 | |
99 // View which contains the window caption buttons. | |
100 FrameCaptionButtonContainerView* caption_button_container_; | |
101 | |
102 // The fraction of the header's height which is visible while in fullscreen. | |
103 // This value is meaningless when not in fullscreen. | |
104 double fullscreen_visible_fraction_; | |
105 | |
106 // Has this instance been set as the ImmersiveFullscreenControllerDelegate? | |
107 bool is_immersive_delegate_ = true; | |
108 | |
109 bool did_layout_ = false; | |
110 | |
111 DISALLOW_COPY_AND_ASSIGN(HeaderView); | |
112 }; | |
113 | |
114 } // namespace ash | |
115 | |
116 #endif // ASH_COMMON_FRAME_HEADER_VIEW_H_ | |
OLD | NEW |