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

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 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/gtk/tabs/tab_renderer_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 21 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
22 #include "chrome/browser/ui/gtk/gtk_util.h" 22 #include "chrome/browser/ui/gtk/gtk_util.h"
23 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 23 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
24 #include "chrome/browser/ui/tabs/tab_utils.h" 24 #include "chrome/browser/ui/tabs/tab_utils.h"
25 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
28 #include "grit/theme_resources.h" 28 #include "grit/theme_resources.h"
29 #include "grit/ui_resources.h" 29 #include "grit/ui_resources.h"
30 #include "skia/ext/image_operations.h" 30 #include "skia/ext/image_operations.h"
31 #include "ui/base/animation/slide_animation.h"
32 #include "ui/base/animation/throb_animation.h"
33 #include "ui/base/gtk/gtk_screen_util.h" 31 #include "ui/base/gtk/gtk_screen_util.h"
34 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/gfx/animation/slide_animation.h"
35 #include "ui/gfx/animation/throb_animation.h"
36 #include "ui/gfx/canvas_skia_paint.h" 36 #include "ui/gfx/canvas_skia_paint.h"
37 #include "ui/gfx/favicon_size.h" 37 #include "ui/gfx/favicon_size.h"
38 #include "ui/gfx/gtk_compat.h" 38 #include "ui/gfx/gtk_compat.h"
39 #include "ui/gfx/gtk_util.h" 39 #include "ui/gfx/gtk_util.h"
40 #include "ui/gfx/image/cairo_cached_surface.h" 40 #include "ui/gfx/image/cairo_cached_surface.h"
41 #include "ui/gfx/image/image.h" 41 #include "ui/gfx/image/image.h"
42 #include "ui/gfx/pango_util.h" 42 #include "ui/gfx/pango_util.h"
43 #include "ui/gfx/platform_font_pango.h" 43 #include "ui/gfx/platform_font_pango.h"
44 #include "ui/gfx/skbitmap_operations.h" 44 #include "ui/gfx/skbitmap_operations.h"
45 45
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 app(false), 271 app(false),
272 capture_state(NONE) { 272 capture_state(NONE) {
273 } 273 }
274 274
275 TabRendererGtk::TabData::~TabData() {} 275 TabRendererGtk::TabData::~TabData() {}
276 276
277 //////////////////////////////////////////////////////////////////////////////// 277 ////////////////////////////////////////////////////////////////////////////////
278 // FaviconCrashAnimation 278 // FaviconCrashAnimation
279 // 279 //
280 // A custom animation subclass to manage the favicon crash animation. 280 // A custom animation subclass to manage the favicon crash animation.
281 class TabRendererGtk::FaviconCrashAnimation : public ui::LinearAnimation, 281 class TabRendererGtk::FaviconCrashAnimation : public gfx::LinearAnimation,
282 public ui::AnimationDelegate { 282 public gfx::AnimationDelegate {
283 public: 283 public:
284 explicit FaviconCrashAnimation(TabRendererGtk* target) 284 explicit FaviconCrashAnimation(TabRendererGtk* target)
285 : ui::LinearAnimation(1000, 25, this), 285 : gfx::LinearAnimation(1000, 25, this),
286 target_(target) { 286 target_(target) {
287 } 287 }
288 virtual ~FaviconCrashAnimation() {} 288 virtual ~FaviconCrashAnimation() {}
289 289
290 // ui::Animation overrides: 290 // gfx::Animation overrides:
291 virtual void AnimateToState(double state) OVERRIDE { 291 virtual void AnimateToState(double state) OVERRIDE {
292 const double kHidingOffset = 27; 292 const double kHidingOffset = 27;
293 293
294 if (state < .5) { 294 if (state < .5) {
295 target_->SetFaviconHidingOffset( 295 target_->SetFaviconHidingOffset(
296 static_cast<int>(floor(kHidingOffset * 2.0 * state))); 296 static_cast<int>(floor(kHidingOffset * 2.0 * state)));
297 } else { 297 } else {
298 target_->DisplayCrashedFavicon(); 298 target_->DisplayCrashedFavicon();
299 target_->SetFaviconHidingOffset( 299 target_->SetFaviconHidingOffset(
300 static_cast<int>( 300 static_cast<int>(
301 floor(kHidingOffset - ((state - .5) * 2.0 * kHidingOffset)))); 301 floor(kHidingOffset - ((state - .5) * 2.0 * kHidingOffset))));
302 } 302 }
303 } 303 }
304 304
305 // ui::AnimationDelegate overrides: 305 // gfx::AnimationDelegate overrides:
306 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE { 306 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE {
307 target_->SetFaviconHidingOffset(0); 307 target_->SetFaviconHidingOffset(0);
308 } 308 }
309 309
310 private: 310 private:
311 TabRendererGtk* target_; 311 TabRendererGtk* target_;
312 312
313 DISALLOW_COPY_AND_ASSIGN(FaviconCrashAnimation); 313 DISALLOW_COPY_AND_ASSIGN(FaviconCrashAnimation);
314 }; 314 };
315 315
316 //////////////////////////////////////////////////////////////////////////////// 316 ////////////////////////////////////////////////////////////////////////////////
(...skipping 20 matching lines...) Expand all
337 337
338 tab_.Own(gtk_fixed_new()); 338 tab_.Own(gtk_fixed_new());
339 gtk_widget_set_app_paintable(tab_.get(), TRUE); 339 gtk_widget_set_app_paintable(tab_.get(), TRUE);
340 g_signal_connect(tab_.get(), "expose-event", 340 g_signal_connect(tab_.get(), "expose-event",
341 G_CALLBACK(OnExposeEventThunk), this); 341 G_CALLBACK(OnExposeEventThunk), this);
342 g_signal_connect(tab_.get(), "size-allocate", 342 g_signal_connect(tab_.get(), "size-allocate",
343 G_CALLBACK(OnSizeAllocateThunk), this); 343 G_CALLBACK(OnSizeAllocateThunk), this);
344 close_button_.reset(MakeCloseButton()); 344 close_button_.reset(MakeCloseButton());
345 gtk_widget_show(tab_.get()); 345 gtk_widget_show(tab_.get());
346 346
347 hover_animation_.reset(new ui::SlideAnimation(this)); 347 hover_animation_.reset(new gfx::SlideAnimation(this));
348 hover_animation_->SetSlideDuration(kHoverDurationMs); 348 hover_animation_->SetSlideDuration(kHoverDurationMs);
349 } 349 }
350 350
351 TabRendererGtk::~TabRendererGtk() { 351 TabRendererGtk::~TabRendererGtk() {
352 tab_.Destroy(); 352 tab_.Destroy();
353 } 353 }
354 354
355 void TabRendererGtk::Observe(int type, 355 void TabRendererGtk::Observe(int type,
356 const content::NotificationSource& source, 356 const content::NotificationSource& source,
357 const content::NotificationDetails& details) { 357 const content::NotificationDetails& details) {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 return bounds; 607 return bounds;
608 } 608 }
609 609
610 gfx::Rect TabRendererGtk::GetRequisition() const { 610 gfx::Rect TabRendererGtk::GetRequisition() const {
611 return gfx::Rect(requisition_.x(), requisition_.y(), 611 return gfx::Rect(requisition_.x(), requisition_.y(),
612 requisition_.width(), requisition_.height()); 612 requisition_.width(), requisition_.height());
613 } 613 }
614 614
615 void TabRendererGtk::StartMiniTabTitleAnimation() { 615 void TabRendererGtk::StartMiniTabTitleAnimation() {
616 if (!mini_title_animation_.get()) { 616 if (!mini_title_animation_.get()) {
617 mini_title_animation_.reset(new ui::ThrobAnimation(this)); 617 mini_title_animation_.reset(new gfx::ThrobAnimation(this));
618 mini_title_animation_->SetThrobDuration(kMiniTitleChangeThrobDuration); 618 mini_title_animation_->SetThrobDuration(kMiniTitleChangeThrobDuration);
619 } 619 }
620 620
621 if (!mini_title_animation_->is_animating()) 621 if (!mini_title_animation_->is_animating())
622 mini_title_animation_->StartThrobbing(-1); 622 mini_title_animation_->StartThrobbing(-1);
623 } 623 }
624 624
625 void TabRendererGtk::StopMiniTabTitleAnimation() { 625 void TabRendererGtk::StopMiniTabTitleAnimation() {
626 if (mini_title_animation_.get()) 626 if (mini_title_animation_.get())
627 mini_title_animation_->Stop(); 627 mini_title_animation_->Stop();
(...skipping 11 matching lines...) Expand all
639 if (gtk_button_get_event_window(GTK_BUTTON(close_button_->widget()))) 639 if (gtk_button_get_event_window(GTK_BUTTON(close_button_->widget())))
640 gdk_window_raise(gtk_button_get_event_window( 640 gdk_window_raise(gtk_button_get_event_window(
641 GTK_BUTTON(close_button_->widget()))); 641 GTK_BUTTON(close_button_->widget())));
642 } 642 }
643 643
644 string16 TabRendererGtk::GetTitle() const { 644 string16 TabRendererGtk::GetTitle() const {
645 return data_.title; 645 return data_.title;
646 } 646 }
647 647
648 /////////////////////////////////////////////////////////////////////////////// 648 ///////////////////////////////////////////////////////////////////////////////
649 // TabRendererGtk, ui::AnimationDelegate implementation: 649 // TabRendererGtk, gfx::AnimationDelegate implementation:
650 650
651 void TabRendererGtk::AnimationProgressed(const ui::Animation* animation) { 651 void TabRendererGtk::AnimationProgressed(const gfx::Animation* animation) {
652 gtk_widget_queue_draw(tab_.get()); 652 gtk_widget_queue_draw(tab_.get());
653 } 653 }
654 654
655 void TabRendererGtk::AnimationCanceled(const ui::Animation* animation) { 655 void TabRendererGtk::AnimationCanceled(const gfx::Animation* animation) {
656 AnimationEnded(animation); 656 AnimationEnded(animation);
657 } 657 }
658 658
659 void TabRendererGtk::AnimationEnded(const ui::Animation* animation) { 659 void TabRendererGtk::AnimationEnded(const gfx::Animation* animation) {
660 gtk_widget_queue_draw(tab_.get()); 660 gtk_widget_queue_draw(tab_.get());
661 } 661 }
662 662
663 //////////////////////////////////////////////////////////////////////////////// 663 ////////////////////////////////////////////////////////////////////////////////
664 // TabRendererGtk, private: 664 // TabRendererGtk, private:
665 665
666 void TabRendererGtk::StartCrashAnimation() { 666 void TabRendererGtk::StartCrashAnimation() {
667 if (!crash_animation_.get()) 667 if (!crash_animation_.get())
668 crash_animation_.reset(new FaviconCrashAnimation(this)); 668 crash_animation_.reset(new FaviconCrashAnimation(this));
669 crash_animation_->Stop(); 669 crash_animation_->Stop();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 recording.ToImageSkia()->width(); 704 recording.ToImageSkia()->width();
705 705
706 GdkPixbuf* pixbuf = data_.favicon.isNull() ? 706 GdkPixbuf* pixbuf = data_.favicon.isNull() ?
707 gfx::GdkPixbufFromSkBitmap(*recording.ToSkBitmap()) : 707 gfx::GdkPixbufFromSkBitmap(*recording.ToSkBitmap()) :
708 GetResizedGdkPixbufFromSkBitmap(*recording.ToSkBitmap(), 708 GetResizedGdkPixbufFromSkBitmap(*recording.ToSkBitmap(),
709 icon_size, icon_size); 709 icon_size, icon_size);
710 data_.cairo_overlay.UsePixbuf(pixbuf); 710 data_.cairo_overlay.UsePixbuf(pixbuf);
711 g_object_unref(pixbuf); 711 g_object_unref(pixbuf);
712 712
713 if (!favicon_overlay_animation_.get()) { 713 if (!favicon_overlay_animation_.get()) {
714 favicon_overlay_animation_.reset(new ui::ThrobAnimation(this)); 714 favicon_overlay_animation_.reset(new gfx::ThrobAnimation(this));
715 favicon_overlay_animation_->SetThrobDuration(kRecordingDurationMs); 715 favicon_overlay_animation_->SetThrobDuration(kRecordingDurationMs);
716 } 716 }
717 if (!favicon_overlay_animation_->is_animating()) 717 if (!favicon_overlay_animation_->is_animating())
718 favicon_overlay_animation_->StartThrobbing(-1); 718 favicon_overlay_animation_->StartThrobbing(-1);
719 } else { 719 } else {
720 data_.cairo_overlay.Reset(); 720 data_.cairo_overlay.Reset();
721 if (favicon_overlay_animation_.get()) 721 if (favicon_overlay_animation_.get())
722 favicon_overlay_animation_->Stop(); 722 favicon_overlay_animation_->Stop();
723 } 723 }
724 } 724 }
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 // get an infinite loop of size-allocate signals. 1210 // get an infinite loop of size-allocate signals.
1211 if (bounds_ == bounds) 1211 if (bounds_ == bounds)
1212 return; 1212 return;
1213 1213
1214 bounds_ = bounds; 1214 bounds_ = bounds;
1215 Layout(); 1215 Layout();
1216 } 1216 }
1217 1217
1218 gboolean TabRendererGtk::OnEnterNotifyEvent(GtkWidget* widget, 1218 gboolean TabRendererGtk::OnEnterNotifyEvent(GtkWidget* widget,
1219 GdkEventCrossing* event) { 1219 GdkEventCrossing* event) {
1220 hover_animation_->SetTweenType(ui::Tween::EASE_OUT); 1220 hover_animation_->SetTweenType(gfx::Tween::EASE_OUT);
1221 hover_animation_->Show(); 1221 hover_animation_->Show();
1222 return FALSE; 1222 return FALSE;
1223 } 1223 }
1224 1224
1225 gboolean TabRendererGtk::OnLeaveNotifyEvent(GtkWidget* widget, 1225 gboolean TabRendererGtk::OnLeaveNotifyEvent(GtkWidget* widget,
1226 GdkEventCrossing* event) { 1226 GdkEventCrossing* event) {
1227 hover_animation_->SetTweenType(ui::Tween::EASE_IN); 1227 hover_animation_->SetTweenType(gfx::Tween::EASE_IN);
1228 hover_animation_->Hide(); 1228 hover_animation_->Hide();
1229 return FALSE; 1229 return FALSE;
1230 } 1230 }
1231 1231
1232 // static 1232 // static
1233 void TabRendererGtk::InitResources() { 1233 void TabRendererGtk::InitResources() {
1234 if (initialized_) 1234 if (initialized_)
1235 return; 1235 return;
1236 1236
1237 // Grab the pixel sizes of our masking images. 1237 // Grab the pixel sizes of our masking images.
(...skipping 10 matching lines...) Expand all
1248 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_CLOSE_1).ToGdkPixbuf(); 1248 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_CLOSE_1).ToGdkPixbuf();
1249 close_button_width_ = gdk_pixbuf_get_width(tab_close); 1249 close_button_width_ = gdk_pixbuf_get_width(tab_close);
1250 close_button_height_ = gdk_pixbuf_get_height(tab_close); 1250 close_button_height_ = gdk_pixbuf_get_height(tab_close);
1251 1251
1252 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); 1252 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont);
1253 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); 1253 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize);
1254 title_font_height_ = title_font_->GetHeight(); 1254 title_font_height_ = title_font_->GetHeight();
1255 1255
1256 initialized_ = true; 1256 initialized_ = true;
1257 } 1257 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698