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

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: Sync and rebase; address comments (sorry). Created 4 years, 8 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/shelf_layout.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/shelf_layout.cc
diff --git a/mash/wm/shelf_layout.cc b/mash/wm/shelf_layout.cc
index e87dc76217e6efea9b2e72cd7e5d01d5e844220e..a62dfea55d82632f135a87dfa85ec0097ffb0d1b 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_(mash::shelf::mojom::Alignment::BOTTOM),
+ auto_hide_behavior_(mash::shelf::mojom::AutoHideBehavior::NEVER) {
AddLayoutProperty(mus::mojom::WindowManager::kPreferredSize_Property);
}
@@ -37,20 +40,54 @@ ShelfLayout::~ShelfLayout() {}
// shelf restarts.
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_ == 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.";
+ }
} else {
- NOTREACHED() << "Unknown window in USER_SHELF container.";
+ 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.";
+ }
}
}
+void ShelfLayout::SetAlignment(mash::shelf::mojom::Alignment alignment) {
+ if (alignment_ == alignment)
+ return;
+
+ alignment_ = alignment;
+ for (mus::Window* window : owner()->children())
+ LayoutWindow(window);
+}
+
+void ShelfLayout::SetAutoHideBehavior(
+ mash::shelf::mojom::AutoHideBehavior auto_hide) {
+ if (auto_hide_behavior_ == auto_hide)
+ return;
+
+ auto_hide_behavior_ = auto_hide;
+ NOTIMPLEMENTED();
+}
+
} // namespace wm
} // namespace mash
« no previous file with comments | « mash/wm/shelf_layout.h ('k') | mash/wm/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698