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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 2823133002: Clean up some ash constants. (Closed)
Patch Set: updates Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_constants.h" 10 #include "ash/ash_constants.h"
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 gfx::Rect last_button_bounds = 1336 gfx::Rect last_button_bounds =
1337 view_model_->view_at(last_button_index)->bounds(); 1337 view_model_->view_at(last_button_index)->bounds();
1338 if (overflow_button_->visible() && 1338 if (overflow_button_->visible() &&
1339 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) { 1339 model_->GetItemIndexForType(TYPE_APP_PANEL) == -1) {
1340 // When overflow button is visible and shelf has no panel items, 1340 // When overflow button is visible and shelf has no panel items,
1341 // last_button_bounds should be overflow button's bounds. 1341 // last_button_bounds should be overflow button's bounds.
1342 last_button_bounds = overflow_button_->bounds(); 1342 last_button_bounds = overflow_button_->bounds();
1343 } 1343 }
1344 1344
1345 if (wm_shelf_->IsHorizontalAlignment()) { 1345 if (wm_shelf_->IsHorizontalAlignment()) {
1346 preferred_size = 1346 preferred_size = gfx::Size(last_button_bounds.right(), kShelfSize);
1347 gfx::Size(last_button_bounds.right(), GetShelfConstant(SHELF_SIZE));
1348 } else { 1347 } else {
1349 preferred_size = 1348 preferred_size = gfx::Size(kShelfSize, last_button_bounds.bottom());
1350 gfx::Size(GetShelfConstant(SHELF_SIZE), last_button_bounds.bottom());
1351 } 1349 }
1352 } 1350 }
1353 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); 1351 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0);
1354 1352
1355 // In overflow mode, we should use OverflowBubbleView as a source for 1353 // In overflow mode, we should use OverflowBubbleView as a source for
1356 // converting |origin| to screen coordinates. When a scroll operation is 1354 // converting |origin| to screen coordinates. When a scroll operation is
1357 // occurred in OverflowBubble, the bounds of ShelfView in OverflowBubble can 1355 // occurred in OverflowBubble, the bounds of ShelfView in OverflowBubble can
1358 // be changed. 1356 // be changed.
1359 if (is_overflow_mode()) 1357 if (is_overflow_mode())
1360 ConvertPointToScreen(owner_overflow_bubble_->bubble_view(), &origin); 1358 ConvertPointToScreen(owner_overflow_bubble_->bubble_view(), &origin);
(...skipping 28 matching lines...) Expand all
1389 // If the modified view will be at the end of the list, return the new end of 1387 // If the modified view will be at the end of the list, return the new end of
1390 // the list. 1388 // the list.
1391 if (at_end) 1389 if (at_end)
1392 return view_model_->view_size(); 1390 return view_model_->view_size();
1393 return modified_view ? view_model_->GetIndexOfView(modified_view) : -1; 1391 return modified_view ? view_model_->GetIndexOfView(modified_view) : -1;
1394 } 1392 }
1395 1393
1396 gfx::Size ShelfView::GetPreferredSize() const { 1394 gfx::Size ShelfView::GetPreferredSize() const {
1397 gfx::Rect overflow_bounds; 1395 gfx::Rect overflow_bounds;
1398 CalculateIdealBounds(&overflow_bounds); 1396 CalculateIdealBounds(&overflow_bounds);
1399 const int shelf_size = GetShelfConstant(SHELF_SIZE); 1397 const int shelf_size = kShelfSize;
James Cook 2017/04/18 15:31:52 nit: inline uses
Evan Stade 2017/04/18 16:41:09 Done.
1400 1398
1401 int last_button_index = last_visible_index_; 1399 int last_button_index = last_visible_index_;
1402 if (!is_overflow_mode()) { 1400 if (!is_overflow_mode()) {
1403 if (last_hidden_index_ < view_model_->view_size() - 1) 1401 if (last_hidden_index_ < view_model_->view_size() - 1)
1404 last_button_index = view_model_->view_size() - 1; 1402 last_button_index = view_model_->view_size() - 1;
1405 else if (overflow_button_ && overflow_button_->visible()) 1403 else if (overflow_button_ && overflow_button_->visible())
1406 last_button_index++; 1404 last_button_index++;
1407 } 1405 }
1408 1406
1409 // When an item is dragged off from the overflow bubble, it is moved to last 1407 // When an item is dragged off from the overflow bubble, it is moved to last
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 1760
1763 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1761 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1764 const gfx::Rect bounds = GetBoundsInScreen(); 1762 const gfx::Rect bounds = GetBoundsInScreen();
1765 int distance = wm_shelf_->SelectValueForShelfAlignment( 1763 int distance = wm_shelf_->SelectValueForShelfAlignment(
1766 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1764 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1767 bounds.x() - coordinate.x()); 1765 bounds.x() - coordinate.x());
1768 return distance > 0 ? distance : 0; 1766 return distance > 0 ? distance : 0;
1769 } 1767 }
1770 1768
1771 } // namespace ash 1769 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698