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

Unified Diff: mash/wm/shelf_layout.cc

Issue 1835403002: Support additional mash shelf alignments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
Index: mash/wm/shelf_layout.cc
diff --git a/mash/wm/shelf_layout.cc b/mash/wm/shelf_layout.cc
index e87dc76217e6efea9b2e72cd7e5d01d5e844220e..bef829f969a32e1d22acf6abe531bd970fbb64a0 100644
--- a/mash/wm/shelf_layout.cc
+++ b/mash/wm/shelf_layout.cc
@@ -26,7 +26,10 @@ mojom::AshWindowType GetAshWindowType(const mus::Window* window) {
} // namespace
-ShelfLayout::ShelfLayout(mus::Window* owner) : LayoutManager(owner) {
+ShelfLayout::ShelfLayout(mus::Window* owner)
+ : LayoutManager(owner),
+ alignment_(mojom::ShelfAlignment::SHELF_ALIGNMENT_BOTTOM),
+ auto_hide_(mojom::ShelfAutoHideBehavior::SHELF_AUTO_HIDE_BEHAVIOR_NEVER) {
AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property);
}
@@ -38,19 +41,66 @@ ShelfLayout::~ShelfLayout() {}
void ShelfLayout::LayoutWindow(mus::Window* window) {
// TODO(msw): Support additional shelf alignments and RTL UI.
- gfx::Size size = GetWindowPreferredSize(window);
- const int y = owner()->bounds().height() - size.height();
const mojom::AshWindowType ash_window_type = GetAshWindowType(window);
- 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) {
- window->SetBounds(gfx::Rect(owner()->bounds().width() - size.width(), y,
- size.width(), size.height()));
+ gfx::Size size = GetWindowPreferredSize(window);
+
+ if (alignment_ == mojom::ShelfAlignment::SHELF_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()));
+ LOG(ERROR) << "MSW Layout Shelf Bottom " << window->bounds().ToString();
+ } else if (ash_window_type == mojom::AshWindowType::STATUS_AREA) {
+ window->SetBounds(gfx::Rect(owner()->bounds().width() - size.width(), y,
+ size.width(), size.height()));
+ LOG(ERROR) << "MSW Layout Status Bottom " << window->bounds().ToString();
+ } else {
+ NOTREACHED() << "Unknown window in USER_SHELF container.";
+ }
} else {
- NOTREACHED() << "Unknown window in USER_SHELF container.";
+
+ // TODO(msw): Use actual preferred sizes (need to update)...
+ size = gfx::Size(47, 150);
+
+ // TODO(msw): Why does the status area sometimes fail to align left?
+ const int x = (alignment_ == mojom::ShelfAlignment::SHELF_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()));
+ LOG(ERROR) << "MSW Layout Shelf Side " << window->bounds().ToString();
+ } else if (ash_window_type == mojom::AshWindowType::STATUS_AREA) {
+ window->SetBounds(gfx::Rect(x, owner()->bounds().height() - size.height(),
+ size.width(), size.height()));
+ LOG(ERROR) << "MSW Layout Status Side " << window->bounds().ToString();
+ } else {
+ NOTREACHED() << "Unknown window in USER_SHELF container.";
+ }
}
}
+void ShelfLayout::SetAlignment(mojom::ShelfAlignment alignment) {
+ LOG(ERROR) << "MSW ShelfLayout::SetAlignment";
+ if (alignment_ == alignment)
+ return;
+
+ // TODO(msw): Check against SHELF_ALIGNMENT_TOP if it's included in the enum.
+ // if (mojom::SHELF_ALIGNMENT_TOP == alignment)
+ // NOTREACHED() << "Unknown window in USER_SHELF container.";
+
+ alignment_ = alignment;
+ for (auto window : owner()->children())
+ LayoutWindow(window);
+}
+
+void ShelfLayout::SetAutoHideBehavior(mojom::ShelfAutoHideBehavior auto_hide) {
+ LOG(ERROR) << "MSW ShelfLayout::SetAutoHideBehavior";
+ if (auto_hide_ == auto_hide)
+ return;
+
+ auto_hide_ = auto_hide;
+ // TODO(msw|jamescook): Implement...
+}
+
} // namespace wm
} // namespace mash

Powered by Google App Engine
This is Rietveld 408576698