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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc

Issue 1300843003: Change width of rows in material design omnibox dropdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change left/right to start/end Created 5 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/views/omnibox/omnibox_popup_contents_view.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/search/search.h" 9 #include "chrome/browser/search/search.h"
10 #include "chrome/browser/themes/theme_properties.h" 10 #include "chrome/browser/themes/theme_properties.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const gfx::FontList& font_list, 56 const gfx::FontList& font_list,
57 OmniboxView* omnibox_view, 57 OmniboxView* omnibox_view,
58 OmniboxEditModel* edit_model, 58 OmniboxEditModel* edit_model,
59 LocationBarView* location_bar_view) 59 LocationBarView* location_bar_view)
60 : model_(new OmniboxPopupModel(this, edit_model)), 60 : model_(new OmniboxPopupModel(this, edit_model)),
61 omnibox_view_(omnibox_view), 61 omnibox_view_(omnibox_view),
62 location_bar_view_(location_bar_view), 62 location_bar_view_(location_bar_view),
63 font_list_(font_list), 63 font_list_(font_list),
64 ignore_mouse_drag_(false), 64 ignore_mouse_drag_(false),
65 size_animation_(this), 65 size_animation_(this),
66 left_margin_(0), 66 start_margin_(0),
67 right_margin_(0) { 67 end_margin_(0) {
68 // The contents is owned by the LocationBarView. 68 // The contents is owned by the LocationBarView.
69 set_owned_by_client(); 69 set_owned_by_client();
70 70
71 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider(); 71 ui::ThemeProvider* theme = location_bar_view_->GetThemeProvider();
72 int bottom_shadow_asset = ui::MaterialDesignController::IsModeMaterial() ? 72 int bottom_shadow_asset = ui::MaterialDesignController::IsModeMaterial() ?
73 IDR_OMNIBOX_DROPDOWN_SHADOW_BOTTOM : IDR_BUBBLE_B; 73 IDR_OMNIBOX_DROPDOWN_SHADOW_BOTTOM : IDR_BUBBLE_B;
74 bottom_shadow_ = theme->GetImageSkiaNamed(bottom_shadow_asset); 74 bottom_shadow_ = theme->GetImageSkiaNamed(bottom_shadow_asset);
75 75
76 SetEventTargeter( 76 SetEventTargeter(
77 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); 77 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 current_frame_bounds.height() + current_height_delta); 109 current_frame_bounds.height() + current_height_delta);
110 return current_frame_bounds; 110 return current_frame_bounds;
111 } 111 }
112 112
113 void OmniboxPopupContentsView::LayoutChildren() { 113 void OmniboxPopupContentsView::LayoutChildren() {
114 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider(); 114 ui::ThemeProvider* theme_provider = location_bar_view_->GetThemeProvider();
115 const int min_vertical_padding = theme_provider->GetDisplayProperty( 115 const int min_vertical_padding = theme_provider->GetDisplayProperty(
116 ThemeProperties::PROPERTY_OMNIBOX_DROPDOWN_MIN_TEXT_VERTICAL_PADDING); 116 ThemeProperties::PROPERTY_OMNIBOX_DROPDOWN_MIN_TEXT_VERTICAL_PADDING);
117 117
118 gfx::Rect contents_rect = GetContentsBounds(); 118 gfx::Rect contents_rect = GetContentsBounds();
119 contents_rect.Inset(
120 0, views::NonClientFrameView::kClientEdgeThickness + min_vertical_padding,
121 0, min_vertical_padding);
119 122
120 contents_rect.Inset( 123 // In the non-material dropdown, the colored/clickable regions within the
121 left_margin_, 124 // dropdown are only as wide as the location bar. In the material version,
122 views::NonClientFrameView::kClientEdgeThickness + min_vertical_padding, 125 // these are full width, and OmniboxResultView instead insets the icons/text
123 right_margin_, 126 // inside to be aligned with the location bar.
124 min_vertical_padding); 127 if (!ui::MaterialDesignController::IsModeMaterial())
128 contents_rect.Inset(start_margin_, 0, end_margin_, 0);
129
125 int top = contents_rect.y(); 130 int top = contents_rect.y();
126 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) { 131 for (size_t i = 0; i < AutocompleteResult::kMaxMatches; ++i) {
127 View* v = child_at(i); 132 View* v = child_at(i);
128 if (v->visible()) { 133 if (v->visible()) {
129 v->SetBounds(contents_rect.x(), top, contents_rect.width(), 134 v->SetBounds(contents_rect.x(), top, contents_rect.width(),
130 v->GetPreferredSize().height()); 135 v->GetPreferredSize().height());
131 top = v->bounds().bottom(); 136 top = v->bounds().bottom();
132 } 137 }
133 } 138 }
134 } 139 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 max_match_contents_width_, view->GetMatchContentsWidth()); 190 max_match_contents_width_, view->GetMatchContentsWidth());
186 } 191 }
187 } 192 }
188 193
189 for (size_t i = result_size; i < AutocompleteResult::kMaxMatches; ++i) 194 for (size_t i = result_size; i < AutocompleteResult::kMaxMatches; ++i)
190 child_at(i)->SetVisible(false); 195 child_at(i)->SetVisible(false);
191 196
192 gfx::Point top_left_screen_coord; 197 gfx::Point top_left_screen_coord;
193 int width; 198 int width;
194 location_bar_view_->GetOmniboxPopupPositioningInfo( 199 location_bar_view_->GetOmniboxPopupPositioningInfo(
195 &top_left_screen_coord, &width, &left_margin_, &right_margin_); 200 &top_left_screen_coord, &width, &start_margin_, &end_margin_);
196 gfx::Rect new_target_bounds(top_left_screen_coord, 201 gfx::Rect new_target_bounds(top_left_screen_coord,
197 gfx::Size(width, CalculatePopupHeight())); 202 gfx::Size(width, CalculatePopupHeight()));
198 203
199 // If we're animating and our target height changes, reset the animation. 204 // If we're animating and our target height changes, reset the animation.
200 // NOTE: If we just reset blindly on _every_ update, then when the user types 205 // NOTE: If we just reset blindly on _every_ update, then when the user types
201 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the 206 // rapidly we could get "stuck" trying repeatedly to animate shrinking by the
202 // last few pixels to get to one visible result. 207 // last few pixels to get to one visible result.
203 if (new_target_bounds.height() != target_bounds_.height()) 208 if (new_target_bounds.height() != target_bounds_.height())
204 size_animation_.Reset(); 209 size_animation_.Reset();
205 target_bounds_ = new_target_bounds; 210 target_bounds_ = new_target_bounds;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 size_t index = GetIndexForPoint(event.location()); 511 size_t index = GetIndexForPoint(event.location());
507 if (!HasMatchAt(index)) 512 if (!HasMatchAt(index))
508 return; 513 return;
509 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, 514 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition,
510 GURL(), base::string16(), index); 515 GURL(), base::string16(), index);
511 } 516 }
512 517
513 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 518 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
514 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 519 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
515 } 520 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h ('k') | chrome/browser/ui/views/omnibox/omnibox_result_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698