| 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 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool ShelfMenuModelAdapter::ShouldReserveSpaceForSubmenuIndicator() const { | 217 bool ShelfMenuModelAdapter::ShouldReserveSpaceForSubmenuIndicator() const { |
| 218 return false; | 218 return false; |
| 219 } | 219 } |
| 220 | 220 |
| 221 // Custom FocusSearch used to navigate the shelf in the order items are in | 221 // Custom FocusSearch used to navigate the shelf in the order items are in |
| 222 // the ViewModel. | 222 // the ViewModel. |
| 223 class ShelfFocusSearch : public views::FocusSearch { | 223 class ShelfFocusSearch : public views::FocusSearch { |
| 224 public: | 224 public: |
| 225 explicit ShelfFocusSearch(views::ViewModel* view_model) | 225 explicit ShelfFocusSearch(views::ViewModel<views::View>* view_model) |
| 226 : FocusSearch(NULL, true, true), | 226 : FocusSearch(NULL, true, true), |
| 227 view_model_(view_model) {} | 227 view_model_(view_model) {} |
| 228 virtual ~ShelfFocusSearch() {} | 228 virtual ~ShelfFocusSearch() {} |
| 229 | 229 |
| 230 // views::FocusSearch overrides: | 230 // views::FocusSearch overrides: |
| 231 virtual View* FindNextFocusableView( | 231 virtual View* FindNextFocusableView( |
| 232 View* starting_view, | 232 View* starting_view, |
| 233 bool reverse, | 233 bool reverse, |
| 234 Direction direction, | 234 Direction direction, |
| 235 bool check_starting_view, | 235 bool check_starting_view, |
| 236 views::FocusTraversable** focus_traversable, | 236 views::FocusTraversable** focus_traversable, |
| 237 View** focus_traversable_view) OVERRIDE { | 237 View** focus_traversable_view) OVERRIDE { |
| 238 int index = view_model_->GetIndexOfView(starting_view); | 238 int index = view_model_->GetIndexOfView(starting_view); |
| 239 if (index == -1) | 239 if (index == -1) |
| 240 return view_model_->view_at(0); | 240 return view_model_->view_at(0); |
| 241 | 241 |
| 242 if (reverse) { | 242 if (reverse) { |
| 243 --index; | 243 --index; |
| 244 if (index < 0) | 244 if (index < 0) |
| 245 index = view_model_->view_size() - 1; | 245 index = view_model_->view_size() - 1; |
| 246 } else { | 246 } else { |
| 247 ++index; | 247 ++index; |
| 248 if (index >= view_model_->view_size()) | 248 if (index >= view_model_->view_size()) |
| 249 index = 0; | 249 index = 0; |
| 250 } | 250 } |
| 251 return view_model_->view_at(index); | 251 return view_model_->view_at(index); |
| 252 } | 252 } |
| 253 | 253 |
| 254 private: | 254 private: |
| 255 views::ViewModel* view_model_; | 255 views::ViewModel<views::View>* view_model_; |
| 256 | 256 |
| 257 DISALLOW_COPY_AND_ASSIGN(ShelfFocusSearch); | 257 DISALLOW_COPY_AND_ASSIGN(ShelfFocusSearch); |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 // AnimationDelegate used when inserting a new item. This steadily increases the | 260 // AnimationDelegate used when inserting a new item. This steadily increases the |
| 261 // opacity of the layer as the animation progress. | 261 // opacity of the layer as the animation progress. |
| 262 class FadeInAnimationDelegate : public gfx::AnimationDelegate { | 262 class FadeInAnimationDelegate : public gfx::AnimationDelegate { |
| 263 public: | 263 public: |
| 264 explicit FadeInAnimationDelegate(views::View* view) : view_(view) {} | 264 explicit FadeInAnimationDelegate(views::View* view) : view_(view) {} |
| 265 virtual ~FadeInAnimationDelegate() {} | 265 virtual ~FadeInAnimationDelegate() {} |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 views::View* view_; | 362 views::View* view_; |
| 363 | 363 |
| 364 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); | 364 DISALLOW_COPY_AND_ASSIGN(StartFadeAnimationDelegate); |
| 365 }; | 365 }; |
| 366 | 366 |
| 367 ShelfView::ShelfView(ShelfModel* model, | 367 ShelfView::ShelfView(ShelfModel* model, |
| 368 ShelfDelegate* delegate, | 368 ShelfDelegate* delegate, |
| 369 ShelfLayoutManager* manager) | 369 ShelfLayoutManager* manager) |
| 370 : model_(model), | 370 : model_(model), |
| 371 delegate_(delegate), | 371 delegate_(delegate), |
| 372 view_model_(new views::ViewModel), | 372 view_model_(new views::ViewModel<views::View>), |
| 373 first_visible_index_(0), | 373 first_visible_index_(0), |
| 374 last_visible_index_(-1), | 374 last_visible_index_(-1), |
| 375 overflow_button_(NULL), | 375 overflow_button_(NULL), |
| 376 owner_overflow_bubble_(NULL), | 376 owner_overflow_bubble_(NULL), |
| 377 drag_pointer_(NONE), | 377 drag_pointer_(NONE), |
| 378 drag_view_(NULL), | 378 drag_view_(NULL), |
| 379 start_drag_index_(-1), | 379 start_drag_index_(-1), |
| 380 context_menu_id_(0), | 380 context_menu_id_(0), |
| 381 leading_inset_(kDefaultLeadingInset), | 381 leading_inset_(kDefaultLeadingInset), |
| 382 cancelling_drag_model_changed_(false), | 382 cancelling_drag_model_changed_(false), |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 distance = bounds.x() - coordinate.x(); | 1927 distance = bounds.x() - coordinate.x(); |
| 1928 break; | 1928 break; |
| 1929 case SHELF_ALIGNMENT_TOP: | 1929 case SHELF_ALIGNMENT_TOP: |
| 1930 distance = coordinate.y() - bounds.bottom(); | 1930 distance = coordinate.y() - bounds.bottom(); |
| 1931 break; | 1931 break; |
| 1932 } | 1932 } |
| 1933 return distance > 0 ? distance : 0; | 1933 return distance > 0 ? distance : 0; |
| 1934 } | 1934 } |
| 1935 | 1935 |
| 1936 } // namespace ash | 1936 } // namespace ash |
| OLD | NEW |