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

Side by Side Diff: chrome/browser/ui/views/translate/translate_bubble_view.cc

Issue 2904443006: Views/Harmony Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Add layout_constants.h back to dialog_example.cc as it refers to kUnrelatedControlVerticalSpacing. … Created 3 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/translate/translate_bubble_view.h" 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/i18n/string_compare.h" 13 #include "base/i18n/string_compare.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/translate/chrome_translate_client.h" 19 #include "chrome/browser/translate/chrome_translate_client.h"
20 #include "chrome/browser/translate/translate_service.h" 20 #include "chrome/browser/translate/translate_service.h"
21 #include "chrome/browser/ui/browser_dialogs.h" 21 #include "chrome/browser/ui/browser_dialogs.h"
22 #include "chrome/browser/ui/chrome_pages.h" 22 #include "chrome/browser/ui/chrome_pages.h"
23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" 23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h"
24 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" 24 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h"
25 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
27 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
28 #include "components/strings/grit/components_strings.h" 29 #include "components/strings/grit/components_strings.h"
29 #include "components/translate/core/browser/translate_download_manager.h" 30 #include "components/translate/core/browser/translate_download_manager.h"
30 #include "components/translate/core/browser/translate_manager.h" 31 #include "components/translate/core/browser/translate_manager.h"
31 #include "components/translate/core/browser/translate_prefs.h" 32 #include "components/translate/core/browser/translate_prefs.h"
32 #include "components/translate/core/browser/translate_ui_delegate.h" 33 #include "components/translate/core/browser/translate_ui_delegate.h"
33 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
34 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/models/combobox_model.h" 36 #include "ui/base/models/combobox_model.h"
36 #include "ui/base/models/simple_combobox_model.h" 37 #include "ui/base/models/simple_combobox_model.h"
37 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/resources/grit/ui_resources.h" 39 #include "ui/resources/grit/ui_resources.h"
39 #include "ui/views/bubble/bubble_frame_view.h" 40 #include "ui/views/bubble/bubble_frame_view.h"
40 #include "ui/views/controls/button/blue_button.h" 41 #include "ui/views/controls/button/blue_button.h"
41 #include "ui/views/controls/button/checkbox.h" 42 #include "ui/views/controls/button/checkbox.h"
42 #include "ui/views/controls/button/label_button.h" 43 #include "ui/views/controls/button/label_button.h"
43 #include "ui/views/controls/button/md_text_button.h" 44 #include "ui/views/controls/button/md_text_button.h"
44 #include "ui/views/controls/button/menu_button.h" 45 #include "ui/views/controls/button/menu_button.h"
45 #include "ui/views/controls/combobox/combobox.h" 46 #include "ui/views/controls/combobox/combobox.h"
46 #include "ui/views/controls/label.h" 47 #include "ui/views/controls/label.h"
47 #include "ui/views/controls/link.h" 48 #include "ui/views/controls/link.h"
48 #include "ui/views/controls/styled_label.h" 49 #include "ui/views/controls/styled_label.h"
49 #include "ui/views/layout/box_layout.h" 50 #include "ui/views/layout/box_layout.h"
50 #include "ui/views/layout/grid_layout.h" 51 #include "ui/views/layout/grid_layout.h"
51 #include "ui/views/layout/layout_constants.h"
52 #include "ui/views/widget/widget.h" 52 #include "ui/views/widget/widget.h"
53 53
54 namespace { 54 namespace {
55 55
56 views::Link* CreateLink(views::LinkListener* listener, 56 views::Link* CreateLink(views::LinkListener* listener,
57 int resource_id, 57 int resource_id,
58 int id) { 58 int id) {
59 views::Link* link = new views::Link(l10n_util::GetStringUTF16(resource_id)); 59 views::Link* link = new views::Link(l10n_util::GetStringUTF16(resource_id));
60 link->set_listener(listener); 60 link->set_listener(listener);
61 link->set_id(id); 61 link->set_id(id);
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 views::GridLayout* layout = new views::GridLayout(view); 539 views::GridLayout* layout = new views::GridLayout(view);
540 view->SetLayoutManager(layout); 540 view->SetLayoutManager(layout);
541 541
542 using views::GridLayout; 542 using views::GridLayout;
543 543
544 enum { 544 enum {
545 COLUMN_SET_ID_MESSAGE, 545 COLUMN_SET_ID_MESSAGE,
546 COLUMN_SET_ID_CONTENT, 546 COLUMN_SET_ID_CONTENT,
547 }; 547 };
548 548
549 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
550 const int button_spacing =
551 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
552
549 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 553 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
550 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 554 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
551 GridLayout::USE_PREF, 0, 0); 555 GridLayout::USE_PREF, 0, 0);
552 if (Use2016Q2UI()) { 556 if (Use2016Q2UI()) {
553 // Add padding between the icon and the text. 557 // Add padding between the icon and the text.
554 cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); 558 cs->AddPaddingColumn(
559 0, provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL));
555 } else { 560 } else {
556 // Add padding between the text and the link. 561 // Add padding between the text and the link.
557 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 562 cs->AddPaddingColumn(0, button_spacing);
558 } 563 }
559 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, 564 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
560 GridLayout::USE_PREF, 0, 0); 565 GridLayout::USE_PREF, 0, 0);
561 cs->AddPaddingColumn(1, 0); 566 cs->AddPaddingColumn(1, 0);
562 567
563 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 568 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
564 cs->AddPaddingColumn(1, 0); 569 cs->AddPaddingColumn(1, 0);
565 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 570 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
566 GridLayout::USE_PREF, 0, 0); 571 GridLayout::USE_PREF, 0, 0);
567 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 572 cs->AddPaddingColumn(0, button_spacing);
568 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 573 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
569 GridLayout::USE_PREF, 0, 0); 574 GridLayout::USE_PREF, 0, 0);
570 575
571 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 576 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
572 if (Use2016Q2UI()) { 577 if (Use2016Q2UI()) {
573 AddIconToLayout(layout); 578 AddIconToLayout(layout);
574 579
575 base::string16 target_language_name = 580 base::string16 target_language_name =
576 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); 581 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex());
577 std::vector<size_t> offsets; 582 std::vector<size_t> offsets;
(...skipping 17 matching lines...) Expand all
595 layout->AddView(styled_label); 600 layout->AddView(styled_label);
596 } else { 601 } else {
597 layout->AddView(new views::Label( 602 layout->AddView(new views::Label(
598 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE))); 603 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_BEFORE_TRANSLATE)));
599 layout->AddView( 604 layout->AddView(
600 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 605 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
601 } 606 }
602 607
603 // In an incognito window, the "Always translate" checkbox shouldn't be shown. 608 // In an incognito window, the "Always translate" checkbox shouldn't be shown.
604 if (Use2016Q2UI() && !is_in_incognito_window_) { 609 if (Use2016Q2UI() && !is_in_incognito_window_) {
605 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 610 layout->AddPaddingRow(0, provider->GetDistanceMetric(
611 views::DISTANCE_RELATED_CONTROL_VERTICAL));
606 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 612 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
607 layout->SkipColumns(1); 613 layout->SkipColumns(1);
608 before_always_translate_checkbox_ = new views::Checkbox( 614 before_always_translate_checkbox_ = new views::Checkbox(
609 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS_DO_THIS)); 615 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS_DO_THIS));
610 before_always_translate_checkbox_->set_id(BUTTON_ID_ALWAYS_TRANSLATE); 616 before_always_translate_checkbox_->set_id(BUTTON_ID_ALWAYS_TRANSLATE);
611 before_always_translate_checkbox_->set_listener(this); 617 before_always_translate_checkbox_->set_listener(this);
612 layout->AddView(before_always_translate_checkbox_); 618 layout->AddView(before_always_translate_checkbox_);
613 } 619 }
614 if (Use2016Q2UI()) { 620
615 layout->AddPaddingRow(0, views::kPanelSubVerticalSpacing); 621 layout->AddPaddingRow(0, provider->GetDistanceMetric(
616 } else { 622 DISTANCE_UNRELATED_CONTROL_VERTICAL));
617 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
618 }
619 623
620 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 624 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
621 views::LabelButton* accept_button = 625 views::LabelButton* accept_button =
622 Use2016Q2UI() 626 Use2016Q2UI()
623 ? views::MdTextButton::CreateSecondaryUiBlueButton( 627 ? views::MdTextButton::CreateSecondaryUiBlueButton(
624 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT)) 628 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT))
625 : views::MdTextButton::CreateSecondaryUiButton( 629 : views::MdTextButton::CreateSecondaryUiButton(
626 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT)); 630 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT));
627 accept_button->set_id(BUTTON_ID_TRANSLATE); 631 accept_button->set_id(BUTTON_ID_TRANSLATE);
628 layout->AddView(accept_button); 632 layout->AddView(accept_button);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 views::GridLayout* layout = new views::GridLayout(view); 668 views::GridLayout* layout = new views::GridLayout(view);
665 view->SetLayoutManager(layout); 669 view->SetLayoutManager(layout);
666 670
667 using views::GridLayout; 671 using views::GridLayout;
668 672
669 enum { 673 enum {
670 COLUMN_SET_ID_MESSAGE, 674 COLUMN_SET_ID_MESSAGE,
671 COLUMN_SET_ID_CONTENT, 675 COLUMN_SET_ID_CONTENT,
672 }; 676 };
673 677
678 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
674 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 679 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
675 if (Use2016Q2UI()) { 680 if (Use2016Q2UI()) {
676 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 681 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
677 views::GridLayout::USE_PREF, 0, 0); 682 views::GridLayout::USE_PREF, 0, 0);
678 // Add padding between the icon and the text. 683 // Add padding between the icon and the text.
679 cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); 684 cs->AddPaddingColumn(
685 0, provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL));
680 } 686 }
681 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 687 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
682 GridLayout::USE_PREF, 0, 0); 688 GridLayout::USE_PREF, 0, 0);
683 cs->AddPaddingColumn(1, 0); 689 cs->AddPaddingColumn(1, 0);
684 690
685 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 691 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
686 cs->AddPaddingColumn(1, 0); 692 cs->AddPaddingColumn(1, 0);
687 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 693 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
688 GridLayout::USE_PREF, 0, 0); 694 GridLayout::USE_PREF, 0, 0);
689 695
690 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 696 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
691 if (Use2016Q2UI()) 697 if (Use2016Q2UI())
692 AddIconToLayout(layout); 698 AddIconToLayout(layout);
693 layout->AddView(label); 699 layout->AddView(label);
694 700
695 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 701 layout->AddPaddingRow(
702 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
696 703
697 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 704 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
698 views::LabelButton* revert_button = 705 views::LabelButton* revert_button =
699 views::MdTextButton::CreateSecondaryUiButton( 706 views::MdTextButton::CreateSecondaryUiButton(
700 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT)); 707 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT));
701 revert_button->set_id(BUTTON_ID_SHOW_ORIGINAL); 708 revert_button->set_id(BUTTON_ID_SHOW_ORIGINAL);
702 revert_button->SetEnabled(false); 709 revert_button->SetEnabled(false);
703 layout->AddView(revert_button); 710 layout->AddView(revert_button);
704 711
705 return view; 712 return view;
706 } 713 }
707 714
708 views::View* TranslateBubbleView::CreateViewAfterTranslate() { 715 views::View* TranslateBubbleView::CreateViewAfterTranslate() {
709 views::Label* label = new views::Label( 716 views::Label* label = new views::Label(
710 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRANSLATED)); 717 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRANSLATED));
711 718
712 views::View* view = new views::View(); 719 views::View* view = new views::View();
713 views::GridLayout* layout = new views::GridLayout(view); 720 views::GridLayout* layout = new views::GridLayout(view);
714 view->SetLayoutManager(layout); 721 view->SetLayoutManager(layout);
715 722
716 using views::GridLayout; 723 using views::GridLayout;
717 724
718 enum { 725 enum {
719 COLUMN_SET_ID_MESSAGE, 726 COLUMN_SET_ID_MESSAGE,
720 COLUMN_SET_ID_CONTENT, 727 COLUMN_SET_ID_CONTENT,
721 }; 728 };
722 729
730 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
731
723 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 732 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
724 733
725 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351 734 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351
726 735
727 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 736 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
728 GridLayout::USE_PREF, 0, 0); 737 GridLayout::USE_PREF, 0, 0);
729 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 738 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
739 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
730 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 740 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
731 GridLayout::USE_PREF, 0, 0); 741 GridLayout::USE_PREF, 0, 0);
732 cs->AddPaddingColumn(1, 0); 742 cs->AddPaddingColumn(1, 0);
733 743
734 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 744 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
735 cs->AddPaddingColumn(1, 0); 745 cs->AddPaddingColumn(1, 0);
736 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 746 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
737 GridLayout::USE_PREF, 0, 0); 747 GridLayout::USE_PREF, 0, 0);
738 748
739 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 749 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
740 layout->AddView(label); 750 layout->AddView(label);
741 layout->AddView( 751 layout->AddView(
742 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 752 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
743 753
744 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 754 layout->AddPaddingRow(
755 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
745 756
746 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 757 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
747 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 758 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
748 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT)); 759 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_REVERT));
749 button->set_id(BUTTON_ID_SHOW_ORIGINAL); 760 button->set_id(BUTTON_ID_SHOW_ORIGINAL);
750 layout->AddView(button); 761 layout->AddView(button);
751 762
752 return view; 763 return view;
753 } 764 }
754 765
755 views::View* TranslateBubbleView::CreateViewError() { 766 views::View* TranslateBubbleView::CreateViewError() {
756 views::Label* label = new views::Label( 767 views::Label* label = new views::Label(
757 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_COULD_NOT_TRANSLATE)); 768 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_COULD_NOT_TRANSLATE));
758 769
759 views::View* view = new views::View(); 770 views::View* view = new views::View();
760 views::GridLayout* layout = new views::GridLayout(view); 771 views::GridLayout* layout = new views::GridLayout(view);
761 view->SetLayoutManager(layout); 772 view->SetLayoutManager(layout);
762 773
763 using views::GridLayout; 774 using views::GridLayout;
764 775
765 enum { 776 enum {
766 COLUMN_SET_ID_MESSAGE, 777 COLUMN_SET_ID_MESSAGE,
767 COLUMN_SET_ID_CONTENT, 778 COLUMN_SET_ID_CONTENT,
768 }; 779 };
769 780
781 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
782
770 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE); 783 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_MESSAGE);
771 784
772 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351 785 // TODO(ftang) Restore icon without causing layout defects: crbug.com/610351
773 786
774 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 787 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
775 GridLayout::USE_PREF, 0, 0); 788 GridLayout::USE_PREF, 0, 0);
776 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 789 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
790 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
777 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 791 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
778 GridLayout::USE_PREF, 0, 0); 792 GridLayout::USE_PREF, 0, 0);
779 cs->AddPaddingColumn(1, 0); 793 cs->AddPaddingColumn(1, 0);
780 794
781 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT); 795 cs = layout->AddColumnSet(COLUMN_SET_ID_CONTENT);
782 cs->AddPaddingColumn(1, 0); 796 cs->AddPaddingColumn(1, 0);
783 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 797 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
784 GridLayout::USE_PREF, 0, 0); 798 GridLayout::USE_PREF, 0, 0);
785 799
786 layout->StartRow(0, COLUMN_SET_ID_MESSAGE); 800 layout->StartRow(0, COLUMN_SET_ID_MESSAGE);
787 layout->AddView(label); 801 layout->AddView(label);
788 layout->AddView( 802 layout->AddView(
789 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED)); 803 CreateLink(this, IDS_TRANSLATE_BUBBLE_ADVANCED, LINK_ID_ADVANCED));
790 804
791 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 805 layout->AddPaddingRow(
806 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
792 807
793 layout->StartRow(0, COLUMN_SET_ID_CONTENT); 808 layout->StartRow(0, COLUMN_SET_ID_CONTENT);
794 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( 809 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton(
795 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRY_AGAIN)); 810 this, l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_TRY_AGAIN));
796 button->set_id(BUTTON_ID_TRY_AGAIN); 811 button->set_id(BUTTON_ID_TRY_AGAIN);
797 layout->AddView(button); 812 layout->AddView(button);
798 813
799 return view; 814 return view;
800 } 815 }
801 816
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 views::GridLayout* layout = new views::GridLayout(view); 852 views::GridLayout* layout = new views::GridLayout(view);
838 view->SetLayoutManager(layout); 853 view->SetLayoutManager(layout);
839 854
840 using views::GridLayout; 855 using views::GridLayout;
841 856
842 enum { 857 enum {
843 COLUMN_SET_ID_LANGUAGES, 858 COLUMN_SET_ID_LANGUAGES,
844 COLUMN_SET_ID_BUTTONS, 859 COLUMN_SET_ID_BUTTONS,
845 }; 860 };
846 861
862 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
863
847 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_LANGUAGES); 864 views::ColumnSet* cs = layout->AddColumnSet(COLUMN_SET_ID_LANGUAGES);
848 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 865 cs->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
849 GridLayout::USE_PREF, 0, 0); 866 GridLayout::USE_PREF, 0, 0);
850 cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 867 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
868 views::DISTANCE_RELATED_CONTROL_HORIZONTAL));
851 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF, 869 cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, GridLayout::USE_PREF,
852 0, 0); 870 0, 0);
853 cs->AddPaddingColumn(1, 0); 871 cs->AddPaddingColumn(1, 0);
854 872
855 cs = layout->AddColumnSet(COLUMN_SET_ID_BUTTONS); 873 cs = layout->AddColumnSet(COLUMN_SET_ID_BUTTONS);
856 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 874 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
857 GridLayout::USE_PREF, 0, 0); 875 GridLayout::USE_PREF, 0, 0);
858 cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing); 876 cs->AddPaddingColumn(
877 1, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
859 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 878 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
860 GridLayout::USE_PREF, 0, 0); 879 GridLayout::USE_PREF, 0, 0);
861 cs->AddPaddingColumn(0, views::kRelatedButtonHSpacing); 880 cs->AddPaddingColumn(0, provider->GetDistanceMetric(
881 views::DISTANCE_RELATED_BUTTON_HORIZONTAL));
862 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 882 cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
863 GridLayout::USE_PREF, 0, 0); 883 GridLayout::USE_PREF, 0, 0);
864 884
865 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 885 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
866 layout->AddView(source_language_label); 886 layout->AddView(source_language_label);
867 layout->AddView(source_language_combobox_); 887 layout->AddView(source_language_combobox_);
868 888
869 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 889 const int vertical_spacing =
890 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
891 layout->AddPaddingRow(0, vertical_spacing);
870 892
871 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 893 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
872 layout->AddView(target_language_label); 894 layout->AddView(target_language_label);
873 layout->AddView(target_language_combobox_); 895 layout->AddView(target_language_combobox_);
874 896
875 if (!is_in_incognito_window_) { 897 if (!is_in_incognito_window_) {
876 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 898 layout->AddPaddingRow(0, vertical_spacing);
877 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES); 899 layout->StartRow(0, COLUMN_SET_ID_LANGUAGES);
878 layout->SkipColumns(1); 900 layout->SkipColumns(1);
879 layout->AddView(advanced_always_translate_checkbox_); 901 layout->AddView(advanced_always_translate_checkbox_);
880 } 902 }
881 903
882 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 904 layout->AddPaddingRow(
905 0, provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL));
883 906
884 layout->StartRow(0, COLUMN_SET_ID_BUTTONS); 907 layout->StartRow(0, COLUMN_SET_ID_BUTTONS);
885 // TODO(estade): this should use CreateExtraView(). 908 // TODO(estade): this should use CreateExtraView().
886 layout->AddView(CreateLink(this, IDS_TRANSLATE_BUBBLE_LANGUAGE_SETTINGS, 909 layout->AddView(CreateLink(this, IDS_TRANSLATE_BUBBLE_LANGUAGE_SETTINGS,
887 LINK_ID_LANGUAGE_SETTINGS)); 910 LINK_ID_LANGUAGE_SETTINGS));
888 advanced_done_button_ = 911 advanced_done_button_ =
889 Use2016Q2UI() ? views::MdTextButton::CreateSecondaryUiBlueButton( 912 Use2016Q2UI() ? views::MdTextButton::CreateSecondaryUiBlueButton(
890 this, l10n_util::GetStringUTF16(IDS_DONE)) 913 this, l10n_util::GetStringUTF16(IDS_DONE))
891 : views::MdTextButton::CreateSecondaryUiButton( 914 : views::MdTextButton::CreateSecondaryUiButton(
892 this, l10n_util::GetStringUTF16(IDS_DONE)); 915 this, l10n_util::GetStringUTF16(IDS_DONE));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 base::string16 label; 977 base::string16 label;
955 if (model_->IsPageTranslatedInCurrentLanguages()) 978 if (model_->IsPageTranslatedInCurrentLanguages())
956 label = l10n_util::GetStringUTF16(IDS_DONE); 979 label = l10n_util::GetStringUTF16(IDS_DONE);
957 else 980 else
958 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 981 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
959 advanced_done_button_->SetText(label); 982 advanced_done_button_->SetText(label);
960 advanced_done_button_->SizeToPreferredSize(); 983 advanced_done_button_->SizeToPreferredSize();
961 if (advanced_view_) 984 if (advanced_view_)
962 advanced_view_->Layout(); 985 advanced_view_->Layout();
963 } 986 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698