summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 17:25:52 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-13 17:25:52 +0000
commit2aa70a4139bd330b5deaaa39e5cb4d7b41be2d02 (patch)
treeb3f6f19d597378bb52a10347b54f457a724b93d5 /chrome
parent31d1af421bb4e710839e7c8b0a89e814593c0848 (diff)
downloadchromium_src-2aa70a4139bd330b5deaaa39e5cb4d7b41be2d02.zip
chromium_src-2aa70a4139bd330b5deaaa39e5cb4d7b41be2d02.tar.gz
chromium_src-2aa70a4139bd330b5deaaa39e5cb4d7b41be2d02.tar.bz2
Hook up throbber animation for vista detached popup windows and app windows.
http://crbug.com/3296 Review URL: http://codereview.chromium.org/7261 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.cc56
-rw-r--r--chrome/browser/views/frame/aero_glass_frame.h19
-rw-r--r--chrome/browser/views/frame/browser_frame.h3
-rw-r--r--chrome/browser/views/frame/browser_view2.cc2
-rw-r--r--chrome/browser/views/frame/opaque_frame.cc4
-rw-r--r--chrome/browser/views/frame/opaque_frame.h2
6 files changed, 76 insertions, 10 deletions
diff --git a/chrome/browser/views/frame/aero_glass_frame.cc b/chrome/browser/views/frame/aero_glass_frame.cc
index a87ed6c..cb86728 100644
--- a/chrome/browser/views/frame/aero_glass_frame.cc
+++ b/chrome/browser/views/frame/aero_glass_frame.cc
@@ -24,15 +24,22 @@ static const int kToolbarOverlapVertOffset = 5;
// remove it.
static const int kWindowsDWMBevelSize = 2;
+HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount];
+
///////////////////////////////////////////////////////////////////////////////
// AeroGlassFrame, public:
AeroGlassFrame::AeroGlassFrame(BrowserView2* browser_view)
: Window(browser_view),
browser_view_(browser_view),
- frame_initialized_(false) {
+ frame_initialized_(false),
+ throbber_running_(false),
+ throbber_frame_(0) {
non_client_view_ = new AeroGlassNonClientView(this, browser_view);
browser_view_->set_frame(this);
+
+ if (window_delegate()->ShouldShowWindowIcon())
+ InitThrobberIcons();
}
AeroGlassFrame::~AeroGlassFrame() {
@@ -67,10 +74,16 @@ gfx::Rect AeroGlassFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
return GetAeroGlassNonClientView()->GetBoundsForTabStrip(tabstrip);
}
-void AeroGlassFrame::UpdateThrobber() {
- // On Vista, for now, we just update the window icon. Figure out something
- // better here to fix http://crbug.com/3296
- UpdateWindowIcon();
+void AeroGlassFrame::UpdateThrobber(bool running) {
+ if (throbber_running_) {
+ if (running) {
+ DisplayNextThrobberFrame();
+ } else {
+ StopThrobber();
+ }
+ } else if (running) {
+ StartThrobber();
+ }
}
ChromeViews::Window* AeroGlassFrame::GetWindow() {
@@ -224,3 +237,36 @@ AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const {
return static_cast<AeroGlassNonClientView*>(non_client_view_);
}
+void AeroGlassFrame::StartThrobber() {
+ if (!throbber_running_) {
+ throbber_running_ = true;
+ throbber_frame_ = 0;
+ InitThrobberIcons();
+ ::SendMessage(GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
+ reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
+ }
+}
+
+void AeroGlassFrame::StopThrobber() {
+ if (throbber_running_)
+ throbber_running_ = false;
+}
+
+void AeroGlassFrame::DisplayNextThrobberFrame() {
+ throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
+ ::SendMessage(GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL),
+ reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
+}
+
+// static
+void AeroGlassFrame::InitThrobberIcons() {
+ static bool initialized = false;
+ if (!initialized) {
+ ResourceBundle &rb = ResourceBundle::GetSharedInstance();
+ for (int i = 0; i < kThrobberIconCount; ++i) {
+ throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i);
+ DCHECK(throbber_icons_[i]);
+ }
+ initialized = true;
+ }
+}
diff --git a/chrome/browser/views/frame/aero_glass_frame.h b/chrome/browser/views/frame/aero_glass_frame.h
index 26fc7b1..a649eef 100644
--- a/chrome/browser/views/frame/aero_glass_frame.h
+++ b/chrome/browser/views/frame/aero_glass_frame.h
@@ -35,7 +35,7 @@ class AeroGlassFrame : public BrowserFrame,
const gfx::Rect& client_bounds);
virtual void SizeToContents(const gfx::Rect& contents_bounds) {}
virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
- virtual void UpdateThrobber();
+ virtual void UpdateThrobber(bool running);
virtual ChromeViews::Window* GetWindow();
// Overridden from ChromeViews::HWNDViewContainer:
@@ -64,11 +64,28 @@ class AeroGlassFrame : public BrowserFrame,
// Return a pointer to the concrete type of our non-client view.
AeroGlassNonClientView* GetAeroGlassNonClientView() const;
+ // Starts/Stops the window throbber running.
+ void StartThrobber();
+ void StopThrobber();
+
+ // Displays the next throbber frame.
+ void DisplayNextThrobberFrame();
+
// The BrowserView2 is our ClientView. This is a pointer to it.
BrowserView2* browser_view_;
bool frame_initialized_;
+ // Whether or not the window throbber is currently animating.
+ bool throbber_running_;
+
+ // The index of the current frame of the throbber animation.
+ int throbber_frame_;
+
+ static const int kThrobberIconCount = 24;
+ static HICON throbber_icons_[kThrobberIconCount];
+ static void InitThrobberIcons();
+
DISALLOW_EVIL_CONSTRUCTORS(AeroGlassFrame);
};
diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h
index e60cdca..5292a59 100644
--- a/chrome/browser/views/frame/browser_frame.h
+++ b/chrome/browser/views/frame/browser_frame.h
@@ -38,7 +38,8 @@ class BrowserFrame {
virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0;
// Updates the current frame of the Throbber animation, if applicable.
- virtual void UpdateThrobber() = 0;
+ // |running| is whether or not the throbber should be running.
+ virtual void UpdateThrobber(bool running) = 0;
// Returns the ChromeViews::Window associated with this frame.
virtual ChromeViews::Window* GetWindow() = 0;
diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc
index 6759c67..87397a6 100644
--- a/chrome/browser/views/frame/browser_view2.cc
+++ b/chrome/browser/views/frame/browser_view2.cc
@@ -398,7 +398,7 @@ void BrowserView2::SetAcceleratorTable(
void BrowserView2::ValidateThrobber() {
if (ShouldShowWindowIcon())
- frame_->UpdateThrobber();
+ frame_->UpdateThrobber(browser_->GetSelectedTabContents()->is_loading());
}
gfx::Rect BrowserView2::GetNormalBounds() {
diff --git a/chrome/browser/views/frame/opaque_frame.cc b/chrome/browser/views/frame/opaque_frame.cc
index 2b32050..97b9566 100644
--- a/chrome/browser/views/frame/opaque_frame.cc
+++ b/chrome/browser/views/frame/opaque_frame.cc
@@ -42,7 +42,9 @@ gfx::Rect OpaqueFrame::GetBoundsForTabStrip(TabStrip* tabstrip) const {
return GetOpaqueNonClientView()->GetBoundsForTabStrip(tabstrip);
}
-void OpaqueFrame::UpdateThrobber() {
+void OpaqueFrame::UpdateThrobber(bool running) {
+ // TODO(beng): pass |running| through rather than letting
+ // OpaqueNonClientView's TabIconView try and figure it out.
// The throbber doesn't run in the Windows TaskBar, so we just update the
// non-client view. Updating the taskbar is muy expensivo.
GetOpaqueNonClientView()->UpdateWindowIcon();
diff --git a/chrome/browser/views/frame/opaque_frame.h b/chrome/browser/views/frame/opaque_frame.h
index 20c8568..a30b855 100644
--- a/chrome/browser/views/frame/opaque_frame.h
+++ b/chrome/browser/views/frame/opaque_frame.h
@@ -35,7 +35,7 @@ class OpaqueFrame : public BrowserFrame,
const gfx::Rect& client_bounds);
virtual void SizeToContents(const gfx::Rect& contents_bounds);
virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const;
- virtual void UpdateThrobber();
+ virtual void UpdateThrobber(bool running);
virtual ChromeViews::Window* GetWindow();
// Overridden from ChromeViews::CustomFrameWindow: