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

Side by Side Diff: chrome/browser/ui/views/frame/minimize_button_metrics_win.h

Issue 2851543002: Update avatar button to MD (part 1) (Closed)
Patch Set: Rebased on CL 2868293002 [Rename new_avatar_button.* to avatar_button] Created 3 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 CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_ 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 11
12 // Class that implements obtaining the X coordinate of the native minimize 12 // Class that implements obtaining the X coordinate of the native minimize
13 // button for the native frame on Windows. 13 // button for the native frame on Windows.
14 // This is a separate class because obtaining it is somewhat tricky and this 14 // This is a separate class because obtaining it is somewhat tricky and this
15 // code is shared between BrowserDesktopWindowTreeHostWin and BrowserFrameWin. 15 // code is shared between BrowserDesktopWindowTreeHostWin and BrowserFrameWin.
16 class MinimizeButtonMetrics { 16 class MinimizeButtonMetrics {
17 public: 17 public:
18 MinimizeButtonMetrics(); 18 MinimizeButtonMetrics();
19 ~MinimizeButtonMetrics(); 19 ~MinimizeButtonMetrics();
20 20
21 // Returns the height of the native caption buttons in DIPs. 21 // Return the width/height of the native caption buttons in DIPs.
Peter Kasting 2017/05/11 01:03:43 Nit: "Returns" was correct; see bit about "descrip
emx 2017/05/11 12:56:11 Oh, it was supposed to be plural to apply to both
22 static int GetCaptionButtonWidthInDIPs();
22 static int GetCaptionButtonHeightInDIPs(); 23 static int GetCaptionButtonHeightInDIPs();
Peter Kasting 2017/05/11 01:03:43 Nit: Maybe static gfx::Size GetCaptionButtonSiz
emx 2017/05/11 12:56:11 Good point, I'll use this if we ever figure out a
23 24
24 void Init(HWND hwnd); 25 void Init(HWND hwnd);
25 26
26 // Obtain the X offset of the native minimize button. Since Windows can lie 27 // Obtain the X offset of the native minimize button. Since Windows can lie
27 // to us if we call this at the wrong moment, this might come from a cached 28 // to us if we call this at the wrong moment, this might come from a cached
28 // value rather than read when called. 29 // value rather than read when called.
29 int GetMinimizeButtonOffsetX() const; 30 int GetMinimizeButtonOffsetX() const;
30 31
31 // Must be called when hwnd_ is activated to update the minimize button 32 // Must be called when hwnd_ is activated to update the minimize button
32 // position cache. 33 // position cache.
33 void OnHWNDActivated(); 34 void OnHWNDActivated();
34 35
35 private: 36 private:
37 static int GetCaptionButtonDimensionInDIPs(int caption_metric,
38 int frame_metric);
39
36 // Gets the value for GetMinimizeButtonOffsetX(), caching if found. 40 // Gets the value for GetMinimizeButtonOffsetX(), caching if found.
37 int GetAndCacheMinimizeButtonOffsetX() const; 41 int GetAndCacheMinimizeButtonOffsetX() const;
38 42
39 int GetButtonBoundsPositionOffset(const RECT& button_bounds, 43 int GetButtonBoundsPositionOffset(const RECT& button_bounds,
40 const RECT& window_bounds) const; 44 const RECT& window_bounds) const;
41 45
42 int GetMinimizeButtonOffsetForWindow() const; 46 int GetMinimizeButtonOffsetForWindow() const;
43 47
44 HWND hwnd_; 48 HWND hwnd_;
45 49
46 // Cached offset of the minimize button. If RTL this is the location of the 50 // Cached offset of the minimize button. If RTL this is the location of the
47 // minimize button, if LTR this is the offset from the right edge of the 51 // minimize button, if LTR this is the offset from the right edge of the
48 // client area to the minimize button. 52 // client area to the minimize button.
49 mutable int cached_minimize_button_x_delta_; 53 mutable int cached_minimize_button_x_delta_;
50 54
51 // Static cache of |cached_minimize_button_x_delta_|. 55 // Static cache of |cached_minimize_button_x_delta_|.
52 static int last_cached_minimize_button_x_delta_; 56 static int last_cached_minimize_button_x_delta_;
53 57
54 // Static cache of offset value representing the difference between 58 // Static cache of offset value representing the difference between
55 // DWMWA_CAPTION_BUTTON_BOUNDS and WM_GETTITLEBARINFOEX 59 // DWMWA_CAPTION_BUTTON_BOUNDS and WM_GETTITLEBARINFOEX
56 static int button_bounds_position_offset_; 60 static int button_bounds_position_offset_;
57 61
58 // Has OnHWNDActivated() been invoked? 62 // Has OnHWNDActivated() been invoked?
59 bool was_activated_; 63 bool was_activated_;
60 64
61 DISALLOW_COPY_AND_ASSIGN(MinimizeButtonMetrics); 65 DISALLOW_COPY_AND_ASSIGN(MinimizeButtonMetrics);
62 }; 66 };
63 67
64 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_ 68 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698