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

Side by Side Diff: mash/wm/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 | « mash/wm/shelf_layout_manager.h ('k') | mash/wm/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
(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 #include "mash/wm/shelf_layout_manager.h"
6
7 #include "ash/public/interfaces/ash_window_type.mojom.h"
8 #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"
12
13 namespace mash {
14 namespace wm {
15
16 ShelfLayoutManager::ShelfLayoutManager(mus::Window* owner,
17 ShelfLayoutManagerDelegate* delegate)
18 : LayoutManager(owner),
19 delegate_(delegate),
20 alignment_(shelf::mojom::Alignment::BOTTOM),
21 auto_hide_behavior_(shelf::mojom::AutoHideBehavior::NEVER) {
22 AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property);
23 }
24
25 ShelfLayoutManager::~ShelfLayoutManager() {}
26
27 mus::Window* ShelfLayoutManager::GetShelfWindow() {
28 for (mus::Window* child : owner()->children()) {
29 if (GetAshWindowType(child) == ash::mojom::AshWindowType::SHELF)
30 return child;
31 }
32 return nullptr;
33 }
34
35 void ShelfLayoutManager::SetAlignment(shelf::mojom::Alignment alignment) {
36 if (alignment_ == alignment)
37 return;
38
39 alignment_ = alignment;
40 for (mus::Window* window : owner()->children())
41 LayoutWindow(window);
42 }
43
44 void ShelfLayoutManager::SetAutoHideBehavior(
45 shelf::mojom::AutoHideBehavior auto_hide) {
46 if (auto_hide_behavior_ == auto_hide)
47 return;
48
49 auto_hide_behavior_ = auto_hide;
50 NOTIMPLEMENTED();
51 }
52
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
55 // shelf restarts.
56
57 void ShelfLayoutManager::LayoutWindow(mus::Window* window) {
58 if (GetAshWindowType(window) != ash::mojom::AshWindowType::SHELF) {
59 // Phantom windows end up in this container, ignore them.
60 return;
61 }
62 gfx::Size size = GetWindowPreferredSize(window);
63
64 if (alignment_ == shelf::mojom::Alignment::BOTTOM) {
65 const int y = owner()->bounds().height() - size.height();
66 size.set_width(owner()->bounds().width());
67 window->SetBounds(gfx::Rect(0, y, size.width(), size.height()));
68 } else {
69 const int x = (alignment_ == shelf::mojom::Alignment::LEFT)
70 ? 0
71 : (owner()->bounds().width() - size.width());
72 size.set_height(owner()->bounds().height());
73 window->SetBounds(gfx::Rect(x, 0, size.width(), size.height()));
74 }
75 }
76
77 void ShelfLayoutManager::WindowAdded(mus::Window* window) {
78 if (GetAshWindowType(window) == ash::mojom::AshWindowType::SHELF)
79 delegate_->OnShelfWindowAvailable();
80 }
81
82 } // namespace wm
83 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/shelf_layout_manager.h ('k') | mash/wm/shelf_layout_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698