Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: ui/views/window/custom_frame_view.h

Issue 240163006: Linux Aura Task Manager Frame Buttons Misaligned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor button observer out of CustomFrameView Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
8 #include <vector>
flackr 2014/05/01 15:43:36 No longer used.
jonross 2014/05/02 17:53:54 Done.
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
11 #include "ui/views/controls/button/button.h" 13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/window/frame_buttons.h"
12 #include "ui/views/window/non_client_view.h" 15 #include "ui/views/window/non_client_view.h"
13 16
14 namespace gfx { 17 namespace gfx {
15 class ImageSkia; 18 class ImageSkia;
16 } 19 }
17 20
18 namespace views { 21 namespace views {
19 22
20 class FrameBackground; 23 class FrameBackground;
21 class ImageButton; 24 class ImageButton;
22 class Widget; 25 class Widget;
23 26
24 /////////////////////////////////////////////////////////////////////////////// 27 ///////////////////////////////////////////////////////////////////////////////
25 // 28 //
26 // CustomFrameView 29 // CustomFrameView
27 // 30 //
28 // A view that provides the non client frame for Windows. This means 31 // A view that provides the non client frame for Windows. This means
29 // rendering the non-standard window caption, border, and controls. 32 // rendering the non-standard window caption, border, and controls.
30 // 33 //
31 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
32 class CustomFrameView : public NonClientFrameView, 35 class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
33 public ButtonListener { 36 public ButtonListener {
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
61 private: 64 private:
65 friend class CustomFrameViewTest;
66
62 // Returns the thickness of the border that makes up the window frame edges. 67 // Returns the thickness of the border that makes up the window frame edges.
63 // This does not include any client edge. 68 // This does not include any client edge.
64 int FrameBorderThickness() const; 69 int FrameBorderThickness() const;
65 70
66 // Returns the thickness of the entire nonclient left, right, and bottom 71 // Returns the thickness of the entire nonclient left, right, and bottom
67 // borders, including both the window frame and any client edge. 72 // borders, including both the window frame and any client edge.
68 int NonClientBorderThickness() const; 73 int NonClientBorderThickness() const;
69 74
70 // Returns the height of the entire nonclient top border, including the window 75 // Returns the height of the entire nonclient top border, including the window
71 // frame, any title area, and any connected client edge. 76 // frame, any title area, and any connected client edge.
(...skipping 25 matching lines...) Expand all
97 // Paint various sub-components of this view. 102 // Paint various sub-components of this view.
98 void PaintRestoredFrameBorder(gfx::Canvas* canvas); 103 void PaintRestoredFrameBorder(gfx::Canvas* canvas);
99 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); 104 void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
100 void PaintTitleBar(gfx::Canvas* canvas); 105 void PaintTitleBar(gfx::Canvas* canvas);
101 void PaintRestoredClientEdge(gfx::Canvas* canvas); 106 void PaintRestoredClientEdge(gfx::Canvas* canvas);
102 107
103 // Compute aspects of the frame needed to paint the frame background. 108 // Compute aspects of the frame needed to paint the frame background.
104 SkColor GetFrameColor() const; 109 SkColor GetFrameColor() const;
105 const gfx::ImageSkia* GetFrameImage() const; 110 const gfx::ImageSkia* GetFrameImage() const;
106 111
107 // Layout various sub-components of this view. 112 // Sets visibility, sizing, and position of an individual button. The value
113 // of |x| and |y| will be the origin for the button.
114 void LayoutButton(ImageButton* button, int x, int y);
115
116 // Performs the layout for the window control buttons based on the
117 // configuration specified in |leading_buttons_| and |trailing_buttons_|.
118 // The sizing and positions of the buttons affects LayoutTitleBar, call
119 // this beforehand.
108 void LayoutWindowControls(); 120 void LayoutWindowControls();
121
122 // Calculations depend on the positions of the window controls. Always call
123 // LayoutWindowControls beforehand.
109 void LayoutTitleBar(); 124 void LayoutTitleBar();
110 void LayoutClientView(); 125 void LayoutClientView();
111 126
112 // Creates, adds and returns a new window caption button (e.g, minimize, 127 // Creates, adds and returns a new window caption button (e.g, minimize,
113 // maximize, restore). 128 // maximize, restore).
114 ImageButton* InitWindowCaptionButton(int accessibility_string_id, 129 ImageButton* InitWindowCaptionButton(int accessibility_string_id,
115 int normal_image_id, 130 int normal_image_id,
116 int hot_image_id, 131 int hot_image_id,
117 int pushed_image_id); 132 int pushed_image_id);
118 133
134 // Returns the window caption button for the given FrameButton type, if it
135 // should be visible. Otherwise NULL.
136 ImageButton* GetImageButton(views::FrameButton button);
137
119 // The bounds of the client view, in this view's coordinates. 138 // The bounds of the client view, in this view's coordinates.
120 gfx::Rect client_view_bounds_; 139 gfx::Rect client_view_bounds_;
121 140
122 // The layout rect of the title, if visible. 141 // The layout rect of the title, if visible.
123 gfx::Rect title_bounds_; 142 gfx::Rect title_bounds_;
124 143
125 // Not owned. 144 // Not owned.
126 Widget* frame_; 145 Widget* frame_;
127 146
128 // The icon of this window. May be NULL. 147 // The icon of this window. May be NULL.
129 ImageButton* window_icon_; 148 ImageButton* window_icon_;
130 149
131 // Window caption buttons. 150 // Window caption buttons.
132 ImageButton* minimize_button_; 151 ImageButton* minimize_button_;
133 ImageButton* maximize_button_; 152 ImageButton* maximize_button_;
134 ImageButton* restore_button_; 153 ImageButton* restore_button_;
135 ImageButton* close_button_; 154 ImageButton* close_button_;
136 155
137 // Should maximize button be shown? 156 // Should maximize button be shown?
138 bool should_show_maximize_button_; 157 bool should_show_maximize_button_;
139 158
140 // Background painter for the window frame. 159 // Background painter for the window frame.
141 scoped_ptr<FrameBackground> frame_background_; 160 scoped_ptr<FrameBackground> frame_background_;
142 161
162 // The horizontal boundaries for the title bar to layout within. Restricted
163 // by the space used by the leading and trailing buttons.
164 int minimum_title_bar_x_;
165 int maximum_title_bar_x_;
166
143 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); 167 DISALLOW_COPY_AND_ASSIGN(CustomFrameView);
144 }; 168 };
145 169
146 } // namespace views 170 } // namespace views
147 171
148 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ 172 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698