| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/notifications/balloon_view_gtk.h" | 5 #include "chrome/browser/gtk/notifications/balloon_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
| 13 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
| 14 #include "app/slide_animation.h" | |
| 15 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 16 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 17 #include "chrome/browser/browser_list.h" | 16 #include "chrome/browser/browser_list.h" |
| 18 #include "chrome/browser/browser_window.h" | 17 #include "chrome/browser/browser_window.h" |
| 19 #include "chrome/browser/extensions/extension_host.h" | 18 #include "chrome/browser/extensions/extension_host.h" |
| 20 #include "chrome/browser/extensions/extension_process_manager.h" | 19 #include "chrome/browser/extensions/extension_process_manager.h" |
| 21 #include "chrome/browser/gtk/custom_button.h" | 20 #include "chrome/browser/gtk/custom_button.h" |
| 22 #include "chrome/browser/gtk/gtk_theme_provider.h" | 21 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 23 #include "chrome/browser/gtk/gtk_util.h" | 22 #include "chrome/browser/gtk/gtk_util.h" |
| 24 #include "chrome/browser/gtk/info_bubble_gtk.h" | 23 #include "chrome/browser/gtk/info_bubble_gtk.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
| 37 #include "chrome/common/notification_details.h" | 36 #include "chrome/common/notification_details.h" |
| 38 #include "chrome/common/notification_service.h" | 37 #include "chrome/common/notification_service.h" |
| 39 #include "chrome/common/notification_source.h" | 38 #include "chrome/common/notification_source.h" |
| 40 #include "chrome/common/notification_type.h" | 39 #include "chrome/common/notification_type.h" |
| 41 #include "gfx/canvas.h" | 40 #include "gfx/canvas.h" |
| 42 #include "gfx/insets.h" | 41 #include "gfx/insets.h" |
| 43 #include "gfx/native_widget_types.h" | 42 #include "gfx/native_widget_types.h" |
| 44 #include "grit/generated_resources.h" | 43 #include "grit/generated_resources.h" |
| 45 #include "grit/theme_resources.h" | 44 #include "grit/theme_resources.h" |
| 45 #include "ui/base/animation/slide_animation.h" |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 // Margin, in pixels, between the notification frame and the contents | 49 // Margin, in pixels, between the notification frame and the contents |
| 50 // of the notification. | 50 // of the notification. |
| 51 const int kTopMargin = 0; | 51 const int kTopMargin = 0; |
| 52 const int kBottomMargin = 1; | 52 const int kBottomMargin = 1; |
| 53 const int kLeftMargin = 1; | 53 const int kLeftMargin = 1; |
| 54 const int kRightMargin = 1; | 54 const int kRightMargin = 1; |
| 55 | 55 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 gtk_window_get_position(GTK_WINDOW(frame_container_), &start_x, &start_y); | 156 gtk_window_get_position(GTK_WINDOW(frame_container_), &start_x, &start_y); |
| 157 gtk_window_get_size(GTK_WINDOW(frame_container_), &start_w, &start_h); | 157 gtk_window_get_size(GTK_WINDOW(frame_container_), &start_w, &start_h); |
| 158 | 158 |
| 159 int end_x = balloon_->GetPosition().x(); | 159 int end_x = balloon_->GetPosition().x(); |
| 160 int end_y = balloon_->GetPosition().y(); | 160 int end_y = balloon_->GetPosition().y(); |
| 161 int end_w = GetDesiredTotalWidth(); | 161 int end_w = GetDesiredTotalWidth(); |
| 162 int end_h = GetDesiredTotalHeight(); | 162 int end_h = GetDesiredTotalHeight(); |
| 163 | 163 |
| 164 anim_frame_start_ = gfx::Rect(start_x, start_y, start_w, start_h); | 164 anim_frame_start_ = gfx::Rect(start_x, start_y, start_w, start_h); |
| 165 anim_frame_end_ = gfx::Rect(end_x, end_y, end_w, end_h); | 165 anim_frame_end_ = gfx::Rect(end_x, end_y, end_w, end_h); |
| 166 animation_.reset(new SlideAnimation(this)); | 166 animation_.reset(new ui::SlideAnimation(this)); |
| 167 animation_->Show(); | 167 animation_->Show(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void BalloonViewImpl::AnimationProgressed(const Animation* animation) { | 170 void BalloonViewImpl::AnimationProgressed(const ui::Animation* animation) { |
| 171 DCHECK_EQ(animation, animation_.get()); | 171 DCHECK_EQ(animation, animation_.get()); |
| 172 | 172 |
| 173 // Linear interpolation from start to end position. | 173 // Linear interpolation from start to end position. |
| 174 double end = animation->GetCurrentValue(); | 174 double end = animation->GetCurrentValue(); |
| 175 double start = 1.0 - end; | 175 double start = 1.0 - end; |
| 176 | 176 |
| 177 gfx::Rect frame_position( | 177 gfx::Rect frame_position( |
| 178 static_cast<int>(start * anim_frame_start_.x() + | 178 static_cast<int>(start * anim_frame_start_.x() + |
| 179 end * anim_frame_end_.x()), | 179 end * anim_frame_end_.x()), |
| 180 static_cast<int>(start * anim_frame_start_.y() + | 180 static_cast<int>(start * anim_frame_start_.y() + |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 418 |
| 419 void BalloonViewImpl::OnOptionsMenuButton(GtkWidget* widget) { | 419 void BalloonViewImpl::OnOptionsMenuButton(GtkWidget* widget) { |
| 420 options_menu_->PopupAsContext(gtk_get_current_event_time()); | 420 options_menu_->PopupAsContext(gtk_get_current_event_time()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 gboolean BalloonViewImpl::OnDestroy(GtkWidget* widget) { | 423 gboolean BalloonViewImpl::OnDestroy(GtkWidget* widget) { |
| 424 frame_container_ = NULL; | 424 frame_container_ = NULL; |
| 425 Close(false); | 425 Close(false); |
| 426 return FALSE; // Propagate. | 426 return FALSE; // Propagate. |
| 427 } | 427 } |
| OLD | NEW |