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

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

Issue 2259153002: mash: Port ash_sysui ShelfDelegateMus impl to mojo:ash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase. Created 4 years, 3 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
(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 "ash/mus/shelf_layout_manager.h"
6
7 #include "ash/mus/property_util.h"
8 #include "ash/mus/shelf_layout_manager_delegate.h"
9 #include "ash/public/interfaces/ash_window_type.mojom.h"
10 #include "services/ui/public/cpp/window.h"
11 #include "ui/gfx/geometry/rect.h"
12
13 namespace ash {
14 namespace mus {
15
16 ShelfLayoutManager::ShelfLayoutManager(ui::Window* owner,
17 ShelfLayoutManagerDelegate* delegate)
18 : LayoutManager(owner),
19 delegate_(delegate),
20 alignment_(mash::shelf::mojom::Alignment::BOTTOM),
21 auto_hide_behavior_(mash::shelf::mojom::AutoHideBehavior::NEVER) {
22 AddLayoutProperty(ui::mojom::WindowManager::kPreferredSize_Property);
23 }
24
25 ShelfLayoutManager::~ShelfLayoutManager() {}
26
27 ui::Window* ShelfLayoutManager::GetShelfWindow() {
28 for (ui::Window* child : owner()->children()) {
29 if (GetAshWindowType(child) == mojom::AshWindowType::SHELF)
30 return child;
31 }
32 return nullptr;
33 }
34
35 void ShelfLayoutManager::SetAlignment(mash::shelf::mojom::Alignment alignment) {
36 if (alignment_ == alignment)
37 return;
38
39 alignment_ = alignment;
40 for (ui::Window* window : owner()->children())
41 LayoutWindow(window);
42 }
43
44 void ShelfLayoutManager::SetAutoHideBehavior(
45 mash::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(ui::Window* window) {
58 if (GetAshWindowType(window) != 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_ == mash::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_ == mash::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(ui::Window* window) {
78 if (GetAshWindowType(window) == mojom::AshWindowType::SHELF)
79 delegate_->OnShelfWindowAvailable();
80 }
81
82 } // namespace mus
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