| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/views/frame/aero_glass_frame.h" | 5 #include "chrome/browser/views/frame/aero_glass_frame.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 | 8 |
| 9 #include "chrome/app/theme/theme_resources.h" | 9 #include "chrome/app/theme/theme_resources.h" |
| 10 #include "chrome/browser/browser_list.h" | 10 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/views/frame/browser_view.h" | 11 #include "chrome/browser/views/frame/browser_view.h" |
| 12 #include "chrome/browser/views/frame/aero_glass_non_client_view.h" | 12 #include "chrome/browser/views/frame/aero_glass_non_client_view.h" |
| 13 #include "chrome/common/resource_bundle.h" | 13 #include "chrome/common/resource_bundle.h" |
| 14 #include "chrome/views/window_delegate.h" | 14 #include "chrome/views/window_delegate.h" |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 | 17 |
| 18 // The width of the client edge to the left and right of the window. | 18 static const int kClientEdgeThickness = 3; |
| 19 static const int kClientEdgeWidth = 3; | |
| 20 // The height of the client edge to the bottom of the window. | |
| 21 static const int kClientEdgeHeight = 2; | |
| 22 | 19 |
| 23 HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount]; | 20 HICON AeroGlassFrame::throbber_icons_[AeroGlassFrame::kThrobberIconCount]; |
| 24 | 21 |
| 25 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
| 26 // AeroGlassFrame, public: | 23 // AeroGlassFrame, public: |
| 27 | 24 |
| 28 AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view) | 25 AeroGlassFrame::AeroGlassFrame(BrowserView* browser_view) |
| 29 : Window(browser_view), | 26 : Window(browser_view), |
| 30 browser_view_(browser_view), | 27 browser_view_(browser_view), |
| 31 frame_initialized_(false), | 28 frame_initialized_(false), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 | 40 |
| 44 void AeroGlassFrame::Init() { | 41 void AeroGlassFrame::Init() { |
| 45 Window::Init(NULL, gfx::Rect()); | 42 Window::Init(NULL, gfx::Rect()); |
| 46 } | 43 } |
| 47 | 44 |
| 48 int AeroGlassFrame::GetMinimizeButtonOffset() const { | 45 int AeroGlassFrame::GetMinimizeButtonOffset() const { |
| 49 TITLEBARINFOEX titlebar_info; | 46 TITLEBARINFOEX titlebar_info; |
| 50 titlebar_info.cbSize = sizeof(TITLEBARINFOEX); | 47 titlebar_info.cbSize = sizeof(TITLEBARINFOEX); |
| 51 SendMessage(GetHWND(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info); | 48 SendMessage(GetHWND(), WM_GETTITLEBARINFOEX, 0, (WPARAM)&titlebar_info); |
| 52 | 49 |
| 53 RECT wr; | 50 CPoint minimize_button_corner(titlebar_info.rgrect[2].left, |
| 54 GetWindowRect(&wr); | 51 titlebar_info.rgrect[2].top); |
| 52 MapWindowPoints(HWND_DESKTOP, GetHWND(), &minimize_button_corner, 1); |
| 55 | 53 |
| 56 return wr.right - titlebar_info.rgrect[2].left; | 54 return minimize_button_corner.x; |
| 57 } | 55 } |
| 58 | 56 |
| 59 /////////////////////////////////////////////////////////////////////////////// | 57 /////////////////////////////////////////////////////////////////////////////// |
| 60 // AeroGlassFrame, BrowserFrame implementation: | 58 // AeroGlassFrame, BrowserFrame implementation: |
| 61 | 59 |
| 62 gfx::Rect AeroGlassFrame::GetWindowBoundsForClientBounds( | 60 gfx::Rect AeroGlassFrame::GetWindowBoundsForClientBounds( |
| 63 const gfx::Rect& client_bounds) { | 61 const gfx::Rect& client_bounds) { |
| 64 RECT rect = client_bounds.ToRECT(); | 62 RECT rect = client_bounds.ToRECT(); |
| 65 AdjustWindowRectEx(&rect, window_style(), FALSE, window_ex_style()); | 63 AdjustWindowRectEx(&rect, window_style(), FALSE, window_ex_style()); |
| 66 return gfx::Rect(rect); | 64 return gfx::Rect(rect); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 137 } |
| 140 | 138 |
| 141 LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { | 139 LRESULT AeroGlassFrame::OnNCCalcSize(BOOL mode, LPARAM l_param) { |
| 142 if (!browser_view_->IsTabStripVisible() || !mode) { | 140 if (!browser_view_->IsTabStripVisible() || !mode) { |
| 143 SetMsgHandled(FALSE); | 141 SetMsgHandled(FALSE); |
| 144 return 0; | 142 return 0; |
| 145 } | 143 } |
| 146 | 144 |
| 147 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param); | 145 NCCALCSIZE_PARAMS* params = reinterpret_cast<NCCALCSIZE_PARAMS*>(l_param); |
| 148 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 146 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
| 149 params->rgrc[0].left += (border_thickness - kClientEdgeWidth); | 147 params->rgrc[0].left += (border_thickness - kClientEdgeThickness); |
| 150 params->rgrc[0].right -= (border_thickness - kClientEdgeWidth); | 148 params->rgrc[0].right -= (border_thickness - kClientEdgeThickness); |
| 151 params->rgrc[0].bottom -= (border_thickness - kClientEdgeHeight); | 149 params->rgrc[0].bottom -= (border_thickness - kClientEdgeThickness); |
| 152 | 150 |
| 153 UpdateDWMFrame(); | 151 UpdateDWMFrame(); |
| 154 | 152 |
| 155 SetMsgHandled(TRUE); | 153 SetMsgHandled(TRUE); |
| 156 return 0; | 154 return 0; |
| 157 } | 155 } |
| 158 | 156 |
| 159 LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) { | 157 LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) { |
| 160 LRESULT result; | 158 LRESULT result; |
| 161 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), | 159 if (DwmDefWindowProc(GetHWND(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 173 } | 171 } |
| 174 | 172 |
| 175 /////////////////////////////////////////////////////////////////////////////// | 173 /////////////////////////////////////////////////////////////////////////////// |
| 176 // AeroGlassFrame, private: | 174 // AeroGlassFrame, private: |
| 177 | 175 |
| 178 void AeroGlassFrame::UpdateDWMFrame() { | 176 void AeroGlassFrame::UpdateDWMFrame() { |
| 179 // Nothing to do yet. | 177 // Nothing to do yet. |
| 180 if (!client_view()) | 178 if (!client_view()) |
| 181 return; | 179 return; |
| 182 | 180 |
| 183 MARGINS margins = { kClientEdgeWidth + 1, | 181 MARGINS margins = { kClientEdgeThickness + 1, |
| 184 kClientEdgeWidth + 1, | 182 kClientEdgeThickness + 1, |
| 185 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(), | 183 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom(), |
| 186 kClientEdgeHeight + 1 }; | 184 kClientEdgeThickness + 1 }; |
| 187 // Note: we don't use DwmEnableBlurBehindWindow because any region not | 185 // Note: we don't use DwmEnableBlurBehindWindow because any region not |
| 188 // included in the glass region is composited source over. This means | 186 // included in the glass region is composited source over. This means |
| 189 // that anything drawn directly with GDI appears fully transparent. | 187 // that anything drawn directly with GDI appears fully transparent. |
| 190 DwmExtendFrameIntoClientArea(GetHWND(), &margins); | 188 DwmExtendFrameIntoClientArea(GetHWND(), &margins); |
| 191 } | 189 } |
| 192 | 190 |
| 193 AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const { | 191 AeroGlassNonClientView* AeroGlassFrame::GetAeroGlassNonClientView() const { |
| 194 // We can safely assume that this conversion is true. | 192 // We can safely assume that this conversion is true. |
| 195 return static_cast<AeroGlassNonClientView*>(non_client_view_); | 193 return static_cast<AeroGlassNonClientView*>(non_client_view_); |
| 196 } | 194 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 221 static bool initialized = false; | 219 static bool initialized = false; |
| 222 if (!initialized) { | 220 if (!initialized) { |
| 223 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); | 221 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
| 224 for (int i = 0; i < kThrobberIconCount; ++i) { | 222 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 225 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i); | 223 throbber_icons_[i] = rb.LoadThemeIcon(IDR_THROBBER_01 + i); |
| 226 DCHECK(throbber_icons_[i]); | 224 DCHECK(throbber_icons_[i]); |
| 227 } | 225 } |
| 228 initialized = true; | 226 initialized = true; |
| 229 } | 227 } |
| 230 } | 228 } |
| OLD | NEW |