Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |