OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/status_bubble_gtk.h" | 5 #include "chrome/browser/gtk/status_bubble_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "app/slide_animation.h" | |
12 #include "app/text_elider.h" | 11 #include "app/text_elider.h" |
13 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
14 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
15 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/gtk/gtk_theme_provider.h" | 15 #include "chrome/browser/gtk/gtk_theme_provider.h" |
17 #include "chrome/browser/gtk/gtk_util.h" | 16 #include "chrome/browser/gtk/gtk_util.h" |
18 #include "chrome/browser/gtk/rounded_window.h" | 17 #include "chrome/browser/gtk/rounded_window.h" |
19 #include "chrome/browser/gtk/slide_animator_gtk.h" | 18 #include "chrome/browser/gtk/slide_animator_gtk.h" |
20 #include "chrome/common/notification_service.h" | 19 #include "chrome/common/notification_service.h" |
| 20 #include "ui/base/animation/slide_animation.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Inner padding between the border and the text label. | 24 // Inner padding between the border and the text label. |
25 const int kInternalTopBottomPadding = 1; | 25 const int kInternalTopBottomPadding = 1; |
26 const int kInternalLeftRightPadding = 2; | 26 const int kInternalLeftRightPadding = 2; |
27 | 27 |
28 // The radius of the edges of our bubble. | 28 // The radius of the edges of our bubble. |
29 const int kCornerSize = 3; | 29 const int kCornerSize = 3; |
30 | 30 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 flip_horizontally ? | 308 flip_horizontally ? |
309 gtk_util::ROUNDED_TOP_LEFT : | 309 gtk_util::ROUNDED_TOP_LEFT : |
310 gtk_util::ROUNDED_TOP_RIGHT, | 310 gtk_util::ROUNDED_TOP_RIGHT, |
311 gtk_util::BORDER_TOP | | 311 gtk_util::BORDER_TOP | |
312 (flip_horizontally ? gtk_util::BORDER_LEFT : gtk_util::BORDER_RIGHT)); | 312 (flip_horizontally ? gtk_util::BORDER_LEFT : gtk_util::BORDER_RIGHT)); |
313 gtk_widget_queue_draw(container_.get()); | 313 gtk_widget_queue_draw(container_.get()); |
314 } | 314 } |
315 | 315 |
316 void StatusBubbleGtk::ExpandURL() { | 316 void StatusBubbleGtk::ExpandURL() { |
317 start_width_ = label_->allocation.width; | 317 start_width_ = label_->allocation.width; |
318 expand_animation_.reset(new SlideAnimation(this)); | 318 expand_animation_.reset(new ui::SlideAnimation(this)); |
319 expand_animation_->SetTweenType(Tween::LINEAR); | 319 expand_animation_->SetTweenType(ui::Tween::LINEAR); |
320 expand_animation_->Show(); | 320 expand_animation_->Show(); |
321 | 321 |
322 SetStatusTextToURL(); | 322 SetStatusTextToURL(); |
323 } | 323 } |
324 | 324 |
325 void StatusBubbleGtk::UpdateLabelSizeRequest() { | 325 void StatusBubbleGtk::UpdateLabelSizeRequest() { |
326 if (!expanded() || !expand_animation_->is_animating()) { | 326 if (!expanded() || !expand_animation_->is_animating()) { |
327 gtk_widget_set_size_request(label_, -1, -1); | 327 gtk_widget_set_size_request(label_, -1, -1); |
328 return; | 328 return; |
329 } | 329 } |
330 | 330 |
331 int new_width = start_width_ + | 331 int new_width = start_width_ + |
332 (desired_width_ - start_width_) * expand_animation_->GetCurrentValue(); | 332 (desired_width_ - start_width_) * expand_animation_->GetCurrentValue(); |
333 gtk_widget_set_size_request(label_, new_width, -1); | 333 gtk_widget_set_size_request(label_, new_width, -1); |
334 } | 334 } |
335 | 335 |
336 gboolean StatusBubbleGtk::HandleMotionNotify(GtkWidget* sender, | 336 gboolean StatusBubbleGtk::HandleMotionNotify(GtkWidget* sender, |
337 GdkEventMotion* event) { | 337 GdkEventMotion* event) { |
338 MouseMoved(gfx::Point(event->x_root, event->y_root), false); | 338 MouseMoved(gfx::Point(event->x_root, event->y_root), false); |
339 return FALSE; | 339 return FALSE; |
340 } | 340 } |
341 | 341 |
342 void StatusBubbleGtk::AnimationEnded(const Animation* animation) { | 342 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { |
343 UpdateLabelSizeRequest(); | 343 UpdateLabelSizeRequest(); |
344 } | 344 } |
345 | 345 |
346 void StatusBubbleGtk::AnimationProgressed(const Animation* animation) { | 346 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { |
347 UpdateLabelSizeRequest(); | 347 UpdateLabelSizeRequest(); |
348 } | 348 } |
OLD | NEW |