OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ | 5 #ifndef ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ |
6 #define ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ | 6 #define ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | |
11 #include <string> | |
12 #include <vector> | |
13 | |
10 #include "ash/mus/frame/detached_title_area_renderer_host.h" | 14 #include "ash/mus/frame/detached_title_area_renderer_host.h" |
11 #include "base/macros.h" | 15 #include "base/macros.h" |
12 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
13 #include "services/ui/public/cpp/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
18 #include "ui/gfx/geometry/insets.h" | |
19 #include "ui/gfx/geometry/rect.h" | |
14 #include "ui/views/widget/widget_delegate.h" | 20 #include "ui/views/widget/widget_delegate.h" |
15 | 21 |
22 namespace aura { | |
23 class Window; | |
24 class WindowManagerClient; | |
25 } | |
26 | |
16 namespace gfx { | 27 namespace gfx { |
17 class Insets; | 28 class Insets; |
18 } | 29 } |
19 | 30 |
20 namespace ui { | 31 namespace ui { |
21 class Window; | 32 namespace mojom { |
22 class WindowManagerClient; | 33 enum class WindowType; |
34 } | |
23 } | 35 } |
24 | 36 |
25 namespace ash { | 37 namespace ash { |
26 namespace mus { | 38 namespace mus { |
27 | 39 |
40 class WindowManager; | |
41 | |
28 // Provides the non-client frame for mus Windows. | 42 // Provides the non-client frame for mus Windows. |
29 class NonClientFrameController : public views::WidgetDelegateView, | 43 class NonClientFrameController : public views::WidgetDelegateView, |
30 public ui::WindowObserver, | 44 public aura::WindowObserver, |
31 public DetachedTitleAreaRendererHost { | 45 public DetachedTitleAreaRendererHost { |
32 public: | 46 public: |
33 // NonClientFrameController deletes itself when |window| is destroyed. | 47 // Creates a new NonClientFrameController and window to render the non-client |
34 static void Create(ui::Window* parent, | 48 // frame decorations. This deletes itself when |window| is destroyed. |parent| |
35 ui::Window* window, | 49 // is the parent to place the newly created window in, and my be null. If |
James Cook
2016/12/05 22:56:34
nit: my -> may
sky
2016/12/06 00:56:16
Done.
| |
36 ui::WindowManagerClient* window_manager_client); | 50 // |parent| is null |context| is used to determine the parent Window. One of |
51 // |parent| or |context| must be non-null. | |
52 NonClientFrameController( | |
53 aura::Window* parent, | |
54 aura::Window* context, | |
55 const gfx::Rect& bounds, | |
56 ui::mojom::WindowType window_type, | |
57 std::map<std::string, std::vector<uint8_t>>* properties, | |
58 WindowManager* window_manager); | |
59 | |
60 // Returns the NonClientFrameController for the specified window, null if | |
61 // one was not created. | |
62 static NonClientFrameController* Get(aura::Window* window); | |
37 | 63 |
38 // Returns the preferred client area insets. | 64 // Returns the preferred client area insets. |
39 static gfx::Insets GetPreferredClientAreaInsets(); | 65 static gfx::Insets GetPreferredClientAreaInsets(); |
40 | 66 |
41 // Returns the width needed to display the standard set of buttons on the | 67 // Returns the width needed to display the standard set of buttons on the |
42 // title bar. | 68 // title bar. |
43 static int GetMaxTitleBarButtonWidth(); | 69 static int GetMaxTitleBarButtonWidth(); |
44 | 70 |
45 ui::Window* window() { return window_; } | 71 aura::Window* window() { return window_; } |
72 | |
73 aura::WindowManagerClient* window_manager_client() { | |
74 return window_manager_client_; | |
75 } | |
76 | |
77 void SetClientArea(const gfx::Insets& insets, | |
78 const std::vector<gfx::Rect>& additional_client_areas); | |
46 | 79 |
47 private: | 80 private: |
48 NonClientFrameController(ui::Window* parent, | |
49 ui::Window* window, | |
50 ui::WindowManagerClient* window_manager_client); | |
51 ~NonClientFrameController() override; | 81 ~NonClientFrameController() override; |
52 | 82 |
53 // DetachedTitleAreaRendererHost: | 83 // DetachedTitleAreaRendererHost: |
54 void OnDetachedTitleAreaRendererDestroyed( | 84 void OnDetachedTitleAreaRendererDestroyed( |
55 DetachedTitleAreaRenderer* renderer) override; | 85 DetachedTitleAreaRenderer* renderer) override; |
56 | 86 |
57 // views::WidgetDelegateView: | 87 // views::WidgetDelegateView: |
58 base::string16 GetWindowTitle() const override; | 88 base::string16 GetWindowTitle() const override; |
59 bool CanResize() const override; | 89 bool CanResize() const override; |
60 bool CanMaximize() const override; | 90 bool CanMaximize() const override; |
61 bool CanMinimize() const override; | 91 bool CanMinimize() const override; |
62 bool ShouldShowWindowTitle() const override; | 92 bool ShouldShowWindowTitle() const override; |
63 views::ClientView* CreateClientView(views::Widget* widget) override; | 93 views::ClientView* CreateClientView(views::Widget* widget) override; |
64 | 94 |
65 // ui::WindowObserver: | 95 // aura::WindowObserver: |
66 void OnTreeChanged(const TreeChangeParams& params) override; | 96 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
67 void OnWindowSharedPropertyChanged( | 97 void OnWindowPropertyChanged(aura::Window* window, |
68 ui::Window* window, | 98 const void* key, |
69 const std::string& name, | 99 intptr_t old) override; |
70 const std::vector<uint8_t>* old_data, | 100 void OnWindowDestroyed(aura::Window* window) override; |
71 const std::vector<uint8_t>* new_data) override; | 101 |
72 void OnWindowLocalPropertyChanged(ui::Window* window, | 102 aura::WindowManagerClient* window_manager_client_; |
73 const void* key, | |
74 intptr_t old) override; | |
75 void OnWindowDestroyed(ui::Window* window) override; | |
76 | 103 |
77 views::Widget* widget_; | 104 views::Widget* widget_; |
78 | 105 |
79 // WARNING: as widget delays destruction there is a portion of time when this | 106 // WARNING: as widget delays destruction there is a portion of time when this |
80 // is null. | 107 // is null. |
81 ui::Window* window_; | 108 aura::Window* window_; |
82 | 109 |
83 // Used if a child window is added that has the | 110 // Used if a child window is added that has the |
84 // kRendererParentTitleArea_Property set. | 111 // kRendererParentTitleArea_Property set. |
85 DetachedTitleAreaRenderer* detached_title_area_renderer_ = nullptr; | 112 DetachedTitleAreaRenderer* detached_title_area_renderer_ = nullptr; |
86 | 113 |
114 bool did_init_native_widget_ = false; | |
115 | |
116 gfx::Insets client_area_insets_; | |
117 std::vector<gfx::Rect> additional_client_areas_; | |
118 | |
87 DISALLOW_COPY_AND_ASSIGN(NonClientFrameController); | 119 DISALLOW_COPY_AND_ASSIGN(NonClientFrameController); |
88 }; | 120 }; |
89 | 121 |
90 } // namespace mus | 122 } // namespace mus |
91 } // namespace ash | 123 } // namespace ash |
92 | 124 |
93 #endif // ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ | 125 #endif // ASH_MUS_NON_CLIENT_FRAME_CONTROLLER_H_ |
OLD | NEW |