glass_browser_frame_view.h revision f2477e01787aa58f445919b809d89e252beef54f
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, 198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) public views::ButtonListener, 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public content::NotificationObserver { 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Constructs a non-client view for an BrowserFrame. 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GlassBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~GlassBrowserFrameView(); 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from BrowserNonClientFrameView: 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const OVERRIDE; 28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual int GetTopInset() const OVERRIDE; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int GetThemeBackgroundXInset() const OVERRIDE; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateThrobber(bool running) OVERRIDE; 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Size GetMinimumSize() OVERRIDE; 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from views::NonClientFrameView: 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual gfx::Rect GetWindowBoundsForClientBounds( 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const gfx::Rect& client_bounds) const OVERRIDE; 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) OVERRIDE {} 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ResetWindowControls() OVERRIDE {} 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateWindowIcon() OVERRIDE {} 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void UpdateWindowTitle() OVERRIDE {} 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden from views::View: 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Layout() OVERRIDE; 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) // Overidden from views::ButtonListener: 518bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) virtual void ButtonPressed(views::Button* sender, 528bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) const ui::Event& event) OVERRIDE; 538bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the thickness of the border that makes up the window frame edges. 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This does not include any client edge. 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int FrameBorderThickness() const; 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the thickness of the entire nonclient left, right, and bottom 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // borders, including both the window frame and any client edge. 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int NonClientBorderThickness() const; 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the height of the entire nonclient top border, including the window 64f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // frame, any title area, and any connected client edge. 65f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int NonClientTopBorderHeight() const; 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Paint various sub-components of this view. 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PaintToolbarBackground(gfx::Canvas* canvas); 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void PaintRestoredClientEdge(gfx::Canvas* canvas); 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Layout various sub-components of this view. 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void LayoutAvatar(); 738bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) void LayoutNewStyleAvatar(); 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void LayoutClientView(); 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the insets of the client area. 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Insets GetClientAreaInsets() const; 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the bounds of the client area for the specified view size. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect CalculateClientAreaBounds(int width, int height) const; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Starts/Stops the window throbber running. 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StartThrobber(); 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void StopThrobber(); 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Displays the next throbber frame. 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void DisplayNextThrobberFrame(); 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // content::NotificationObserver implementation: 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void Observe(int type, 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationSource& source, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const content::NotificationDetails& details) OVERRIDE; 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The layout rect of the avatar icon, if visible. 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect avatar_bounds_; 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The bounds of the ClientView. 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect client_view_bounds_; 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether or not the window throbber is currently animating. 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool throbber_running_; 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The index of the current frame of the throbber animation. 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int throbber_frame_; 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationRegistrar registrar_; 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int kThrobberIconCount = 24; 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static HICON throbber_icons_[kThrobberIconCount]; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void InitThrobberIcons(); 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(GlassBrowserFrameView); 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_FRAME_VIEW_H_ 116