OLD | NEW |
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 Loading... |
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) | |
86 style.foreground = kURLTextColor; | |
87 if (it->styles & app_list::SearchResult::Tag::DIM) | 78 if (it->styles & app_list::SearchResult::Tag::DIM) |
88 style.foreground = kDimmedTextColor; | 79 render_text->ApplyColor(kDimmedTextColor, it->range); |
89 | 80 else if (it->styles & app_list::SearchResult::Tag::URL) |
90 render_text->ApplyStyleRange(style); | 81 render_text->ApplyColor(kURLTextColor, it->range); |
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 Loading... |
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 |
OLD | NEW |