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

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

Issue 574983002: Remove unnecessary font list creation in AppListItemView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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 #include "ui/app_list/views/app_list_item_view.h" 5 #include "ui/app_list/views/app_list_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/accessibility/ax_view_state.h" 10 #include "ui/accessibility/ax_view_state.h"
(...skipping 23 matching lines...) Expand all
34 #include "ui/views/drag_controller.h" 34 #include "ui/views/drag_controller.h"
35 35
36 namespace app_list { 36 namespace app_list {
37 37
38 namespace { 38 namespace {
39 39
40 const int kTopPadding = 20; 40 const int kTopPadding = 20;
41 const int kIconTitleSpacing = 7; 41 const int kIconTitleSpacing = 7;
42 const int kProgressBarHorizontalPadding = 12; 42 const int kProgressBarHorizontalPadding = 12;
43 43
44 // The font is different on each platform. The font size is adjusted on some
45 // platforms to keep a consistent look.
46 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
47 // Reducing the font size by 2 makes it the same as the Windows font size.
48 const int kFontSizeDelta = -2;
49 #else
50 const int kFontSizeDelta = 0;
51 #endif
52
53 // Radius of the folder dropping preview circle. 44 // Radius of the folder dropping preview circle.
54 const int kFolderPreviewRadius = 40; 45 const int kFolderPreviewRadius = 40;
55 46
56 const int kLeftRightPaddingChars = 1; 47 const int kLeftRightPaddingChars = 1;
57 48
58 // Scale to transform the icon when a drag starts. 49 // Scale to transform the icon when a drag starts.
59 const float kDraggingIconScale = 1.5f; 50 const float kDraggingIconScale = 1.5f;
60 51
61 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. 52 // Delay in milliseconds of when the dragging UI should be shown for mouse drag.
62 const int kMouseDragUIDelayInMs = 200; 53 const int kMouseDragUIDelayInMs = 200;
(...skipping 25 matching lines...) Expand all
88 ui_state_(UI_STATE_NORMAL), 79 ui_state_(UI_STATE_NORMAL),
89 touch_dragging_(false), 80 touch_dragging_(false),
90 is_installing_(false), 81 is_installing_(false),
91 is_highlighted_(false) { 82 is_highlighted_(false) {
92 icon_->set_interactive(false); 83 icon_->set_interactive(false);
93 84
94 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 85 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
95 title_->SetBackgroundColor(0); 86 title_->SetBackgroundColor(0);
96 title_->SetAutoColorReadabilityEnabled(false); 87 title_->SetAutoColorReadabilityEnabled(false);
97 title_->SetEnabledColor(kGridTitleColor); 88 title_->SetEnabledColor(kGridTitleColor);
98 title_->SetFontList( 89
99 rb.GetFontList(kItemTextFontStyle).DeriveWithSizeDelta(kFontSizeDelta)); 90 const gfx::FontList& font_list = rb.GetFontList(kItemTextFontStyle);
91 // The font is different on each platform. The font size is adjusted on some
92 // platforms to keep a consistent look.
93 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
94 // Reducing the font size by 2 makes it the same as the Windows font size.
95 const int kFontSizeDelta = -2;
96 font_list = font_list.DeriveWithSizeDelta(kFontSizeDelta);
tapted 2014/09/18 01:56:45 assigning to a const reference? pretty sure that s
97 #endif
98 title_->SetFontList(font_list);
tapted 2014/09/18 01:56:45 nit: I think I liked the #ifdefs being just around
100 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 99 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
101 title_->Invalidate(); 100 title_->Invalidate();
102 SetTitleSubpixelAA(); 101 SetTitleSubpixelAA();
103 102
104 AddChildView(icon_); 103 AddChildView(icon_);
105 AddChildView(title_); 104 AddChildView(title_);
106 AddChildView(progress_bar_); 105 AddChildView(progress_bar_);
107 106
108 SetIcon(item->icon(), item->has_shadow()); 107 SetIcon(item->icon(), item->has_shadow());
109 SetItemName(base::UTF8ToUTF16(item->GetDisplayName()), 108 SetItemName(base::UTF8ToUTF16(item->GetDisplayName()),
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 SetItemPercentDownloaded(item_weak_->percent_downloaded()); 549 SetItemPercentDownloaded(item_weak_->percent_downloaded());
551 } 550 }
552 551
553 void AppListItemView::ItemBeingDestroyed() { 552 void AppListItemView::ItemBeingDestroyed() {
554 DCHECK(item_weak_); 553 DCHECK(item_weak_);
555 item_weak_->RemoveObserver(this); 554 item_weak_->RemoveObserver(this);
556 item_weak_ = NULL; 555 item_weak_ = NULL;
557 } 556 }
558 557
559 } // namespace app_list 558 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698