| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/views/frame/opaque_frame.h" | 8 #include "chrome/browser/views/frame/browser_frame.h" |
| 9 #include "chrome/browser/views/tab_icon_view.h" | 9 #include "chrome/browser/views/tab_icon_view.h" |
| 10 #include "chrome/views/non_client_view.h" | 10 #include "chrome/views/non_client_view.h" |
| 11 #include "chrome/views/button.h" | 11 #include "chrome/views/button.h" |
| 12 | 12 |
| 13 class BrowserView; | 13 class BrowserView; |
| 14 class OpaqueFrame; | |
| 15 class TabContents; | 14 class TabContents; |
| 16 class TabStrip; | 15 class TabStrip; |
| 17 namespace views { | 16 namespace views { |
| 18 class WindowResources; | 17 class WindowResources; |
| 19 } | 18 } |
| 20 | 19 |
| 21 class OpaqueNonClientView : public views::NonClientView, | 20 class OpaqueBrowserFrameView : public BrowserNonClientFrameView, |
| 22 public views::BaseButton::ButtonListener, | 21 public views::BaseButton::ButtonListener, |
| 23 public TabIconView::TabIconViewModel { | 22 public TabIconView::TabIconViewModel { |
| 24 public: | 23 public: |
| 25 // Constructs a non-client view for an OpaqueFrame. |is_otr| specifies if the | 24 // Constructs a non-client view for an BrowserFrame. |is_otr| specifies if the |
| 26 // frame was created "off-the-record" and as such different bitmaps should be | 25 // frame was created "off-the-record" and as such different bitmaps should be |
| 27 // used to render the frame. | 26 // used to render the frame. |
| 28 OpaqueNonClientView(OpaqueFrame* frame, BrowserView* browser_view); | 27 OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); |
| 29 virtual ~OpaqueNonClientView(); | 28 virtual ~OpaqueBrowserFrameView(); |
| 30 | 29 |
| 31 // Retrieve the bounds of the window for the specified contents bounds. | 30 // Overridden from BrowserNonClientFrameView: |
| 32 gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect& client_bounds); | 31 virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; |
| 33 | 32 virtual void UpdateThrobber(bool running); |
| 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 | 33 |
| 41 protected: | 34 protected: |
| 42 // Overridden from views::NonClientView: | 35 // Overridden from views::NonClientFrameView: |
| 43 virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; | 36 virtual gfx::Rect GetBoundsForClientView() const; |
| 44 virtual gfx::Size CalculateWindowSizeForClientSize(int width, | 37 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 45 int height) const; | 38 const gfx::Rect& client_bounds) const; |
| 46 virtual gfx::Point GetSystemMenuPoint() const; | 39 virtual gfx::Point GetSystemMenuPoint() const; |
| 47 virtual int NonClientHitTest(const gfx::Point& point); | 40 virtual int NonClientHitTest(const gfx::Point& point); |
| 48 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); | 41 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); |
| 49 virtual void EnableClose(bool enable); | 42 virtual void EnableClose(bool enable); |
| 50 virtual void ResetWindowControls(); | 43 virtual void ResetWindowControls(); |
| 51 | 44 |
| 52 // Overridden from views::View: | 45 // Overridden from views::View: |
| 53 virtual void Paint(ChromeCanvas* canvas); | 46 virtual void Paint(ChromeCanvas* canvas); |
| 54 virtual void Layout(); | 47 virtual void Layout(); |
| 55 virtual views::View* GetViewForPoint(const gfx::Point& point, | 48 virtual views::View* GetViewForPoint(const gfx::Point& point, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void PaintOTRAvatar(ChromeCanvas* canvas); | 100 void PaintOTRAvatar(ChromeCanvas* canvas); |
| 108 void PaintRestoredClientEdge(ChromeCanvas* canvas); | 101 void PaintRestoredClientEdge(ChromeCanvas* canvas); |
| 109 | 102 |
| 110 // Layout various sub-components of this view. | 103 // Layout various sub-components of this view. |
| 111 void LayoutWindowControls(); | 104 void LayoutWindowControls(); |
| 112 void LayoutDistributorLogo(); | 105 void LayoutDistributorLogo(); |
| 113 void LayoutTitleBar(); | 106 void LayoutTitleBar(); |
| 114 void LayoutOTRAvatar(); | 107 void LayoutOTRAvatar(); |
| 115 void LayoutClientView(); | 108 void LayoutClientView(); |
| 116 | 109 |
| 110 // Returns the bounds of the client area for the specified view size. |
| 111 gfx::Rect CalculateClientAreaBounds(int width, int height) const; |
| 112 |
| 117 // Returns the set of resources to use to paint this view. | 113 // Returns the set of resources to use to paint this view. |
| 118 views::WindowResources* resources() const { | 114 views::WindowResources* resources() const { |
| 119 return frame_->is_active() || paint_as_active() ? | 115 return frame_->is_active() || paint_as_active() ? |
| 120 current_active_resources_ : current_inactive_resources_; | 116 current_active_resources_ : current_inactive_resources_; |
| 121 } | 117 } |
| 122 | 118 |
| 123 // The layout rect of the title, if visible. | 119 // The layout rect of the title, if visible. |
| 124 gfx::Rect title_bounds_; | 120 gfx::Rect title_bounds_; |
| 125 | 121 |
| 126 // The layout rect of the distributor logo, if visible. | 122 // The layout rect of the distributor logo, if visible. |
| 127 gfx::Rect logo_bounds_; | 123 gfx::Rect logo_bounds_; |
| 128 | 124 |
| 129 // The layout rect of the OTR avatar icon, if visible. | 125 // The layout rect of the OTR avatar icon, if visible. |
| 130 gfx::Rect otr_avatar_bounds_; | 126 gfx::Rect otr_avatar_bounds_; |
| 131 | 127 |
| 132 // Window controls. | 128 // Window controls. |
| 133 views::Button* minimize_button_; | 129 views::Button* minimize_button_; |
| 134 views::Button* maximize_button_; | 130 views::Button* maximize_button_; |
| 135 views::Button* restore_button_; | 131 views::Button* restore_button_; |
| 136 views::Button* close_button_; | 132 views::Button* close_button_; |
| 137 | 133 |
| 138 // The Window icon. | 134 // The Window icon. |
| 139 TabIconView* window_icon_; | 135 TabIconView* window_icon_; |
| 140 | 136 |
| 141 // The frame that hosts this view. | 137 // The frame that hosts this view. |
| 142 OpaqueFrame* frame_; | 138 BrowserFrame* frame_; |
| 143 | 139 |
| 144 // The BrowserView hosted within this View. | 140 // The BrowserView hosted within this View. |
| 145 BrowserView* browser_view_; | 141 BrowserView* browser_view_; |
| 146 | 142 |
| 143 // The bounds of the ClientView. |
| 144 gfx::Rect client_view_bounds_; |
| 145 |
| 147 // The resources currently used to paint this view. | 146 // The resources currently used to paint this view. |
| 148 views::WindowResources* current_active_resources_; | 147 views::WindowResources* current_active_resources_; |
| 149 views::WindowResources* current_inactive_resources_; | 148 views::WindowResources* current_inactive_resources_; |
| 150 | 149 |
| 151 // The accessible name of this view. | 150 // The accessible name of this view. |
| 152 std::wstring accessible_name_; | 151 std::wstring accessible_name_; |
| 153 | 152 |
| 154 static void InitClass(); | 153 static void InitClass(); |
| 155 static void InitAppWindowResources(); | 154 static void InitAppWindowResources(); |
| 156 static SkBitmap* distributor_logo_; | 155 static SkBitmap* distributor_logo_; |
| 157 static views::WindowResources* active_resources_; | 156 static views::WindowResources* active_resources_; |
| 158 static views::WindowResources* inactive_resources_; | 157 static views::WindowResources* inactive_resources_; |
| 159 static views::WindowResources* active_otr_resources_; | 158 static views::WindowResources* active_otr_resources_; |
| 160 static views::WindowResources* inactive_otr_resources_; | 159 static views::WindowResources* inactive_otr_resources_; |
| 161 static ChromeFont title_font_; | 160 static ChromeFont title_font_; |
| 162 | 161 |
| 163 DISALLOW_EVIL_CONSTRUCTORS(OpaqueNonClientView); | 162 DISALLOW_EVIL_CONSTRUCTORS(OpaqueBrowserFrameView); |
| 164 }; | 163 }; |
| 165 | 164 |
| 166 #endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_NON_CLIENT_VIEW_H_ | 165 #endif // #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ |
| 167 | 166 |
| OLD | NEW |