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

Side by Side Diff: ui/app_list/views/apps_grid_view.h

Issue 302803002: Refactor app list so AppsGridView owns the PaginationModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests and bugs. Created 6 years, 6 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 | Annotate | Revision Log
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 #ifndef UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 5 #ifndef UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 6 #define UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
tapted 2014/06/02 04:02:21 nit: unused?
Matt Giuca 2014/06/02 07:11:23 Done.
Matt Giuca 2014/06/03 01:52:36 Actually, ref_counted.h is used (not by my code, b
14 #include "base/memory/scoped_ptr.h"
13 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
14 #include "ui/app_list/app_list_export.h" 16 #include "ui/app_list/app_list_export.h"
15 #include "ui/app_list/app_list_model.h" 17 #include "ui/app_list/app_list_model.h"
16 #include "ui/app_list/app_list_model_observer.h" 18 #include "ui/app_list/app_list_model_observer.h"
17 #include "ui/app_list/pagination_model_observer.h" 19 #include "ui/app_list/pagination_model_observer.h"
18 #include "ui/base/models/list_model_observer.h" 20 #include "ui/base/models/list_model_observer.h"
19 #include "ui/compositor/layer_animation_observer.h" 21 #include "ui/compositor/layer_animation_observer.h"
20 #include "ui/gfx/image/image_skia_operations.h" 22 #include "ui/gfx/image/image_skia_operations.h"
21 #include "ui/views/animation/bounds_animator.h" 23 #include "ui/views/animation/bounds_animator.h"
22 #include "ui/views/controls/button/button.h" 24 #include "ui/views/controls/button/button.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 public AppListModelObserver, 65 public AppListModelObserver,
64 public ui::ImplicitAnimationObserver { 66 public ui::ImplicitAnimationObserver {
65 public: 67 public:
66 enum Pointer { 68 enum Pointer {
67 NONE, 69 NONE,
68 MOUSE, 70 MOUSE,
69 TOUCH, 71 TOUCH,
70 }; 72 };
71 73
72 // Constructs the app icon grid view. |delegate| is the delegate of this 74 // Constructs the app icon grid view. |delegate| is the delegate of this
73 // view, which usually is the hosting AppListView. |pagination_model| is 75 // view, which usually is the hosting AppListView.
74 // the paging info shared within the launcher UI. 76 AppsGridView(AppsGridViewDelegate* delegate);
75 AppsGridView(AppsGridViewDelegate* delegate,
76 PaginationModel* pagination_model);
77 virtual ~AppsGridView(); 77 virtual ~AppsGridView();
78 78
79 // Sets fixed layout parameters. After setting this, CalculateLayout below 79 // Sets fixed layout parameters. After setting this, CalculateLayout below
80 // is no longer called to dynamically choosing those layout params. 80 // is no longer called to dynamically choosing those layout params.
81 void SetLayout(int icon_size, int cols, int rows_per_page); 81 void SetLayout(int icon_size, int cols, int rows_per_page);
82 82
83 int cols() { return cols_; } 83 int cols() { return cols_; }
84 int rows_per_page() { return rows_per_page_; } 84 int rows_per_page() { return rows_per_page_; }
85 85
86 // This resets the grid view to a fresh state for showing the app list. 86 // This resets the grid view to a fresh state for showing the app list.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 // Prerenders the icons on and around |page_index|. 125 // Prerenders the icons on and around |page_index|.
126 void Prerender(int page_index); 126 void Prerender(int page_index);
127 127
128 // Return true if the |bounds_animator_| is animating |view|. 128 // Return true if the |bounds_animator_| is animating |view|.
129 bool IsAnimatingView(views::View* view); 129 bool IsAnimatingView(views::View* view);
130 130
131 bool has_dragged_view() const { return drag_view_ != NULL; } 131 bool has_dragged_view() const { return drag_view_ != NULL; }
132 bool dragging() const { return drag_pointer_ != NONE; } 132 bool dragging() const { return drag_pointer_ != NONE; }
133 133
134 // Gets the PaginationModel used for the grid view.
135 PaginationModel* GetPaginationModel() const {
xiyuan 2014/05/30 15:47:47 GetPaginationModel -> pagination_model and get rid
Matt Giuca 2014/06/02 07:11:23 Done.
136 return pagination_model_.get();
137 }
138
134 // Overridden from views::View: 139 // Overridden from views::View:
135 virtual gfx::Size GetPreferredSize() const OVERRIDE; 140 virtual gfx::Size GetPreferredSize() const OVERRIDE;
136 virtual void Layout() OVERRIDE; 141 virtual void Layout() OVERRIDE;
137 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 142 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
138 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; 143 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE;
139 virtual void ViewHierarchyChanged( 144 virtual void ViewHierarchyChanged(
140 const ViewHierarchyChangedDetails& details) OVERRIDE; 145 const ViewHierarchyChangedDetails& details) OVERRIDE;
141 virtual bool GetDropFormats( 146 virtual bool GetDropFormats(
142 int* formats, 147 int* formats,
143 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; 148 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 const base::FilePath& path); 459 const base::FilePath& path);
455 #endif 460 #endif
456 461
457 AppListModel* model_; // Owned by AppListView. 462 AppListModel* model_; // Owned by AppListView.
458 AppListItemList* item_list_; // Not owned. 463 AppListItemList* item_list_; // Not owned.
459 AppsGridViewDelegate* delegate_; 464 AppsGridViewDelegate* delegate_;
460 465
461 // This can be NULL. Only grid views inside folders have a folder delegate. 466 // This can be NULL. Only grid views inside folders have a folder delegate.
462 AppsGridViewFolderDelegate* folder_delegate_; 467 AppsGridViewFolderDelegate* folder_delegate_;
463 468
464 PaginationModel* pagination_model_; // Owned by AppListController. 469 scoped_ptr<PaginationModel> pagination_model_;
tapted 2014/06/02 04:02:21 I'd consider trying this out as a non-pointer data
Matt Giuca 2014/06/02 07:11:23 Done.
465 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. 470 PageSwitcher* page_switcher_view_; // Owned by views hierarchy.
466 471
467 gfx::Size icon_size_; 472 gfx::Size icon_size_;
468 int cols_; 473 int cols_;
469 int rows_per_page_; 474 int rows_per_page_;
470 475
471 // Tracks app item views. There is a view per item in |model_|. 476 // Tracks app item views. There is a view per item in |model_|.
472 views::ViewModel view_model_; 477 views::ViewModel view_model_;
473 478
474 // Tracks pulsing block views. 479 // Tracks pulsing block views.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 552
548 // True if the drag_view_ item is a folder item being dragged for reparenting. 553 // True if the drag_view_ item is a folder item being dragged for reparenting.
549 bool dragging_for_reparent_item_; 554 bool dragging_for_reparent_item_;
550 555
551 DISALLOW_COPY_AND_ASSIGN(AppsGridView); 556 DISALLOW_COPY_AND_ASSIGN(AppsGridView);
552 }; 557 };
553 558
554 } // namespace app_list 559 } // namespace app_list
555 560
556 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 561 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698