| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/android/compositor/layer/contextual_search_layer.h" | 5 #include "chrome/browser/android/compositor/layer/contextual_search_layer.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/layers/nine_patch_layer.h" | 8 #include "cc/layers/nine_patch_layer.h" |
| 9 #include "cc/layers/solid_color_layer.h" | 9 #include "cc/layers/solid_color_layer.h" |
| 10 #include "cc/layers/ui_resource_layer.h" | 10 #include "cc/layers/ui_resource_layer.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 const SkColor kSearchBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee); | 23 const SkColor kSearchBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee); |
| 24 const SkColor kSearchBarBackgroundColor = SkColorSetRGB(0xff, 0xff, 0xff); | 24 const SkColor kSearchBarBackgroundColor = SkColorSetRGB(0xff, 0xff, 0xff); |
| 25 const SkColor kSearchBarBorderColor = SkColorSetRGB(0xf1, 0xf1, 0xf1); | 25 const SkColor kSearchBarBorderColor = SkColorSetRGB(0xf1, 0xf1, 0xf1); |
| 26 const SkColor kPeekPromoRippleBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xF4); | 26 const SkColor kPeekPromoRippleBackgroundColor = SkColorSetRGB(0x42, 0x85, 0xF4); |
| 27 | 27 |
| 28 // The alpha blend used in the Peek Promo Background in order to achieve | 28 // The alpha blend used in the Peek Promo Background in order to achieve |
| 29 // a lighter shade of the color of the Peek Promo Ripple. | 29 // a lighter shade of the color of the Peek Promo Ripple. |
| 30 const SkAlpha kPeekPromoBackgroundMaximumAlphaBlend = 0.25f * 255; | 30 const SkAlpha kPeekPromoBackgroundMaximumAlphaBlend = 0.25f * 255; |
| 31 | 31 |
| 32 // This is the default width for any icon displayed on an OverlayPanel. |
| 33 const float kDefaultIconWidthDp = 36.0f; |
| 34 |
| 32 } // namespace | 35 } // namespace |
| 33 | 36 |
| 34 namespace chrome { | 37 namespace chrome { |
| 35 namespace android { | 38 namespace android { |
| 36 | 39 |
| 37 // static | 40 // static |
| 38 scoped_refptr<ContextualSearchLayer> ContextualSearchLayer::Create( | 41 scoped_refptr<ContextualSearchLayer> ContextualSearchLayer::Create( |
| 39 ui::ResourceManager* resource_manager) { | 42 ui::ResourceManager* resource_manager) { |
| 40 return make_scoped_refptr(new ContextualSearchLayer(resource_manager)); | 43 return make_scoped_refptr(new ContextualSearchLayer(resource_manager)); |
| 41 } | 44 } |
| 42 | 45 |
| 43 void ContextualSearchLayer::SetProperties( | 46 void ContextualSearchLayer::SetProperties( |
| 44 int panel_shadow_resource_id, | 47 int panel_shadow_resource_id, |
| 45 int search_context_resource_id, | 48 int search_context_resource_id, |
| 46 int search_term_resource_id, | 49 int search_term_resource_id, |
| 47 int search_bar_shadow_resource_id, | 50 int search_bar_shadow_resource_id, |
| 48 int panel_icon_resource_id, | 51 int panel_icon_resource_id, |
| 49 int arrow_up_resource_id, | 52 int arrow_up_resource_id, |
| 50 int close_icon_resource_id, | 53 int close_icon_resource_id, |
| 51 int progress_bar_background_resource_id, | 54 int progress_bar_background_resource_id, |
| 52 int progress_bar_resource_id, | 55 int progress_bar_resource_id, |
| 53 int search_promo_resource_id, | 56 int search_promo_resource_id, |
| 54 int peek_promo_ripple_resource_id, | 57 int peek_promo_ripple_resource_id, |
| 55 int peek_promo_text_resource_id, | 58 int peek_promo_text_resource_id, |
| 56 int search_provider_icon_sprite_bitmap_resource_id, | 59 int search_provider_icon_sprite_bitmap_resource_id, |
| 57 int search_provider_icon_sprite_metadata_resource_id, | 60 int search_provider_icon_sprite_metadata_resource_id, |
| 61 float dp_to_px, |
| 58 content::ContentViewCore* content_view_core, | 62 content::ContentViewCore* content_view_core, |
| 59 bool search_promo_visible, | 63 bool search_promo_visible, |
| 60 float search_promo_height, | 64 float search_promo_height, |
| 61 float search_promo_opacity, | 65 float search_promo_opacity, |
| 62 bool search_peek_promo_visible, | 66 bool search_peek_promo_visible, |
| 63 float search_peek_promo_height, | 67 float search_peek_promo_height, |
| 64 float search_peek_promo_padding, | 68 float search_peek_promo_padding, |
| 65 float search_peek_promo_ripple_width, | 69 float search_peek_promo_ripple_width, |
| 66 float search_peek_promo_ripple_opacity, | 70 float search_peek_promo_ripple_opacity, |
| 67 float search_peek_promo_text_opacity, | 71 float search_peek_promo_text_opacity, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // --------------------------------------------------------------------------- | 269 // --------------------------------------------------------------------------- |
| 266 if (should_use_static_icon) { | 270 if (should_use_static_icon) { |
| 267 if (panel_icon_->parent() != layer_) { | 271 if (panel_icon_->parent() != layer_) { |
| 268 layer_->AddChild(panel_icon_); | 272 layer_->AddChild(panel_icon_); |
| 269 } | 273 } |
| 270 ui::ResourceManager::Resource* panel_icon_resource = | 274 ui::ResourceManager::Resource* panel_icon_resource = |
| 271 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 275 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
| 272 panel_icon_resource_id); | 276 panel_icon_resource_id); |
| 273 DCHECK(panel_icon_resource); | 277 DCHECK(panel_icon_resource); |
| 274 | 278 |
| 279 // If the icon is not the default width, add or remove padding so it appears |
| 280 // centered. |
| 281 float icon_padding = (kDefaultIconWidthDp * dp_to_px - |
| 282 panel_icon_resource->size.width()) / 2.0f; |
| 283 |
| 275 // Positions the Icon at the start of the Search Bar. | 284 // Positions the Icon at the start of the Search Bar. |
| 276 float search_provider_icon_left; | 285 float search_provider_icon_left; |
| 277 if (is_rtl) { | 286 if (is_rtl) { |
| 278 search_provider_icon_left = search_panel_width - | 287 search_provider_icon_left = search_panel_width - |
| 279 panel_icon_resource->size.width() - search_bar_margin_side; | 288 panel_icon_resource->size.width() - |
| 289 (search_bar_margin_side + icon_padding); |
| 280 } else { | 290 } else { |
| 281 search_provider_icon_left = search_bar_margin_side; | 291 search_provider_icon_left = search_bar_margin_side + icon_padding; |
| 282 } | 292 } |
| 283 | 293 |
| 284 // Centers the Icon vertically in the Search Bar. | 294 // Centers the Icon vertically in the Search Bar. |
| 285 float search_provider_icon_top = search_bar_top + | 295 float search_provider_icon_top = search_bar_top + |
| 286 search_bar_height / 2 - | 296 search_bar_height / 2 - |
| 287 panel_icon_resource->size.height() / 2; | 297 panel_icon_resource->size.height() / 2; |
| 288 | 298 |
| 289 panel_icon_->SetUIResourceId( | 299 panel_icon_->SetUIResourceId( |
| 290 panel_icon_resource->ui_resource->id()); | 300 panel_icon_resource->ui_resource->id()); |
| 291 panel_icon_->SetBounds(panel_icon_resource->size); | 301 panel_icon_->SetBounds(panel_icon_resource->size); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 | 672 |
| 663 ContextualSearchLayer::~ContextualSearchLayer() { | 673 ContextualSearchLayer::~ContextualSearchLayer() { |
| 664 } | 674 } |
| 665 | 675 |
| 666 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() { | 676 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() { |
| 667 return layer_; | 677 return layer_; |
| 668 } | 678 } |
| 669 | 679 |
| 670 } // namespace android | 680 } // namespace android |
| 671 } // namespace chrome | 681 } // namespace chrome |
| OLD | NEW |