glass_browser_frame_view.h revision 116680a4aac90f2aa7413d9095a592090648e557
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. 4 5#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_ 6#define CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_ 7 8#include "base/compiler_specific.h" 9#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" 10#include "content/public/browser/notification_observer.h" 11#include "content/public/browser/notification_registrar.h" 12#include "ui/views/controls/button/button.h" 13#include "ui/views/window/non_client_view.h" 14 15class BrowserView; 16 17class GlassBrowserFrameView : public BrowserNonClientFrameView, 18 public views::ButtonListener, 19 public content::NotificationObserver { 20 public: 21 // Constructs a non-client view for an BrowserFrame. 22 GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); 23 virtual ~GlassBrowserFrameView(); 24 25 // BrowserNonClientFrameView: 26 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 27 virtual int GetTopInset() const OVERRIDE; 28 virtual int GetThemeBackgroundXInset() const OVERRIDE; 29 virtual void UpdateThrobber(bool running) OVERRIDE; 30 virtual gfx::Size GetMinimumSize() const OVERRIDE; 31 32 // views::NonClientFrameView: 33 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 34 virtual gfx::Rect GetWindowBoundsForClientBounds( 35 const gfx::Rect& client_bounds) const OVERRIDE; 36 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 37 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) 38 OVERRIDE {} 39 virtual void ResetWindowControls() OVERRIDE {} 40 virtual void UpdateWindowIcon() OVERRIDE {} 41 virtual void UpdateWindowTitle() OVERRIDE {} 42 43 protected: 44 // views::View: 45 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 46 virtual void Layout() OVERRIDE; 47 48 // views::ButtonListener: 49 virtual void ButtonPressed(views::Button* sender, 50 const ui::Event& event) OVERRIDE; 51 52 private: 53 // views::NonClientFrameView: 54 virtual bool DoesIntersectRect(const views::View* target, 55 const gfx::Rect& rect) const OVERRIDE; 56 57 // Returns the thickness of the border that makes up the window frame edges. 58 // This does not include any client edge. 59 int FrameBorderThickness() const; 60 61 // Returns the thickness of the entire nonclient left, right, and bottom 62 // borders, including both the window frame and any client edge. 63 int NonClientBorderThickness() const; 64 65 // Returns the height of the entire nonclient top border, including the window 66 // frame, any title area, and any connected client edge. 67 int NonClientTopBorderHeight() const; 68 69 // Paint various sub-components of this view. 70 void PaintToolbarBackground(gfx::Canvas* canvas); 71 void PaintRestoredClientEdge(gfx::Canvas* canvas); 72 73 // Layout various sub-components of this view. 74 void LayoutAvatar(); 75 void LayoutNewStyleAvatar(); 76 void LayoutClientView(); 77 78 // Returns the insets of the client area. 79 gfx::Insets GetClientAreaInsets() const; 80 81 // Returns the bounds of the client area for the specified view size. 82 gfx::Rect CalculateClientAreaBounds(int width, int height) const; 83 84 // Starts/Stops the window throbber running. 85 void StartThrobber(); 86 void StopThrobber(); 87 88 // Displays the next throbber frame. 89 void DisplayNextThrobberFrame(); 90 91 // content::NotificationObserver implementation: 92 virtual void Observe(int type, 93 const content::NotificationSource& source, 94 const content::NotificationDetails& details) OVERRIDE; 95 96 // The layout rect of the avatar icon, if visible. 97 gfx::Rect avatar_bounds_; 98 99 // The bounds of the ClientView. 100 gfx::Rect client_view_bounds_; 101 102 // Whether or not the window throbber is currently animating. 103 bool throbber_running_; 104 105 // The index of the current frame of the throbber animation. 106 int throbber_frame_; 107 108 content::NotificationRegistrar registrar_; 109 110 static const int kThrobberIconCount = 24; 111 static HICON throbber_icons_[kThrobberIconCount]; 112 static void InitThrobberIcons(); 113 114 DISALLOW_COPY_AND_ASSIGN(GlassBrowserFrameView); 115}; 116 117#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_ 118