| 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 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // AppListView is the top-level view and controller of app list UI. It creates | 32 // AppListView is the top-level view and controller of app list UI. It creates |
| 33 // and hosts a AppsGridView and passes AppListModel to it for display. | 33 // and hosts a AppsGridView and passes AppListModel to it for display. |
| 34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 34 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, |
| 35 public SpeechUIModelObserver { | 35 public SpeechUIModelObserver { |
| 36 public: | 36 public: |
| 37 // Does not take ownership of |delegate|. | 37 // Does not take ownership of |delegate|. |
| 38 explicit AppListView(AppListViewDelegate* delegate); | 38 explicit AppListView(AppListViewDelegate* delegate); |
| 39 ~AppListView() override; | 39 ~AppListView() override; |
| 40 | 40 |
| 41 // Initializes the widget. | 41 // Initializes the widget as a bubble or fullscreen view depending on the |
| 42 void InitAsBubble(gfx::NativeView parent, int initial_apps_page); | 42 // presence of a cmd line switch. parent and initial_apps_page are used for |
| 43 // both the bubble and fullscreen initialization. |
| 44 void Initialize(gfx::NativeView parent, int initial_apps_page); |
| 43 | 45 |
| 44 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); | 46 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); |
| 45 | 47 |
| 46 void SetAnchorPoint(const gfx::Point& anchor_point); | 48 void MaybeSetAnchorPoint(const gfx::Point& anchor_point); |
| 47 | 49 |
| 48 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop | 50 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop |
| 49 // operations outside the application list. This has to be called after | 51 // operations outside the application list. This has to be called after |
| 50 // InitAsBubble was called since the app list object needs to exist so that | 52 // Initialize was called since the app list object needs to exist so that |
| 51 // it can set the host. | 53 // it can set the host. |
| 52 void SetDragAndDropHostOfCurrentAppList( | 54 void SetDragAndDropHostOfCurrentAppList( |
| 53 ApplicationDragAndDropHost* drag_and_drop_host); | 55 ApplicationDragAndDropHost* drag_and_drop_host); |
| 54 | 56 |
| 55 // Shows the UI when there are no pending icon loads. Otherwise, starts a | 57 // Shows the UI when there are no pending icon loads. Otherwise, starts a |
| 56 // timer to show the UI when a maximum allowed wait time has expired. | 58 // timer to show the UI when a maximum allowed wait time has expired. |
| 57 void ShowWhenReady(); | 59 void ShowWhenReady(); |
| 58 | 60 |
| 59 void CloseAppList(); | 61 void CloseAppList(); |
| 60 | 62 |
| 61 void UpdateBounds(); | 63 void UpdateBounds(); |
| 62 | 64 |
| 63 // Enables/disables a semi-transparent overlay over the app list (good for | 65 // Enables/disables a semi-transparent overlay over the app list (good for |
| 64 // hiding the app list when a modal dialog is being shown). | 66 // hiding the app list when a modal dialog is being shown). |
| 65 void SetAppListOverlayVisible(bool visible); | 67 void SetAppListOverlayVisible(bool visible); |
| 66 | 68 |
| 67 views::Widget* search_box_widget() const { return search_box_widget_; } | 69 views::Widget* search_box_widget() const { return search_box_widget_; } |
| 68 | 70 |
| 69 // Overridden from views::View: | 71 // Overridden from views::View: |
| 70 gfx::Size GetPreferredSize() const override; | 72 gfx::Size GetPreferredSize() const override; |
| 71 void OnPaint(gfx::Canvas* canvas) override; | 73 void OnPaint(gfx::Canvas* canvas) override; |
| 74 const char* GetClassName() const override; |
| 72 | 75 |
| 73 // WidgetDelegate overrides: | 76 // WidgetDelegate overrides: |
| 74 bool ShouldHandleSystemCommands() const override; | 77 bool ShouldHandleSystemCommands() const override; |
| 75 bool ShouldDescendIntoChildForEventHandling( | 78 bool ShouldDescendIntoChildForEventHandling( |
| 76 gfx::NativeView child, | 79 gfx::NativeView child, |
| 77 const gfx::Point& location) override; | 80 const gfx::Point& location) override; |
| 78 | 81 |
| 79 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 82 AppListMainView* app_list_main_view() { return app_list_main_view_; } |
| 80 | 83 |
| 81 // Gets the PaginationModel owned by this view's apps grid. | 84 // Gets the PaginationModel owned by this view's apps grid. |
| 82 PaginationModel* GetAppsPaginationModel(); | 85 PaginationModel* GetAppsPaginationModel(); |
| 83 | 86 |
| 84 // Overridden from views::View: | 87 // Overridden from views::View: |
| 85 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 88 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 86 void Layout() override; | 89 void Layout() override; |
| 87 void SchedulePaintInRect(const gfx::Rect& rect) override; | 90 void SchedulePaintInRect(const gfx::Rect& rect) override; |
| 88 | 91 |
| 89 private: | 92 private: |
| 90 friend class test::AppListViewTestApi; | 93 friend class test::AppListViewTestApi; |
| 91 | 94 |
| 92 void InitContents(gfx::NativeView parent, int initial_apps_page); | 95 void InitContents(gfx::NativeView parent, int initial_apps_page); |
| 93 | 96 |
| 94 void InitChildWidgets(); | 97 void InitChildWidgets(); |
| 95 | 98 |
| 99 // Initializes the widget for fullscreen mode. |
| 100 void InitializeFullscreen(gfx::NativeView parent, int initial_apps_page); |
| 101 |
| 102 // Initializes the widget as a bubble. |
| 103 void InitializeBubble(gfx::NativeView parent, int initial_apps_page); |
| 104 |
| 96 // Overridden from views::BubbleDialogDelegateView: | 105 // Overridden from views::BubbleDialogDelegateView: |
| 97 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 106 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, |
| 98 views::Widget* widget) const override; | 107 views::Widget* widget) const override; |
| 99 int GetDialogButtons() const override; | 108 int GetDialogButtons() const override; |
| 100 | 109 |
| 101 // Overridden from views::WidgetDelegateView: | 110 // Overridden from views::WidgetDelegateView: |
| 102 views::View* GetInitiallyFocusedView() override; | 111 views::View* GetInitiallyFocusedView() override; |
| 103 bool WidgetHasHitTestMask() const override; | 112 bool WidgetHasHitTestMask() const override; |
| 104 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 113 void GetWidgetHitTestMask(gfx::Path* mask) const override; |
| 105 | 114 |
| 106 // Overridden from views::WidgetObserver: | 115 // Overridden from views::WidgetObserver: |
| 107 void OnWidgetDestroying(views::Widget* widget) override; | 116 void OnWidgetDestroying(views::Widget* widget) override; |
| 108 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 117 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; |
| 109 | 118 |
| 110 // Overridden from SpeechUIModelObserver: | 119 // Overridden from SpeechUIModelObserver: |
| 111 void OnSpeechRecognitionStateChanged( | 120 void OnSpeechRecognitionStateChanged( |
| 112 SpeechRecognitionState new_state) override; | 121 SpeechRecognitionState new_state) override; |
| 113 | 122 |
| 114 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 123 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. |
| 115 | 124 |
| 116 AppListMainView* app_list_main_view_; | 125 AppListMainView* app_list_main_view_; |
| 117 SpeechView* speech_view_; | 126 SpeechView* speech_view_; |
| 118 | 127 |
| 119 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 128 views::View* search_box_focus_host_; // Owned by the views hierarchy. |
| 120 views::Widget* search_box_widget_; // Owned by the app list's widget. | 129 views::Widget* search_box_widget_; // Owned by the app list's widget. |
| 121 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 130 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. |
| 122 | 131 |
| 123 // A semi-transparent white overlay that covers the app list while dialogs are | 132 // A semi-transparent white overlay that covers the app list while dialogs are |
| 124 // open. | 133 // open. |
| 125 views::View* overlay_view_; | 134 views::View* overlay_view_; |
| 126 | 135 |
| 127 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 136 std::unique_ptr<HideViewAnimationObserver> animation_observer_; |
| 128 | 137 |
| 129 // For UMA and testing. If non-null, triggered when the app list is painted. | 138 // For UMA and testing. If non-null, triggered when the app list is painted. |
| 130 base::Closure next_paint_callback_; | 139 base::Closure next_paint_callback_; |
| 131 | 140 |
| 132 DISALLOW_COPY_AND_ASSIGN(AppListView); | 141 DISALLOW_COPY_AND_ASSIGN(AppListView); |
| 133 }; | 142 }; |
| 134 | 143 |
| 135 } // namespace app_list | 144 } // namespace app_list |
| 136 | 145 |
| 137 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 146 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
| OLD | NEW |