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

Side by Side Diff: chrome/browser/ui/views/download/download_shelf_view.h

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: tests Created 3 years, 9 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
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 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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/browser/download/download_shelf.h" 14 #include "chrome/browser/download/download_shelf.h"
15 #include "ui/gfx/animation/animation_delegate.h" 15 #include "ui/gfx/animation/animation_delegate.h"
16 #include "ui/gfx/animation/slide_animation.h" 16 #include "ui/gfx/animation/slide_animation.h"
17 #include "ui/views/accessible_pane_view.h" 17 #include "ui/views/accessible_pane_view.h"
18 #include "ui/views/controls/button/vector_icon_button_delegate.h" 18 #include "ui/views/controls/button/button.h"
19 #include "ui/views/controls/link_listener.h" 19 #include "ui/views/controls/link_listener.h"
20 #include "ui/views/mouse_watcher.h" 20 #include "ui/views/mouse_watcher.h"
21 21
22 class Browser; 22 class Browser;
23 class BrowserView; 23 class BrowserView;
24 class DownloadItemView; 24 class DownloadItemView;
25 25
26 namespace content { 26 namespace content {
27 class DownloadItem; 27 class DownloadItem;
28 class PageNavigator; 28 class PageNavigator;
29 } 29 }
30 30
31 namespace views { 31 namespace views {
32 class ImageButton; 32 class ImageButton;
33 class MdTextButton; 33 class MdTextButton;
34 } 34 }
35 35
36 // DownloadShelfView is a view that contains individual views for each download, 36 // DownloadShelfView is a view that contains individual views for each download,
37 // as well as a close button and a link to show all downloads. 37 // as well as a close button and a link to show all downloads.
38 // 38 //
39 // DownloadShelfView does not hold an infinite number of download views, rather 39 // DownloadShelfView does not hold an infinite number of download views, rather
40 // it'll automatically remove views once a certain point is reached. 40 // it'll automatically remove views once a certain point is reached.
41 class DownloadShelfView : public views::AccessiblePaneView, 41 class DownloadShelfView : public views::AccessiblePaneView,
42 public gfx::AnimationDelegate, 42 public gfx::AnimationDelegate,
43 public DownloadShelf, 43 public DownloadShelf,
44 public views::VectorIconButtonDelegate, 44 public views::ButtonListener,
45 public views::LinkListener, 45 public views::LinkListener,
46 public views::MouseWatcherListener { 46 public views::MouseWatcherListener {
47 public: 47 public:
48 DownloadShelfView(Browser* browser, BrowserView* parent); 48 DownloadShelfView(Browser* browser, BrowserView* parent);
49 ~DownloadShelfView() override; 49 ~DownloadShelfView() override;
50 50
51 // Sent from the DownloadItemView when the user opens an item. 51 // Sent from the DownloadItemView when the user opens an item.
52 void OpenedDownload(); 52 void OpenedDownload();
53 53
54 // Returns the relevant containing object that can load pages. 54 // Returns the relevant containing object that can load pages.
55 // i.e. the |browser_|. 55 // i.e. the |browser_|.
56 content::PageNavigator* GetNavigator(); 56 content::PageNavigator* GetNavigator();
57 57
58 // Returns the parent_. 58 // Returns the parent_.
59 BrowserView* get_parent() { return parent_; } 59 BrowserView* get_parent() { return parent_; }
60 60
61 // Implementation of View. 61 // views::View:
62 gfx::Size GetPreferredSize() const override; 62 gfx::Size GetPreferredSize() const override;
63 void Layout() override; 63 void Layout() override;
64 void ViewHierarchyChanged( 64 void ViewHierarchyChanged(
65 const ViewHierarchyChangedDetails& details) override; 65 const ViewHierarchyChangedDetails& details) override;
66 66
67 // Implementation of gfx::AnimationDelegate. 67 // gfx::AnimationDelegate.
68 void AnimationProgressed(const gfx::Animation* animation) override; 68 void AnimationProgressed(const gfx::Animation* animation) override;
69 void AnimationEnded(const gfx::Animation* animation) override; 69 void AnimationEnded(const gfx::Animation* animation) override;
70 70
71 // Implementation of views::LinkListener. 71 // views::LinkListener.
72 // Invoked when the user clicks the 'show all downloads' link button. 72 // Invoked when the user clicks the 'show all downloads' link button.
73 void LinkClicked(views::Link* source, int event_flags) override; 73 void LinkClicked(views::Link* source, int event_flags) override;
74 74
75 // Implementation of VectorIconButtonDelegate. 75 // views::ButtonListener:
76 // Invoked when the user clicks the close button. Asks the browser to 76 // Invoked when the user clicks the close button. Asks the browser to
77 // hide the download shelf. 77 // hide the download shelf.
78 void ButtonPressed(views::Button* button, const ui::Event& event) override; 78 void ButtonPressed(views::Button* button, const ui::Event& event) override;
79 SkColor GetVectorIconBaseColor() const override;
80 79
81 // Implementation of DownloadShelf. 80 // DownloadShelf:
82 bool IsShowing() const override; 81 bool IsShowing() const override;
83 bool IsClosing() const override; 82 bool IsClosing() const override;
84 Browser* browser() const override; 83 Browser* browser() const override;
85 84
86 // Implementation of MouseWatcherListener override. 85 // views::MouseWatcherListener:
87 void MouseMovedOutOfHost() override; 86 void MouseMovedOutOfHost() override;
88 87
89 // Removes a specified download view. The supplied view is deleted after 88 // Removes a specified download view. The supplied view is deleted after
90 // it's removed. 89 // it's removed.
91 void RemoveDownloadView(views::View* view); 90 void RemoveDownloadView(views::View* view);
92 91
93 // Updates |button| according to the active theme. 92 // Updates |button| according to the active theme.
94 void ConfigureButtonForTheme(views::MdTextButton* button); 93 void ConfigureButtonForTheme(views::MdTextButton* button);
95 94
96 protected: 95 protected:
97 // Implementation of DownloadShelf. 96 // DownloadShelf:
98 void DoAddDownload(content::DownloadItem* download) override; 97 void DoAddDownload(content::DownloadItem* download) override;
99 void DoOpen() override; 98 void DoOpen() override;
100 void DoClose(CloseReason reason) override; 99 void DoClose(CloseReason reason) override;
101 void DoHide() override; 100 void DoHide() override;
102 void DoUnhide() override; 101 void DoUnhide() override;
103 102
104 // From AccessiblePaneView 103 // views::AccessiblePaneView:
105 views::View* GetDefaultFocusableChild() override; 104 views::View* GetDefaultFocusableChild() override;
106 105
107 private: 106 private:
108 // Adds a View representing a download to this DownloadShelfView. 107 // Adds a View representing a download to this DownloadShelfView.
109 // DownloadShelfView takes ownership of the View, and will delete it as 108 // DownloadShelfView takes ownership of the View, and will delete it as
110 // necessary. 109 // necessary.
111 void AddDownloadView(DownloadItemView* view); 110 void AddDownloadView(DownloadItemView* view);
112 111
113 // Paints the border. 112 // Paints the border.
114 void OnPaintBorder(gfx::Canvas* canvas) override; 113 void OnPaintBorder(gfx::Canvas* canvas) override;
115 114
116 // Returns true if the shelf is wide enough to show the first download item. 115 // Returns true if the shelf is wide enough to show the first download item.
117 bool CanFitFirstDownloadItem(); 116 bool CanFitFirstDownloadItem();
118 117
119 // Called on theme change. 118 // Called on theme change.
120 void UpdateColorsFromTheme(); 119 void UpdateColorsFromTheme();
121 120
122 // Overridden from views::View. 121 // views::View:
123 void OnThemeChanged() override; 122 void OnThemeChanged() override;
124 123
124 void UpdateCloseButton();
125
125 // Called when the "close shelf" animation ended. 126 // Called when the "close shelf" animation ended.
126 void Closed(); 127 void Closed();
127 128
128 // Returns true if we can auto close. We can auto-close if all the items on 129 // Returns true if we can auto close. We can auto-close if all the items on
129 // the shelf have been opened. 130 // the shelf have been opened.
130 bool CanAutoClose(); 131 bool CanAutoClose();
131 132
132 // Returns the color of text for the shelf (used for deriving icon color). 133 // Returns the color of text for the shelf (used for deriving icon color).
133 SkColor GetTextColorForIconMd(); 134 SkColor GetTextColorForIconMd();
134 135
(...skipping 19 matching lines...) Expand all
154 155
155 // The window this shelf belongs to. 156 // The window this shelf belongs to.
156 BrowserView* parent_; 157 BrowserView* parent_;
157 158
158 views::MouseWatcher mouse_watcher_; 159 views::MouseWatcher mouse_watcher_;
159 160
160 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); 161 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView);
161 }; 162 };
162 163
163 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ 164 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698