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

Side by Side Diff: chrome/browser/download/download_shelf.h

Issue 1236463002: Vectorize download shelf progress indicators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 5 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
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/download/download_shelf.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_DOWNLOAD_DOWNLOAD_SHELF_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_
7 7
8 #include "base/callback_forward.h"
9 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 9 #include "base/time/time.h"
11 #include "build/build_config.h" 10 #include "build/build_config.h"
12 11
13 class Browser; 12 class Browser;
14 13
14 namespace base {
15 class TimeTicks;
16 }
17
15 namespace gfx { 18 namespace gfx {
16 class Canvas; 19 class Canvas;
17 class ImageSkia; 20 class ImageSkia;
18 class Rect; 21 class Rect;
19 } 22 }
20 23
21 namespace content { 24 namespace content {
22 class DownloadItem; 25 class DownloadItem;
23 class DownloadManager; 26 class DownloadManager;
24 } 27 }
(...skipping 11 matching lines...) Expand all
36 39
37 // Closing shelf due to a user selection. E.g.: the user clicked on the 40 // Closing shelf due to a user selection. E.g.: the user clicked on the
38 // 'close' button on the download shelf, or the shelf is being closed as a 41 // 'close' button on the download shelf, or the shelf is being closed as a
39 // side-effect of the user opening the downloads page. 42 // side-effect of the user opening the downloads page.
40 USER_ACTION 43 USER_ACTION
41 }; 44 };
42 45
43 // Download progress animations ---------------------------------------------- 46 // Download progress animations ----------------------------------------------
44 47
45 enum { 48 enum {
46 // Arc sweep angle for use with downloads of unknown size.
47 kUnknownAngleDegrees = 50,
48
49 // Rate of progress for use with downloads of unknown size.
50 kUnknownIncrementDegrees = 12,
51
52 // Start angle for downloads with known size (midnight position).
53 kStartAngleDegrees = -90,
54
55 // A the maximum number of degrees of a circle.
56 kMaxDegrees = 360,
57
58 // Progress animation timer period, in milliseconds. 49 // Progress animation timer period, in milliseconds.
59 kProgressRateMs = 150, 50 kProgressRateMs = 30,
60 51
61 // Size of the filetype icon. 52 // Size of the filetype icon.
62 kSmallIconSize = 16, 53 kSmallIconSize = 16,
63 54
64 // Size of the progress asset that's painted behind the filetype icon. 55 // Size of the progress asset that's painted behind the filetype icon.
65 kSmallProgressIconSize = 39, 56 kSmallProgressIconSize = 39,
66 57
67 kSmallProgressIconOffset = (kSmallProgressIconSize - kSmallIconSize) / 2 58 kSmallProgressIconOffset = (kSmallProgressIconSize - kSmallIconSize) / 2
68 }; 59 };
69 60
70 // Type of the callback used on toolkit-views platforms for the |rtl_mirror|
71 // argument of the PaintDownload functions. It captures the View subclass
72 // within which the progress animation is drawn and is used to update the
73 // correct 'left' value for the given rectangle in RTL locales. This is used
74 // to mirror the position of the progress animation. The callback is
75 // guaranteed to be invoked before the paint function returns.
76 typedef base::Callback<void(gfx::Rect*)> BoundsAdjusterCallback;
77
78 DownloadShelf(); 61 DownloadShelf();
79 virtual ~DownloadShelf(); 62 virtual ~DownloadShelf();
80 63
81 // Paint the common download animation progress foreground and background, 64 // Paint the common download animation progress foreground and background,
82 // clipping the foreground to 'percent' full. If percent is -1, then we don't 65 // clipping the foreground to 'percent' full. If percent is -1, then we don't
83 // know the total size, so we just draw a rotating segment until we're done. 66 // know the total size, so we just draw a rotating segment until we're done.
asanka 2015/07/16 00:45:08 Nit: Mention that |progress_start_time| is only ne
Evan Stade 2015/07/16 02:16:44 Done.
84 static void PaintCustomDownloadProgress(
85 gfx::Canvas* canvas,
86 const gfx::ImageSkia& background_image,
87 const gfx::ImageSkia& foreground_image,
88 int image_size,
89 const gfx::Rect& bounds,
90 int start_angle,
91 int percent_done);
92
93 static void PaintDownloadProgress(gfx::Canvas* canvas, 67 static void PaintDownloadProgress(gfx::Canvas* canvas,
94 const BoundsAdjusterCallback& rtl_mirror, 68 const base::TimeTicks& progress_start_time,
95 int origin_x,
96 int origin_y,
97 int start_angle,
98 int percent); 69 int percent);
99 70
100 static void PaintDownloadComplete(gfx::Canvas* canvas, 71 static void PaintDownloadComplete(gfx::Canvas* canvas,
101 const BoundsAdjusterCallback& rtl_mirror,
102 int origin_x,
103 int origin_y,
104 double animation_progress); 72 double animation_progress);
105 73
106 static void PaintDownloadInterrupted(gfx::Canvas* canvas, 74 static void PaintDownloadInterrupted(gfx::Canvas* canvas,
107 const BoundsAdjusterCallback& rtl_mirror,
108 int origin_x,
109 int origin_y,
110 double animation_progress); 75 double animation_progress);
111 76
112 // A new download has started. Add it to our shelf and show the download 77 // A new download has started. Add it to our shelf and show the download
113 // started animation. 78 // started animation.
114 // 79 //
115 // Some downloads are removed from the shelf on completion (See 80 // Some downloads are removed from the shelf on completion (See
116 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient 81 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient
117 // downloads are added to the shelf after a delay. If the download completes 82 // downloads are added to the shelf after a delay. If the download completes
118 // before the delay duration, it will not be added to the shelf at all. 83 // before the delay duration, it will not be added to the shelf at all.
119 void AddDownload(content::DownloadItem* download); 84 void AddDownload(content::DownloadItem* download);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // download should belong to the DownloadManager returned by 133 // download should belong to the DownloadManager returned by
169 // GetDownloadManager(). 134 // GetDownloadManager().
170 void ShowDownloadById(int32 download_id); 135 void ShowDownloadById(int32 download_id);
171 136
172 bool should_show_on_unhide_; 137 bool should_show_on_unhide_;
173 bool is_hidden_; 138 bool is_hidden_;
174 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; 139 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_;
175 }; 140 };
176 141
177 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ 142 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | chrome/browser/download/download_shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698