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

Side by Side Diff: chrome/browser/ui/views/location_bar/content_setting_image_view.cc

Issue 10899009: Fix assets related to ev bubble and tab to search UI elements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 3 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 | Annotate | Revision Log
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/location_bar/content_setting_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" 9 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" 10 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
(...skipping 14 matching lines...) Expand all
25 using content::WebContents; 25 using content::WebContents;
26 26
27 namespace { 27 namespace {
28 // Animation parameters. 28 // Animation parameters.
29 const int kOpenTimeMs = 150; 29 const int kOpenTimeMs = 150;
30 const int kFullOpenedTimeMs = 3200; 30 const int kFullOpenedTimeMs = 3200;
31 const int kMoveTimeMs = kFullOpenedTimeMs + 2 * kOpenTimeMs; 31 const int kMoveTimeMs = kFullOpenedTimeMs + 2 * kOpenTimeMs;
32 const int kFrameRateHz = 60; 32 const int kFrameRateHz = 60;
33 // Margins for animated box. 33 // Margins for animated box.
34 const int kTextMarginPixels = 4; 34 const int kTextMarginPixels = 4;
35 const int kIconLeftMargin = 4; 35 const int kIconLeftMargin = 2;
36 36
37 37
38 // The fraction of the animation we'll spend animating the string into view, and 38 // The fraction of the animation we'll spend animating the string into view, and
39 // then again animating it closed - total animation (slide out, show, then 39 // then again animating it closed - total animation (slide out, show, then
40 // slide in) is 1.0. 40 // slide in) is 1.0.
41 const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs; 41 const double kAnimatingFraction = kOpenTimeMs * 1.0 / kMoveTimeMs;
42 } 42 }
43 43
44 ContentSettingImageView::ContentSettingImageView( 44 ContentSettingImageView::ContentSettingImageView(
45 ContentSettingsType content_type, 45 ContentSettingsType content_type,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 slide_animator_->SetTweenType(ui::Tween::LINEAR); 104 slide_animator_->SetTweenType(ui::Tween::LINEAR);
105 } 105 }
106 // Do not start animation if already in progress. 106 // Do not start animation if already in progress.
107 if (!slide_animator_->is_animating()) { 107 if (!slide_animator_->is_animating()) {
108 // Initialize animated string. It will be cleared when animation is 108 // Initialize animated string. It will be cleared when animation is
109 // completed. 109 // completed.
110 animated_text_ = l10n_util::GetStringUTF16(animated_string_id); 110 animated_text_ = l10n_util::GetStringUTF16(animated_string_id);
111 text_size_ = ui::ResourceBundle::GetSharedInstance().GetFont( 111 text_size_ = ui::ResourceBundle::GetSharedInstance().GetFont(
112 ui::ResourceBundle::MediumFont).GetStringWidth(animated_text_); 112 ui::ResourceBundle::MediumFont).GetStringWidth(animated_text_);
113 text_size_ += 2 * kTextMarginPixels + kIconLeftMargin; 113 text_size_ += 2 * kTextMarginPixels + kIconLeftMargin;
114 if (border())
115 border()->GetInsets(&saved_insets_);
116 slide_animator_->Show(); 114 slide_animator_->Show();
117 } 115 }
118 } 116 }
119 117
120 gfx::Size ContentSettingImageView::GetPreferredSize() { 118 gfx::Size ContentSettingImageView::GetPreferredSize() {
121 gfx::Size preferred_size(views::ImageView::GetPreferredSize()); 119 gfx::Size preferred_size(views::ImageView::GetPreferredSize());
122 preferred_size.set_height(std::max(preferred_size.height(), 120 preferred_size.set_height(std::max(preferred_size.height(),
123 background_painter_.height())); 121 background_painter_.height()));
124 // When view is animated visible_text_size_ > 0, it is 0 otherwise. 122 // When view is animated visible_text_size_ > 0, it is 0 otherwise.
125 preferred_size.set_width(preferred_size.width() + visible_text_size_); 123 preferred_size.set_width(preferred_size.width() + visible_text_size_);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 // is changing in size during the animation, giving the appearance of the text 213 // is changing in size during the animation, giving the appearance of the text
216 // sliding out and then back in. When the text completely slid out the yellow 214 // sliding out and then back in. When the text completely slid out the yellow
217 // border is no longer painted around the icon. |visible_text_size_| is 0 when 215 // border is no longer painted around the icon. |visible_text_size_| is 0 when
218 // animation is stopped. 216 // animation is stopped.
219 if (slide_animator_.get() && 217 if (slide_animator_.get() &&
220 (slide_animator_->is_animating() || pause_animation_)) { 218 (slide_animator_->is_animating() || pause_animation_)) {
221 // In the non-animated state borders' left() is 0, in the animated state it 219 // In the non-animated state borders' left() is 0, in the animated state it
222 // is the kIconLeftMargin, so we need to animate border reduction when it 220 // is the kIconLeftMargin, so we need to animate border reduction when it
223 // starts to disappear. 221 // starts to disappear.
224 int necessary_left_margin = std::min(kIconLeftMargin, visible_text_size_); 222 int necessary_left_margin = std::min(kIconLeftMargin, visible_text_size_);
225 views::Border* empty_border = views::Border::CreateEmptyBorder( 223 views::Border* empty_border =
226 saved_insets_.top(), 224 views::Border::CreateEmptyBorder(0, necessary_left_margin, 0, 0);
227 saved_insets_.left() + necessary_left_margin,
228 saved_insets_.bottom(),
229 saved_insets_.right());
230 set_border(empty_border); 225 set_border(empty_border);
231 views::ImageView::OnPaint(canvas); 226 views::ImageView::OnPaint(canvas);
232 227
233 // Paint text to the right of the icon. 228 // Paint text to the right of the icon.
234 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 229 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
235 canvas->DrawStringInt(animated_text_, 230 canvas->DrawStringInt(animated_text_,
236 rb.GetFont(ui::ResourceBundle::MediumFont), SK_ColorBLACK, 231 rb.GetFont(ui::ResourceBundle::MediumFont), SK_ColorBLACK,
237 GetImageBounds().right() + kTextMarginPixels, y(), 232 GetImageBounds().right() + kTextMarginPixels, 0,
238 width() - GetImageBounds().width(), height(), 233 width() - GetImageBounds().width(), height(),
239 gfx::Canvas::TEXT_ALIGN_LEFT | gfx::Canvas::TEXT_VALIGN_MIDDLE); 234 gfx::Canvas::TEXT_ALIGN_LEFT | gfx::Canvas::TEXT_VALIGN_MIDDLE);
240 } else { 235 } else {
241 views::ImageView::OnPaint(canvas); 236 views::ImageView::OnPaint(canvas);
242 } 237 }
243 } 238 }
244 239
245 void ContentSettingImageView::OnPaintBackground(gfx::Canvas* canvas) { 240 void ContentSettingImageView::OnPaintBackground(gfx::Canvas* canvas) {
246 if (slide_animator_.get() && 241 if (slide_animator_.get() &&
247 (slide_animator_->is_animating() || pause_animation_)) 242 (slide_animator_->is_animating() || pause_animation_))
(...skipping 11 matching lines...) Expand all
259 slide_animator_->Reset( 254 slide_animator_->Reset(
260 1.0 - (visible_text_size_ * kAnimatingFraction) / text_size_); 255 1.0 - (visible_text_size_ * kAnimatingFraction) / text_size_);
261 pause_animation_ = false; 256 pause_animation_ = false;
262 slide_animator_->Show(); 257 slide_animator_->Show();
263 } 258 }
264 } 259 }
265 260
266 int ContentSettingImageView::GetBuiltInHorizontalPadding() const { 261 int ContentSettingImageView::GetBuiltInHorizontalPadding() const {
267 return GetBuiltInHorizontalPaddingImpl(); 262 return GetBuiltInHorizontalPaddingImpl();
268 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698