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

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

Issue 2898633004: Layout the translate bubble after changing child view visibility. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | 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 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>
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 void TranslateBubbleView::UpdateChildVisibilities() { 513 void TranslateBubbleView::UpdateChildVisibilities() {
514 // Update the statew of the always translate checkbox 514 // Update the statew of the always translate checkbox
515 if (advanced_always_translate_checkbox_) 515 if (advanced_always_translate_checkbox_)
516 advanced_always_translate_checkbox_->SetChecked(should_always_translate_); 516 advanced_always_translate_checkbox_->SetChecked(should_always_translate_);
517 if (before_always_translate_checkbox_) 517 if (before_always_translate_checkbox_)
518 before_always_translate_checkbox_->SetChecked(should_always_translate_); 518 before_always_translate_checkbox_->SetChecked(should_always_translate_);
519 for (int i = 0; i < child_count(); i++) { 519 for (int i = 0; i < child_count(); i++) {
520 views::View* view = child_at(i); 520 views::View* view = child_at(i);
521 view->SetVisible(view == GetCurrentView()); 521 view->SetVisible(view == GetCurrentView());
522 } 522 }
523 // BoxLayout only considers visible children, so ensure any newly visible
524 // child views are positioned correctly.
525 Layout();
523 } 526 }
524 527
525 views::View* TranslateBubbleView::CreateViewBeforeTranslate() { 528 views::View* TranslateBubbleView::CreateViewBeforeTranslate() {
526 const int kQuestionWidth = 200; 529 const int kQuestionWidth = 200;
527 530
528 base::string16 original_language_name = 531 base::string16 original_language_name =
529 model_->GetLanguageNameAt(model_->GetOriginalLanguageIndex()); 532 model_->GetLanguageNameAt(model_->GetOriginalLanguageIndex());
530 if (original_language_name.empty()) { 533 if (original_language_name.empty()) {
531 original_language_name = 534 original_language_name =
532 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_UNKNOWN_LANGUAGE); 535 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_UNKNOWN_LANGUAGE);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 return nullptr; 915 return nullptr;
913 } 916 }
914 } 917 }
915 918
916 void TranslateBubbleView::SwitchView( 919 void TranslateBubbleView::SwitchView(
917 TranslateBubbleModel::ViewState view_state) { 920 TranslateBubbleModel::ViewState view_state) {
918 if (model_->GetViewState() == view_state) 921 if (model_->GetViewState() == view_state)
919 return; 922 return;
920 923
921 model_->SetViewState(view_state); 924 model_->SetViewState(view_state);
922 UpdateChildVisibilities();
923 if (view_state == TranslateBubbleModel::VIEW_STATE_ADVANCED) 925 if (view_state == TranslateBubbleModel::VIEW_STATE_ADVANCED)
924 UpdateAdvancedView(); 926 UpdateAdvancedView();
927 UpdateChildVisibilities();
925 SizeToContents(); 928 SizeToContents();
926 } 929 }
927 930
928 void TranslateBubbleView::SwitchToErrorView( 931 void TranslateBubbleView::SwitchToErrorView(
929 translate::TranslateErrors::Type error_type) { 932 translate::TranslateErrors::Type error_type) {
930 SwitchView(TranslateBubbleModel::VIEW_STATE_ERROR); 933 SwitchView(TranslateBubbleModel::VIEW_STATE_ERROR);
931 error_type_ = error_type; 934 error_type_ = error_type;
932 model_->ShowError(error_type); 935 model_->ShowError(error_type);
933 } 936 }
934 937
(...skipping 16 matching lines...) Expand all
951 base::string16 label; 954 base::string16 label;
952 if (model_->IsPageTranslatedInCurrentLanguages()) 955 if (model_->IsPageTranslatedInCurrentLanguages())
953 label = l10n_util::GetStringUTF16(IDS_DONE); 956 label = l10n_util::GetStringUTF16(IDS_DONE);
954 else 957 else
955 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 958 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
956 advanced_done_button_->SetText(label); 959 advanced_done_button_->SetText(label);
957 advanced_done_button_->SizeToPreferredSize(); 960 advanced_done_button_->SizeToPreferredSize();
958 if (advanced_view_) 961 if (advanced_view_)
959 advanced_view_->Layout(); 962 advanced_view_->Layout();
960 } 963 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698