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

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

Issue 11535014: Replace StyleRange with BreakList; update RenderText, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify OmniboxResultView; Rename StyleBreak; cleanup. Created 7 years, 11 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
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/search_result_view.h" 5 #include "ui/app_list/views/search_result_view.h"
6 6
7 #include "ui/app_list/app_list_constants.h" 7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/app_list/search_result.h" 8 #include "ui/app_list/search_result.h"
9 #include "ui/app_list/views/search_result_list_view.h" 9 #include "ui/app_list/views/search_result_list_view.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 DISALLOW_COPY_AND_ASSIGN(IconView); 58 DISALLOW_COPY_AND_ASSIGN(IconView);
59 }; 59 };
60 60
61 // Creates a RenderText of given |text| and |styles|. Caller takes ownership 61 // Creates a RenderText of given |text| and |styles|. Caller takes ownership
62 // of returned RenderText. 62 // of returned RenderText.
63 gfx::RenderText* CreateRenderText(const string16& text, 63 gfx::RenderText* CreateRenderText(const string16& text,
64 const app_list::SearchResult::Tags& tags) { 64 const app_list::SearchResult::Tags& tags) {
65 gfx::RenderText* render_text = gfx::RenderText::CreateInstance(); 65 gfx::RenderText* render_text = gfx::RenderText::CreateInstance();
66 render_text->SetText(text); 66 render_text->SetText(text);
67 67 render_text->SetColor(kDefaultTextColor);
68 gfx::StyleRange default_style;
69 default_style.foreground = kDefaultTextColor;
70 render_text->set_default_style(default_style);
71 render_text->ApplyDefaultStyle();
72 68
73 for (app_list::SearchResult::Tags::const_iterator it = tags.begin(); 69 for (app_list::SearchResult::Tags::const_iterator it = tags.begin();
74 it != tags.end(); 70 it != tags.end();
75 ++it) { 71 ++it) {
76 // NONE means default style so do nothing. 72 // NONE means default style so do nothing.
77 if (it->styles == app_list::SearchResult::Tag::NONE) 73 if (it->styles == app_list::SearchResult::Tag::NONE)
78 continue; 74 continue;
79 75
80 gfx::StyleRange style;
81 style.range = it->range;
82
83 if (it->styles & app_list::SearchResult::Tag::MATCH) 76 if (it->styles & app_list::SearchResult::Tag::MATCH)
84 style.font_style = gfx::Font::BOLD; 77 render_text->ApplyStyle(gfx::BOLD, true, it->range);
85 if (it->styles & app_list::SearchResult::Tag::URL) 78 if (it->styles & app_list::SearchResult::Tag::URL)
86 style.foreground = kURLTextColor; 79 render_text->ApplyColor(kURLTextColor, it->range);
87 if (it->styles & app_list::SearchResult::Tag::DIM) 80 if (it->styles & app_list::SearchResult::Tag::DIM)
Alexei Svitkine (slow) 2013/01/22 19:20:21 Can you make the last two if statements an "if els
msw 2013/01/22 22:27:24 Done.
88 style.foreground = kDimmedTextColor; 81 render_text->ApplyColor(kDimmedTextColor, it->range);
89
90 render_text->ApplyStyleRange(style);
91 } 82 }
92 83
93 return render_text; 84 return render_text;
94 } 85 }
95 86
96 } // namespace 87 } // namespace
97 88
98 namespace app_list { 89 namespace app_list {
99 90
100 // static 91 // static
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 views::ImageButton* button = action_buttons_[i]; 291 views::ImageButton* button = action_buttons_[i];
301 button->SetImage(views::CustomButton::STATE_NORMAL, &icon.base_image); 292 button->SetImage(views::CustomButton::STATE_NORMAL, &icon.base_image);
302 button->SetImage(views::CustomButton::STATE_HOVERED, &icon.hover_image); 293 button->SetImage(views::CustomButton::STATE_HOVERED, &icon.hover_image);
303 button->SetImage(views::CustomButton::STATE_PRESSED, &icon.pressed_image); 294 button->SetImage(views::CustomButton::STATE_PRESSED, &icon.pressed_image);
304 button->SetTooltipText(icon.tooltip_text); 295 button->SetTooltipText(icon.tooltip_text);
305 } 296 }
306 } 297 }
307 } 298 }
308 299
309 } // namespace app_list 300 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698