glass_browser_frame_view.h revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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_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" 15 16class BrowserView; 17 18class GlassBrowserFrameView : public BrowserNonClientFrameView, 19 public views::ButtonListener, 20 public content::NotificationObserver { 21 public: 22 // Constructs a non-client view for an BrowserFrame. 23 GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); 24 virtual ~GlassBrowserFrameView(); 25 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; 32 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) 39 OVERRIDE {} 40 virtual void ResetWindowControls() OVERRIDE {} 41 virtual void UpdateWindowIcon() OVERRIDE {} 42 virtual void UpdateWindowTitle() OVERRIDE {} 43 44 protected: 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; 49 50 // Overidden from views::ButtonListener: 51 virtual void ButtonPressed(views::Button* sender, 52 const ui::Event& event) OVERRIDE; 53 54 private: 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; 58 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; 62 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; 67 68 // Paint various sub-components of this view. 69 void PaintToolbarBackground(gfx::Canvas* canvas); 70 void PaintRestoredClientEdge(gfx::Canvas* canvas); 71 72 // Layout various sub-components of this view. 73 void LayoutAvatar(); 74 void LayoutNewStyleAvatar(); 75 void LayoutClientView(); 76 77 // Returns the insets of the client area. 78 gfx::Insets GetClientAreaInsets() const; 79 80 // Returns the bounds of the client area for the specified view size. 81 gfx::Rect CalculateClientAreaBounds(int width, int height) const; 82 83 // Starts/Stops the window throbber running. 84 void StartThrobber(); 85 void StopThrobber(); 86 87 // Displays the next throbber frame. 88 void DisplayNextThrobberFrame(); 89 90 // content::NotificationObserver implementation: 91 virtual void Observe(int type, 92 const content::NotificationSource& source, 93 const content::NotificationDetails& details) OVERRIDE; 94 95 // The layout rect of the avatar icon, if visible. 96 gfx::Rect avatar_bounds_; 97 98 // The bounds of the ClientView. 99 gfx::Rect client_view_bounds_; 100 101 // Whether or not the window throbber is currently animating. 102 bool throbber_running_; 103 104 // The index of the current frame of the throbber animation. 105 int throbber_frame_; 106 107 content::NotificationRegistrar registrar_; 108 109 static const int kThrobberIconCount = 24; 110 static HICON throbber_icons_[kThrobberIconCount]; 111 static void InitThrobberIcons(); 112 113 DISALLOW_COPY_AND_ASSIGN(GlassBrowserFrameView); 114}; 115 116#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_ 117