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

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

Issue 1399253005: Fix layout of omnibox rows for material design (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 5 years, 2 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // height differences. 110 // height differences.
111 int current_height_delta = static_cast<int>( 111 int current_height_delta = static_cast<int>(
112 size_animation_.GetCurrentValue() * total_height_delta - 0.5); 112 size_animation_.GetCurrentValue() * total_height_delta - 0.5);
113 current_frame_bounds.set_height( 113 current_frame_bounds.set_height(
114 current_frame_bounds.height() + current_height_delta); 114 current_frame_bounds.height() + current_height_delta);
115 return current_frame_bounds; 115 return current_frame_bounds;
116 } 116 }
117 117
118 void OmniboxPopupContentsView::LayoutChildren() { 118 void OmniboxPopupContentsView::LayoutChildren() {
119 gfx::Rect contents_rect = GetContentsBounds(); 119 gfx::Rect contents_rect = GetContentsBounds();
120 contents_rect.Inset(GetLayoutInsets(OMNIBOX_DROPDOWN_TEXT)); 120 contents_rect.Inset(GetLayoutInsets(OMNIBOX_DROPDOWN));
121 contents_rect.Inset(0, views::NonClientFrameView::kClientEdgeThickness, 0, 0); 121 contents_rect.Inset(0, views::NonClientFrameView::kClientEdgeThickness, 0, 0);
122 122
123 // In the non-material dropdown, the colored/clickable regions within the 123 // In the non-material dropdown, the colored/clickable regions within the
124 // dropdown are only as wide as the location bar. In the material version, 124 // dropdown are only as wide as the location bar. In the material version,
125 // these are full width, and OmniboxResultView instead insets the icons/text 125 // these are full width, and OmniboxResultView instead insets the icons/text
126 // inside to be aligned with the location bar. 126 // inside to be aligned with the location bar.
127 if (!ui::MaterialDesignController::IsModeMaterial()) 127 if (!ui::MaterialDesignController::IsModeMaterial())
128 contents_rect.Inset(start_margin_, 0, end_margin_, 0); 128 contents_rect.Inset(start_margin_, 0, end_margin_, 0);
129 129
130 int top = contents_rect.y(); 130 int top = contents_rect.y();
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 int OmniboxPopupContentsView::CalculatePopupHeight() { 415 int OmniboxPopupContentsView::CalculatePopupHeight() {
416 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size()); 416 DCHECK_GE(static_cast<size_t>(child_count()), model_->result().size());
417 int popup_height = 0; 417 int popup_height = 0;
418 for (size_t i = 0; i < model_->result().size(); ++i) 418 for (size_t i = 0; i < model_->result().size(); ++i)
419 popup_height += child_at(i)->GetPreferredSize().height(); 419 popup_height += child_at(i)->GetPreferredSize().height();
420 420
421 // Add enough space on the top and bottom so it looks like there is the same 421 // Add enough space on the top and bottom so it looks like there is the same
422 // amount of space between the text and the popup border as there is in the 422 // amount of space between the text and the popup border as there is in the
423 // interior between each row of text. 423 // interior between each row of text.
424 return popup_height + views::NonClientFrameView::kClientEdgeThickness + 424 return popup_height + views::NonClientFrameView::kClientEdgeThickness +
425 GetLayoutInsets(OMNIBOX_DROPDOWN_TEXT).height() + 425 GetLayoutInsets(OMNIBOX_DROPDOWN).height() +
426 bottom_shadow_->height() - 426 bottom_shadow_->height() -
427 GetLayoutConstant(OMNIBOX_DROPDOWN_BORDER_INTERIOR); 427 GetLayoutConstant(OMNIBOX_DROPDOWN_BORDER_INTERIOR);
428 } 428 }
429 429
430 OmniboxResultView* OmniboxPopupContentsView::CreateResultView( 430 OmniboxResultView* OmniboxPopupContentsView::CreateResultView(
431 int model_index, 431 int model_index,
432 const gfx::FontList& font_list) { 432 const gfx::FontList& font_list) {
433 return new OmniboxResultView(this, model_index, location_bar_view_, 433 return new OmniboxResultView(this, model_index, location_bar_view_,
434 font_list); 434 font_list);
435 } 435 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 size_t index = GetIndexForPoint(event.location()); 525 size_t index = GetIndexForPoint(event.location());
526 if (!HasMatchAt(index)) 526 if (!HasMatchAt(index))
527 return; 527 return;
528 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition, 528 omnibox_view_->OpenMatch(model_->result().match_at(index), disposition,
529 GURL(), base::string16(), index); 529 GURL(), base::string16(), index);
530 } 530 }
531 531
532 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { 532 OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) {
533 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i))); 533 return static_cast<OmniboxResultView*>(child_at(static_cast<int>(i)));
534 } 534 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/layout_constants.cc ('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