OLD | NEW |
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/infobars/translate_infobar_base.h" | 5 #include "chrome/browser/ui/views/infobars/translate_infobar_base.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/translate/chrome_translate_client.h" | 8 #include "chrome/browser/translate/chrome_translate_client.h" |
9 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" | 9 #include "chrome/browser/ui/views/infobars/after_translate_infobar.h" |
10 #include "chrome/browser/ui/views/infobars/before_translate_infobar.h" | 10 #include "chrome/browser/ui/views/infobars/before_translate_infobar.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // TranslateInfoBarBase ------------------------------------------------------- | 41 // TranslateInfoBarBase ------------------------------------------------------- |
42 | 42 |
43 // static | 43 // static |
44 const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; | 44 const int TranslateInfoBarBase::kButtonInLabelSpacing = 5; |
45 | 45 |
46 void TranslateInfoBarBase::UpdateLanguageButtonText( | 46 void TranslateInfoBarBase::UpdateLanguageButtonText( |
47 views::MenuButton* button, | 47 views::MenuButton* button, |
48 const base::string16& text) { | 48 const base::string16& text) { |
49 DCHECK(button); | 49 DCHECK(button); |
50 button->SetText(text); | 50 button->SetText(text); |
51 button->ClearMaxTextSize(); | |
52 button->SizeToPreferredSize(); | 51 button->SizeToPreferredSize(); |
53 Layout(); | 52 Layout(); |
54 SchedulePaint(); | 53 SchedulePaint(); |
55 } | 54 } |
56 | 55 |
57 TranslateInfoBarBase::TranslateInfoBarBase( | 56 TranslateInfoBarBase::TranslateInfoBarBase( |
58 scoped_ptr<TranslateInfoBarDelegate> delegate) | 57 scoped_ptr<TranslateInfoBarDelegate> delegate) |
59 : InfoBarView(delegate.PassAs<infobars::InfoBarDelegate>()), | 58 : InfoBarView(delegate.PassAs<infobars::InfoBarDelegate>()), |
60 error_background_(infobars::InfoBarDelegate::WARNING_TYPE) { | 59 error_background_(infobars::InfoBarDelegate::WARNING_TYPE) { |
61 } | 60 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 122 |
124 void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas, | 123 void TranslateInfoBarBase::FadeBackground(gfx::Canvas* canvas, |
125 double animation_value, | 124 double animation_value, |
126 const views::Background& background) { | 125 const views::Background& background) { |
127 // Draw the background into an offscreen buffer with alpha value per animation | 126 // Draw the background into an offscreen buffer with alpha value per animation |
128 // value, then blend it back into the current canvas. | 127 // value, then blend it back into the current canvas. |
129 canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255)); | 128 canvas->SaveLayerAlpha(static_cast<int>(animation_value * 255)); |
130 background.Paint(canvas, this); | 129 background.Paint(canvas, this); |
131 canvas->Restore(); | 130 canvas->Restore(); |
132 } | 131 } |
OLD | NEW |