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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/ui/views/frame/browser_frame_win.h"
10 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/window/non_client_view.h"
18 class GlassBrowserFrameView : public BrowserNonClientFrameView,
19 public views::ButtonListener,
20 public content::NotificationObserver {
22 // Constructs a non-client view for an BrowserFrame.
23 GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
24 virtual ~GlassBrowserFrameView();
26 // Overridden from BrowserNonClientFrameView:
27 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
28 virtual TabStripInsets GetTabStripInsets(bool restored) const OVERRIDE;
29 virtual int GetThemeBackgroundXInset() const OVERRIDE;
30 virtual void UpdateThrobber(bool running) OVERRIDE;
31 virtual gfx::Size GetMinimumSize() OVERRIDE;
33 // Overridden from views::NonClientFrameView:
34 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
35 virtual gfx::Rect GetWindowBoundsForClientBounds(
36 const gfx::Rect& client_bounds) const OVERRIDE;
37 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
38 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask)
40 virtual void ResetWindowControls() OVERRIDE {}
41 virtual void UpdateWindowIcon() OVERRIDE {}
42 virtual void UpdateWindowTitle() OVERRIDE {}
45 // Overridden from views::View:
46 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
47 virtual void Layout() OVERRIDE;
48 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
50 // Overidden from views::ButtonListener:
51 virtual void ButtonPressed(views::Button* sender,
52 const ui::Event& event) OVERRIDE;
55 // Returns the thickness of the border that makes up the window frame edges.
56 // This does not include any client edge.
57 int FrameBorderThickness() const;
59 // Returns the thickness of the entire nonclient left, right, and bottom
60 // borders, including both the window frame and any client edge.
61 int NonClientBorderThickness() const;
63 // Returns the height of the entire nonclient top border, including the window
64 // frame, any title area, and any connected client edge. If |restored| is
65 // true, acts as if the window is restored regardless of the real mode.
66 int NonClientTopBorderHeight(bool restored) const;
68 // Paint various sub-components of this view.
69 void PaintToolbarBackground(gfx::Canvas* canvas);
70 void PaintRestoredClientEdge(gfx::Canvas* canvas);
72 // Layout various sub-components of this view.
74 void LayoutNewStyleAvatar();
75 void LayoutClientView();
77 // Returns the insets of the client area.
78 gfx::Insets GetClientAreaInsets() const;
80 // Returns the bounds of the client area for the specified view size.
81 gfx::Rect CalculateClientAreaBounds(int width, int height) const;
83 // Starts/Stops the window throbber running.
87 // Displays the next throbber frame.
88 void DisplayNextThrobberFrame();
90 // content::NotificationObserver implementation:
91 virtual void Observe(int type,
92 const content::NotificationSource& source,
93 const content::NotificationDetails& details) OVERRIDE;
95 // The layout rect of the avatar icon, if visible.
96 gfx::Rect avatar_bounds_;
98 // The bounds of the ClientView.
99 gfx::Rect client_view_bounds_;
101 // Whether or not the window throbber is currently animating.
102 bool throbber_running_;
104 // The index of the current frame of the throbber animation.
107 content::NotificationRegistrar registrar_;
109 static const int kThrobberIconCount = 24;
110 static HICON throbber_icons_[kThrobberIconCount];
111 static void InitThrobberIcons();
113 DISALLOW_COPY_AND_ASSIGN(GlassBrowserFrameView);
116 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_