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

Side by Side Diff: chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.cc

Issue 6469074: AutocompletePopupContentsView must override View::PaintChildren to prevent views (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: modified according to ocmments Created 9 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "touch_autocomplete_popup_contents_view.h" 5 #include "touch_autocomplete_popup_contents_view.h"
6 6
7 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 7 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/canvas_skia.h" 10 #include "ui/gfx/canvas_skia.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 TouchAutocompletePopupContentsView::~TouchAutocompletePopupContentsView() { 79 TouchAutocompletePopupContentsView::~TouchAutocompletePopupContentsView() {
80 } 80 }
81 81
82 void TouchAutocompletePopupContentsView::UpdatePopupAppearance() { 82 void TouchAutocompletePopupContentsView::UpdatePopupAppearance() {
83 AutocompletePopupContentsView::UpdatePopupAppearance(); 83 AutocompletePopupContentsView::UpdatePopupAppearance();
84 Layout(); 84 Layout();
85 } 85 }
86 86
87 void TouchAutocompletePopupContentsView::PaintChildren( 87 void TouchAutocompletePopupContentsView::LayoutChildren() {
88 std::vector<View*> visible_children(GetVisibleChildren());
89 gfx::Rect bounds(GetContentsBounds());
90 double child_width =
91 static_cast<double>(bounds.width()) / visible_children.size();
92 int x = bounds.x();
93 for (size_t i = 0; i < visible_children.size(); ++i) {
94 int next_x = bounds.x() + static_cast<int>(((i + 1) * child_width) + 0.5);
95 visible_children[i]->SetBounds(x, bounds.y(), next_x - x, bounds.height());
96 x = next_x;
97 }
98 }
99
100 void TouchAutocompletePopupContentsView::PaintResultViews(
88 gfx::CanvasSkia* canvas) { 101 gfx::CanvasSkia* canvas) {
89 AutocompletePopupContentsView::PaintChildren(canvas); 102 AutocompletePopupContentsView::PaintResultViews(canvas);
90 103
91 // Draw divider lines. 104 // Draw divider lines.
92 std::vector<View*> visible_children(GetVisibleChildren()); 105 std::vector<View*> visible_children(GetVisibleChildren());
93 if (visible_children.size() < 2) 106 if (visible_children.size() < 2)
94 return; 107 return;
95 SkColor color = AutocompleteResultView::GetColor( 108 SkColor color = AutocompleteResultView::GetColor(
96 AutocompleteResultView::NORMAL, AutocompleteResultView::DIMMED_TEXT); 109 AutocompleteResultView::NORMAL, AutocompleteResultView::DIMMED_TEXT);
97 gfx::Rect bounds(GetContentsBounds()); 110 gfx::Rect bounds(GetContentsBounds());
98 for (std::vector<View*>::const_iterator i(visible_children.begin() + 1); 111 for (std::vector<View*>::const_iterator i(visible_children.begin() + 1);
99 i != visible_children.end(); ++i) { 112 i != visible_children.end(); ++i) {
100 canvas->DrawLineInt(color, (*i)->x(), bounds.y(), (*i)->x(), 113 canvas->DrawLineInt(color, (*i)->x(), bounds.y(), (*i)->x(),
101 bounds.bottom()); 114 bounds.bottom());
102 } 115 }
103 } 116 }
104 117
105 void TouchAutocompletePopupContentsView::LayoutChildren() {
106 std::vector<View*> visible_children(GetVisibleChildren());
107 gfx::Rect bounds(GetContentsBounds());
108 double child_width =
109 static_cast<double>(bounds.width()) / visible_children.size();
110 int x = bounds.x();
111 for (size_t i = 0; i < visible_children.size(); ++i) {
112 int next_x = bounds.x() + static_cast<int>(((i + 1) * child_width) + 0.5);
113 visible_children[i]->SetBounds(x, bounds.y(), next_x - x, bounds.height());
114 x = next_x;
115 }
116 }
117
118 int TouchAutocompletePopupContentsView::CalculatePopupHeight() { 118 int TouchAutocompletePopupContentsView::CalculatePopupHeight() {
119 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); 119 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
120 int popup_height = 0; 120 int popup_height = 0;
121 for (size_t i = 0; i < model_->result().size(); ++i) { 121 for (size_t i = 0; i < model_->result().size(); ++i) {
122 popup_height = std::max(popup_height, 122 popup_height = std::max(popup_height,
123 GetChildViewAt(i)->GetPreferredSize().height()); 123 GetChildViewAt(i)->GetPreferredSize().height());
124 } 124 }
125 popup_height = std::max(popup_height, opt_in_view_ ? 125 popup_height = std::max(popup_height, opt_in_view_ ?
126 opt_in_view_->GetPreferredSize().height() : 0); 126 opt_in_view_->GetPreferredSize().height() : 0);
127 return popup_height; 127 return popup_height;
(...skipping 10 matching lines...) Expand all
138 std::vector<views::View*> 138 std::vector<views::View*>
139 TouchAutocompletePopupContentsView::GetVisibleChildren() { 139 TouchAutocompletePopupContentsView::GetVisibleChildren() {
140 std::vector<View*> visible_children; 140 std::vector<View*> visible_children;
141 for (int i = 0; i < child_count(); ++i) { 141 for (int i = 0; i < child_count(); ++i) {
142 View* v = GetChildViewAt(i); 142 View* v = GetChildViewAt(i);
143 if (GetChildViewAt(i)->IsVisible()) 143 if (GetChildViewAt(i)->IsVisible())
144 visible_children.push_back(v); 144 visible_children.push_back(v);
145 } 145 }
146 return visible_children; 146 return visible_children;
147 } 147 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autocomplete/touch_autocomplete_popup_contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698