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

Unified Diff: ash/shelf/shelf_layout_manager.cc

Issue 1998933002: Update shelf spacing in Chrome OS according to the MD specs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: ash/shelf/shelf_layout_manager.cc
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index ff95424866e43eb71462d8b27f3d071040a14ef6..66aa5dac3e60334306ddabcf0debfc5ad4fb80fe 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -12,6 +12,7 @@
#include "ash/accelerators/accelerator_commands.h"
#include "ash/ash_switches.h"
+#include "ash/material_design/material_design_controller.h"
#include "ash/root_window_controller.h"
#include "ash/screen_util.h"
#include "ash/session/session_state_delegate.h"
@@ -86,18 +87,6 @@ ui::Layer* GetLayer(views::Widget* widget) {
} // namespace
-// static
-const int ShelfLayoutManager::kWorkspaceAreaVisibleInset = 2;
-
-// static
-const int ShelfLayoutManager::kWorkspaceAreaAutoHideInset = 5;
-
-// static
-const int ShelfLayoutManager::kAutoHideSize = 3;
-
-// static
-const int ShelfLayoutManager::kShelfItemInset = 3;
-
// ShelfLayoutManager::AutoHideEventFilter -------------------------------------
// Notifies ShelfLayoutManager any time the mouse moves.
@@ -283,10 +272,12 @@ bool ShelfLayoutManager::IsVisible() const {
gfx::Rect ShelfLayoutManager::GetIdealBounds() {
gfx::Rect rect(ScreenUtil::GetDisplayBoundsInParent(shelf_->GetNativeView()));
return SelectValueForShelfAlignment(
- gfx::Rect(rect.x(), rect.bottom() - kShelfSize, rect.width(), kShelfSize),
- gfx::Rect(rect.x(), rect.y(), kShelfSize, rect.height()),
- gfx::Rect(rect.right() - kShelfSize, rect.y(), kShelfSize,
- rect.height()));
+ gfx::Rect(rect.x(), rect.bottom() - GetShelfLayoutConstant(SHELF_SIZE),
+ rect.width(), GetShelfLayoutConstant(SHELF_SIZE)),
+ gfx::Rect(rect.x(), rect.y(), GetShelfLayoutConstant(SHELF_SIZE),
+ rect.height()),
+ gfx::Rect(rect.right() - GetShelfLayoutConstant(SHELF_SIZE), rect.y(),
+ GetShelfLayoutConstant(SHELF_SIZE), rect.height()));
}
void ShelfLayoutManager::LayoutShelf() {
@@ -546,6 +537,23 @@ void ShelfLayoutManager::SetChromeVoxPanelHeight(int height) {
LayoutShelf();
}
+// static
+int ShelfLayoutManager::GetShelfItemInset(
+ ShelfLayoutManager::ShelfItemInset constant) {
+ const int kShelfItemInset[] = {3, 4};
+
+ int mode = MaterialDesignController::Mode::NON_MATERIAL;
+ if (MaterialDesignController::IsShelfMaterial())
+ mode = MaterialDesignController::Mode::MATERIAL_NORMAL;
+
+ switch (constant) {
+ case ShelfLayoutManager::ShelfItemInset::SHELF_ITEM_INSET:
+ return kShelfItemInset[mode];
+ }
+ NOTREACHED();
+ return 0;
+}
+
////////////////////////////////////////////////////////////////////////////////
// ShelfLayoutManager, private:
@@ -737,7 +745,7 @@ void ShelfLayoutManager::StopAnimating() {
void ShelfLayoutManager::CalculateTargetBounds(const State& state,
TargetBounds* target_bounds) {
- int shelf_size = kShelfSize;
+ int shelf_size = GetShelfLayoutConstant(SHELF_SIZE);
if (state.visibility_state == SHELF_AUTO_HIDE &&
state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
// Auto-hidden shelf always starts with the default size. If a gesture-drag
@@ -770,9 +778,9 @@ void ShelfLayoutManager::CalculateTargetBounds(const State& state,
gfx::Size status_size(
shelf_->status_area_widget()->GetWindowBoundsInScreen().size());
if (IsHorizontalAlignment())
- status_size.set_height(kShelfSize);
+ status_size.set_height(GetShelfLayoutConstant(SHELF_SIZE));
else
- status_size.set_width(kShelfSize);
+ status_size.set_width(GetShelfLayoutConstant(SHELF_SIZE));
gfx::Point status_origin = SelectValueForShelfAlignment(
gfx::Point(0, 0),
@@ -856,7 +864,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
// changed since then, e.g. because the tray-menu was shown because of the
// drag), then allow the drag some resistance-free region at first to make
// sure the shelf sticks with the finger until the shelf is visible.
- resistance_free_region = kShelfSize - kAutoHideSize;
+ resistance_free_region = GetShelfLayoutConstant(SHELF_SIZE) - kAutoHideSize;
}
bool resist = SelectValueForShelfAlignment(
@@ -907,7 +915,7 @@ void ShelfLayoutManager::UpdateTargetBoundsForGesture(
else
target_bounds->status_bounds_in_shelf.set_x(
target_bounds->shelf_bounds_in_root.width() -
- kShelfSize);
+ GetShelfLayoutConstant(SHELF_SIZE));
}
}

Powered by Google App Engine
This is Rietveld 408576698