| OLD | NEW |
| (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/status_layout_manager.h" | |
| 6 | |
| 7 #include "ash/mus/property_util.h" | |
| 8 #include "ash/public/interfaces/ash_window_type.mojom.h" | |
| 9 #include "services/ui/public/cpp/window.h" | |
| 10 #include "ui/gfx/geometry/rect.h" | |
| 11 | |
| 12 namespace ash { | |
| 13 namespace mus { | |
| 14 | |
| 15 StatusLayoutManager::StatusLayoutManager(ui::Window* owner) | |
| 16 : LayoutManager(owner), | |
| 17 alignment_(mash::shelf::mojom::Alignment::BOTTOM), | |
| 18 auto_hide_behavior_(mash::shelf::mojom::AutoHideBehavior::NEVER) { | |
| 19 AddLayoutProperty(ui::mojom::WindowManager::kPreferredSize_Property); | |
| 20 } | |
| 21 | |
| 22 StatusLayoutManager::~StatusLayoutManager() {} | |
| 23 | |
| 24 // We explicitly don't make assertions about the number of children in this | |
| 25 // layout as the number of children can vary when the application providing the | |
| 26 // status area restarts. | |
| 27 | |
| 28 void StatusLayoutManager::LayoutWindow(ui::Window* window) { | |
| 29 if (GetAshWindowType(window) != mojom::AshWindowType::STATUS_AREA) { | |
| 30 // TODO(jamescook): Layout for notifications and other windows. | |
| 31 NOTIMPLEMENTED() << "Non-status-area window needs layout."; | |
| 32 return; | |
| 33 } | |
| 34 gfx::Size size = GetWindowPreferredSize(window); | |
| 35 if (alignment_ == mash::shelf::mojom::Alignment::BOTTOM) { | |
| 36 const int y = owner()->bounds().height() - size.height(); | |
| 37 // TODO(msw): Place the status area widget on the left for RTL UIs. | |
| 38 window->SetBounds(gfx::Rect(owner()->bounds().width() - size.width(), y, | |
| 39 size.width(), size.height())); | |
| 40 } else { | |
| 41 const int x = (alignment_ == mash::shelf::mojom::Alignment::LEFT) | |
| 42 ? 0 | |
| 43 : (owner()->bounds().width() - size.width()); | |
| 44 window->SetBounds(gfx::Rect(x, owner()->bounds().height() - size.height(), | |
| 45 size.width(), size.height())); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 void StatusLayoutManager::SetAlignment( | |
| 50 mash::shelf::mojom::Alignment alignment) { | |
| 51 if (alignment_ == alignment) | |
| 52 return; | |
| 53 | |
| 54 alignment_ = alignment; | |
| 55 for (ui::Window* window : owner()->children()) | |
| 56 LayoutWindow(window); | |
| 57 } | |
| 58 | |
| 59 void StatusLayoutManager::SetAutoHideBehavior( | |
| 60 mash::shelf::mojom::AutoHideBehavior auto_hide) { | |
| 61 if (auto_hide_behavior_ == auto_hide) | |
| 62 return; | |
| 63 | |
| 64 auto_hide_behavior_ = auto_hide; | |
| 65 NOTIMPLEMENTED(); | |
| 66 } | |
| 67 | |
| 68 } // namespace mus | |
| 69 } // namespace ash | |
| OLD | NEW |