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

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

Issue 2542883004: Bottom browser controls position based on window height (Closed)
Patch Set: rebase Created 4 years 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/toolbar_layer.h" 5 #include "chrome/browser/android/compositor/layer/toolbar_layer.h"
6 6
7 #include "cc/layers/nine_patch_layer.h" 7 #include "cc/layers/nine_patch_layer.h"
8 #include "cc/layers/solid_color_layer.h" 8 #include "cc/layers/solid_color_layer.h"
9 #include "cc/layers/ui_resource_layer.h" 9 #include "cc/layers/ui_resource_layer.h"
10 #include "cc/resources/scoped_ui_resource.h" 10 #include "cc/resources/scoped_ui_resource.h"
(...skipping 13 matching lines...) Expand all
24 return layer_; 24 return layer_;
25 } 25 }
26 26
27 void ToolbarLayer::PushResource( 27 void ToolbarLayer::PushResource(
28 int toolbar_resource_id, 28 int toolbar_resource_id,
29 int toolbar_background_color, 29 int toolbar_background_color,
30 bool anonymize, 30 bool anonymize,
31 int toolbar_textbox_background_color, 31 int toolbar_textbox_background_color,
32 int url_bar_background_resource_id, 32 int url_bar_background_resource_id,
33 float url_bar_alpha, 33 float url_bar_alpha,
34 float view_height, 34 float window_height,
35 float y_offset,
35 bool show_debug, 36 bool show_debug,
36 bool clip_shadow, 37 bool clip_shadow,
37 bool browser_controls_at_bottom) { 38 bool browser_controls_at_bottom) {
38 ui::ResourceManager::Resource* resource = 39 ui::ResourceManager::Resource* resource =
39 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC, 40 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_DYNAMIC,
40 toolbar_resource_id); 41 toolbar_resource_id);
41 42
42 // Ensure the toolbar resource is available before making the layer visible. 43 // Ensure the toolbar resource is available before making the layer visible.
43 layer_->SetHideLayerAndSubtree(!resource); 44 layer_->SetHideLayerAndSubtree(!resource);
44 if (!resource) 45 if (!resource)
45 return; 46 return;
46 47
47 // This layer effectively draws over the space it takes for shadows. Set the 48 // This layer effectively draws over the space it takes for shadows. Set the
48 // bounds to the non-shadow size so that other things can properly line up. 49 // bounds to the non-shadow size so that other things can properly line up.
49 // Padding height does not include the height of the tabstrip, so we add 50 // Padding height does not include the height of the tabstrip, so we add
50 // it explicitly by adding y offset. 51 // it explicitly by adding y offset.
51 gfx::Size size = gfx::Size( 52 gfx::Size size = gfx::Size(
52 resource->padding.width(), 53 resource->padding.width(),
53 resource->padding.height() + resource->padding.y()); 54 resource->padding.height() + resource->padding.y());
54 layer_->SetBounds(size); 55 layer_->SetBounds(size);
55 56
56 // The toolbar_root_ contains all of the layers that make up the toolbar. The 57 // The toolbar_root_ contains all of the layers that make up the toolbar. The
57 // toolbar_root_ is moved around inside of layer_ to allow appropriate 58 // toolbar_root_ is moved around inside of layer_ to allow appropriate
58 // clipping of the shadow. 59 // clipping of the shadow.
59 toolbar_root_->SetBounds(resource->padding.size()); 60 toolbar_root_->SetBounds(resource->padding.size());
60 61
62 gfx::PointF root_layer_position(0, y_offset);
61 gfx::PointF background_position(resource->padding.origin()); 63 gfx::PointF background_position(resource->padding.origin());
62 if (browser_controls_at_bottom) { 64 if (browser_controls_at_bottom) {
65 // The toolbar's position as if it were completely shown.
66 float base_toolbar_y = window_height - resource->padding.size().height();
63 float layer_offset = 67 float layer_offset =
64 resource->size.height() - resource->padding.size().height(); 68 resource->size.height() - resource->padding.size().height();
65 layer_->SetPosition(gfx::PointF(0, view_height)); 69
70 root_layer_position.set_y(base_toolbar_y + y_offset);
66 toolbar_root_->SetPosition(gfx::PointF(0, -layer_offset)); 71 toolbar_root_->SetPosition(gfx::PointF(0, -layer_offset));
67 background_position.set_y(layer_offset); 72 background_position.set_y(layer_offset);
68 } 73 }
74 layer_->SetPosition(root_layer_position);
69 75
70 toolbar_background_layer_->SetBounds(resource->padding.size()); 76 toolbar_background_layer_->SetBounds(resource->padding.size());
71 toolbar_background_layer_->SetPosition(background_position); 77 toolbar_background_layer_->SetPosition(background_position);
72 toolbar_background_layer_->SetBackgroundColor(toolbar_background_color); 78 toolbar_background_layer_->SetBackgroundColor(toolbar_background_color);
73 79
74 bool url_bar_visible = (resource->aperture.width() != 0); 80 bool url_bar_visible = (resource->aperture.width() != 0);
75 url_bar_background_layer_->SetHideLayerAndSubtree(!url_bar_visible); 81 url_bar_background_layer_->SetHideLayerAndSubtree(!url_bar_visible);
76 if (url_bar_visible) { 82 if (url_bar_visible) {
77 ui::ResourceManager::Resource* url_bar_background_resource = 83 ui::ResourceManager::Resource* url_bar_background_resource =
78 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC, 84 resource_manager_->GetResource(ui::ANDROID_RESOURCE_TYPE_STATIC,
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 195
190 debug_layer_->SetIsDrawable(true); 196 debug_layer_->SetIsDrawable(true);
191 debug_layer_->SetBackgroundColor(SK_ColorGREEN); 197 debug_layer_->SetBackgroundColor(SK_ColorGREEN);
192 debug_layer_->SetOpacity(0.5f); 198 debug_layer_->SetOpacity(0.5f);
193 } 199 }
194 200
195 ToolbarLayer::~ToolbarLayer() { 201 ToolbarLayer::~ToolbarLayer() {
196 } 202 }
197 203
198 } // namespace android 204 } // namespace android
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698