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

Unified Diff: mash/wm/status_layout_manager.cc

Issue 1950293003: mash: Add status area container to mash window manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mash/wm/status_layout_manager.h ('k') | mash/wm/window_manager_application.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mash/wm/status_layout_manager.cc
diff --git a/mash/wm/shelf_layout.cc b/mash/wm/status_layout_manager.cc
similarity index 44%
rename from mash/wm/shelf_layout.cc
rename to mash/wm/status_layout_manager.cc
index a62dfea55d82632f135a87dfa85ec0097ffb0d1b..c6ee8cbd662d4a4bc38bf8871986df5f87bc2c7f 100644
--- a/mash/wm/shelf_layout.cc
+++ b/mash/wm/status_layout_manager.cc
@@ -2,11 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "mash/wm/shelf_layout.h"
+#include "mash/wm/status_layout_manager.h"
-#include "components/mus/public/cpp/property_type_converters.h"
#include "components/mus/public/cpp/window.h"
-#include "components/mus/public/cpp/window_property.h"
#include "mash/wm/property_util.h"
#include "mash/wm/public/interfaces/ash_window_type.mojom.h"
#include "ui/gfx/geometry/rect.h"
@@ -14,64 +12,42 @@
namespace mash {
namespace wm {
-namespace {
-
-mojom::AshWindowType GetAshWindowType(const mus::Window* window) {
- if (!window->HasSharedProperty(mojom::kAshWindowType_Property))
- return mojom::AshWindowType::COUNT;
-
- return static_cast<mojom::AshWindowType>(
- window->GetSharedProperty<int32_t>(mojom::kAshWindowType_Property));
-}
-
-} // namespace
-
-ShelfLayout::ShelfLayout(mus::Window* owner)
+StatusLayoutManager::StatusLayoutManager(mus::Window* owner)
: LayoutManager(owner),
alignment_(mash::shelf::mojom::Alignment::BOTTOM),
auto_hide_behavior_(mash::shelf::mojom::AutoHideBehavior::NEVER) {
AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property);
}
-ShelfLayout::~ShelfLayout() {}
+StatusLayoutManager::~StatusLayoutManager() {}
// We explicitly don't make assertions about the number of children in this
// layout as the number of children can vary when the application providing the
-// shelf restarts.
+// status area restarts.
-void ShelfLayout::LayoutWindow(mus::Window* window) {
- const mojom::AshWindowType ash_window_type = GetAshWindowType(window);
+void StatusLayoutManager::LayoutWindow(mus::Window* window) {
+ if (GetAshWindowType(window) != mojom::AshWindowType::STATUS_AREA) {
+ // TODO(jamescook): Layout for notifications and other windows.
+ NOTIMPLEMENTED() << "Non-status-area window needs layout.";
+ return;
+ }
gfx::Size size = GetWindowPreferredSize(window);
-
if (alignment_ == mash::shelf::mojom::Alignment::BOTTOM) {
const int y = owner()->bounds().height() - size.height();
- if (ash_window_type == mojom::AshWindowType::SHELF) {
- size.set_width(owner()->bounds().width());
- window->SetBounds(gfx::Rect(0, y, size.width(), size.height()));
- } else if (ash_window_type == mojom::AshWindowType::STATUS_AREA) {
- // TODO(msw): Place the status area on the left for RTL UIs.
- window->SetBounds(gfx::Rect(owner()->bounds().width() - size.width(), y,
- size.width(), size.height()));
- } else {
- NOTREACHED() << "Unknown window in USER_SHELF container.";
- }
+ // TODO(msw): Place the status area widget on the left for RTL UIs.
+ window->SetBounds(gfx::Rect(owner()->bounds().width() - size.width(), y,
+ size.width(), size.height()));
} else {
const int x = (alignment_ == mash::shelf::mojom::Alignment::LEFT)
? 0
: (owner()->bounds().width() - size.width());
- if (ash_window_type == mojom::AshWindowType::SHELF) {
- size.set_height(owner()->bounds().height());
- window->SetBounds(gfx::Rect(x, 0, size.width(), size.height()));
- } else if (ash_window_type == mojom::AshWindowType::STATUS_AREA) {
- window->SetBounds(gfx::Rect(x, owner()->bounds().height() - size.height(),
- size.width(), size.height()));
- } else {
- NOTREACHED() << "Unknown window in USER_SHELF container.";
- }
+ window->SetBounds(gfx::Rect(x, owner()->bounds().height() - size.height(),
+ size.width(), size.height()));
}
}
-void ShelfLayout::SetAlignment(mash::shelf::mojom::Alignment alignment) {
+void StatusLayoutManager::SetAlignment(
+ mash::shelf::mojom::Alignment alignment) {
if (alignment_ == alignment)
return;
@@ -80,7 +56,7 @@ void ShelfLayout::SetAlignment(mash::shelf::mojom::Alignment alignment) {
LayoutWindow(window);
}
-void ShelfLayout::SetAutoHideBehavior(
+void StatusLayoutManager::SetAutoHideBehavior(
mash::shelf::mojom::AutoHideBehavior auto_hide) {
if (auto_hide_behavior_ == auto_hide)
return;
« no previous file with comments | « mash/wm/status_layout_manager.h ('k') | mash/wm/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698