| 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 CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/download/download_shelf.h" | 12 #include "chrome/browser/download/download_shelf.h" |
| 13 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/gfx/animation/animation_delegate.h" |
| 14 #include "ui/views/accessible_pane_view.h" | 14 #include "ui/views/accessible_pane_view.h" |
| 15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 16 #include "ui/views/controls/link_listener.h" | 16 #include "ui/views/controls/link_listener.h" |
| 17 #include "ui/views/mouse_watcher.h" | 17 #include "ui/views/mouse_watcher.h" |
| 18 | 18 |
| 19 class Browser; | 19 class Browser; |
| 20 class BrowserView; | 20 class BrowserView; |
| 21 class DownloadItemView; | 21 class DownloadItemView; |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 class DownloadItem; | 24 class DownloadItem; |
| 25 class PageNavigator; | 25 class PageNavigator; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace ui { | 28 namespace gfx { |
| 29 class SlideAnimation; | 29 class SlideAnimation; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace views { | 32 namespace views { |
| 33 class ImageButton; | 33 class ImageButton; |
| 34 class ImageView; | 34 class ImageView; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // DownloadShelfView is a view that contains individual views for each download, | 37 // DownloadShelfView is a view that contains individual views for each download, |
| 38 // as well as a close button and a link to show all downloads. | 38 // as well as a close button and a link to show all downloads. |
| 39 // | 39 // |
| 40 // DownloadShelfView does not hold an infinite number of download views, rather | 40 // DownloadShelfView does not hold an infinite number of download views, rather |
| 41 // it'll automatically remove views once a certain point is reached. | 41 // it'll automatically remove views once a certain point is reached. |
| 42 class DownloadShelfView : public views::AccessiblePaneView, | 42 class DownloadShelfView : public views::AccessiblePaneView, |
| 43 public ui::AnimationDelegate, | 43 public gfx::AnimationDelegate, |
| 44 public DownloadShelf, | 44 public DownloadShelf, |
| 45 public views::ButtonListener, | 45 public views::ButtonListener, |
| 46 public views::LinkListener, | 46 public views::LinkListener, |
| 47 public views::MouseWatcherListener { | 47 public views::MouseWatcherListener { |
| 48 public: | 48 public: |
| 49 DownloadShelfView(Browser* browser, BrowserView* parent); | 49 DownloadShelfView(Browser* browser, BrowserView* parent); |
| 50 virtual ~DownloadShelfView(); | 50 virtual ~DownloadShelfView(); |
| 51 | 51 |
| 52 // Sent from the DownloadItemView when the user opens an item. | 52 // Sent from the DownloadItemView when the user opens an item. |
| 53 void OpenedDownload(DownloadItemView* view); | 53 void OpenedDownload(DownloadItemView* view); |
| 54 | 54 |
| 55 // Returns the relevant containing object that can load pages. | 55 // Returns the relevant containing object that can load pages. |
| 56 // i.e. the |browser_|. | 56 // i.e. the |browser_|. |
| 57 content::PageNavigator* GetNavigator(); | 57 content::PageNavigator* GetNavigator(); |
| 58 | 58 |
| 59 // Implementation of View. | 59 // Implementation of View. |
| 60 virtual gfx::Size GetPreferredSize() OVERRIDE; | 60 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 61 virtual void Layout() OVERRIDE; | 61 virtual void Layout() OVERRIDE; |
| 62 virtual void ViewHierarchyChanged( | 62 virtual void ViewHierarchyChanged( |
| 63 const ViewHierarchyChangedDetails& details) OVERRIDE; | 63 const ViewHierarchyChangedDetails& details) OVERRIDE; |
| 64 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 64 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 65 | 65 |
| 66 // Implementation of ui::AnimationDelegate. | 66 // Implementation of gfx::AnimationDelegate. |
| 67 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 67 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 68 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 68 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 69 | 69 |
| 70 // Implementation of views::LinkListener. | 70 // Implementation of views::LinkListener. |
| 71 // Invoked when the user clicks the 'show all downloads' link button. | 71 // Invoked when the user clicks the 'show all downloads' link button. |
| 72 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 72 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 73 | 73 |
| 74 // Implementation of ButtonListener. | 74 // Implementation of ButtonListener. |
| 75 // Invoked when the user clicks the close button. Asks the browser to | 75 // Invoked when the user clicks the close button. Asks the browser to |
| 76 // hide the download shelf. | 76 // hide the download shelf. |
| 77 virtual void ButtonPressed(views::Button* button, | 77 virtual void ButtonPressed(views::Button* button, |
| 78 const ui::Event& event) OVERRIDE; | 78 const ui::Event& event) OVERRIDE; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 void SchedulePaintForDownloadItem(views::View* view); | 135 void SchedulePaintForDownloadItem(views::View* view); |
| 136 | 136 |
| 137 // Get the rect that perfectly surrounds a DownloadItemView so we can | 137 // Get the rect that perfectly surrounds a DownloadItemView so we can |
| 138 // draw a focus rect around it. | 138 // draw a focus rect around it. |
| 139 gfx::Rect GetFocusRectBounds(const DownloadItemView* download_item_view); | 139 gfx::Rect GetFocusRectBounds(const DownloadItemView* download_item_view); |
| 140 | 140 |
| 141 // The browser for this shelf. | 141 // The browser for this shelf. |
| 142 Browser* browser_; | 142 Browser* browser_; |
| 143 | 143 |
| 144 // The animation for adding new items to the shelf. | 144 // The animation for adding new items to the shelf. |
| 145 scoped_ptr<ui::SlideAnimation> new_item_animation_; | 145 scoped_ptr<gfx::SlideAnimation> new_item_animation_; |
| 146 | 146 |
| 147 // The show/hide animation for the shelf itself. | 147 // The show/hide animation for the shelf itself. |
| 148 scoped_ptr<ui::SlideAnimation> shelf_animation_; | 148 scoped_ptr<gfx::SlideAnimation> shelf_animation_; |
| 149 | 149 |
| 150 // The download views. These are also child Views, and deleted when | 150 // The download views. These are also child Views, and deleted when |
| 151 // the DownloadShelfView is deleted. | 151 // the DownloadShelfView is deleted. |
| 152 std::vector<DownloadItemView*> download_views_; | 152 std::vector<DownloadItemView*> download_views_; |
| 153 | 153 |
| 154 // An image displayed on the right of the "Show all downloads..." link. | 154 // An image displayed on the right of the "Show all downloads..." link. |
| 155 views::ImageView* arrow_image_; | 155 views::ImageView* arrow_image_; |
| 156 | 156 |
| 157 // Link for showing all downloads. This is contained as a child, and deleted | 157 // Link for showing all downloads. This is contained as a child, and deleted |
| 158 // by View. | 158 // by View. |
| 159 views::Link* show_all_view_; | 159 views::Link* show_all_view_; |
| 160 | 160 |
| 161 // Button for closing the downloads. This is contained as a child, and | 161 // Button for closing the downloads. This is contained as a child, and |
| 162 // deleted by View. | 162 // deleted by View. |
| 163 views::ImageButton* close_button_; | 163 views::ImageButton* close_button_; |
| 164 | 164 |
| 165 // The window this shelf belongs to. | 165 // The window this shelf belongs to. |
| 166 BrowserView* parent_; | 166 BrowserView* parent_; |
| 167 | 167 |
| 168 views::MouseWatcher mouse_watcher_; | 168 views::MouseWatcher mouse_watcher_; |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); | 170 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 173 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
| OLD | NEW |