Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 5 #ifndef UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
| 6 #define UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 6 #define UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
| 7 | 7 |
|
flackr
2014/04/22 18:36:45
#include <vector>
jonross
2014/04/23 18:53:53
Done.
| |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/linux_ui/window_button_order_observer.h" | |
|
flackr
2014/04/22 18:36:45
Including ui/views/linux_ui/ from all views platfo
jonross
2014/04/23 18:53:53
Done.
| |
| 13 #include "ui/views/window/frame_buttons.h" | |
| 12 #include "ui/views/window/non_client_view.h" | 14 #include "ui/views/window/non_client_view.h" |
| 13 | 15 |
| 14 namespace gfx { | 16 namespace gfx { |
| 15 class ImageSkia; | 17 class ImageSkia; |
| 16 } | 18 } |
| 17 | 19 |
| 18 namespace views { | 20 namespace views { |
| 19 | 21 |
| 20 class FrameBackground; | 22 class FrameBackground; |
| 21 class ImageButton; | 23 class ImageButton; |
| 22 class Widget; | 24 class Widget; |
| 23 | 25 |
| 24 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 25 // | 27 // |
| 26 // CustomFrameView | 28 // CustomFrameView |
| 27 // | 29 // |
| 28 // A view that provides the non client frame for Windows. This means | 30 // A view that provides the non client frame for Windows. This means |
| 29 // rendering the non-standard window caption, border, and controls. | 31 // rendering the non-standard window caption, border, and controls. |
| 30 // | 32 // |
| 31 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 32 class CustomFrameView : public NonClientFrameView, | 34 class VIEWS_EXPORT CustomFrameView : public NonClientFrameView, |
| 33 public ButtonListener { | 35 public ButtonListener, |
| 36 public WindowButtonOrderObserver { | |
|
flackr
2014/04/22 18:36:45
nit: align public, which probably means wrapping t
jonross
2014/04/23 18:53:53
Done.
| |
| 34 public: | 37 public: |
| 35 CustomFrameView(); | 38 CustomFrameView(); |
| 36 virtual ~CustomFrameView(); | 39 virtual ~CustomFrameView(); |
| 37 | 40 |
| 38 void Init(Widget* frame); | 41 void Init(Widget* frame); |
| 39 | 42 |
| 40 // Overridden from NonClientFrameView: | 43 // NonClientFrameView: |
| 41 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; | 44 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; |
| 42 virtual gfx::Rect GetWindowBoundsForClientBounds( | 45 virtual gfx::Rect GetWindowBoundsForClientBounds( |
| 43 const gfx::Rect& client_bounds) const OVERRIDE; | 46 const gfx::Rect& client_bounds) const OVERRIDE; |
| 44 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; | 47 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; |
| 45 virtual void GetWindowMask(const gfx::Size& size, | 48 virtual void GetWindowMask(const gfx::Size& size, |
| 46 gfx::Path* window_mask) OVERRIDE; | 49 gfx::Path* window_mask) OVERRIDE; |
| 47 virtual void ResetWindowControls() OVERRIDE; | 50 virtual void ResetWindowControls() OVERRIDE; |
| 48 virtual void UpdateWindowIcon() OVERRIDE; | 51 virtual void UpdateWindowIcon() OVERRIDE; |
| 49 virtual void UpdateWindowTitle() OVERRIDE; | 52 virtual void UpdateWindowTitle() OVERRIDE; |
| 50 | 53 |
| 51 // Overridden from View: | 54 // View: |
| 52 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 55 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| 53 virtual void Layout() OVERRIDE; | 56 virtual void Layout() OVERRIDE; |
| 54 virtual gfx::Size GetPreferredSize() OVERRIDE; | 57 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 55 virtual gfx::Size GetMinimumSize() OVERRIDE; | 58 virtual gfx::Size GetMinimumSize() OVERRIDE; |
| 56 virtual gfx::Size GetMaximumSize() OVERRIDE; | 59 virtual gfx::Size GetMaximumSize() OVERRIDE; |
| 57 | 60 |
| 58 // Overridden from ButtonListener: | 61 // ButtonListener: |
| 59 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; | 62 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; |
| 60 | 63 |
| 64 // WindowButtonOrderObserver: | |
| 65 virtual void OnWindowButtonOrderingChange( | |
| 66 const std::vector<views::FrameButton>& leading_buttons, | |
| 67 const std::vector<views::FrameButton>& trailing_buttons) OVERRIDE; | |
| 68 | |
| 61 private: | 69 private: |
| 70 friend class CustomFrameViewTest; | |
| 71 | |
| 62 // Returns the thickness of the border that makes up the window frame edges. | 72 // Returns the thickness of the border that makes up the window frame edges. |
| 63 // This does not include any client edge. | 73 // This does not include any client edge. |
| 64 int FrameBorderThickness() const; | 74 int FrameBorderThickness() const; |
| 65 | 75 |
| 66 // Returns the thickness of the entire nonclient left, right, and bottom | 76 // Returns the thickness of the entire nonclient left, right, and bottom |
| 67 // borders, including both the window frame and any client edge. | 77 // borders, including both the window frame and any client edge. |
| 68 int NonClientBorderThickness() const; | 78 int NonClientBorderThickness() const; |
| 69 | 79 |
| 70 // Returns the height of the entire nonclient top border, including the window | 80 // Returns the height of the entire nonclient top border, including the window |
| 71 // frame, any title area, and any connected client edge. | 81 // frame, any title area, and any connected client edge. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 98 void PaintRestoredFrameBorder(gfx::Canvas* canvas); | 108 void PaintRestoredFrameBorder(gfx::Canvas* canvas); |
| 99 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); | 109 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); |
| 100 void PaintTitleBar(gfx::Canvas* canvas); | 110 void PaintTitleBar(gfx::Canvas* canvas); |
| 101 void PaintRestoredClientEdge(gfx::Canvas* canvas); | 111 void PaintRestoredClientEdge(gfx::Canvas* canvas); |
| 102 | 112 |
| 103 // Compute aspects of the frame needed to paint the frame background. | 113 // Compute aspects of the frame needed to paint the frame background. |
| 104 SkColor GetFrameColor() const; | 114 SkColor GetFrameColor() const; |
| 105 const gfx::ImageSkia* GetFrameImage() const; | 115 const gfx::ImageSkia* GetFrameImage() const; |
| 106 | 116 |
| 107 // Layout various sub-components of this view. | 117 // Layout various sub-components of this view. |
| 118 void LayoutButton(ImageButton* button, int x, int y, bool leading); | |
|
flackr
2014/04/22 18:36:45
I think it would be worth documenting this functio
jonross
2014/04/23 18:53:53
Removed the need for leading. Added comments.
| |
| 108 void LayoutWindowControls(); | 119 void LayoutWindowControls(); |
| 109 void LayoutTitleBar(); | 120 void LayoutTitleBar(); |
| 110 void LayoutClientView(); | 121 void LayoutClientView(); |
| 111 | 122 |
| 112 // Creates, adds and returns a new window caption button (e.g, minimize, | 123 // Creates, adds and returns a new window caption button (e.g, minimize, |
| 113 // maximize, restore). | 124 // maximize, restore). |
| 114 ImageButton* InitWindowCaptionButton(int accessibility_string_id, | 125 ImageButton* InitWindowCaptionButton(int accessibility_string_id, |
| 115 int normal_image_id, | 126 int normal_image_id, |
| 116 int hot_image_id, | 127 int hot_image_id, |
| 117 int pushed_image_id); | 128 int pushed_image_id); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 133 ImageButton* maximize_button_; | 144 ImageButton* maximize_button_; |
| 134 ImageButton* restore_button_; | 145 ImageButton* restore_button_; |
| 135 ImageButton* close_button_; | 146 ImageButton* close_button_; |
| 136 | 147 |
| 137 // Should maximize button be shown? | 148 // Should maximize button be shown? |
| 138 bool should_show_maximize_button_; | 149 bool should_show_maximize_button_; |
| 139 | 150 |
| 140 // Background painter for the window frame. | 151 // Background painter for the window frame. |
| 141 scoped_ptr<FrameBackground> frame_background_; | 152 scoped_ptr<FrameBackground> frame_background_; |
| 142 | 153 |
| 154 // Layout arrangement of the window caption buttons. On linux these will be | |
| 155 // set via OnWindowButtonOrderingChange. On other platforms a default | |
| 156 // arrangement of a trailing minimize, maximize, close, will be set. | |
| 157 std::vector<views::FrameButton> leading_buttons_; | |
| 158 std::vector<views::FrameButton> trailing_buttons_; | |
| 159 | |
| 160 // The horizontal boundaries for the title bar to layout within. Restricted | |
| 161 // by the space used by the leading and trailing buttons. | |
| 162 int minimum_title_bar_x_; | |
| 163 int maximum_title_bar_x_; | |
| 164 | |
| 143 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); | 165 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); |
| 144 }; | 166 }; |
| 145 | 167 |
| 146 } // namespace views | 168 } // namespace views |
| 147 | 169 |
| 148 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ | 170 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ |
| OLD | NEW |