| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_BROWSER_FRAME_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/views/frame/browser_frame.h" | 8 #include "chrome/browser/views/frame/browser_frame.h" |
| 9 #include "chrome/browser/views/frame/browser_non_client_frame_view.h" | 9 #include "chrome/browser/views/frame/browser_non_client_frame_view.h" |
| 10 #include "chrome/browser/views/tab_icon_view.h" | 10 #include "chrome/browser/views/tab_icon_view.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class OpaqueBrowserFrameView : public BrowserNonClientFrameView, | 25 class OpaqueBrowserFrameView : public BrowserNonClientFrameView, |
| 26 public views::ButtonListener, | 26 public views::ButtonListener, |
| 27 public TabIconView::TabIconViewModel { | 27 public TabIconView::TabIconViewModel { |
| 28 public: | 28 public: |
| 29 // Constructs a non-client view for an BrowserFrame. | 29 // Constructs a non-client view for an BrowserFrame. |
| 30 OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); | 30 OpaqueBrowserFrameView(BrowserFrame* frame, BrowserView* browser_view); |
| 31 virtual ~OpaqueBrowserFrameView(); | 31 virtual ~OpaqueBrowserFrameView(); |
| 32 | 32 |
| 33 // Overridden from BrowserNonClientFrameView: | 33 // Overridden from BrowserNonClientFrameView: |
| 34 virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const; | 34 virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const; |
| 35 virtual int GetHorizontalTabStripVerticalOffset(bool restored) const; |
| 35 virtual void UpdateThrobber(bool running); | 36 virtual void UpdateThrobber(bool running); |
| 36 virtual gfx::Size GetMinimumSize(); | 37 virtual gfx::Size GetMinimumSize(); |
| 37 | 38 |
| 38 protected: | 39 protected: |
| 39 // Overridden from views::NonClientFrameView: | 40 // Overridden from views::NonClientFrameView: |
| 40 virtual gfx::Rect GetBoundsForClientView() const; | 41 virtual gfx::Rect GetBoundsForClientView() const; |
| 41 virtual bool AlwaysUseNativeFrame() const; | 42 virtual bool AlwaysUseNativeFrame() const; |
| 42 virtual bool AlwaysUseCustomFrame() const; | 43 virtual bool AlwaysUseCustomFrame() const; |
| 43 virtual gfx::Rect GetWindowBoundsForClientBounds( | 44 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 44 const gfx::Rect& client_bounds) const; | 45 const gfx::Rect& client_bounds) const; |
| 45 virtual int NonClientHitTest(const gfx::Point& point); | 46 virtual int NonClientHitTest(const gfx::Point& point); |
| 46 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); | 47 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); |
| 47 virtual void EnableClose(bool enable); | 48 virtual void EnableClose(bool enable); |
| 48 virtual void ResetWindowControls(); | 49 virtual void ResetWindowControls(); |
| 49 | 50 |
| 50 // Overridden from views::View: | 51 // Overridden from views::View: |
| 51 virtual void Paint(gfx::Canvas* canvas); | 52 virtual void Paint(gfx::Canvas* canvas); |
| 52 virtual void PaintChildren(gfx::Canvas* canvas); | |
| 53 virtual void Layout(); | 53 virtual void Layout(); |
| 54 virtual bool HitTest(const gfx::Point& l) const; | 54 virtual bool HitTest(const gfx::Point& l) const; |
| 55 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); | 55 virtual bool GetAccessibleRole(AccessibilityTypes::Role* role); |
| 56 | 56 |
| 57 // Overridden from views::ButtonListener: | 57 // Overridden from views::ButtonListener: |
| 58 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 58 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 59 | 59 |
| 60 // Overridden from TabIconView::TabIconViewModel: | 60 // Overridden from TabIconView::TabIconViewModel: |
| 61 virtual bool ShouldTabIconViewAnimate() const; | 61 virtual bool ShouldTabIconViewAnimate() const; |
| 62 virtual SkBitmap GetFavIconForTabIconView(); | 62 virtual SkBitmap GetFavIconForTabIconView(); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 // Returns the thickness of the border that makes up the window frame edges. | 65 // Returns the thickness of the border that makes up the window frame edges. |
| 66 // This does not include any client edge. | 66 // This does not include any client edge. If |restored| is true, acts as if |
| 67 int FrameBorderThickness() const; | 67 // the window is restored regardless of the real mode. |
| 68 int FrameBorderThickness(bool restored) const; |
| 68 | 69 |
| 69 // Returns the height of the top resize area. This is smaller than the frame | 70 // Returns the height of the top resize area. This is smaller than the frame |
| 70 // border height in order to increase the window draggable area. | 71 // border height in order to increase the window draggable area. |
| 71 int TopResizeHeight() const; | 72 int TopResizeHeight() const; |
| 72 | 73 |
| 73 // Returns the thickness of the entire nonclient left, right, and bottom | 74 // Returns the thickness of the entire nonclient left, right, and bottom |
| 74 // borders, including both the window frame and any client edge. | 75 // borders, including both the window frame and any client edge. |
| 75 int NonClientBorderThickness() const; | 76 int NonClientBorderThickness() const; |
| 76 | 77 |
| 77 // Returns the height of the entire nonclient top border, including the window | 78 // Returns the height of the entire nonclient top border, including the window |
| 78 // frame, any title area, and any connected client edge. | 79 // frame, any title area, and any connected client edge. If |restored| is |
| 79 int NonClientTopBorderHeight() const; | 80 // true, acts as if the window is restored regardless of the real mode. If |
| 81 // |ignore_vertical_tabs| is true, acts as if vertical tabs are off regardless |
| 82 // of the real state. |
| 83 int NonClientTopBorderHeight(bool restored, bool ignore_vertical_tabs) const; |
| 80 | 84 |
| 81 // Returns the y-coordinate of the caption buttons. | 85 // Returns the y-coordinate of the caption buttons. If |restored| is true, |
| 82 int CaptionButtonY() const; | 86 // acts as if the window is restored regardless of the real mode. |
| 87 int CaptionButtonY(bool restored) const; |
| 83 | 88 |
| 84 // Returns the thickness of the nonclient portion of the 3D edge along the | 89 // Returns the thickness of the 3D edge along the bottom of the titlebar. If |
| 85 // bottom of the titlebar. | 90 // |restored| is true, acts as if the window is restored regardless of the |
| 86 int TitlebarBottomThickness() const; | 91 // real mode. |
| 92 int TitlebarBottomThickness(bool restored) const; |
| 87 | 93 |
| 88 // Returns the size of the titlebar icon. This is used even when the icon is | 94 // Returns the size of the titlebar icon. This is used even when the icon is |
| 89 // not shown, e.g. to set the titlebar height. | 95 // not shown, e.g. to set the titlebar height. |
| 90 int IconSize() const; | 96 int IconSize() const; |
| 91 | 97 |
| 92 // Returns the bounds of the titlebar icon (or where the icon would be if | 98 // Returns the bounds of the titlebar icon (or where the icon would be if |
| 93 // there was one). | 99 // there was one). |
| 94 gfx::Rect IconBounds() const; | 100 gfx::Rect IconBounds() const; |
| 95 | 101 |
| 96 // Paint various sub-components of this view. The *FrameBorder() functions | 102 // Paint various sub-components of this view. The *FrameBorder() functions |
| 97 // also paint the background of the titlebar area, since the top frame border | 103 // also paint the background of the titlebar area, since the top frame border |
| 98 // and titlebar background are a contiguous component. | 104 // and titlebar background are a contiguous component. |
| 99 void PaintRestoredFrameBorder(gfx::Canvas* canvas); | 105 void PaintRestoredFrameBorder(gfx::Canvas* canvas); |
| 100 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); | 106 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); |
| 101 void PaintTitleBar(gfx::Canvas* canvas); | 107 void PaintTitleBar(gfx::Canvas* canvas); |
| 102 void PaintToolbarBackground(gfx::Canvas* canvas); | 108 void PaintToolbarBackground(gfx::Canvas* canvas); |
| 109 void PaintOTRAvatar(gfx::Canvas* canvas); |
| 103 void PaintRestoredClientEdge(gfx::Canvas* canvas); | 110 void PaintRestoredClientEdge(gfx::Canvas* canvas); |
| 104 | 111 |
| 105 // Layout various sub-components of this view. | 112 // Layout various sub-components of this view. |
| 106 void LayoutWindowControls(); | 113 void LayoutWindowControls(); |
| 107 void LayoutTitleBar(); | 114 void LayoutTitleBar(); |
| 108 void LayoutOTRAvatar(); | 115 void LayoutOTRAvatar(); |
| 109 | 116 |
| 110 // Returns the bounds of the client area for the specified view size. | 117 // Returns the bounds of the client area for the specified view size. |
| 111 gfx::Rect CalculateClientAreaBounds(int width, int height) const; | 118 gfx::Rect CalculateClientAreaBounds(int width, int height) const; |
| 112 | 119 |
| 113 // Returns the bounds of |src| in the coordinate system of |dst|. | |
| 114 // TODO(sky): promote this to view. | |
| 115 static gfx::Rect GetViewBounds(views::View* src, views::View* dst); | |
| 116 | |
| 117 // The layout rect of the title, if visible. | 120 // The layout rect of the title, if visible. |
| 118 gfx::Rect title_bounds_; | 121 gfx::Rect title_bounds_; |
| 119 | 122 |
| 120 // Off the record avatar icon. | 123 // The layout rect of the OTR avatar icon, if visible. |
| 121 views::ImageView* otr_avatar_icon_; | 124 gfx::Rect otr_avatar_bounds_; |
| 122 | 125 |
| 123 // Window controls. | 126 // Window controls. |
| 124 views::ImageButton* minimize_button_; | 127 views::ImageButton* minimize_button_; |
| 125 views::ImageButton* maximize_button_; | 128 views::ImageButton* maximize_button_; |
| 126 views::ImageButton* restore_button_; | 129 views::ImageButton* restore_button_; |
| 127 views::ImageButton* close_button_; | 130 views::ImageButton* close_button_; |
| 128 | 131 |
| 129 // The Window icon. | 132 // The Window icon. |
| 130 TabIconView* window_icon_; | 133 TabIconView* window_icon_; |
| 131 | 134 |
| 132 // The frame that hosts this view. | 135 // The frame that hosts this view. |
| 133 BrowserFrame* frame_; | 136 BrowserFrame* frame_; |
| 134 | 137 |
| 135 // The BrowserView hosted within this View. | 138 // The BrowserView hosted within this View. |
| 136 BrowserView* browser_view_; | 139 BrowserView* browser_view_; |
| 137 | 140 |
| 138 // The bounds of the ClientView. | 141 // The bounds of the ClientView. |
| 139 gfx::Rect client_view_bounds_; | 142 gfx::Rect client_view_bounds_; |
| 140 | 143 |
| 141 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView); | 144 DISALLOW_COPY_AND_ASSIGN(OpaqueBrowserFrameView); |
| 142 }; | 145 }; |
| 143 | 146 |
| 144 #endif // CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ | 147 #endif // CHROME_BROWSER_VIEWS_FRAME_OPAQUE_BROWSER_FRAME_VIEW_H_ |
| OLD | NEW |