Index: chrome/browser/views/frame/glass_browser_frame_view.cc |
=================================================================== |
--- chrome/browser/views/frame/glass_browser_frame_view.cc (revision 10646) |
+++ chrome/browser/views/frame/glass_browser_frame_view.cc (working copy) |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/views/frame/aero_glass_non_client_view.h" |
+#include "chrome/browser/views/frame/glass_browser_frame_view.h" |
#include "chrome/browser/views/frame/browser_view.h" |
#include "chrome/browser/views/tabs/tab_strip.h" |
@@ -26,12 +26,12 @@ |
FRAME_PART_BITMAP_COUNT // Must be last. |
}; |
-class AeroGlassWindowResources { |
+class GlassBrowserWindowResources { |
public: |
- AeroGlassWindowResources() { |
+ GlassBrowserWindowResources() { |
InitClass(); |
} |
- virtual ~AeroGlassWindowResources() { } |
+ virtual ~GlassBrowserWindowResources() { } |
virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part) const { |
return standard_frame_bitmaps_[part]; |
@@ -58,14 +58,15 @@ |
static SkBitmap* standard_frame_bitmaps_[FRAME_PART_BITMAP_COUNT]; |
- DISALLOW_EVIL_CONSTRUCTORS(AeroGlassWindowResources); |
+ DISALLOW_EVIL_CONSTRUCTORS(GlassBrowserWindowResources); |
}; |
// static |
-SkBitmap* AeroGlassWindowResources::standard_frame_bitmaps_[]; |
+SkBitmap* GlassBrowserWindowResources::standard_frame_bitmaps_[]; |
-AeroGlassWindowResources* AeroGlassNonClientView::resources_ = NULL; |
-SkBitmap* AeroGlassNonClientView::distributor_logo_ = NULL; |
+GlassBrowserWindowResources* GlassBrowserFrameView::resources_ = NULL; |
+SkBitmap* GlassBrowserFrameView::distributor_logo_ = NULL; |
+HICON GlassBrowserFrameView::throbber_icons_[GlassBrowserFrameView::kThrobberIconCount]; |
namespace { |
// There are 3 px of client edge drawn inside the outer frame borders. |
@@ -102,19 +103,28 @@ |
} |
/////////////////////////////////////////////////////////////////////////////// |
-// AeroGlassNonClientView, public: |
+// GlassBrowserFrameView, public: |
-AeroGlassNonClientView::AeroGlassNonClientView(AeroGlassFrame* frame, |
- BrowserView* browser_view) |
- : frame_(frame), |
- browser_view_(browser_view) { |
+GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, |
+ BrowserView* browser_view) |
+ : BrowserNonClientFrameView(), |
+ frame_(frame), |
+ browser_view_(browser_view), |
+ throbber_running_(false), |
+ throbber_frame_(0) { |
InitClass(); |
+ if (frame_->window_delegate()->ShouldShowWindowIcon()) |
+ InitThrobberIcons(); |
} |
-AeroGlassNonClientView::~AeroGlassNonClientView() { |
+GlassBrowserFrameView::~GlassBrowserFrameView() { |
} |
-gfx::Rect AeroGlassNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) { |
+/////////////////////////////////////////////////////////////////////////////// |
+// GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
+ |
+gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
+ TabStrip* tabstrip) const { |
int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
(otr_avatar_bounds_.right() + kOTRSideSpacing) : |
NonClientBorderThickness(); |
@@ -125,30 +135,46 @@ |
std::max(0, tabstrip_width), tabstrip->GetPreferredHeight()); |
} |
+void GlassBrowserFrameView::UpdateThrobber(bool running) { |
+ if (throbber_running_) { |
+ if (running) { |
+ DisplayNextThrobberFrame(); |
+ } else { |
+ StopThrobber(); |
+ } |
+ } else if (running) { |
+ StartThrobber(); |
+ } |
+} |
+ |
/////////////////////////////////////////////////////////////////////////////// |
-// AeroGlassNonClientView, views::NonClientView implementation: |
+// GlassBrowserFrameView, views::NonClientFrameView implementation: |
-gfx::Rect AeroGlassNonClientView::CalculateClientAreaBounds(int width, |
- int height) const { |
- if (!browser_view_->IsTabStripVisible()) |
- return gfx::Rect(0, 0, this->width(), this->height()); |
+gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { |
+ return client_view_bounds_; |
+} |
+gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( |
+ const gfx::Rect& client_bounds) const { |
+ if (!browser_view_->IsTabStripVisible()) { |
+ // If we don't have a tabstrip, we're either a popup or an app window, in |
+ // which case we have a standard size non-client area and can just use |
+ // AdjustWindowRectEx to obtain it. |
+ RECT rect = client_bounds.ToRECT(); |
+ AdjustWindowRectEx(&rect, frame_->window_style(), FALSE, |
+ frame_->window_ex_style()); |
+ return gfx::Rect(rect); |
+ } |
+ |
int top_height = NonClientTopBorderHeight(); |
int border_thickness = NonClientBorderThickness(); |
- return gfx::Rect(border_thickness, top_height, |
- std::max(0, width - (2 * border_thickness)), |
- std::max(0, height - top_height - border_thickness)); |
+ return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
+ std::max(0, client_bounds.y() - top_height), |
+ client_bounds.width() + (2 * border_thickness), |
+ client_bounds.height() + top_height + border_thickness); |
} |
-gfx::Size AeroGlassNonClientView::CalculateWindowSizeForClientSize( |
- int width, |
- int height) const { |
- int border_thickness = NonClientBorderThickness(); |
- return gfx::Size(width + (2 * border_thickness), |
- height + NonClientTopBorderHeight() + border_thickness); |
-} |
- |
-gfx::Point AeroGlassNonClientView::GetSystemMenuPoint() const { |
+gfx::Point GlassBrowserFrameView::GetSystemMenuPoint() const { |
gfx::Point system_menu_point; |
if (browser_view_->IsBrowserTypeNormal()) { |
// The maximized mode bit here is because in maximized mode the frame edge |
@@ -166,7 +192,7 @@ |
return system_menu_point; |
} |
-int AeroGlassNonClientView::NonClientHitTest(const gfx::Point& point) { |
+int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
// If the browser isn't in normal mode, we haven't customized the frame, so |
// Windows can figure this out. If the point isn't within our bounds, then |
// it's in the native portion of the frame, so again Windows can figure it |
@@ -188,9 +214,9 @@ |
} |
/////////////////////////////////////////////////////////////////////////////// |
-// AeroGlassNonClientView, views::View overrides: |
+// GlassBrowserFrameView, views::View overrides: |
-void AeroGlassNonClientView::Paint(ChromeCanvas* canvas) { |
+void GlassBrowserFrameView::Paint(ChromeCanvas* canvas) { |
if (!browser_view_->IsTabStripVisible()) |
return; // Nothing is visible, so don't bother to paint. |
@@ -200,39 +226,29 @@ |
PaintClientEdge(canvas); |
} |
-void AeroGlassNonClientView::Layout() { |
+void GlassBrowserFrameView::Layout() { |
LayoutDistributorLogo(); |
LayoutOTRAvatar(); |
LayoutClientView(); |
} |
-void AeroGlassNonClientView::ViewHierarchyChanged(bool is_add, |
- views::View* parent, |
- views::View* child) { |
- if (is_add && child == this) { |
- DCHECK(GetWidget()); |
- DCHECK(frame_->client_view()->GetParent() != this); |
- AddChildView(frame_->client_view()); |
- } |
-} |
- |
/////////////////////////////////////////////////////////////////////////////// |
-// AeroGlassNonClientView, private: |
+// GlassBrowserFrameView, private: |
-int AeroGlassNonClientView::FrameBorderThickness() const { |
+int GlassBrowserFrameView::FrameBorderThickness() const { |
return GetSystemMetrics(SM_CXSIZEFRAME); |
} |
-int AeroGlassNonClientView::NonClientBorderThickness() const { |
+int GlassBrowserFrameView::NonClientBorderThickness() const { |
return kNonClientBorderThickness; |
} |
-int AeroGlassNonClientView::NonClientTopBorderHeight() const { |
+int GlassBrowserFrameView::NonClientTopBorderHeight() const { |
return FrameBorderThickness() + |
(frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); |
} |
-void AeroGlassNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) { |
+void GlassBrowserFrameView::PaintDistributorLogo(ChromeCanvas* canvas) { |
// The distributor logo is only painted when the frame is not maximized and |
// when we actually have a logo. |
if (!frame_->IsMaximized() && distributor_logo_) { |
@@ -244,7 +260,7 @@ |
} |
} |
-void AeroGlassNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) { |
+void GlassBrowserFrameView::PaintToolbarBackground(ChromeCanvas* canvas) { |
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds()); |
gfx::Point toolbar_origin(toolbar_bounds.origin()); |
View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin); |
@@ -265,7 +281,7 @@ |
toolbar_bounds.right(), toolbar_bounds.y()); |
} |
-void AeroGlassNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) { |
+void GlassBrowserFrameView::PaintOTRAvatar(ChromeCanvas* canvas) { |
if (!browser_view_->ShouldShowOffTheRecordAvatar()) |
return; |
@@ -277,7 +293,7 @@ |
otr_avatar_bounds_.width(), otr_avatar_bounds_.height(), false); |
} |
-void AeroGlassNonClientView::PaintClientEdge(ChromeCanvas* canvas) { |
+void GlassBrowserFrameView::PaintClientEdge(ChromeCanvas* canvas) { |
// The client edges start below the toolbar upper corner images regardless |
// of how tall the toolbar itself is. |
int client_area_top = |
@@ -311,7 +327,7 @@ |
client_area_top, left->width(), client_area_height); |
} |
-void AeroGlassNonClientView::LayoutDistributorLogo() { |
+void GlassBrowserFrameView::LayoutDistributorLogo() { |
if (distributor_logo_) { |
logo_bounds_.SetRect(frame_->GetMinimizeButtonOffset() - |
distributor_logo_->width() - kLogoCaptionSpacing, kLogoTopSpacing, |
@@ -322,7 +338,7 @@ |
} |
} |
-void AeroGlassNonClientView::LayoutOTRAvatar() { |
+void GlassBrowserFrameView::LayoutOTRAvatar() { |
SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
int top_height = NonClientTopBorderHeight(); |
int tabstrip_height, otr_height; |
@@ -339,17 +355,62 @@ |
otr_avatar_icon.width(), otr_height); |
} |
-void AeroGlassNonClientView::LayoutClientView() { |
- frame_->client_view()->SetBounds(CalculateClientAreaBounds(width(), |
- height())); |
+void GlassBrowserFrameView::LayoutClientView() { |
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
} |
+gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width, |
+ int height) const { |
+ if (!browser_view_->IsTabStripVisible()) |
+ return gfx::Rect(0, 0, this->width(), this->height()); |
+ |
+ int top_height = NonClientTopBorderHeight(); |
+ int border_thickness = NonClientBorderThickness(); |
+ return gfx::Rect(border_thickness, top_height, |
+ std::max(0, width - (2 * border_thickness)), |
+ std::max(0, height - top_height - border_thickness)); |
+} |
+ |
+void GlassBrowserFrameView::StartThrobber() { |
+ if (!throbber_running_) { |
+ throbber_running_ = true; |
+ throbber_frame_ = 0; |
+ InitThrobberIcons(); |
+ SendMessage(frame_->GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL), |
+ reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
+ } |
+} |
+ |
+void GlassBrowserFrameView::StopThrobber() { |
+ if (throbber_running_) |
+ throbber_running_ = false; |
+} |
+ |
+void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
+ throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
+ SendMessage(frame_->GetHWND(), WM_SETICON, static_cast<WPARAM>(ICON_SMALL), |
+ reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
+} |
+ |
// static |
-void AeroGlassNonClientView::InitClass() { |
+void GlassBrowserFrameView::InitThrobberIcons() { |
static bool initialized = false; |
if (!initialized) { |
- resources_ = new AeroGlassWindowResources; |
+ 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; |
+ } |
+} |
+// static |
+void GlassBrowserFrameView::InitClass() { |
+ static bool initialized = false; |
+ if (!initialized) { |
+ resources_ = new GlassBrowserWindowResources; |
+ |
#if defined(GOOGLE_CHROME_BUILD) |
distributor_logo_ = ResourceBundle::GetSharedInstance(). |
GetBitmapNamed(IDR_DISTRIBUTOR_LOGO); |
Property changes on: chrome\browser\views\frame\glass_browser_frame_view.cc |
___________________________________________________________________ |
Added: svn:mergeinfo |
Merged /branches/chrome_webkit_merge_branch/chrome/browser/views/frame/aero_glass_non_client_view.cc:r69-2775 |