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 <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/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void SearchResultView::ChildPreferredSizeChanged(views::View* child) { | 239 void SearchResultView::ChildPreferredSizeChanged(views::View* child) { |
240 Layout(); | 240 Layout(); |
241 } | 241 } |
242 | 242 |
243 void SearchResultView::OnPaint(gfx::Canvas* canvas) { | 243 void SearchResultView::OnPaint(gfx::Canvas* canvas) { |
244 gfx::Rect rect(GetContentsBounds()); | 244 gfx::Rect rect(GetContentsBounds()); |
245 if (rect.IsEmpty()) | 245 if (rect.IsEmpty()) |
246 return; | 246 return; |
247 | 247 |
248 gfx::Rect content_rect(rect); | 248 gfx::Rect content_rect(rect); |
249 if (!switches::IsExperimentalAppListEnabled()) | |
250 content_rect.set_height(rect.height() - kBorderSize); | |
251 | |
252 const bool selected = list_view_->IsResultViewSelected(this); | 249 const bool selected = list_view_->IsResultViewSelected(this); |
253 const bool hover = state() == STATE_HOVERED || state() == STATE_PRESSED; | 250 const bool hover = state() == STATE_HOVERED || state() == STATE_PRESSED; |
254 | 251 |
255 canvas->FillRect(content_rect, switches::IsExperimentalAppListEnabled() | 252 canvas->FillRect(content_rect, kCardBackgroundColor); |
256 ? kCardBackgroundColor | |
257 : kContentsBackgroundColor); | |
258 | 253 |
259 // Possibly call FillRect a second time (these colours are partially | 254 // Possibly call FillRect a second time (these colours are partially |
260 // transparent, so the previous FillRect is not redundant). | 255 // transparent, so the previous FillRect is not redundant). |
261 if (selected) | 256 if (selected) |
262 canvas->FillRect(content_rect, kSelectedColor); | 257 canvas->FillRect(content_rect, kSelectedColor); |
263 else if (hover) | 258 else if (hover) |
264 canvas->FillRect(content_rect, kHighlightedColor); | 259 canvas->FillRect(content_rect, kHighlightedColor); |
265 | 260 |
266 if (switches::IsExperimentalAppListEnabled() && !is_last_result_) { | 261 if (!is_last_result_) { |
267 gfx::Rect line_rect = content_rect; | 262 gfx::Rect line_rect = content_rect; |
268 line_rect.set_height(kBorderSize); | 263 line_rect.set_height(kBorderSize); |
269 line_rect.set_y(content_rect.bottom() - kBorderSize); | 264 line_rect.set_y(content_rect.bottom() - kBorderSize); |
270 line_rect.set_x(kSeparatorPadding); | 265 line_rect.set_x(kSeparatorPadding); |
271 canvas->FillRect(line_rect, kSeparatorColor); | 266 canvas->FillRect(line_rect, kSeparatorColor); |
272 } | 267 } |
273 | 268 |
274 gfx::Rect border_bottom = gfx::SubtractRects(rect, content_rect); | 269 gfx::Rect border_bottom = gfx::SubtractRects(rect, content_rect); |
275 canvas->FillRect(border_bottom, kResultBorderColor); | 270 canvas->FillRect(border_bottom, kResultBorderColor); |
276 | 271 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 return; | 407 return; |
413 | 408 |
414 context_menu_runner_.reset(new views::MenuRunner( | 409 context_menu_runner_.reset(new views::MenuRunner( |
415 menu_model, views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::ASYNC)); | 410 menu_model, views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::ASYNC)); |
416 context_menu_runner_->RunMenuAt(GetWidget(), NULL, | 411 context_menu_runner_->RunMenuAt(GetWidget(), NULL, |
417 gfx::Rect(point, gfx::Size()), | 412 gfx::Rect(point, gfx::Size()), |
418 views::MENU_ANCHOR_TOPLEFT, source_type); | 413 views::MENU_ANCHOR_TOPLEFT, source_type); |
419 } | 414 } |
420 | 415 |
421 } // namespace app_list | 416 } // namespace app_list |
OLD | NEW |