| 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/gtk/status_bubble_gtk.h" | 5 #include "chrome/browser/ui/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 "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/themes/theme_properties.h" | 15 #include "chrome/browser/themes/theme_properties.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 16 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 17 #include "chrome/browser/ui/gtk/gtk_util.h" | 17 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 18 #include "chrome/browser/ui/gtk/rounded_window.h" | 18 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
| 20 #include "ui/base/animation/slide_animation.h" | |
| 21 #include "ui/base/gtk/gtk_hig_constants.h" | 20 #include "ui/base/gtk/gtk_hig_constants.h" |
| 21 #include "ui/gfx/animation/slide_animation.h" |
| 22 #include "ui/gfx/font.h" | 22 #include "ui/gfx/font.h" |
| 23 #include "ui/gfx/gtk_compat.h" | 23 #include "ui/gfx/gtk_compat.h" |
| 24 #include "ui/gfx/text_elider.h" | 24 #include "ui/gfx/text_elider.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Inner padding between the border and the text label. | 28 // Inner padding between the border and the text label. |
| 29 const int kInternalTopBottomPadding = 1; | 29 const int kInternalTopBottomPadding = 1; |
| 30 const int kInternalLeftRightPadding = 2; | 30 const int kInternalLeftRightPadding = 2; |
| 31 | 31 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 gtk_util::ROUNDED_TOP_RIGHT, | 333 gtk_util::ROUNDED_TOP_RIGHT, |
| 334 gtk_util::BORDER_TOP | | 334 gtk_util::BORDER_TOP | |
| 335 (flip_horizontally ? gtk_util::BORDER_LEFT : gtk_util::BORDER_RIGHT)); | 335 (flip_horizontally ? gtk_util::BORDER_LEFT : gtk_util::BORDER_RIGHT)); |
| 336 gtk_widget_queue_draw(container_.get()); | 336 gtk_widget_queue_draw(container_.get()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void StatusBubbleGtk::ExpandURL() { | 339 void StatusBubbleGtk::ExpandURL() { |
| 340 GtkAllocation allocation; | 340 GtkAllocation allocation; |
| 341 gtk_widget_get_allocation(label_.get(), &allocation); | 341 gtk_widget_get_allocation(label_.get(), &allocation); |
| 342 start_width_ = allocation.width; | 342 start_width_ = allocation.width; |
| 343 expand_animation_.reset(new ui::SlideAnimation(this)); | 343 expand_animation_.reset(new gfx::SlideAnimation(this)); |
| 344 expand_animation_->SetTweenType(ui::Tween::LINEAR); | 344 expand_animation_->SetTweenType(gfx::Tween::LINEAR); |
| 345 expand_animation_->Show(); | 345 expand_animation_->Show(); |
| 346 | 346 |
| 347 SetStatusTextToURL(); | 347 SetStatusTextToURL(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void StatusBubbleGtk::UpdateLabelSizeRequest() { | 350 void StatusBubbleGtk::UpdateLabelSizeRequest() { |
| 351 if (!expanded() || !expand_animation_->is_animating()) { | 351 if (!expanded() || !expand_animation_->is_animating()) { |
| 352 gtk_widget_set_size_request(label_.get(), -1, -1); | 352 gtk_widget_set_size_request(label_.get(), -1, -1); |
| 353 return; | 353 return; |
| 354 } | 354 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 365 MouseMoved(gfx::Point(event->x_root, event->y_root), false); | 365 MouseMoved(gfx::Point(event->x_root, event->y_root), false); |
| 366 return FALSE; | 366 return FALSE; |
| 367 } | 367 } |
| 368 | 368 |
| 369 gboolean StatusBubbleGtk::HandleMotionNotify(GtkWidget* sender, | 369 gboolean StatusBubbleGtk::HandleMotionNotify(GtkWidget* sender, |
| 370 GdkEventMotion* event) { | 370 GdkEventMotion* event) { |
| 371 MouseMoved(gfx::Point(event->x_root, event->y_root), false); | 371 MouseMoved(gfx::Point(event->x_root, event->y_root), false); |
| 372 return FALSE; | 372 return FALSE; |
| 373 } | 373 } |
| 374 | 374 |
| 375 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { | 375 void StatusBubbleGtk::AnimationEnded(const gfx::Animation* animation) { |
| 376 UpdateLabelSizeRequest(); | 376 UpdateLabelSizeRequest(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { | 379 void StatusBubbleGtk::AnimationProgressed(const gfx::Animation* animation) { |
| 380 UpdateLabelSizeRequest(); | 380 UpdateLabelSizeRequest(); |
| 381 } | 381 } |
| OLD | NEW |