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 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 void Init(HWND hwnd); | 21 void Init(HWND hwnd); |
| 22 | 22 |
| 23 // Obtain the X offset of the native minimize button. Since Windows can lie | 23 // Obtain the X offset of the native minimize button. Since Windows can lie |
| 24 // to us if we call this at the wrong moment, this might come from a cached | 24 // to us if we call this at the wrong moment, this might come from a cached |
| 25 // value rather than read when called. | 25 // value rather than read when called. |
| 26 int GetMinimizeButtonOffsetX() const; | 26 int GetMinimizeButtonOffsetX() const; |
| 27 | 27 |
| 28 // Obtain the height of the native minimize button. | |
| 29 // As for GetMinimizeButtonOffsetX(), this might come from a cached value. | |
| 30 int GetMinimizeButtonHeight() const; | |
| 31 | |
| 28 // 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 |
| 29 // position cache. | 33 // position cache. |
| 30 void OnHWNDActivated(); | 34 void OnHWNDActivated(); |
| 31 | 35 |
| 32 private: | 36 private: |
| 33 // Gets the value for GetMinimizeButtonOffsetX(), caching if found. | 37 // Gets the value for GetMinimizeButtonOffsetX(), caching if found. |
| 34 int GetAndCacheMinimizeButtonOffsetX() const; | 38 int GetAndCacheMinimizeButtonOffsetX() const; |
| 35 | 39 |
| 36 int GetButtonBoundsPositionOffset(const RECT& button_bounds, | 40 int GetButtonBoundsPositionOffset(const RECT& button_bounds, |
| 37 const RECT& window_bounds) const; | 41 const RECT& window_bounds) const; |
| 38 | 42 |
| 39 int GetMinimizeButtonOffsetForWindow() const; | 43 int GetMinimizeButtonOffsetForWindow() const; |
| 40 | 44 |
| 41 HWND hwnd_; | 45 HWND hwnd_; |
| 42 | 46 |
| 43 // Cached offset of the minimize button. If RTL this is the location of the | 47 // Cached offset of the minimize button. If RTL this is the location of the |
| 44 // minimize button, if LTR this is the offset from the right edge of the | 48 // minimize button, if LTR this is the offset from the right edge of the |
| 45 // client area to the minimize button. | 49 // client area to the minimize button. |
| 46 mutable int cached_minimize_button_x_delta_; | 50 mutable int cached_minimize_button_x_delta_; |
| 47 | 51 |
| 48 // Static cache of |cached_minimize_button_x_delta_|. | 52 // Static cache of |cached_minimize_button_x_delta_|. |
| 49 static int last_cached_minimize_button_x_delta_; | 53 static int last_cached_minimize_button_x_delta_; |
| 50 | 54 |
| 51 // Static cache of offset value representing the different between | 55 // Static cache of offset value representing the difference between |
| 52 // DWMWA_CAPTION_BUTTON_BOUNDS and WM_GETTITLEBARINFOEX | 56 // DWMWA_CAPTION_BUTTON_BOUNDS and WM_GETTITLEBARINFOEX |
| 53 static int button_bounds_position_offset_; | 57 static int button_bounds_position_offset_; |
| 54 | 58 |
| 59 // Static cache of Windows caption button height | |
|
Peter Kasting
2017/04/24 23:00:17
Nit: Trailing period.
emx
2017/04/25 11:57:40
Done.
| |
| 60 static int button_bounds_height_; | |
|
Peter Kasting
2017/04/24 23:00:17
Nit: Name |caption_button_height_|?
emx
2017/04/25 11:57:40
Done.
| |
| 61 | |
| 55 // Has OnHWNDActivated() been invoked? | 62 // Has OnHWNDActivated() been invoked? |
| 56 bool was_activated_; | 63 bool was_activated_; |
| 57 | 64 |
| 58 DISALLOW_COPY_AND_ASSIGN(MinimizeButtonMetrics); | 65 DISALLOW_COPY_AND_ASSIGN(MinimizeButtonMetrics); |
| 59 }; | 66 }; |
| 60 | 67 |
| 61 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_ | 68 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_MINIMIZE_BUTTON_METRICS_WIN_H_ |
| OLD | NEW |