glass_browser_frame_view.h revision 5821806d5e7f356e8fa4b058a389a808ea183019
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_frame_win.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_registrar.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/controls/button/button.h"
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/window/non_client_view.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserView;
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GlassBrowserFrameView : public BrowserNonClientFrameView,
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                              public content::NotificationObserver {
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Constructs a non-client view for an BrowserFrame.
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view);
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~GlassBrowserFrameView();
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from BrowserNonClientFrameView:
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE;
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual TabStripInsets GetTabStripInsets(bool restored) const OVERRIDE;
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int GetThemeBackgroundXInset() const OVERRIDE;
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateThrobber(bool running) OVERRIDE;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Size GetMinimumSize() OVERRIDE;
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from views::NonClientFrameView:
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual gfx::Rect GetWindowBoundsForClientBounds(
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      const gfx::Rect& client_bounds) const OVERRIDE;
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      OVERRIDE {}
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void ResetWindowControls() OVERRIDE {}
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateWindowIcon() OVERRIDE {}
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void UpdateWindowTitle() OVERRIDE {}
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Overridden from views::View:
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Layout() OVERRIDE;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the thickness of the border that makes up the window frame edges.
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This does not include any client edge.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int FrameBorderThickness() const;
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the thickness of the entire nonclient left, right, and bottom
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // borders, including both the window frame and any client edge.
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int NonClientBorderThickness() const;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the height of the entire nonclient top border, including the window
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // frame, any title area, and any connected client edge.  If |restored| is
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // true, acts as if the window is restored regardless of the real mode.
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int NonClientTopBorderHeight(bool restored) const;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Paint various sub-components of this view.
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PaintToolbarBackground(gfx::Canvas* canvas);
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void PaintRestoredClientEdge(gfx::Canvas* canvas);
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Layout various sub-components of this view.
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void LayoutAvatar();
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void LayoutClientView();
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the insets of the client area.
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Insets GetClientAreaInsets() const;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Returns the bounds of the client area for the specified view size.
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect CalculateClientAreaBounds(int width, int height) const;
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Starts/Stops the window throbber running.
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StartThrobber();
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void StopThrobber();
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Displays the next throbber frame.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DisplayNextThrobberFrame();
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // content::NotificationObserver implementation:
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void Observe(int type,
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationSource& source,
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                       const content::NotificationDetails& details) OVERRIDE;
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The layout rect of the avatar icon, if visible.
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect avatar_bounds_;
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The bounds of the ClientView.
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Rect client_view_bounds_;
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether or not the window throbber is currently animating.
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool throbber_running_;
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The index of the current frame of the throbber animation.
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int throbber_frame_;
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  content::NotificationRegistrar registrar_;
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int kThrobberIconCount = 24;
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static HICON throbber_icons_[kThrobberIconCount];
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static void InitThrobberIcons();
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(GlassBrowserFrameView);
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_
111