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

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

Issue 1996563002: Add ImeMenuTray element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check the valid of |last_item_index|. 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); 826 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h));
827 x = shelf_->PrimaryAxisValue(x + w + button_spacing, x); 827 x = shelf_->PrimaryAxisValue(x + w + button_spacing, x);
828 y = shelf_->PrimaryAxisValue(y, y + h + button_spacing); 828 y = shelf_->PrimaryAxisValue(y, y + h + button_spacing);
829 } 829 }
830 830
831 if (is_overflow_mode()) { 831 if (is_overflow_mode()) {
832 const_cast<ShelfView*>(this)->UpdateAllButtonsVisibilityInOverflowMode(); 832 const_cast<ShelfView*>(this)->UpdateAllButtonsVisibilityInOverflowMode();
833 return; 833 return;
834 } 834 }
835 835
836 // IME menu icon.
sky 2016/05/20 16:23:39 This comment isn't helpful. It should describe wha
Azure Wei 2016/05/24 07:21:16 Updated.
837 int last_item_index = view_model_->view_size() - 1;
838 bool is_last_item_menu =
sky 2016/05/20 16:23:39 is_last_item_ime_menu
Azure Wei 2016/05/24 07:21:16 Done.
839 (last_item_index >= 0) &&
840 (model_->items()[last_item_index].type == TYPE_IME_MENU);
841 if (is_last_item_menu) {
842 x = shelf_->PrimaryAxisValue(available_size - w, 0);
843 y = shelf_->PrimaryAxisValue(0, available_size - h);
844 view_model_->set_ideal_bounds(last_item_index, gfx::Rect(x, y, w, h));
845 --last_item_index;
846 available_size = shelf_->PrimaryAxisValue(x, y);
847 }
848
836 // Right aligned icons. 849 // Right aligned icons.
837 int end_position = available_size - button_spacing; 850 int end_position = available_size - button_spacing;
838 x = shelf_->PrimaryAxisValue(end_position, 0); 851 x = shelf_->PrimaryAxisValue(end_position, 0);
839 y = shelf_->PrimaryAxisValue(0, end_position); 852 y = shelf_->PrimaryAxisValue(0, end_position);
840 for (int i = view_model_->view_size() - 1; 853 for (int i = last_item_index; i >= first_panel_index; --i) {
841 i >= first_panel_index; --i) {
842 x = shelf_->PrimaryAxisValue(x - w - button_spacing, x); 854 x = shelf_->PrimaryAxisValue(x - w - button_spacing, x);
843 y = shelf_->PrimaryAxisValue(y, y - h - button_spacing); 855 y = shelf_->PrimaryAxisValue(y, y - h - button_spacing);
844 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h)); 856 view_model_->set_ideal_bounds(i, gfx::Rect(x, y, w, h));
845 end_position = shelf_->PrimaryAxisValue(x, y); 857 end_position = shelf_->PrimaryAxisValue(x, y);
846 } 858 }
847 859
848 // Icons on the left / top are guaranteed up to kLeftIconProportion of 860 // Icons on the left / top are guaranteed up to kLeftIconProportion of
849 // the available space. 861 // the available space.
850 int last_icon_position = 862 int last_icon_position =
851 shelf_->PrimaryAxisValue( 863 shelf_->PrimaryAxisValue(
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 1899
1888 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1900 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1889 const gfx::Rect bounds = GetBoundsInScreen(); 1901 const gfx::Rect bounds = GetBoundsInScreen();
1890 int distance = shelf_->SelectValueForShelfAlignment( 1902 int distance = shelf_->SelectValueForShelfAlignment(
1891 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1903 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1892 bounds.x() - coordinate.x()); 1904 bounds.x() - coordinate.x());
1893 return distance > 0 ? distance : 0; 1905 return distance > 0 ? distance : 0;
1894 } 1906 }
1895 1907
1896 } // namespace ash 1908 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698