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

Side by Side Diff: chrome/browser/ui/gtk/throbber_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
« no previous file with comments | « chrome/browser/ui/gtk/throbber_gtk.h ('k') | chrome/browser/ui/panels/panel_bounds_animation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/throbber_gtk.h" 5 #include "chrome/browser/ui/gtk/throbber_gtk.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 9 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
10 #include "content/public/browser/notification_source.h" 10 #include "content/public/browser/notification_source.h"
11 #include "grit/ui_resources.h" 11 #include "grit/ui_resources.h"
12 #include "ui/base/animation/tween.h" 12 #include "ui/gfx/animation/tween.h"
13 #include "ui/gfx/image/cairo_cached_surface.h" 13 #include "ui/gfx/image/cairo_cached_surface.h"
14 14
15 namespace { 15 namespace {
16 16
17 // The length of a single cycle of the animation in milliseconds. 17 // The length of a single cycle of the animation in milliseconds.
18 const int kThrobberDurationMs = 750; 18 const int kThrobberDurationMs = 750;
19 19
20 } // namespace 20 } // namespace
21 21
22 ThrobberGtk::ThrobberGtk(GtkThemeService* theme_service) 22 ThrobberGtk::ThrobberGtk(GtkThemeService* theme_service)
23 : theme_service_(theme_service), 23 : theme_service_(theme_service),
24 animation_(this), 24 animation_(this),
25 num_frames_(0) { 25 num_frames_(0) {
26 DCHECK(theme_service_); 26 DCHECK(theme_service_);
27 Init(); 27 Init();
28 } 28 }
29 29
30 ThrobberGtk::~ThrobberGtk() { 30 ThrobberGtk::~ThrobberGtk() {
31 widget_.Destroy(); 31 widget_.Destroy();
32 } 32 }
33 33
34 void ThrobberGtk::Start() { 34 void ThrobberGtk::Start() {
35 animation_.Show(); 35 animation_.Show();
36 } 36 }
37 37
38 void ThrobberGtk::Stop() { 38 void ThrobberGtk::Stop() {
39 animation_.Reset(); 39 animation_.Reset();
40 } 40 }
41 41
42 void ThrobberGtk::AnimationEnded(const ui::Animation* animation) { 42 void ThrobberGtk::AnimationEnded(const gfx::Animation* animation) {
43 animation_.Reset(); 43 animation_.Reset();
44 animation_.Show(); 44 animation_.Show();
45 } 45 }
46 46
47 void ThrobberGtk::AnimationProgressed(const ui::Animation* animation) { 47 void ThrobberGtk::AnimationProgressed(const gfx::Animation* animation) {
48 gtk_widget_queue_draw(widget_.get()); 48 gtk_widget_queue_draw(widget_.get());
49 } 49 }
50 50
51 void ThrobberGtk::Observe(int type, 51 void ThrobberGtk::Observe(int type,
52 const content::NotificationSource& source, 52 const content::NotificationSource& source,
53 const content::NotificationDetails& details) { 53 const content::NotificationDetails& details) {
54 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type); 54 DCHECK_EQ(chrome::NOTIFICATION_BROWSER_THEME_CHANGED, type);
55 LoadFrames(); 55 LoadFrames();
56 gtk_widget_queue_draw(widget_.get()); 56 gtk_widget_queue_draw(widget_.get());
57 } 57 }
(...skipping 14 matching lines...) Expand all
72 cairo_frames->SetSource(cairo_context, widget, -image_offset, 0); 72 cairo_frames->SetSource(cairo_context, widget, -image_offset, 0);
73 cairo_rectangle(cairo_context, 0, 0, image_size, image_size); 73 cairo_rectangle(cairo_context, 0, 0, image_size, image_size);
74 cairo_fill(cairo_context); 74 cairo_fill(cairo_context);
75 cairo_destroy(cairo_context); 75 cairo_destroy(cairo_context);
76 76
77 return TRUE; 77 return TRUE;
78 } 78 }
79 79
80 void ThrobberGtk::Init() { 80 void ThrobberGtk::Init() {
81 animation_.SetSlideDuration(kThrobberDurationMs); 81 animation_.SetSlideDuration(kThrobberDurationMs);
82 animation_.SetTweenType(ui::Tween::LINEAR); 82 animation_.SetTweenType(gfx::Tween::LINEAR);
83 widget_.Own(gtk_image_new()); 83 widget_.Own(gtk_image_new());
84 gtk_widget_set_can_focus(widget_.get(), FALSE); 84 gtk_widget_set_can_focus(widget_.get(), FALSE);
85 g_signal_connect(widget_.get(), "expose-event", G_CALLBACK(OnExposeThunk), 85 g_signal_connect(widget_.get(), "expose-event", G_CALLBACK(OnExposeThunk),
86 this); 86 this);
87 87
88 theme_service_->InitThemesFor(this); 88 theme_service_->InitThemesFor(this);
89 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, 89 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
90 content::Source<ThemeService>(theme_service_)); 90 content::Source<ThemeService>(theme_service_));
91 } 91 }
92 92
93 void ThrobberGtk::LoadFrames() { 93 void ThrobberGtk::LoadFrames() {
94 frames_ = theme_service_->GetImageNamed(IDR_THROBBER); 94 frames_ = theme_service_->GetImageNamed(IDR_THROBBER);
95 DCHECK(!frames_.IsEmpty()); 95 DCHECK(!frames_.IsEmpty());
96 const int width = frames_.ToCairo()->Width(); 96 const int width = frames_.ToCairo()->Width();
97 const int height = frames_.ToCairo()->Height(); 97 const int height = frames_.ToCairo()->Height();
98 DCHECK_EQ(0, width % height); 98 DCHECK_EQ(0, width % height);
99 num_frames_ = width / height; 99 num_frames_ = width / height;
100 100
101 gtk_widget_set_size_request(widget_.get(), height, height); 101 gtk_widget_set_size_request(widget_.get(), height, height);
102 } 102 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/throbber_gtk.h ('k') | chrome/browser/ui/panels/panel_bounds_animation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698