| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_ | |
| 6 #define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_ | |
| 7 | |
| 8 #include "chrome/browser/views/frame/opaque_frame.h" | |
| 9 #include "chrome/browser/views/tab_icon_view.h" | |
| 10 #include "chrome/views/non_client_view.h" | |
| 11 #include "chrome/views/button.h" | |
| 12 | |
| 13 class BrowserView; | |
| 14 class OpaqueFrame; | |
| 15 class TabContents; | |
| 16 class TabStrip; | |
| 17 namespace views { | |
| 18 class WindowResources; | |
| 19 } | |
| 20 | |
| 21 class OpaqueNonClientView : public views::NonClientView, | |
| 22 public views::BaseButton::ButtonListener, | |
| 23 public TabIconView::TabIconViewModel { | |
| 24 public: | |
| 25 // Constructs a non-client view for an OpaqueFrame. |is_otr| specifies if the | |
| 26 // frame was created "off-the-record" and as such different bitmaps should be | |
| 27 // used to render the frame. | |
| 28 OpaqueNonClientView(OpaqueFrame* frame, BrowserView* browser_view); | |
| 29 virtual ~OpaqueNonClientView(); | |
| 30 | |
| 31 // Retrieve the bounds of the window for the specified contents bounds. | |
| 32 gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect& client_bounds); | |
| 33 | |
| 34 // Retrieve the bounds for the specified |tabstrip|, in the coordinate system | |
| 35 // of the non-client view (which whould be window coordinates). | |
| 36 gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip); | |
| 37 | |
| 38 // Updates the window icon/throbber. | |
| 39 void UpdateWindowIcon(); | |
| 40 | |
| 41 protected: | |
| 42 // Overridden from views::NonClientView: | |
| 43 virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; | |
| 44 virtual gfx::Size CalculateWindowSizeForClientSize(int width, | |
| 45 int height) const; | |
| 46 virtual gfx::Point GetSystemMenuPoint() const; | |
| 47 virtual int NonClientHitTest(const gfx::Point& point); | |
| 48 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); | |
| 49 virtual void EnableClose(bool enable); | |
| 50 virtual void ResetWindowControls(); | |
| 51 | |
| 52 // Overridden from views::View: | |
| 53 virtual void Paint(ChromeCanvas* canvas); | |
| 54 virtual void Layout(); | |
| 55 virtual views::View* GetViewForPoint(const gfx::Point& point, | |
| 56 bool can_create_floating); | |
| 57 virtual void ViewHierarchyChanged(bool is_add, | |
| 58 views::View* parent, | |
| 59 views::View* child); | |
| 60 virtual bool GetAccessibleRole(VARIANT* role); | |
| 61 virtual bool GetAccessibleName(std::wstring* name); | |
| 62 virtual void SetAccessibleName(const std::wstring& name); | |
| 63 | |
| 64 // Overridden from views::BaseButton::ButtonListener: | |
| 65 virtual void ButtonPressed(views::BaseButton* sender); | |
| 66 | |
| 67 // Overridden from TabIconView::TabIconViewModel: | |
| 68 virtual bool ShouldTabIconViewAnimate() const; | |
| 69 virtual SkBitmap GetFavIconForTabIconView(); | |
| 70 | |
| 71 private: | |
| 72 // Returns the thickness of the border that makes up the window frame edges. | |
| 73 // This does not include any client edge. | |
| 74 int FrameBorderThickness() const; | |
| 75 | |
| 76 // Returns the height of the top resize area. This is smaller than the frame | |
| 77 // border height in order to increase the window draggable area. | |
| 78 int TopResizeHeight() const; | |
| 79 | |
| 80 // Returns the thickness of the entire nonclient left, right, and bottom | |
| 81 // borders, including both the window frame and any client edge. | |
| 82 int NonClientBorderThickness() const; | |
| 83 | |
| 84 // Returns the height of the entire nonclient top border, including the window | |
| 85 // frame, any title area, and any connected client edge. | |
| 86 int NonClientTopBorderHeight() const; | |
| 87 | |
| 88 // The nonclient area at the top of the window may include some "unavailable" | |
| 89 // pixels at its bottom: a dark shadow along the bottom of the titlebar and a | |
| 90 // client edge. These vary from mode to mode, so this function returns the | |
| 91 // number of such pixels the nonclient height includes. | |
| 92 int UnavailablePixelsAtBottomOfNonClientHeight() const; | |
| 93 | |
| 94 // Calculates multiple values related to title layout. Returns the height of | |
| 95 // the entire titlebar including any connected client edge. | |
| 96 int TitleCoordinates(int* title_top_spacing, | |
| 97 int* title_thickness) const; | |
| 98 | |
| 99 // Paint various sub-components of this view. The *FrameBorder() functions | |
| 100 // also paint the background of the titlebar area, since the top frame border | |
| 101 // and titlebar background are a contiguous component. | |
| 102 void PaintRestoredFrameBorder(ChromeCanvas* canvas); | |
| 103 void PaintMaximizedFrameBorder(ChromeCanvas* canvas); | |
| 104 void PaintDistributorLogo(ChromeCanvas* canvas); | |
| 105 void PaintTitleBar(ChromeCanvas* canvas); | |
| 106 void PaintToolbarBackground(ChromeCanvas* canvas); | |
| 107 void PaintOTRAvatar(ChromeCanvas* canvas); | |
| 108 void PaintRestoredClientEdge(ChromeCanvas* canvas); | |
| 109 | |
| 110 // Layout various sub-components of this view. | |
| 111 void LayoutWindowControls(); | |
| 112 void LayoutDistributorLogo(); | |
| 113 void LayoutTitleBar(); | |
| 114 void LayoutOTRAvatar(); | |
| 115 void LayoutClientView(); | |
| 116 | |
| 117 // Returns the set of resources to use to paint this view. | |
| 118 views::WindowResources* resources() const { | |
| 119 return frame_->is_active() || paint_as_active() ? | |
| 120 current_active_resources_ : current_inactive_resources_; | |
| 121 } | |
| 122 | |
| 123 // The layout rect of the title, if visible. | |
| 124 gfx::Rect title_bounds_; | |
| 125 | |
| 126 // The layout rect of the distributor logo, if visible. | |
| 127 gfx::Rect logo_bounds_; | |
| 128 | |
| 129 // The layout rect of the OTR avatar icon, if visible. | |
| 130 gfx::Rect otr_avatar_bounds_; | |
| 131 | |
| 132 // Window controls. | |
| 133 views::Button* minimize_button_; | |
| 134 views::Button* maximize_button_; | |
| 135 views::Button* restore_button_; | |
| 136 views::Button* close_button_; | |
| 137 | |
| 138 // The Window icon. | |
| 139 TabIconView* window_icon_; | |
| 140 | |
| 141 // The frame that hosts this view. | |
| 142 OpaqueFrame* frame_; | |
| 143 | |
| 144 // The BrowserView hosted within this View. | |
| 145 BrowserView* browser_view_; | |
| 146 | |
| 147 // The resources currently used to paint this view. | |
| 148 views::WindowResources* current_active_resources_; | |
| 149 views::WindowResources* current_inactive_resources_; | |
| 150 | |
| 151 // The accessible name of this view. | |
| 152 std::wstring accessible_name_; | |
| 153 | |
| 154 static void InitClass(); | |
| 155 static void InitAppWindowResources(); | |
| 156 static SkBitmap* distributor_logo_; | |
| 157 static views::WindowResources* active_resources_; | |
| 158 static views::WindowResources* inactive_resources_; | |
| 159 static views::WindowResources* active_otr_resources_; | |
| 160 static views::WindowResources* inactive_otr_resources_; | |
| 161 static ChromeFont title_font_; | |
| 162 | |
| 163 DISALLOW_EVIL_CONSTRUCTORS(OpaqueNonClientView); | |
| 164 }; | |
| 165 | |
| 166 #endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_ | |
| 167 | |
| OLD | NEW |