| 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/search_result_view.h" | 5 #include "ui/app_list/search_result_view.h" |
| 6 | 6 |
| 7 #include "ui/app_list/app_list_constants.h" |
| 7 #include "ui/app_list/search_result.h" | 8 #include "ui/app_list/search_result.h" |
| 8 #include "ui/app_list/search_result_list_view.h" | 9 #include "ui/app_list/search_result_list_view.h" |
| 9 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 10 #include "ui/gfx/font.h" | 11 #include "ui/gfx/font.h" |
| 11 #include "ui/gfx/image/image_skia_operations.h" | 12 #include "ui/gfx/image/image_skia_operations.h" |
| 12 #include "ui/gfx/render_text.h" | 13 #include "ui/gfx/render_text.h" |
| 13 #include "ui/views/controls/button/image_button.h" | 14 #include "ui/views/controls/button/image_button.h" |
| 14 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 | 32 |
| 32 // Extra margin at the right of the rightmost action icon. | 33 // Extra margin at the right of the rightmost action icon. |
| 33 const int kActionButtonRightMargin = 8; | 34 const int kActionButtonRightMargin = 8; |
| 34 | 35 |
| 35 const SkColor kBorderColor = SkColorSetARGB(0x0F, 0, 0, 0); | 36 const SkColor kBorderColor = SkColorSetARGB(0x0F, 0, 0, 0); |
| 36 | 37 |
| 37 const SkColor kDefaultTextColor = SkColorSetRGB(0x33, 0x33, 0x33); | 38 const SkColor kDefaultTextColor = SkColorSetRGB(0x33, 0x33, 0x33); |
| 38 const SkColor kDimmedTextColor = SkColorSetRGB(0x96, 0x96, 0x96); | 39 const SkColor kDimmedTextColor = SkColorSetRGB(0x96, 0x96, 0x96); |
| 39 const SkColor kURLTextColor = SkColorSetRGB(0x00, 0x99, 0x33); | 40 const SkColor kURLTextColor = SkColorSetRGB(0x00, 0x99, 0x33); |
| 40 | 41 |
| 41 const SkColor kBackgroundColor = SkColorSetRGB(0xF5, 0xF5, 0xF5); | |
| 42 const SkColor kSelectedBorderColor = kBorderColor; | 42 const SkColor kSelectedBorderColor = kBorderColor; |
| 43 const SkColor kSelectedBackgroundColor = SkColorSetARGB(0x0F, 0x4D, 0x90, 0xFE); | 43 const SkColor kSelectedBackgroundColor = SkColorSetARGB(0x0F, 0x4D, 0x90, 0xFE); |
| 44 const SkColor kHoverAndPushedColor = SkColorSetARGB(0x05, 0, 0, 0); | 44 const SkColor kHoverAndPushedColor = SkColorSetARGB(0x05, 0, 0, 0); |
| 45 | 45 |
| 46 // A non-interactive image view to display result icon. | 46 // A non-interactive image view to display result icon. |
| 47 class IconView : public views::ImageView { | 47 class IconView : public views::ImageView { |
| 48 public: | 48 public: |
| 49 IconView() : ImageView() {} | 49 IconView() : ImageView() {} |
| 50 virtual ~IconView() {} | 50 virtual ~IconView() {} |
| 51 | 51 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 } | 183 } |
| 184 | 184 |
| 185 void SearchResultView::OnPaint(gfx::Canvas* canvas) { | 185 void SearchResultView::OnPaint(gfx::Canvas* canvas) { |
| 186 gfx::Rect rect(GetContentsBounds()); | 186 gfx::Rect rect(GetContentsBounds()); |
| 187 if (rect.IsEmpty()) | 187 if (rect.IsEmpty()) |
| 188 return; | 188 return; |
| 189 | 189 |
| 190 gfx::Rect content_rect(rect); | 190 gfx::Rect content_rect(rect); |
| 191 content_rect.set_height(rect.height() - kBorderSize); | 191 content_rect.set_height(rect.height() - kBorderSize); |
| 192 | 192 |
| 193 canvas->FillRect(content_rect, kBackgroundColor); | 193 canvas->FillRect(content_rect, kContentsBackgroundColor); |
| 194 | 194 |
| 195 bool selected = list_view_->IsResultViewSelected(this); | 195 bool selected = list_view_->IsResultViewSelected(this); |
| 196 if (selected) { | 196 if (selected) { |
| 197 canvas->FillRect(content_rect, kSelectedBackgroundColor); | 197 canvas->FillRect(content_rect, kSelectedBackgroundColor); |
| 198 } else if (state() == BS_HOT || state() == BS_PUSHED) { | 198 } else if (state() == BS_HOT || state() == BS_PUSHED) { |
| 199 canvas->FillRect(content_rect, kHoverAndPushedColor); | 199 canvas->FillRect(content_rect, kHoverAndPushedColor); |
| 200 } | 200 } |
| 201 | 201 |
| 202 gfx::Rect border_bottom = rect.Subtract(content_rect); | 202 gfx::Rect border_bottom = rect.Subtract(content_rect); |
| 203 canvas->FillRect(border_bottom, | 203 canvas->FillRect(border_bottom, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 views::ImageButton* button = action_buttons_[i]; | 295 views::ImageButton* button = action_buttons_[i]; |
| 296 button->SetImage(views::CustomButton::BS_NORMAL, &icon.base_image); | 296 button->SetImage(views::CustomButton::BS_NORMAL, &icon.base_image); |
| 297 button->SetImage(views::CustomButton::BS_HOT, &icon.hover_image); | 297 button->SetImage(views::CustomButton::BS_HOT, &icon.hover_image); |
| 298 button->SetImage(views::CustomButton::BS_PUSHED, &icon.pressed_image); | 298 button->SetImage(views::CustomButton::BS_PUSHED, &icon.pressed_image); |
| 299 button->SetTooltipText(icon.tooltip_text); | 299 button->SetTooltipText(icon.tooltip_text); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace app_list | 304 } // namespace app_list |
| OLD | NEW |