forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnon_client_frame_view_ash.h
172 lines (132 loc) · 6.15 KB
/
non_client_frame_view_ash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_FRAME_NON_CLIENT_FRAME_VIEW_ASH_H_
#define ASH_FRAME_NON_CLIENT_FRAME_VIEW_ASH_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/frame/header_view.h"
#include "ash/wm/overview/overview_observer.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/non_client_view.h"
namespace chromeos {
class FrameCaptionButtonContainerView;
class ImmersiveFullscreenController;
class MoveToDesksMenuModel;
}
namespace views {
class Widget;
class MenuRunner;
}
namespace ash {
class NonClientFrameViewAshImmersiveHelper;
// A NonClientFrameView used for packaged apps, dialogs and other non-browser
// windows. It supports immersive fullscreen. When in immersive fullscreen, the
// client view takes up the entire widget and the window header is an overlay.
// The window header overlay slides onscreen when the user hovers the mouse at
// the top of the screen. See also views::CustomFrameView and
// BrowserNonClientFrameViewAsh.
class ASH_EXPORT NonClientFrameViewAsh : public views::NonClientFrameView,
public views::ContextMenuController {
public:
METADATA_HEADER(NonClientFrameViewAsh);
// |control_immersive| controls whether ImmersiveFullscreenController is
// created for the NonClientFrameViewAsh; if true and a WindowStateDelegate
// has not been set on the WindowState associated with |frame|, then an
// ImmersiveFullscreenController is created.
explicit NonClientFrameViewAsh(views::Widget* frame);
NonClientFrameViewAsh(const NonClientFrameViewAsh&) = delete;
NonClientFrameViewAsh& operator=(const NonClientFrameViewAsh&) = delete;
~NonClientFrameViewAsh() override;
static NonClientFrameViewAsh* Get(aura::Window* window);
// Sets the caption button modeland updates the caption buttons.
void SetCaptionButtonModel(
std::unique_ptr<chromeos::CaptionButtonModel> model);
// Inits |immersive_fullscreen_controller| so that the controller reveals
// and hides |header_view_| in immersive fullscreen.
// NonClientFrameViewAsh does not take ownership of
// |immersive_fullscreen_controller|.
void InitImmersiveFullscreenControllerForView(
chromeos::ImmersiveFullscreenController* immersive_fullscreen_controller);
// Sets the active and inactive frame colors. Note the inactive frame color
// will have some transparency added when the frame is drawn.
void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
// Get the view of the header.
HeaderView* GetHeaderView();
// Calculate the client bounds for given window bounds.
gfx::Rect GetClientBoundsForWindowBounds(
const gfx::Rect& window_bounds) const;
// views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override;
gfx::Rect GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const override;
int NonClientHitTest(const gfx::Point& point) override;
void GetWindowMask(const gfx::Size& size, SkPath* window_mask) override;
void ResetWindowControls() override;
void UpdateWindowIcon() override;
void UpdateWindowTitle() override;
void SizeConstraintsChanged() override;
// views::View:
gfx::Size CalculatePreferredSize() const override;
void Layout() override;
gfx::Size GetMinimumSize() const override;
gfx::Size GetMaximumSize() const override;
// views::ContextMenuController:
void ShowContextMenuForViewImpl(View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) override;
// If |paint| is false, we should not paint the header. Used for overview mode
// with OnOverviewModeStarting() and OnOverviewModeEnded() to hide/show the
// header of v2 and ARC apps.
virtual void SetShouldPaintHeader(bool paint);
// Height from top of window to top of client area.
int NonClientTopBorderHeight() const;
// Expected height from top of window to top of client area when non client
// view is visible.
int NonClientTopBorderPreferredHeight() const;
const views::View* GetAvatarIconViewForTest() const;
SkColor GetActiveFrameColorForTest() const;
SkColor GetInactiveFrameColorForTest() const;
views::Widget* frame() { return frame_; }
bool GetFrameEnabled() const { return frame_enabled_; }
virtual void SetFrameEnabled(bool enabled);
protected:
// views::View:
void OnDidSchedulePaint(const gfx::Rect& r) override;
private:
class OverlayView;
friend class NonClientFrameViewAshTestWidgetDelegate;
friend class TestWidgetConstraintsDelegate;
friend class WindowServiceDelegateImplTest;
// views::NonClientFrameView:
bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override;
// Returns the container for the minimize/maximize/close buttons that is
// held by the HeaderView. Used in testing.
chromeos::FrameCaptionButtonContainerView*
GetFrameCaptionButtonContainerViewForTest();
// Called when |frame_|'s "paint as active" state has changed.
void PaintAsActiveChanged();
// Not owned.
views::Widget* const frame_;
// View which contains the title and window controls.
HeaderView* header_view_ = nullptr;
OverlayView* overlay_view_ = nullptr;
bool frame_enabled_ = true;
std::unique_ptr<NonClientFrameViewAshImmersiveHelper> immersive_helper_;
std::unique_ptr<chromeos::MoveToDesksMenuModel> move_to_desks_menu_model_;
std::unique_ptr<views::MenuRunner> menu_runner_;
base::CallbackListSubscription paint_as_active_subscription_ =
frame_->RegisterPaintAsActiveChangedCallback(
base::BindRepeating(&NonClientFrameViewAsh::PaintAsActiveChanged,
base::Unretained(this)));
base::WeakPtrFactory<NonClientFrameViewAsh> weak_factory_{this};
};
} // namespace ash
#endif // ASH_FRAME_NON_CLIENT_FRAME_VIEW_ASH_H_