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

Side by Side Diff: ui/app_list/views/progress_bar_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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
« no previous file with comments | « ui/app_list/views/progress_bar_view.h ('k') | ui/app_list/views/search_box_view.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "ui/app_list/views/progress_bar_view.h" 5 #include "ui/app_list/views/progress_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 16 matching lines...) Expand all
27 27
28 ProgressBarView::ProgressBarView() 28 ProgressBarView::ProgressBarView()
29 : background_painter_(views::Painter::CreateImagePainter( 29 : background_painter_(views::Painter::CreateImagePainter(
30 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 30 *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
31 IDR_APP_LIST_ITEM_PROGRESS_BACKGROUND), 31 IDR_APP_LIST_ITEM_PROGRESS_BACKGROUND),
32 gfx::Insets(2, 2, 2, 2))), 32 gfx::Insets(2, 2, 2, 2))),
33 bar_painter_(new views::HorizontalPainter(kProgressBarImages)) {} 33 bar_painter_(new views::HorizontalPainter(kProgressBarImages)) {}
34 34
35 ProgressBarView::~ProgressBarView() {} 35 ProgressBarView::~ProgressBarView() {}
36 36
37 gfx::Size ProgressBarView::GetPreferredSize() { 37 gfx::Size ProgressBarView::GetPreferredSize() const {
38 return background_painter_->GetMinimumSize(); 38 return background_painter_->GetMinimumSize();
39 } 39 }
40 40
41 void ProgressBarView::OnPaint(gfx::Canvas* canvas) { 41 void ProgressBarView::OnPaint(gfx::Canvas* canvas) {
42 gfx::Size paint_size = size(); 42 gfx::Size paint_size = size();
43 43
44 const gfx::Size min_size(background_painter_->GetMinimumSize()); 44 const gfx::Size min_size(background_painter_->GetMinimumSize());
45 if (paint_size.width() < min_size.width() || 45 if (paint_size.width() < min_size.width() ||
46 paint_size.height() < min_size.height()) { 46 paint_size.height() < min_size.height()) {
47 return; 47 return;
48 } 48 }
49 49
50 background_painter_->Paint(canvas, paint_size); 50 background_painter_->Paint(canvas, paint_size);
51 51
52 const int kBarEndWidth = 4; 52 const int kBarEndWidth = 4;
53 const int bar_width = paint_size.width() - kBarEndWidth; 53 const int bar_width = paint_size.width() - kBarEndWidth;
54 DCHECK_GE(bar_width, 0); 54 DCHECK_GE(bar_width, 0);
55 55
56 // Map normalized value in [0,1] to the pixel width in 56 // Map normalized value in [0,1] to the pixel width in
57 // [kBarEndWidth, view_size.width()]. 57 // [kBarEndWidth, view_size.width()].
58 paint_size.set_width(kBarEndWidth + bar_width * GetNormalizedValue()); 58 paint_size.set_width(kBarEndWidth + bar_width * GetNormalizedValue());
59 bar_painter_->Paint(canvas, paint_size); 59 bar_painter_->Paint(canvas, paint_size);
60 } 60 }
61 61
62 } // namespace app_list 62 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/progress_bar_view.h ('k') | ui/app_list/views/search_box_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698