Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Side by Side Diff: ash/mus/shelf_layout_manager.cc

Issue 2029883002: Moves mash/wm into ash/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_static_assert
Patch Set: move comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/mus/shelf_layout_manager.h ('k') | ash/mus/shelf_layout_manager_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "mash/wm/shelf_layout_manager.h" 5 #include "ash/mus/shelf_layout_manager.h"
6 6
7 #include "ash/mus/property_util.h"
8 #include "ash/mus/shelf_layout_manager_delegate.h"
7 #include "ash/public/interfaces/ash_window_type.mojom.h" 9 #include "ash/public/interfaces/ash_window_type.mojom.h"
8 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
9 #include "mash/wm/property_util.h"
10 #include "mash/wm/shelf_layout_manager_delegate.h"
11 #include "ui/gfx/geometry/rect.h" 11 #include "ui/gfx/geometry/rect.h"
12 12
13 namespace mash { 13 namespace ash {
14 namespace wm { 14 namespace mus {
15 15
16 ShelfLayoutManager::ShelfLayoutManager(mus::Window* owner, 16 ShelfLayoutManager::ShelfLayoutManager(::mus::Window* owner,
17 ShelfLayoutManagerDelegate* delegate) 17 ShelfLayoutManagerDelegate* delegate)
18 : LayoutManager(owner), 18 : LayoutManager(owner),
19 delegate_(delegate), 19 delegate_(delegate),
20 alignment_(shelf::mojom::Alignment::BOTTOM), 20 alignment_(mash::shelf::mojom::Alignment::BOTTOM),
21 auto_hide_behavior_(shelf::mojom::AutoHideBehavior::NEVER) { 21 auto_hide_behavior_(mash::shelf::mojom::AutoHideBehavior::NEVER) {
22 AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property); 22 AddLayoutProperty(::mus::mojom::WindowManager::kPreferredSize_Property);
23 } 23 }
24 24
25 ShelfLayoutManager::~ShelfLayoutManager() {} 25 ShelfLayoutManager::~ShelfLayoutManager() {}
26 26
27 mus::Window* ShelfLayoutManager::GetShelfWindow() { 27 ::mus::Window* ShelfLayoutManager::GetShelfWindow() {
28 for (mus::Window* child : owner()->children()) { 28 for (::mus::Window* child : owner()->children()) {
29 if (GetAshWindowType(child) == ash::mojom::AshWindowType::SHELF) 29 if (GetAshWindowType(child) == mojom::AshWindowType::SHELF)
30 return child; 30 return child;
31 } 31 }
32 return nullptr; 32 return nullptr;
33 } 33 }
34 34
35 void ShelfLayoutManager::SetAlignment(shelf::mojom::Alignment alignment) { 35 void ShelfLayoutManager::SetAlignment(mash::shelf::mojom::Alignment alignment) {
36 if (alignment_ == alignment) 36 if (alignment_ == alignment)
37 return; 37 return;
38 38
39 alignment_ = alignment; 39 alignment_ = alignment;
40 for (mus::Window* window : owner()->children()) 40 for (::mus::Window* window : owner()->children())
41 LayoutWindow(window); 41 LayoutWindow(window);
42 } 42 }
43 43
44 void ShelfLayoutManager::SetAutoHideBehavior( 44 void ShelfLayoutManager::SetAutoHideBehavior(
45 shelf::mojom::AutoHideBehavior auto_hide) { 45 mash::shelf::mojom::AutoHideBehavior auto_hide) {
46 if (auto_hide_behavior_ == auto_hide) 46 if (auto_hide_behavior_ == auto_hide)
47 return; 47 return;
48 48
49 auto_hide_behavior_ = auto_hide; 49 auto_hide_behavior_ = auto_hide;
50 NOTIMPLEMENTED(); 50 NOTIMPLEMENTED();
51 } 51 }
52 52
53 // We explicitly don't make assertions about the number of children in this 53 // We explicitly don't make assertions about the number of children in this
54 // layout as the number of children can vary when the application providing the 54 // layout as the number of children can vary when the application providing the
55 // shelf restarts. 55 // shelf restarts.
56 56
57 void ShelfLayoutManager::LayoutWindow(mus::Window* window) { 57 void ShelfLayoutManager::LayoutWindow(::mus::Window* window) {
58 if (GetAshWindowType(window) != ash::mojom::AshWindowType::SHELF) { 58 if (GetAshWindowType(window) != mojom::AshWindowType::SHELF) {
59 // Phantom windows end up in this container, ignore them. 59 // Phantom windows end up in this container, ignore them.
60 return; 60 return;
61 } 61 }
62 gfx::Size size = GetWindowPreferredSize(window); 62 gfx::Size size = GetWindowPreferredSize(window);
63 63
64 if (alignment_ == shelf::mojom::Alignment::BOTTOM) { 64 if (alignment_ == mash::shelf::mojom::Alignment::BOTTOM) {
65 const int y = owner()->bounds().height() - size.height(); 65 const int y = owner()->bounds().height() - size.height();
66 size.set_width(owner()->bounds().width()); 66 size.set_width(owner()->bounds().width());
67 window->SetBounds(gfx::Rect(0, y, size.width(), size.height())); 67 window->SetBounds(gfx::Rect(0, y, size.width(), size.height()));
68 } else { 68 } else {
69 const int x = (alignment_ == shelf::mojom::Alignment::LEFT) 69 const int x = (alignment_ == mash::shelf::mojom::Alignment::LEFT)
70 ? 0 70 ? 0
71 : (owner()->bounds().width() - size.width()); 71 : (owner()->bounds().width() - size.width());
72 size.set_height(owner()->bounds().height()); 72 size.set_height(owner()->bounds().height());
73 window->SetBounds(gfx::Rect(x, 0, size.width(), size.height())); 73 window->SetBounds(gfx::Rect(x, 0, size.width(), size.height()));
74 } 74 }
75 } 75 }
76 76
77 void ShelfLayoutManager::WindowAdded(mus::Window* window) { 77 void ShelfLayoutManager::WindowAdded(::mus::Window* window) {
78 if (GetAshWindowType(window) == ash::mojom::AshWindowType::SHELF) 78 if (GetAshWindowType(window) == mojom::AshWindowType::SHELF)
79 delegate_->OnShelfWindowAvailable(); 79 delegate_->OnShelfWindowAvailable();
80 } 80 }
81 81
82 } // namespace wm 82 } // namespace mus
83 } // namespace mash 83 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/shelf_layout_manager.h ('k') | ash/mus/shelf_layout_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698