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

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: Add #ifdefs Created 6 years, 8 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
« no previous file with comments | « ui/views/views.gyp ('k') | ui/views/window/custom_frame_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/04/24 21:40:13 nit: separate system includes from the rest. i.e.
jonross 2014/04/25 15:59:58 Done.
8 #include "base/basictypes.h" 9 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "ui/views/controls/button/button.h" 12 #include "ui/views/controls/button/button.h"
13
14 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
flackr 2014/04/24 21:40:13 nit: Move this to the end (i.e. after ui/views/win
jonross 2014/04/25 15:59:58 Done.
15 #include "ui/views/linux_ui/window_button_order_observer.h"
16 #endif
17
18 #include "ui/views/window/frame_buttons.h"
12 #include "ui/views/window/non_client_view.h" 19 #include "ui/views/window/non_client_view.h"
13 20
14 namespace gfx { 21 namespace gfx {
15 class ImageSkia; 22 class ImageSkia;
16 } 23 }
17 24
18 namespace views { 25 namespace views {
19 26
20 class FrameBackground; 27 class FrameBackground;
21 class ImageButton; 28 class ImageButton;
22 class Widget; 29 class Widget;
23 30
24 /////////////////////////////////////////////////////////////////////////////// 31 ///////////////////////////////////////////////////////////////////////////////
25 // 32 //
26 // CustomFrameView 33 // CustomFrameView
27 // 34 //
28 // A view that provides the non client frame for Windows. This means 35 // A view that provides the non client frame for Windows. This means
29 // rendering the non-standard window caption, border, and controls. 36 // rendering the non-standard window caption, border, and controls.
30 // 37 //
31 //////////////////////////////////////////////////////////////////////////////// 38 ////////////////////////////////////////////////////////////////////////////////
32 class CustomFrameView : public NonClientFrameView, 39 class VIEWS_EXPORT CustomFrameView : public NonClientFrameView,
33 public ButtonListener { 40 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
41 public ButtonListener,
42 public WindowButtonOrderObserver {
43 #else
44 public ButtonListener {
45 #endif
flackr 2014/04/24 21:40:13 I hate that we have to duplicate the '{', kind of
jonross 2014/04/25 15:59:58 Done.
34 public: 46 public:
35 CustomFrameView(); 47 CustomFrameView();
36 virtual ~CustomFrameView(); 48 virtual ~CustomFrameView();
37 49
38 void Init(Widget* frame); 50 void Init(Widget* frame);
39 51
40 // Overridden from NonClientFrameView: 52 // NonClientFrameView:
41 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE; 53 virtual gfx::Rect GetBoundsForClientView() const OVERRIDE;
42 virtual gfx::Rect GetWindowBoundsForClientBounds( 54 virtual gfx::Rect GetWindowBoundsForClientBounds(
43 const gfx::Rect& client_bounds) const OVERRIDE; 55 const gfx::Rect& client_bounds) const OVERRIDE;
44 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE; 56 virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
45 virtual void GetWindowMask(const gfx::Size& size, 57 virtual void GetWindowMask(const gfx::Size& size,
46 gfx::Path* window_mask) OVERRIDE; 58 gfx::Path* window_mask) OVERRIDE;
47 virtual void ResetWindowControls() OVERRIDE; 59 virtual void ResetWindowControls() OVERRIDE;
48 virtual void UpdateWindowIcon() OVERRIDE; 60 virtual void UpdateWindowIcon() OVERRIDE;
49 virtual void UpdateWindowTitle() OVERRIDE; 61 virtual void UpdateWindowTitle() OVERRIDE;
50 62
51 // Overridden from View: 63 // View:
52 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 64 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
53 virtual void Layout() OVERRIDE; 65 virtual void Layout() OVERRIDE;
54 virtual gfx::Size GetPreferredSize() OVERRIDE; 66 virtual gfx::Size GetPreferredSize() OVERRIDE;
55 virtual gfx::Size GetMinimumSize() OVERRIDE; 67 virtual gfx::Size GetMinimumSize() OVERRIDE;
56 virtual gfx::Size GetMaximumSize() OVERRIDE; 68 virtual gfx::Size GetMaximumSize() OVERRIDE;
57 69
58 // Overridden from ButtonListener: 70 // ButtonListener:
59 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE; 71 virtual void ButtonPressed(Button* sender, const ui::Event& event) OVERRIDE;
60 72
73 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
74 // WindowButtonOrderObserver:
75 virtual void OnWindowButtonOrderingChange(
76 const std::vector<views::FrameButton>& leading_buttons,
77 const std::vector<views::FrameButton>& trailing_buttons) OVERRIDE;
78 #endif
79
61 private: 80 private:
81 friend class CustomFrameViewTest;
82
62 // Returns the thickness of the border that makes up the window frame edges. 83 // Returns the thickness of the border that makes up the window frame edges.
63 // This does not include any client edge. 84 // This does not include any client edge.
64 int FrameBorderThickness() const; 85 int FrameBorderThickness() const;
65 86
66 // Returns the thickness of the entire nonclient left, right, and bottom 87 // Returns the thickness of the entire nonclient left, right, and bottom
67 // borders, including both the window frame and any client edge. 88 // borders, including both the window frame and any client edge.
68 int NonClientBorderThickness() const; 89 int NonClientBorderThickness() const;
69 90
70 // Returns the height of the entire nonclient top border, including the window 91 // Returns the height of the entire nonclient top border, including the window
71 // frame, any title area, and any connected client edge. 92 // frame, any title area, and any connected client edge.
(...skipping 25 matching lines...) Expand all
97 // Paint various sub-components of this view. 118 // Paint various sub-components of this view.
98 void PaintRestoredFrameBorder(gfx::Canvas* canvas); 119 void PaintRestoredFrameBorder(gfx::Canvas* canvas);
99 void PaintMaximizedFrameBorder(gfx::Canvas* canvas); 120 void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
100 void PaintTitleBar(gfx::Canvas* canvas); 121 void PaintTitleBar(gfx::Canvas* canvas);
101 void PaintRestoredClientEdge(gfx::Canvas* canvas); 122 void PaintRestoredClientEdge(gfx::Canvas* canvas);
102 123
103 // Compute aspects of the frame needed to paint the frame background. 124 // Compute aspects of the frame needed to paint the frame background.
104 SkColor GetFrameColor() const; 125 SkColor GetFrameColor() const;
105 const gfx::ImageSkia* GetFrameImage() const; 126 const gfx::ImageSkia* GetFrameImage() const;
106 127
107 // Layout various sub-components of this view. 128 // Sets visibility, sizing, and position of an individual button. The value
129 // of |x| and |y| will be the origin for the button.
130 void LayoutButton(ImageButton* button, int x, int y);
131
132 // Performs the layout for the window control buttons based on the
133 // configuration specified in |leading_buttons_| and |trailing_buttons_|.
134 // The sizing and positions of the buttons affects LayoutTitleBar, call
135 // this beforehand.
108 void LayoutWindowControls(); 136 void LayoutWindowControls();
137
138 // Calculations depend on the positions of the window controls. Always call
139 // LayoutWindowControls beforehand.
109 void LayoutTitleBar(); 140 void LayoutTitleBar();
110 void LayoutClientView(); 141 void LayoutClientView();
111 142
112 // Creates, adds and returns a new window caption button (e.g, minimize, 143 // Creates, adds and returns a new window caption button (e.g, minimize,
113 // maximize, restore). 144 // maximize, restore).
114 ImageButton* InitWindowCaptionButton(int accessibility_string_id, 145 ImageButton* InitWindowCaptionButton(int accessibility_string_id,
115 int normal_image_id, 146 int normal_image_id,
116 int hot_image_id, 147 int hot_image_id,
117 int pushed_image_id); 148 int pushed_image_id);
118 149
150 // Returns the window caption button for the given FrameButton, if it should
flackr 2014/04/24 21:40:13 Since FrameButton is an enum essentially specifyin
jonross 2014/04/25 15:59:58 Done.
151 // be visible. Otherwise NULL.
152 ImageButton* GetImageButton(views::FrameButton button);
153
119 // The bounds of the client view, in this view's coordinates. 154 // The bounds of the client view, in this view's coordinates.
120 gfx::Rect client_view_bounds_; 155 gfx::Rect client_view_bounds_;
121 156
122 // The layout rect of the title, if visible. 157 // The layout rect of the title, if visible.
123 gfx::Rect title_bounds_; 158 gfx::Rect title_bounds_;
124 159
125 // Not owned. 160 // Not owned.
126 Widget* frame_; 161 Widget* frame_;
127 162
128 // The icon of this window. May be NULL. 163 // The icon of this window. May be NULL.
129 ImageButton* window_icon_; 164 ImageButton* window_icon_;
130 165
131 // Window caption buttons. 166 // Window caption buttons.
132 ImageButton* minimize_button_; 167 ImageButton* minimize_button_;
133 ImageButton* maximize_button_; 168 ImageButton* maximize_button_;
134 ImageButton* restore_button_; 169 ImageButton* restore_button_;
135 ImageButton* close_button_; 170 ImageButton* close_button_;
136 171
137 // Should maximize button be shown? 172 // Should maximize button be shown?
138 bool should_show_maximize_button_; 173 bool should_show_maximize_button_;
139 174
140 // Background painter for the window frame. 175 // Background painter for the window frame.
141 scoped_ptr<FrameBackground> frame_background_; 176 scoped_ptr<FrameBackground> frame_background_;
142 177
178 // Layout arrangement of the window caption buttons. On linux these will be
179 // set via OnWindowButtonOrderingChange. On other platforms a default
180 // arrangement of a trailing minimize, maximize, close, will be set.
181 std::vector<views::FrameButton> leading_buttons_;
182 std::vector<views::FrameButton> trailing_buttons_;
183
184 // The horizontal boundaries for the title bar to layout within. Restricted
185 // by the space used by the leading and trailing buttons.
186 int minimum_title_bar_x_;
187 int maximum_title_bar_x_;
188
143 DISALLOW_COPY_AND_ASSIGN(CustomFrameView); 189 DISALLOW_COPY_AND_ASSIGN(CustomFrameView);
144 }; 190 };
145 191
146 } // namespace views 192 } // namespace views
147 193
148 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_ 194 #endif // UI_VIEWS_WINDOW_CUSTOM_FRAME_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/views.gyp ('k') | ui/views/window/custom_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698