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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 float search_bar_height, | 55 float search_bar_height, |
56 float search_context_opacity, | 56 float search_context_opacity, |
57 float search_term_opacity, | 57 float search_term_opacity, |
58 bool search_bar_border_visible, | 58 bool search_bar_border_visible, |
59 float search_bar_border_y, | 59 float search_bar_border_y, |
60 float search_bar_border_height, | 60 float search_bar_border_height, |
61 bool search_bar_shadow_visible, | 61 bool search_bar_shadow_visible, |
62 float search_bar_shadow_opacity, | 62 float search_bar_shadow_opacity, |
63 float arrow_icon_opacity, | 63 float arrow_icon_opacity, |
64 float arrow_icon_rotation, | 64 float arrow_icon_rotation, |
65 bool close_icon_visible, | |
66 float close_icon_opacity, | 65 float close_icon_opacity, |
67 bool progress_bar_visible, | 66 bool progress_bar_visible, |
68 float progress_bar_y, | 67 float progress_bar_y, |
69 float progress_bar_height, | 68 float progress_bar_height, |
70 float progress_bar_opacity, | 69 float progress_bar_opacity, |
71 int progress_bar_completion) { | 70 int progress_bar_completion) { |
72 // Grabs the dynamic Search Bar Text resource. | 71 // Grabs the dynamic Search Bar Text resource. |
73 ui::ResourceManager::Resource* search_context_resource = | 72 ui::ResourceManager::Resource* search_context_resource = |
74 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, | 73 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, |
75 search_context_resource_id); | 74 search_context_resource_id); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 search_provider_icon_->SetPosition( | 167 search_provider_icon_->SetPosition( |
169 gfx::PointF(search_provider_icon_left, search_provider_icon_top)); | 168 gfx::PointF(search_provider_icon_left, search_provider_icon_top)); |
170 | 169 |
171 // --------------------------------------------------------------------------- | 170 // --------------------------------------------------------------------------- |
172 // Arrow Icon | 171 // Arrow Icon |
173 // --------------------------------------------------------------------------- | 172 // --------------------------------------------------------------------------- |
174 // Grabs the Search Arrow Icon resource. | 173 // Grabs the Search Arrow Icon resource. |
175 ui::ResourceManager::Resource* arrow_icon_resource = | 174 ui::ResourceManager::Resource* arrow_icon_resource = |
176 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 175 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
177 arrow_up_resource_id); | 176 arrow_up_resource_id); |
178 if (arrow_icon_->parent() != layer_) { | |
179 layer_->AddChild(arrow_icon_); | |
180 } | |
181 | 177 |
182 // Positions the icon at the end of the Search Bar. | 178 // Positions the icon at the end of the Search Bar. |
183 float arrow_icon_left; | 179 float arrow_icon_left; |
184 if (is_rtl) { | 180 if (is_rtl) { |
185 arrow_icon_left = search_bar_margin_side; | 181 arrow_icon_left = search_bar_margin_side; |
186 } else { | 182 } else { |
187 arrow_icon_left = search_panel_width - | 183 arrow_icon_left = search_panel_width - |
188 arrow_icon_resource->size.width() - search_bar_margin_side; | 184 arrow_icon_resource->size.width() - search_bar_margin_side; |
189 } | 185 } |
190 | 186 |
(...skipping 15 matching lines...) Expand all Loading... |
206 gfx::PointF pivot_origin(pivot_x, pivot_y); | 202 gfx::PointF pivot_origin(pivot_x, pivot_y); |
207 transform.Translate(pivot_origin.x(), pivot_origin.y()); | 203 transform.Translate(pivot_origin.x(), pivot_origin.y()); |
208 transform.RotateAboutZAxis(arrow_icon_rotation); | 204 transform.RotateAboutZAxis(arrow_icon_rotation); |
209 transform.Translate(-pivot_origin.x(), -pivot_origin.y()); | 205 transform.Translate(-pivot_origin.x(), -pivot_origin.y()); |
210 } | 206 } |
211 arrow_icon_->SetTransform(transform); | 207 arrow_icon_->SetTransform(transform); |
212 | 208 |
213 // --------------------------------------------------------------------------- | 209 // --------------------------------------------------------------------------- |
214 // Close Icon | 210 // Close Icon |
215 // --------------------------------------------------------------------------- | 211 // --------------------------------------------------------------------------- |
216 if (close_icon_visible) { | 212 // Grab the Close Icon resource. |
217 // Grab the Close Icon resource. | 213 ui::ResourceManager::Resource* close_icon_resource = |
218 ui::ResourceManager::Resource* close_icon_resource = | 214 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, |
219 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, | 215 close_icon_resource_id); |
220 close_icon_resource_id); | |
221 if (close_icon_->parent() != layer_) { | |
222 layer_->AddChild(close_icon_); | |
223 } | |
224 | 216 |
225 // Positions the icon at the end of the Search Bar. | 217 // Positions the icon at the end of the Search Bar. |
226 float close_icon_left; | 218 float close_icon_left; |
227 if (is_rtl) { | 219 if (is_rtl) { |
228 close_icon_left = search_bar_margin_side; | 220 close_icon_left = search_bar_margin_side; |
229 } else { | 221 } else { |
230 close_icon_left = search_panel_width - | 222 close_icon_left = search_panel_width - |
231 close_icon_resource->size.width() - search_bar_margin_side; | 223 close_icon_resource->size.width() - search_bar_margin_side; |
232 } | 224 } |
233 | 225 |
234 // Centers the Close Icon vertically in the Search Bar. | 226 // Centers the Close Icon vertically in the Search Bar. |
235 float close_icon_top = | 227 float close_icon_top = |
236 search_bar_height / 2 - | 228 search_bar_height / 2 - |
237 close_icon_resource->size.height() / 2; | 229 close_icon_resource->size.height() / 2; |
238 | 230 |
239 close_icon_->SetUIResourceId(close_icon_resource->ui_resource->id()); | 231 close_icon_->SetUIResourceId(close_icon_resource->ui_resource->id()); |
240 close_icon_->SetBounds(close_icon_resource->size); | 232 close_icon_->SetBounds(close_icon_resource->size); |
241 close_icon_->SetPosition( | 233 close_icon_->SetPosition( |
242 gfx::PointF(close_icon_left, close_icon_top)); | 234 gfx::PointF(close_icon_left, close_icon_top)); |
243 close_icon_->SetOpacity(close_icon_opacity); | 235 close_icon_->SetOpacity(close_icon_opacity); |
244 } else { | |
245 if (close_icon_.get() && close_icon_->parent()) | |
246 close_icon_->RemoveFromParent(); | |
247 } | |
248 | 236 |
249 // --------------------------------------------------------------------------- | 237 // --------------------------------------------------------------------------- |
250 // Search Promo | 238 // Search Promo |
251 // --------------------------------------------------------------------------- | 239 // --------------------------------------------------------------------------- |
252 if (search_promo_visible) { | 240 if (search_promo_visible) { |
253 // Grabs the Search Opt Out Promo resource. | 241 // Grabs the Search Opt Out Promo resource. |
254 ui::ResourceManager::Resource* search_promo_resource = | 242 ui::ResourceManager::Resource* search_promo_resource = |
255 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, | 243 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, |
256 search_promo_resource_id); | 244 search_promo_resource_id); |
257 // Search Promo Container | 245 // Search Promo Container |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 layer_->AddChild(search_context_); | 437 layer_->AddChild(search_context_); |
450 search_term_->SetIsDrawable(true); | 438 search_term_->SetIsDrawable(true); |
451 layer_->AddChild(search_term_); | 439 layer_->AddChild(search_term_); |
452 | 440 |
453 // Search Provider Icon | 441 // Search Provider Icon |
454 search_provider_icon_->SetIsDrawable(true); | 442 search_provider_icon_->SetIsDrawable(true); |
455 layer_->AddChild(search_provider_icon_); | 443 layer_->AddChild(search_provider_icon_); |
456 | 444 |
457 // Arrow Icon | 445 // Arrow Icon |
458 arrow_icon_->SetIsDrawable(true); | 446 arrow_icon_->SetIsDrawable(true); |
| 447 layer_->AddChild(arrow_icon_); |
459 | 448 |
460 // Close Icon | 449 // Close Icon |
461 close_icon_->SetIsDrawable(true); | 450 close_icon_->SetIsDrawable(true); |
| 451 layer_->AddChild(close_icon_); |
462 | 452 |
463 // Search Opt Out Promo | 453 // Search Opt Out Promo |
464 search_promo_container_->SetIsDrawable(true); | 454 search_promo_container_->SetIsDrawable(true); |
465 search_promo_container_->SetBackgroundColor(kSearchBackgroundColor); | 455 search_promo_container_->SetBackgroundColor(kSearchBackgroundColor); |
466 search_promo_->SetIsDrawable(true); | 456 search_promo_->SetIsDrawable(true); |
467 | 457 |
468 // Search Bar Border | 458 // Search Bar Border |
469 search_bar_border_->SetIsDrawable(true); | 459 search_bar_border_->SetIsDrawable(true); |
470 search_bar_border_->SetBackgroundColor(kSearchBarBorderColor); | 460 search_bar_border_->SetBackgroundColor(kSearchBarBorderColor); |
471 | 461 |
(...skipping 14 matching lines...) Expand all Loading... |
486 | 476 |
487 ContextualSearchLayer::~ContextualSearchLayer() { | 477 ContextualSearchLayer::~ContextualSearchLayer() { |
488 } | 478 } |
489 | 479 |
490 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() { | 480 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() { |
491 return layer_; | 481 return layer_; |
492 } | 482 } |
493 | 483 |
494 } // namespace android | 484 } // namespace android |
495 } // namespace chrome | 485 } // namespace chrome |
OLD | NEW |