| 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/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/gtk/tabs/tab_renderer_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 const NotificationSource& source, | 193 const NotificationSource& source, |
| 194 const NotificationDetails& details) { | 194 const NotificationDetails& details) { |
| 195 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 195 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); |
| 196 data_.reset(new Data(theme_provider_)); | 196 data_.reset(new Data(theme_provider_)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 //////////////////////////////////////////////////////////////////////////////// | 199 //////////////////////////////////////////////////////////////////////////////// |
| 200 // FaviconCrashAnimation | 200 // FaviconCrashAnimation |
| 201 // | 201 // |
| 202 // A custom animation subclass to manage the favicon crash animation. | 202 // A custom animation subclass to manage the favicon crash animation. |
| 203 class TabRendererGtk::FavIconCrashAnimation : public Animation, | 203 class TabRendererGtk::FavIconCrashAnimation : public LinearAnimation, |
| 204 public AnimationDelegate { | 204 public AnimationDelegate { |
| 205 public: | 205 public: |
| 206 explicit FavIconCrashAnimation(TabRendererGtk* target) | 206 explicit FavIconCrashAnimation(TabRendererGtk* target) |
| 207 : ALLOW_THIS_IN_INITIALIZER_LIST(Animation(1000, 25, this)), | 207 : ALLOW_THIS_IN_INITIALIZER_LIST(LinearAnimation(1000, 25, this)), |
| 208 target_(target) { | 208 target_(target) { |
| 209 } | 209 } |
| 210 virtual ~FavIconCrashAnimation() {} | 210 virtual ~FavIconCrashAnimation() {} |
| 211 | 211 |
| 212 // Animation overrides: | 212 // Animation overrides: |
| 213 virtual void AnimateToState(double state) { | 213 virtual void AnimateToState(double state) { |
| 214 const double kHidingOffset = 27; | 214 const double kHidingOffset = 27; |
| 215 | 215 |
| 216 if (state < .5) { | 216 if (state < .5) { |
| 217 target_->SetFavIconHidingOffset( | 217 target_->SetFavIconHidingOffset( |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 return gfx::Rect(requisition_.x(), requisition_.y(), | 494 return gfx::Rect(requisition_.x(), requisition_.y(), |
| 495 requisition_.width(), requisition_.height()); | 495 requisition_.width(), requisition_.height()); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void TabRendererGtk::StartMiniTabTitleAnimation() { | 498 void TabRendererGtk::StartMiniTabTitleAnimation() { |
| 499 if (!mini_title_animation_.get()) { | 499 if (!mini_title_animation_.get()) { |
| 500 mini_title_animation_.reset(new ThrobAnimation(this)); | 500 mini_title_animation_.reset(new ThrobAnimation(this)); |
| 501 mini_title_animation_->SetThrobDuration(kMiniTitleChangeThrobDuration); | 501 mini_title_animation_->SetThrobDuration(kMiniTitleChangeThrobDuration); |
| 502 } | 502 } |
| 503 | 503 |
| 504 if (!mini_title_animation_->IsAnimating()) { | 504 if (!mini_title_animation_->is_animating()) { |
| 505 mini_title_animation_->StartThrobbing(2); | 505 mini_title_animation_->StartThrobbing(2); |
| 506 } else if (mini_title_animation_->cycles_remaining() <= 2) { | 506 } else if (mini_title_animation_->cycles_remaining() <= 2) { |
| 507 // The title changed while we're already animating. Add at most one more | 507 // The title changed while we're already animating. Add at most one more |
| 508 // cycle. This is done in an attempt to smooth out pages that continuously | 508 // cycle. This is done in an attempt to smooth out pages that continuously |
| 509 // change the title. | 509 // change the title. |
| 510 mini_title_animation_->set_cycles_remaining( | 510 mini_title_animation_->set_cycles_remaining( |
| 511 mini_title_animation_->cycles_remaining() + 2); | 511 mini_title_animation_->cycles_remaining() + 2); |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 | 514 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 crash_animation_->Start(); | 568 crash_animation_->Start(); |
| 569 } | 569 } |
| 570 | 570 |
| 571 void TabRendererGtk::StopCrashAnimation() { | 571 void TabRendererGtk::StopCrashAnimation() { |
| 572 if (!crash_animation_.get()) | 572 if (!crash_animation_.get()) |
| 573 return; | 573 return; |
| 574 crash_animation_->Stop(); | 574 crash_animation_->Stop(); |
| 575 } | 575 } |
| 576 | 576 |
| 577 bool TabRendererGtk::IsPerformingCrashAnimation() const { | 577 bool TabRendererGtk::IsPerformingCrashAnimation() const { |
| 578 return crash_animation_.get() && crash_animation_->IsAnimating(); | 578 return crash_animation_.get() && crash_animation_->is_animating(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 void TabRendererGtk::SetFavIconHidingOffset(int offset) { | 581 void TabRendererGtk::SetFavIconHidingOffset(int offset) { |
| 582 fav_icon_hiding_offset_ = offset; | 582 fav_icon_hiding_offset_ = offset; |
| 583 SchedulePaint(); | 583 SchedulePaint(); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void TabRendererGtk::DisplayCrashedFavIcon() { | 586 void TabRendererGtk::DisplayCrashedFavIcon() { |
| 587 should_display_crashed_favicon_ = true; | 587 should_display_crashed_favicon_ = true; |
| 588 } | 588 } |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 G_CALLBACK(OnEnterNotifyEvent), this); | 979 G_CALLBACK(OnEnterNotifyEvent), this); |
| 980 g_signal_connect(button->widget(), "leave-notify-event", | 980 g_signal_connect(button->widget(), "leave-notify-event", |
| 981 G_CALLBACK(OnLeaveNotifyEvent), this); | 981 G_CALLBACK(OnLeaveNotifyEvent), this); |
| 982 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); | 982 GTK_WIDGET_UNSET_FLAGS(button->widget(), GTK_CAN_FOCUS); |
| 983 gtk_fixed_put(GTK_FIXED(tab_.get()), button->widget(), 0, 0); | 983 gtk_fixed_put(GTK_FIXED(tab_.get()), button->widget(), 0, 0); |
| 984 | 984 |
| 985 return button; | 985 return button; |
| 986 } | 986 } |
| 987 | 987 |
| 988 double TabRendererGtk::GetThrobValue() { | 988 double TabRendererGtk::GetThrobValue() { |
| 989 if (mini_title_animation_.get() && mini_title_animation_->IsAnimating()) { | 989 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) { |
| 990 return mini_title_animation_->GetCurrentValue() * | 990 return mini_title_animation_->GetCurrentValue() * |
| 991 kMiniTitleChangeThrobOpacity; | 991 kMiniTitleChangeThrobOpacity; |
| 992 } | 992 } |
| 993 return hover_animation_.get() ? | 993 return hover_animation_.get() ? |
| 994 kHoverOpacity * hover_animation_->GetCurrentValue() : 0; | 994 kHoverOpacity * hover_animation_->GetCurrentValue() : 0; |
| 995 } | 995 } |
| 996 | 996 |
| 997 void TabRendererGtk::CloseButtonClicked() { | 997 void TabRendererGtk::CloseButtonClicked() { |
| 998 // Nothing to do. | 998 // Nothing to do. |
| 999 } | 999 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 return; | 1038 return; |
| 1039 | 1039 |
| 1040 tab->bounds_ = bounds; | 1040 tab->bounds_ = bounds; |
| 1041 tab->Layout(); | 1041 tab->Layout(); |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 // static | 1044 // static |
| 1045 gboolean TabRendererGtk::OnEnterNotifyEvent(GtkWidget* widget, | 1045 gboolean TabRendererGtk::OnEnterNotifyEvent(GtkWidget* widget, |
| 1046 GdkEventCrossing* event, | 1046 GdkEventCrossing* event, |
| 1047 TabRendererGtk* tab) { | 1047 TabRendererGtk* tab) { |
| 1048 tab->hover_animation_->SetTweenType(SlideAnimation::EASE_OUT); | 1048 tab->hover_animation_->SetTweenType(Tween::EASE_OUT); |
| 1049 tab->hover_animation_->Show(); | 1049 tab->hover_animation_->Show(); |
| 1050 return FALSE; | 1050 return FALSE; |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 // static | 1053 // static |
| 1054 gboolean TabRendererGtk::OnLeaveNotifyEvent(GtkWidget* widget, | 1054 gboolean TabRendererGtk::OnLeaveNotifyEvent(GtkWidget* widget, |
| 1055 GdkEventCrossing* event, | 1055 GdkEventCrossing* event, |
| 1056 TabRendererGtk* tab) { | 1056 TabRendererGtk* tab) { |
| 1057 tab->hover_animation_->SetTweenType(SlideAnimation::EASE_IN); | 1057 tab->hover_animation_->SetTweenType(Tween::EASE_IN); |
| 1058 tab->hover_animation_->Hide(); | 1058 tab->hover_animation_->Hide(); |
| 1059 return FALSE; | 1059 return FALSE; |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 // static | 1062 // static |
| 1063 void TabRendererGtk::InitResources() { | 1063 void TabRendererGtk::InitResources() { |
| 1064 if (initialized_) | 1064 if (initialized_) |
| 1065 return; | 1065 return; |
| 1066 | 1066 |
| 1067 LoadTabImages(); | 1067 LoadTabImages(); |
| 1068 | 1068 |
| 1069 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1069 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1070 // Force the font size to 9pt, which matches Windows' default font size | 1070 // Force the font size to 9pt, which matches Windows' default font size |
| 1071 // (taken from the system). | 1071 // (taken from the system). |
| 1072 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1072 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 1073 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); | 1073 title_font_ = new gfx::Font(gfx::Font::CreateFont(base_font.FontName(), 9)); |
| 1074 title_font_height_ = title_font_->height(); | 1074 title_font_height_ = title_font_->height(); |
| 1075 | 1075 |
| 1076 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 1076 crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
| 1077 | 1077 |
| 1078 initialized_ = true; | 1078 initialized_ = true; |
| 1079 } | 1079 } |
| OLD | NEW |