Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: chrome/browser/android/compositor/layer/contextual_search_layer.cc

Issue 1219133003: Contextual Search UI changes for custom tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RTL support Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 20 matching lines...) Expand all
31 return make_scoped_refptr(new ContextualSearchLayer(resource_manager)); 31 return make_scoped_refptr(new ContextualSearchLayer(resource_manager));
32 } 32 }
33 33
34 void ContextualSearchLayer::SetProperties( 34 void ContextualSearchLayer::SetProperties(
35 int search_bar_background_resource_id, 35 int search_bar_background_resource_id,
36 int search_bar_text_resource_id, 36 int search_bar_text_resource_id,
37 int search_bar_shadow_resource_id, 37 int search_bar_shadow_resource_id,
38 int search_provider_icon_resource_id, 38 int search_provider_icon_resource_id,
39 int search_icon_resource_id, 39 int search_icon_resource_id,
40 int arrow_up_resource_id, 40 int arrow_up_resource_id,
41 int close_icon_resource_id,
41 int progress_bar_background_resource_id, 42 int progress_bar_background_resource_id,
42 int progress_bar_resource_id, 43 int progress_bar_resource_id,
43 int search_promo_resource_id, 44 int search_promo_resource_id,
44 content::ContentViewCore* content_view_core, 45 content::ContentViewCore* content_view_core,
45 bool search_promo_visible, 46 bool search_promo_visible,
46 float search_promo_height, 47 float search_promo_height,
47 float search_promo_opacity, 48 float search_promo_opacity,
48 float search_panel_y, 49 float search_panel_y,
49 float search_panel_width, 50 float search_panel_width,
50 float search_bar_margin_top, 51 float search_bar_margin_top,
51 float search_bar_margin_side, 52 float search_bar_margin_side,
52 float search_bar_height, 53 float search_bar_height,
53 float search_bar_text_opacity, 54 float search_bar_text_opacity,
54 bool search_bar_border_visible, 55 bool search_bar_border_visible,
55 float search_bar_border_y, 56 float search_bar_border_y,
56 float search_bar_border_height, 57 float search_bar_border_height,
57 bool search_bar_shadow_visible, 58 bool search_bar_shadow_visible,
58 float search_bar_shadow_opacity, 59 float search_bar_shadow_opacity,
59 float search_provider_icon_opacity, 60 float search_provider_icon_opacity,
60 float search_icon_opacity, 61 float search_icon_opacity,
61 bool arrow_icon_visible, 62 bool arrow_icon_visible,
62 float arrow_icon_opacity, 63 float arrow_icon_opacity,
63 float arrow_icon_rotation, 64 float arrow_icon_rotation,
65 bool close_icon_visible,
66 float close_icon_opacity,
64 bool progress_bar_visible, 67 bool progress_bar_visible,
65 float progress_bar_y, 68 float progress_bar_y,
66 float progress_bar_height, 69 float progress_bar_height,
67 float progress_bar_opacity, 70 float progress_bar_opacity,
68 int progress_bar_completion) { 71 int progress_bar_completion) {
69 // Grab the dynamic Search Bar Text resource. 72 // Grab the dynamic Search Bar Text resource.
70 ui::ResourceManager::Resource* search_bar_text_resource = 73 ui::ResourceManager::Resource* search_bar_text_resource =
71 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 74 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC,
72 search_bar_text_resource_id); 75 search_bar_text_resource_id);
73 76
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 transform.RotateAboutZAxis(arrow_icon_rotation); 200 transform.RotateAboutZAxis(arrow_icon_rotation);
198 transform.Translate(-pivot_origin.x(), -pivot_origin.y()); 201 transform.Translate(-pivot_origin.x(), -pivot_origin.y());
199 } 202 }
200 arrow_icon_->SetTransform(transform); 203 arrow_icon_->SetTransform(transform);
201 } else { 204 } else {
202 if (arrow_icon_.get() && arrow_icon_->parent()) 205 if (arrow_icon_.get() && arrow_icon_->parent())
203 arrow_icon_->RemoveFromParent(); 206 arrow_icon_->RemoveFromParent();
204 } 207 }
205 208
206 // --------------------------------------------------------------------------- 209 // ---------------------------------------------------------------------------
210 // Close Icon
211 // ---------------------------------------------------------------------------
212 if (close_icon_visible) {
213 // Grab the Close Icon resource.
214 ui::ResourceManager::Resource* close_icon_resource =
215 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC,
216 close_icon_resource_id);
217 if (close_icon_->parent() != layer_) {
218 layer_->AddChild(close_icon_);
219 }
220
221 // Positions the icon at the end of the Search Bar.
222 float close_icon_left;
223 if (is_rtl) {
224 close_icon_left = search_bar_margin_side;
225 } else {
226 close_icon_left = search_panel_width -
227 close_icon_resource->size.width() - search_bar_margin_side;
228 }
229
230 // Centers the Close Icon vertically in the Search Bar.
231 float close_icon_top = search_bar_margin_top +
232 (search_bar_height - search_bar_margin_top) / 2 -
233 close_icon_resource->size.height() / 2;
234
235 close_icon_->SetUIResourceId(close_icon_resource->ui_resource->id());
236 close_icon_->SetBounds(close_icon_resource->size);
237 close_icon_->SetPosition(
238 gfx::PointF(close_icon_left, close_icon_top));
239 close_icon_->SetOpacity(close_icon_opacity);
240 }
pedro (no code reviews) 2015/07/08 00:43:47 Add else block that removes the layer, if not pres
Theresa 2015/07/08 16:03:58 Done.
241
242 // ---------------------------------------------------------------------------
207 // Search Promo 243 // Search Promo
208 // --------------------------------------------------------------------------- 244 // ---------------------------------------------------------------------------
209 if (search_promo_visible) { 245 if (search_promo_visible) {
210 // Grab the Search Opt Out Promo resource. 246 // Grab the Search Opt Out Promo resource.
211 ui::ResourceManager::Resource* search_promo_resource = 247 ui::ResourceManager::Resource* search_promo_resource =
212 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 248 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC,
213 search_promo_resource_id); 249 search_promo_resource_id);
214 // Search Promo Container 250 // Search Promo Container
215 if (search_promo_container_->parent() != layer_) { 251 if (search_promo_container_->parent() != layer_) {
216 // NOTE(pedrosimonetti): The Promo layer should be always placed before 252 // NOTE(pedrosimonetti): The Promo layer should be always placed before
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 search_bar_text_( 401 search_bar_text_(
366 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), 402 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
367 search_bar_shadow_( 403 search_bar_shadow_(
368 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), 404 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
369 search_provider_icon_( 405 search_provider_icon_(
370 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), 406 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
371 search_icon_( 407 search_icon_(
372 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), 408 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
373 arrow_icon_( 409 arrow_icon_(
374 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), 410 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
411 close_icon_(
412 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
375 content_view_container_( 413 content_view_container_(
376 cc::Layer::Create(content::Compositor::LayerSettings())), 414 cc::Layer::Create(content::Compositor::LayerSettings())),
377 search_bar_border_( 415 search_bar_border_(
378 cc::SolidColorLayer::Create(content::Compositor::LayerSettings())), 416 cc::SolidColorLayer::Create(content::Compositor::LayerSettings())),
379 progress_bar_( 417 progress_bar_(
380 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())), 418 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())),
381 progress_bar_background_( 419 progress_bar_background_(
382 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())), 420 cc::NinePatchLayer::Create(content::Compositor::LayerSettings())),
383 search_promo_( 421 search_promo_(
384 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())), 422 cc::UIResourceLayer::Create(content::Compositor::LayerSettings())),
(...skipping 15 matching lines...) Expand all
400 search_provider_icon_->SetIsDrawable(true); 438 search_provider_icon_->SetIsDrawable(true);
401 layer_->AddChild(search_provider_icon_); 439 layer_->AddChild(search_provider_icon_);
402 440
403 // Search Icon 441 // Search Icon
404 search_icon_->SetIsDrawable(true); 442 search_icon_->SetIsDrawable(true);
405 layer_->AddChild(search_icon_); 443 layer_->AddChild(search_icon_);
406 444
407 // Arrow Icon 445 // Arrow Icon
408 arrow_icon_->SetIsDrawable(true); 446 arrow_icon_->SetIsDrawable(true);
409 447
448 // Close Icon
449 close_icon_->SetIsDrawable(true);
450
410 // Search Opt Out Promo 451 // Search Opt Out Promo
411 search_promo_container_->SetIsDrawable(true); 452 search_promo_container_->SetIsDrawable(true);
412 search_promo_container_->SetBackgroundColor(kSearchBackgroundColor); 453 search_promo_container_->SetBackgroundColor(kSearchBackgroundColor);
413 search_promo_->SetIsDrawable(true); 454 search_promo_->SetIsDrawable(true);
414 455
415 // Search Bar Border 456 // Search Bar Border
416 search_bar_border_->SetIsDrawable(true); 457 search_bar_border_->SetIsDrawable(true);
417 search_bar_border_->SetBackgroundColor(kSearchBarBorderColor); 458 search_bar_border_->SetBackgroundColor(kSearchBarBorderColor);
418 459
419 // Progress Bar Background 460 // Progress Bar Background
(...skipping 13 matching lines...) Expand all
433 474
434 ContextualSearchLayer::~ContextualSearchLayer() { 475 ContextualSearchLayer::~ContextualSearchLayer() {
435 } 476 }
436 477
437 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() { 478 scoped_refptr<cc::Layer> ContextualSearchLayer::layer() {
438 return layer_; 479 return layer_;
439 } 480 }
440 481
441 } // namespace android 482 } // namespace android
442 } // namespace chrome 483 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698