| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorDisabler); | 134 DISALLOW_COPY_AND_ASSIGN(BoundsAnimatorDisabler); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 // The MenuModelAdapter gets slightly changed to adapt the menu appearance to | 137 // The MenuModelAdapter gets slightly changed to adapt the menu appearance to |
| 138 // our requirements. | 138 // our requirements. |
| 139 class ShelfMenuModelAdapter : public views::MenuModelAdapter { | 139 class ShelfMenuModelAdapter : public views::MenuModelAdapter { |
| 140 public: | 140 public: |
| 141 explicit ShelfMenuModelAdapter(ShelfMenuModel* menu_model); | 141 explicit ShelfMenuModelAdapter(ShelfMenuModel* menu_model); |
| 142 | 142 |
| 143 // views::MenuModelAdapter: | 143 // views::MenuModelAdapter: |
| 144 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; | 144 virtual const gfx::FontList* GetLabelFontList(int command_id) const override; |
| 145 virtual bool IsCommandEnabled(int id) const OVERRIDE; | 145 virtual bool IsCommandEnabled(int id) const override; |
| 146 virtual void GetHorizontalIconMargins(int id, | 146 virtual void GetHorizontalIconMargins(int id, |
| 147 int icon_size, | 147 int icon_size, |
| 148 int* left_margin, | 148 int* left_margin, |
| 149 int* right_margin) const OVERRIDE; | 149 int* right_margin) const override; |
| 150 virtual bool GetForegroundColor(int command_id, | 150 virtual bool GetForegroundColor(int command_id, |
| 151 bool is_hovered, | 151 bool is_hovered, |
| 152 SkColor* override_color) const OVERRIDE; | 152 SkColor* override_color) const override; |
| 153 virtual bool GetBackgroundColor(int command_id, | 153 virtual bool GetBackgroundColor(int command_id, |
| 154 bool is_hovered, | 154 bool is_hovered, |
| 155 SkColor* override_color) const OVERRIDE; | 155 SkColor* override_color) const override; |
| 156 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE; | 156 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) override; |
| 157 virtual bool ShouldReserveSpaceForSubmenuIndicator() const OVERRIDE; | 157 virtual bool ShouldReserveSpaceForSubmenuIndicator() const override; |
| 158 | 158 |
| 159 private: | 159 private: |
| 160 ShelfMenuModel* menu_model_; | 160 ShelfMenuModel* menu_model_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(ShelfMenuModelAdapter); | 162 DISALLOW_COPY_AND_ASSIGN(ShelfMenuModelAdapter); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 ShelfMenuModelAdapter::ShelfMenuModelAdapter(ShelfMenuModel* menu_model) | 165 ShelfMenuModelAdapter::ShelfMenuModelAdapter(ShelfMenuModel* menu_model) |
| 166 : MenuModelAdapter(menu_model), | 166 : MenuModelAdapter(menu_model), |
| 167 menu_model_(menu_model) { | 167 menu_model_(menu_model) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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() {} |
| 266 | 266 |
| 267 // AnimationDelegate overrides: | 267 // AnimationDelegate overrides: |
| 268 virtual void AnimationProgressed(const Animation* animation) OVERRIDE { | 268 virtual void AnimationProgressed(const Animation* animation) override { |
| 269 view_->layer()->SetOpacity(animation->GetCurrentValue()); | 269 view_->layer()->SetOpacity(animation->GetCurrentValue()); |
| 270 view_->layer()->ScheduleDraw(); | 270 view_->layer()->ScheduleDraw(); |
| 271 } | 271 } |
| 272 virtual void AnimationEnded(const Animation* animation) OVERRIDE { | 272 virtual void AnimationEnded(const Animation* animation) override { |
| 273 view_->layer()->SetOpacity(1.0f); | 273 view_->layer()->SetOpacity(1.0f); |
| 274 view_->layer()->ScheduleDraw(); | 274 view_->layer()->ScheduleDraw(); |
| 275 } | 275 } |
| 276 virtual void AnimationCanceled(const Animation* animation) OVERRIDE { | 276 virtual void AnimationCanceled(const Animation* animation) override { |
| 277 view_->layer()->SetOpacity(1.0f); | 277 view_->layer()->SetOpacity(1.0f); |
| 278 view_->layer()->ScheduleDraw(); | 278 view_->layer()->ScheduleDraw(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 private: | 281 private: |
| 282 views::View* view_; | 282 views::View* view_; |
| 283 | 283 |
| 284 DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate); | 284 DISALLOW_COPY_AND_ASSIGN(FadeInAnimationDelegate); |
| 285 }; | 285 }; |
| 286 | 286 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 314 // AnimationDelegate used when deleting an item. This steadily decreased the | 314 // AnimationDelegate used when deleting an item. This steadily decreased the |
| 315 // opacity of the layer as the animation progress. | 315 // opacity of the layer as the animation progress. |
| 316 class ShelfView::FadeOutAnimationDelegate : public gfx::AnimationDelegate { | 316 class ShelfView::FadeOutAnimationDelegate : public gfx::AnimationDelegate { |
| 317 public: | 317 public: |
| 318 FadeOutAnimationDelegate(ShelfView* host, views::View* view) | 318 FadeOutAnimationDelegate(ShelfView* host, views::View* view) |
| 319 : shelf_view_(host), | 319 : shelf_view_(host), |
| 320 view_(view) {} | 320 view_(view) {} |
| 321 virtual ~FadeOutAnimationDelegate() {} | 321 virtual ~FadeOutAnimationDelegate() {} |
| 322 | 322 |
| 323 // AnimationDelegate overrides: | 323 // AnimationDelegate overrides: |
| 324 virtual void AnimationProgressed(const Animation* animation) OVERRIDE { | 324 virtual void AnimationProgressed(const Animation* animation) override { |
| 325 view_->layer()->SetOpacity(1 - animation->GetCurrentValue()); | 325 view_->layer()->SetOpacity(1 - animation->GetCurrentValue()); |
| 326 view_->layer()->ScheduleDraw(); | 326 view_->layer()->ScheduleDraw(); |
| 327 } | 327 } |
| 328 virtual void AnimationEnded(const Animation* animation) OVERRIDE { | 328 virtual void AnimationEnded(const Animation* animation) override { |
| 329 shelf_view_->OnFadeOutAnimationEnded(); | 329 shelf_view_->OnFadeOutAnimationEnded(); |
| 330 } | 330 } |
| 331 virtual void AnimationCanceled(const Animation* animation) OVERRIDE { | 331 virtual void AnimationCanceled(const Animation* animation) override { |
| 332 } | 332 } |
| 333 | 333 |
| 334 private: | 334 private: |
| 335 ShelfView* shelf_view_; | 335 ShelfView* shelf_view_; |
| 336 scoped_ptr<views::View> view_; | 336 scoped_ptr<views::View> view_; |
| 337 | 337 |
| 338 DISALLOW_COPY_AND_ASSIGN(FadeOutAnimationDelegate); | 338 DISALLOW_COPY_AND_ASSIGN(FadeOutAnimationDelegate); |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 // AnimationDelegate used to trigger fading an element in. When an item is | 341 // AnimationDelegate used to trigger fading an element in. When an item is |
| 342 // inserted this delegate is attached to the animation that expands the size of | 342 // inserted this delegate is attached to the animation that expands the size of |
| 343 // the item. When done it kicks off another animation to fade the item in. | 343 // the item. When done it kicks off another animation to fade the item in. |
| 344 class ShelfView::StartFadeAnimationDelegate : public gfx::AnimationDelegate { | 344 class ShelfView::StartFadeAnimationDelegate : public gfx::AnimationDelegate { |
| 345 public: | 345 public: |
| 346 StartFadeAnimationDelegate(ShelfView* host, | 346 StartFadeAnimationDelegate(ShelfView* host, |
| 347 views::View* view) | 347 views::View* view) |
| 348 : shelf_view_(host), | 348 : shelf_view_(host), |
| 349 view_(view) {} | 349 view_(view) {} |
| 350 virtual ~StartFadeAnimationDelegate() {} | 350 virtual ~StartFadeAnimationDelegate() {} |
| 351 | 351 |
| 352 // AnimationDelegate overrides: | 352 // AnimationDelegate overrides: |
| 353 virtual void AnimationEnded(const Animation* animation) OVERRIDE { | 353 virtual void AnimationEnded(const Animation* animation) override { |
| 354 shelf_view_->FadeIn(view_); | 354 shelf_view_->FadeIn(view_); |
| 355 } | 355 } |
| 356 virtual void AnimationCanceled(const Animation* animation) OVERRIDE { | 356 virtual void AnimationCanceled(const Animation* animation) override { |
| 357 view_->layer()->SetOpacity(1.0f); | 357 view_->layer()->SetOpacity(1.0f); |
| 358 } | 358 } |
| 359 | 359 |
| 360 private: | 360 private: |
| 361 ShelfView* shelf_view_; | 361 ShelfView* shelf_view_; |
| 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 |
| (...skipping 1560 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 |