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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_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: 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 // For WinDDK ATL compatibility, these ATL headers must come first. 5 // For WinDDK ATL compatibility, these ATL headers must come first.
6 #include "build/build_config.h" 6 #include "build/build_config.h"
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <atlbase.h> // NOLINT 8 #include <atlbase.h> // NOLINT
9 #include <atlwin.h> // NOLINT 9 #include <atlwin.h> // NOLINT
10 #endif 10 #endif
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR); 430 gfx::DIRECTIONALITY_FORCE_RTL : gfx::DIRECTIONALITY_FORCE_LTR);
431 prefix_render_text->SetHorizontalAlignment( 431 prefix_render_text->SetHorizontalAlignment(
432 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT); 432 is_match_contents_rtl ? gfx::ALIGN_RIGHT : gfx::ALIGN_LEFT);
433 prefix_render_text->SetDisplayRect( 433 prefix_render_text->SetDisplayRect(
434 gfx::Rect(mirroring_context_->mirrored_left_coord( 434 gfx::Rect(mirroring_context_->mirrored_left_coord(
435 prefix_x, prefix_x + prefix_width), 435 prefix_x, prefix_x + prefix_width),
436 y, prefix_width, GetContentLineHeight())); 436 y, prefix_width, GetContentLineHeight()));
437 prefix_render_text->Draw(canvas); 437 prefix_render_text->Draw(canvas);
438 } 438 }
439 439
440 // No text should be drawn within the right margin.
Peter Kasting 2015/08/18 19:55:37 This isn't the right way to do this. You need to
tdanderson 2015/08/19 17:22:35 OK, please take a look at what I've done in Patch
441 if (ui::MaterialDesignController::IsModeMaterial())
442 right_x = std::min(right_x, width() - RightOffset());
443
440 // Set the display rect to trigger eliding. 444 // Set the display rect to trigger eliding.
441 render_text->SetDisplayRect( 445 render_text->SetDisplayRect(
442 gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y, 446 gfx::Rect(mirroring_context_->mirrored_left_coord(x, right_x), y,
443 right_x - x, GetContentLineHeight())); 447 right_x - x, GetContentLineHeight()));
444 render_text->Draw(canvas); 448 render_text->Draw(canvas);
445 return right_x; 449 return right_x;
446 } 450 }
447 451
448 scoped_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText( 452 scoped_ptr<gfx::RenderText> OmniboxResultView::CreateRenderText(
449 const base::string16& text) const { 453 const base::string16& text) const {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // |theme_provider| can be null when animations are running during shutdown, 623 // |theme_provider| can be null when animations are running during shutdown,
620 // after OmniboxResultView has been removed from the tree of Views. 624 // after OmniboxResultView has been removed from the tree of Views.
621 if (!theme_provider) 625 if (!theme_provider)
622 return; 626 return;
623 const int horizontal_padding = theme_provider->GetDisplayProperty( 627 const int horizontal_padding = theme_provider->GetDisplayProperty(
624 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING); 628 ThemeProperties::PROPERTY_LOCATION_BAR_HORIZONTAL_PADDING);
625 const int trailing_padding = theme_provider->GetDisplayProperty( 629 const int trailing_padding = theme_provider->GetDisplayProperty(
626 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING); 630 ThemeProperties::PROPERTY_ICON_LABEL_VIEW_TRAILING_PADDING);
627 631
628 icon_bounds_.SetRect( 632 icon_bounds_.SetRect(
629 horizontal_padding + 633 horizontal_padding + LeftOffset() +
Peter Kasting 2015/08/18 19:55:37 Nit: If we create two more temps: const int sta
tdanderson 2015/08/19 17:22:35 Thanks, should've caught that. Done.
630 ((icon.width() == default_icon_size_) ? 0 : trailing_padding), 634 ((icon.width() == default_icon_size_) ? 0 : trailing_padding),
631 (GetContentLineHeight() - icon.height()) / 2, icon.width(), 635 (GetContentLineHeight() - icon.height()) / 2, icon.width(),
632 icon.height()); 636 icon.height());
633 637
634 int text_x = (2 * horizontal_padding) + default_icon_size_; 638 const int text_x =
635 int text_width = width() - text_x - horizontal_padding; 639 LeftOffset() + (2 * horizontal_padding) + default_icon_size_;
640 int text_width = width() - text_x - horizontal_padding - RightOffset();
636 641
637 if (match_.associated_keyword.get()) { 642 if (match_.associated_keyword.get()) {
638 const int kw_collapsed_size = keyword_icon_->width() + horizontal_padding; 643 const int kw_collapsed_size = keyword_icon_->width() + horizontal_padding;
639 const int max_kw_x = width() - kw_collapsed_size; 644 const int max_kw_x = width() - kw_collapsed_size - RightOffset();
640 const int kw_x = 645 const int kw_x = animation_->CurrentValueBetween(
641 animation_->CurrentValueBetween(max_kw_x, horizontal_padding); 646 max_kw_x, LeftOffset() + horizontal_padding);
647
642 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding; 648 const int kw_text_x = kw_x + keyword_icon_->width() + horizontal_padding;
643
644 text_width = kw_x - text_x - horizontal_padding; 649 text_width = kw_x - text_x - horizontal_padding;
645 keyword_text_bounds_.SetRect( 650 keyword_text_bounds_.SetRect(
646 kw_text_x, 0, std::max(width() - kw_text_x - horizontal_padding, 0), 651 kw_text_x, 0, std::max(width() - kw_text_x - horizontal_padding, 0),
647 height()); 652 height());
648 keyword_icon_->SetPosition( 653 keyword_icon_->SetPosition(
649 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2)); 654 gfx::Point(kw_x, (height() - keyword_icon_->height()) / 2));
650 } 655 }
651 656
652 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height()); 657 text_bounds_.SetRect(text_x, 0, std::max(text_width, 0), height());
653 } 658 }
654 659
655 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 660 void OmniboxResultView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
656 animation_->SetSlideDuration(width() / 4); 661 animation_->SetSlideDuration((width() - LeftOffset() - RightOffset()) / 4);
657 } 662 }
658 663
659 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) { 664 void OmniboxResultView::OnPaint(gfx::Canvas* canvas) {
660 const ResultViewState state = GetState(); 665 const ResultViewState state = GetState();
661 if (state != NORMAL) 666 if (state != NORMAL)
662 canvas->DrawColor(GetColor(state, BACKGROUND)); 667 canvas->DrawColor(GetColor(state, BACKGROUND));
663 668
664 // NOTE: While animating the keyword match, both matches may be visible. 669 // NOTE: While animating the keyword match, both matches may be visible.
665 670
666 if (!ShowOnlyKeywordMatch()) { 671 if (!ShowOnlyKeywordMatch()) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 gfx::Range range(offset, offset + text.length()); 798 gfx::Range range(offset, offset + text.length());
794 destination->AppendText(text); 799 destination->AppendText(text);
795 const TextStyle& text_style = GetTextStyle(text_type); 800 const TextStyle& text_style = GetTextStyle(text_type);
796 // TODO(dschuyler): follow up on the problem of different font sizes within 801 // TODO(dschuyler): follow up on the problem of different font sizes within
797 // one RenderText. Maybe with destination->SetFontList(...). 802 // one RenderText. Maybe with destination->SetFontList(...).
798 destination->ApplyStyle(gfx::BOLD, is_bold, range); 803 destination->ApplyStyle(gfx::BOLD, is_bold, range);
799 destination->ApplyColor( 804 destination->ApplyColor(
800 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range); 805 GetNativeTheme()->GetSystemColor(text_style.colors[GetState()]), range);
801 destination->ApplyBaselineStyle(text_style.baseline, range); 806 destination->ApplyBaselineStyle(text_style.baseline, range);
802 } 807 }
808
809 int OmniboxResultView::LeftOffset() const {
810 if (ui::MaterialDesignController::IsModeMaterial())
Peter Kasting 2015/08/18 19:55:37 Nit: Shorter: return ui::MaterialDesignControll
tdanderson 2015/08/19 17:22:35 Done.
811 return model_->left_margin();
812 return 0;
813 }
814
815 int OmniboxResultView::RightOffset() const {
816 if (ui::MaterialDesignController::IsModeMaterial())
817 return model_->right_margin();
818 return 0;
819 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698