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_non_client_frame_view.h" 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_observer.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_registrar.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/controls/button/button.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/window/non_client_view.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class BrowserView; 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GlassBrowserFrameView : public BrowserNonClientFrameView, 188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public views::ButtonListener, 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) 25116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // BrowserNonClientFrameView: 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual int GetTopInset() const OVERRIDE; 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetThemeBackgroundXInset() const OVERRIDE; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateThrobber(bool running) OVERRIDE; 30cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual gfx::Size GetMinimumSize() const OVERRIDE; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // 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 {} 421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci virtual void SizeConstraintsChanged() OVERRIDE {} 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // views::View: 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Layout() OVERRIDE; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // views::ButtonListener: 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void ButtonPressed(views::Button* sender, 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const ui::Event& event) OVERRIDE; 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // views::NonClientFrameView: 55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual bool DoesIntersectRect(const views::View* target, 56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const gfx::Rect& rect) const OVERRIDE; 57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the thickness of the border that makes up the window frame edges. 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This does not include any client edge. 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int FrameBorderThickness() const; 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the thickness of the entire nonclient left, right, and bottom 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // borders, including both the window frame and any client edge. 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int NonClientBorderThickness() const; 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the height of the entire nonclient top border, including the window 67f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // frame, any title area, and any connected client edge. 68f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int NonClientTopBorderHeight() const; 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Paint various sub-components of this view. 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PaintToolbarBackground(gfx::Canvas* canvas); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PaintRestoredClientEdge(gfx::Canvas* canvas); 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Layout various sub-components of this view. 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void LayoutAvatar(); 768bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void LayoutNewStyleAvatar(); 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void LayoutClientView(); 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the insets of the client area. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Insets GetClientAreaInsets() const; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the bounds of the client area for the specified view size. 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect CalculateClientAreaBounds(int width, int height) const; 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Starts/Stops the window throbber running. 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StartThrobber(); 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StopThrobber(); 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Displays the next throbber frame. 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DisplayNextThrobberFrame(); 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // content::NotificationObserver implementation: 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Observe(int type, 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) OVERRIDE; 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The layout rect of the avatar icon, if visible. 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect avatar_bounds_; 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The bounds of the ClientView. 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect client_view_bounds_; 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether or not the window throbber is currently animating. 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool throbber_running_; 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The index of the current frame of the throbber animation. 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int throbber_frame_; 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationRegistrar registrar_; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kThrobberIconCount = 24; 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static HICON throbber_icons_[kThrobberIconCount]; 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void InitThrobberIcons(); 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(GlassBrowserFrameView); 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_ 119