| 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 "ui/app_list/app_list_constants.h" | 9 #include "ui/app_list/app_list_constants.h" |
| 10 #include "ui/app_list/app_list_switches.h" |
| 10 #include "ui/app_list/search_result.h" | 11 #include "ui/app_list/search_result.h" |
| 11 #include "ui/app_list/views/progress_bar_view.h" | 12 #include "ui/app_list/views/progress_bar_view.h" |
| 12 #include "ui/app_list/views/search_result_actions_view.h" | 13 #include "ui/app_list/views/search_result_actions_view.h" |
| 13 #include "ui/app_list/views/search_result_list_view.h" | 14 #include "ui/app_list/views/search_result_list_view.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
| 16 #include "ui/gfx/image/image_skia_operations.h" | 17 #include "ui/gfx/image/image_skia_operations.h" |
| 17 #include "ui/gfx/render_text.h" | 18 #include "ui/gfx/render_text.h" |
| 18 #include "ui/views/controls/button/image_button.h" | 19 #include "ui/views/controls/button/image_button.h" |
| 19 #include "ui/views/controls/image_view.h" | 20 #include "ui/views/controls/image_view.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 void SearchResultView::ChildPreferredSizeChanged(views::View* child) { | 203 void SearchResultView::ChildPreferredSizeChanged(views::View* child) { |
| 203 Layout(); | 204 Layout(); |
| 204 } | 205 } |
| 205 | 206 |
| 206 void SearchResultView::OnPaint(gfx::Canvas* canvas) { | 207 void SearchResultView::OnPaint(gfx::Canvas* canvas) { |
| 207 gfx::Rect rect(GetContentsBounds()); | 208 gfx::Rect rect(GetContentsBounds()); |
| 208 if (rect.IsEmpty()) | 209 if (rect.IsEmpty()) |
| 209 return; | 210 return; |
| 210 | 211 |
| 211 gfx::Rect content_rect(rect); | 212 gfx::Rect content_rect(rect); |
| 212 content_rect.set_height(rect.height() - kBorderSize); | 213 if (!switches::IsExperimentalAppListEnabled()) |
| 214 content_rect.set_height(rect.height() - kBorderSize); |
| 213 | 215 |
| 214 const bool selected = list_view_->IsResultViewSelected(this); | 216 const bool selected = list_view_->IsResultViewSelected(this); |
| 215 const bool hover = state() == STATE_HOVERED || state() == STATE_PRESSED; | 217 const bool hover = state() == STATE_HOVERED || state() == STATE_PRESSED; |
| 216 if (selected) | 218 if (selected) |
| 217 canvas->FillRect(content_rect, kSelectedColor); | 219 canvas->FillRect(content_rect, kSelectedColor); |
| 218 else if (hover) | 220 else if (hover) |
| 219 canvas->FillRect(content_rect, kHighlightedColor); | 221 canvas->FillRect(content_rect, kHighlightedColor); |
| 220 else | 222 else if (!switches::IsExperimentalAppListEnabled()) |
| 221 canvas->FillRect(content_rect, kContentsBackgroundColor); | 223 canvas->FillRect(content_rect, kContentsBackgroundColor); |
| 222 | 224 |
| 223 gfx::Rect border_bottom = gfx::SubtractRects(rect, content_rect); | 225 gfx::Rect border_bottom = gfx::SubtractRects(rect, content_rect); |
| 224 canvas->FillRect(border_bottom, kResultBorderColor); | 226 canvas->FillRect(border_bottom, kResultBorderColor); |
| 225 | 227 |
| 226 gfx::Rect text_bounds(rect); | 228 gfx::Rect text_bounds(rect); |
| 227 text_bounds.set_x(GetIconViewWidth()); | 229 text_bounds.set_x(GetIconViewWidth()); |
| 228 if (actions_view_->visible()) { | 230 if (actions_view_->visible()) { |
| 229 text_bounds.set_width( | 231 text_bounds.set_width( |
| 230 rect.width() - GetIconViewWidth() - kTextTrailPadding - | 232 rect.width() - GetIconViewWidth() - kTextTrailPadding - |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 if (context_menu_runner_->RunMenuAt(GetWidget(), | 351 if (context_menu_runner_->RunMenuAt(GetWidget(), |
| 350 NULL, | 352 NULL, |
| 351 gfx::Rect(point, gfx::Size()), | 353 gfx::Rect(point, gfx::Size()), |
| 352 views::MENU_ANCHOR_TOPLEFT, | 354 views::MENU_ANCHOR_TOPLEFT, |
| 353 source_type) == | 355 source_type) == |
| 354 views::MenuRunner::MENU_DELETED) | 356 views::MenuRunner::MENU_DELETED) |
| 355 return; | 357 return; |
| 356 } | 358 } |
| 357 | 359 |
| 358 } // namespace app_list | 360 } // namespace app_list |
| OLD | NEW |