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 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 36 #include "ui/views/layout/layout_constants.h" | 36 #include "ui/views/layout/layout_constants.h" |
| 37 #include "ui/views/resources/grit/views_resources.h" | 37 #include "ui/views/resources/grit/views_resources.h" |
| 38 #include "ui/views/win/hwnd_util.h" | 38 #include "ui/views/win/hwnd_util.h" |
| 39 #include "ui/views/window/client_view.h" | 39 #include "ui/views/window/client_view.h" |
| 40 | 40 |
| 41 HICON GlassBrowserFrameView::throbber_icons_[ | 41 HICON GlassBrowserFrameView::throbber_icons_[ |
| 42 GlassBrowserFrameView::kThrobberIconCount]; | 42 GlassBrowserFrameView::kThrobberIconCount]; |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 // Size of client edge drawn inside the outer frame borders. | 45 // Thickness of the border in the client area that separates it from the |
| 46 const int kNonClientBorderThicknessPreWin10 = 3; | 46 // non-client area. Not to be confused with kClientEdgeThickness, which is the |
| 47 const int kNonClientBorderThicknessWin10 = 1; | 47 // thickness of the border between the web content and our frame border. |
| 48 // Besides the frame border, there's empty space atop the window in restored | 48 const int kClientBorderThicknessPreWin10 = 3; |
| 49 // mode, to use to drag the window around. | 49 const int kClientBorderThicknessWin10 = 1; |
| 50 // Extra empty space to draw in restored mode to make the titlebar thicker. | |
| 50 const int kNonClientRestoredExtraThickness = 11; | 51 const int kNonClientRestoredExtraThickness = 11; |
| 51 // In the window corners, the resize areas don't actually expand bigger, but the | 52 // The size of the corners of the titlebar that trigger diagonal resizing. |
| 52 // 16 px at the end of the top and bottom edges triggers diagonal resizing. | |
| 53 const int kResizeCornerWidth = 16; | 53 const int kResizeCornerWidth = 16; |
| 54 // How far the new avatar button is from the left of the minimize button. | 54 // How far the avatar button is from the left of the minimize button. |
| 55 const int kNewAvatarButtonOffset = 5; | 55 const int kNewAvatarButtonOffset = 5; |
| 56 // The content edge images have a shadow built into them. | 56 // The content edge images have a shadow built into them. |
| 57 const int kContentEdgeShadowThickness = 2; | 57 const int kContentEdgeShadowThickness = 2; |
| 58 // In restored mode, the New Tab button isn't at the same height as the caption | 58 // In restored mode, the New Tab button isn't at the same height as the caption |
| 59 // buttons, but the space will look cluttered if it actually slides under them, | 59 // buttons, but the space will look cluttered if it actually slides under them, |
| 60 // so we stop it when the gap between the two is down to 5 px. | 60 // so we stop it when the gap between the two is down to 5 px. |
| 61 const int kNewTabCaptionRestoredSpacing = 5; | 61 const int kNewTabCaptionRestoredSpacing = 5; |
| 62 // In maximized mode, where the New Tab button and the caption buttons are at | 62 // In maximized mode, where the New Tab button and the caption buttons are at |
| 63 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid | 63 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid |
| 64 // looking too cluttered. | 64 // looking too cluttered. |
| 65 const int kNewTabCaptionMaximizedSpacing = 16; | 65 const int kNewTabCaptionMaximizedSpacing = 16; |
| 66 // Height of the avatar button. Same as the height of the Windows 7/8 caption | |
| 67 // buttons but doesn't change for 10 where the caption buttons are much bigger. | |
| 68 const int kAvatarButtonHeightRestored = 20; | |
| 69 const int kAvatarButtonHeightMaximized = 19; | |
| 66 | 70 |
| 67 // Converts the |image| to a Windows icon and returns the corresponding HICON | 71 // Converts the |image| to a Windows icon and returns the corresponding HICON |
| 68 // handle. |image| is resized to desired |width| and |height| if needed. | 72 // handle. |image| is resized to desired |width| and |height| if needed. |
| 69 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( | 73 base::win::ScopedHICON CreateHICONFromSkBitmapSizedTo( |
| 70 const gfx::ImageSkia& image, | 74 const gfx::ImageSkia& image, |
| 71 int width, | 75 int width, |
| 72 int height) { | 76 int height) { |
| 73 return IconUtil::CreateHICONFromSkBitmap( | 77 return IconUtil::CreateHICONFromSkBitmap( |
| 74 width == image.width() && height == image.height() | 78 width == image.width() && height == image.height() |
| 75 ? *image.bitmap() | 79 ? *image.bitmap() |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 97 } | 101 } |
| 98 | 102 |
| 99 /////////////////////////////////////////////////////////////////////////////// | 103 /////////////////////////////////////////////////////////////////////////////// |
| 100 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 104 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
| 101 | 105 |
| 102 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 106 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
| 103 views::View* tabstrip) const { | 107 views::View* tabstrip) const { |
| 104 // In maximized RTL windows, don't let the tabstrip overlap the caption area, | 108 // In maximized RTL windows, don't let the tabstrip overlap the caption area, |
| 105 // or the alpha-blending it does will make things like the new avatar button | 109 // or the alpha-blending it does will make things like the new avatar button |
| 106 // look glitchy. | 110 // look glitchy. |
| 107 const int offset = | 111 const int offset = (ui::MaterialDesignController::IsModeMaterial() || |
| 108 (ui::MaterialDesignController::IsModeMaterial() || !base::i18n::IsRTL() || | 112 !RTLSpecialLayout() || !frame()->IsMaximized()) |
| 109 !frame()->IsMaximized()) ? | 113 ? GetLayoutInsets(AVATAR_ICON).right() |
| 110 GetLayoutInsets(AVATAR_ICON).right() : 0; | 114 : 0; |
| 111 const int x = incognito_bounds_.right() + offset; | 115 const int x = incognito_bounds_.right() + offset; |
| 112 int end_x = width() - NonClientBorderThickness(false); | 116 int end_x = width() - ClientBorderThickness(false); |
| 113 if (!base::i18n::IsRTL()) { | 117 if (!RTLSpecialLayout()) { |
| 114 end_x = std::min(frame()->GetMinimizeButtonOffset(), end_x) - | 118 end_x = std::min(frame()->GetMinimizeButtonOffset(), end_x) - |
| 115 (frame()->IsMaximized() ? | 119 (frame()->IsMaximized() ? |
| 116 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); | 120 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); |
| 117 | 121 |
| 118 // The new avatar button is optionally displayed to the left of the | 122 // The new avatar button is optionally displayed to the left of the |
| 119 // minimize button. | 123 // minimize button. |
| 120 if (profile_switcher_.view()) { | 124 if (profile_switcher_.view()) { |
| 121 const int old_end_x = end_x; | 125 const int old_end_x = end_x; |
| 122 end_x -= profile_switcher_.view()->width() + kNewAvatarButtonOffset; | 126 end_x -= profile_switcher_.view()->width() + kNewAvatarButtonOffset; |
| 123 | 127 |
| 124 // In non-maximized mode, allow the new tab button to slide completely | 128 // In non-maximized mode, allow the new tab button to slide completely |
| 125 // under the avatar button. | 129 // under the avatar button. |
| 126 if (!frame()->IsMaximized()) { | 130 if (!frame()->IsMaximized()) { |
| 127 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() + | 131 end_x = std::min(end_x + GetLayoutSize(NEW_TAB_BUTTON).width() + |
| 128 kNewTabCaptionRestoredSpacing, | 132 kNewTabCaptionRestoredSpacing, |
| 129 old_end_x); | 133 old_end_x); |
| 130 } | 134 } |
| 131 } | 135 } |
| 132 } | 136 } |
| 133 return gfx::Rect(x, NonClientTopBorderHeight(false), std::max(0, end_x - x), | 137 return gfx::Rect(x, NonClientTopHeight(false), std::max(0, end_x - x), |
| 134 tabstrip->GetPreferredSize().height()); | 138 tabstrip->GetPreferredSize().height()); |
| 135 } | 139 } |
| 136 | 140 |
| 137 int GlassBrowserFrameView::GetTopInset(bool restored) const { | 141 int GlassBrowserFrameView::GetTopInset(bool restored) const { |
| 138 return GetClientAreaInsets(restored).top(); | 142 return GetClientAreaInsets(restored).top(); |
| 139 } | 143 } |
| 140 | 144 |
| 141 int GlassBrowserFrameView::GetThemeBackgroundXInset() const { | 145 int GlassBrowserFrameView::GetThemeBackgroundXInset() const { |
| 142 return 0; | 146 return 0; |
| 143 } | 147 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 if ((avatar_button() && | 224 if ((avatar_button() && |
| 221 avatar_button()->GetMirroredBounds().Contains(point)) || | 225 avatar_button()->GetMirroredBounds().Contains(point)) || |
| 222 (profile_switcher_.view() && | 226 (profile_switcher_.view() && |
| 223 profile_switcher_.view()->GetMirroredBounds().Contains(point))) | 227 profile_switcher_.view()->GetMirroredBounds().Contains(point))) |
| 224 return HTCLIENT; | 228 return HTCLIENT; |
| 225 | 229 |
| 226 int frame_component = frame()->client_view()->NonClientHitTest(point); | 230 int frame_component = frame()->client_view()->NonClientHitTest(point); |
| 227 | 231 |
| 228 // See if we're in the sysmenu region. We still have to check the tabstrip | 232 // See if we're in the sysmenu region. We still have to check the tabstrip |
| 229 // first so that clicks in a tab don't get treated as sysmenu clicks. | 233 // first so that clicks in a tab don't get treated as sysmenu clicks. |
| 230 int nonclient_border_thickness = NonClientBorderThickness(false); | 234 int client_border_thickness = ClientBorderThickness(false); |
| 231 if (gfx::Rect(nonclient_border_thickness, | 235 if (gfx::Rect(client_border_thickness, |
| 232 gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME), | 236 gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME), |
| 233 gfx::win::GetSystemMetricsInDIP(SM_CXSMICON), | 237 gfx::win::GetSystemMetricsInDIP(SM_CXSMICON), |
| 234 gfx::win::GetSystemMetricsInDIP(SM_CYSMICON)).Contains(point)) | 238 gfx::win::GetSystemMetricsInDIP(SM_CYSMICON)) |
| 239 .Contains(point)) | |
| 235 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 240 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
| 236 | 241 |
| 237 if (frame_component != HTNOWHERE) | 242 if (frame_component != HTNOWHERE) |
| 238 return frame_component; | 243 return frame_component; |
| 239 | 244 |
| 240 int frame_top_border_height = FrameTopBorderHeight(false); | 245 int top_border_thickness = NonClientTopBorderThickness(false); |
| 241 // We want the resize corner behavior to apply to the kResizeCornerWidth | 246 // We want the resize corner behavior to apply to the kResizeCornerWidth |
| 242 // pixels at each end of the top and bottom edges. Because |point|'s x | 247 // pixels at each end of the top and bottom edges. Because |point|'s x |
| 243 // coordinate is based on the DWM-inset portion of the window (so, it's 0 at | 248 // coordinate is based on the DWM-inset portion of the window (so, it's 0 at |
| 244 // the first pixel inside the left DWM margin), we need to subtract the DWM | 249 // the first pixel inside the left DWM margin), we need to subtract the DWM |
| 245 // margin thickness, which we calculate as the total frame border thickness | 250 // margin thickness, which we calculate as the total frame border thickness |
| 246 // minus the nonclient border thickness. | 251 // minus the nonclient border thickness. |
| 247 const int dwm_margin = FrameBorderThickness() - nonclient_border_thickness; | 252 const int dwm_margin = NonClientBorderThickness() - client_border_thickness; |
| 248 int window_component = GetHTComponentForFrame(point, frame_top_border_height, | 253 int window_component = GetHTComponentForFrame( |
| 249 nonclient_border_thickness, frame_top_border_height, | 254 point, top_border_thickness, client_border_thickness, |
| 250 kResizeCornerWidth - dwm_margin, frame()->widget_delegate()->CanResize()); | 255 top_border_thickness, kResizeCornerWidth - dwm_margin, |
| 256 frame()->widget_delegate()->CanResize()); | |
| 251 // Fall back to the caption if no other component matches. | 257 // Fall back to the caption if no other component matches. |
| 252 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 258 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
| 253 } | 259 } |
| 254 | 260 |
| 255 /////////////////////////////////////////////////////////////////////////////// | 261 /////////////////////////////////////////////////////////////////////////////// |
| 256 // GlassBrowserFrameView, views::View overrides: | 262 // GlassBrowserFrameView, views::View overrides: |
| 257 | 263 |
| 258 void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 264 void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
| 259 if (!browser_view()->IsTabStripVisible()) | 265 if (!browser_view()->IsTabStripVisible()) |
| 260 return; | 266 return; |
| 261 if (IsToolbarVisible()) | 267 if (IsToolbarVisible()) |
| 262 PaintToolbarBackground(canvas); | 268 PaintToolbarBackground(canvas); |
| 263 if (!frame()->IsMaximized()) | 269 if (!frame()->IsMaximized()) |
| 264 PaintClientEdge(canvas); | 270 PaintClientEdge(canvas); |
| 265 } | 271 } |
| 266 | 272 |
| 267 void GlassBrowserFrameView::Layout() { | 273 void GlassBrowserFrameView::Layout() { |
| 268 if (browser_view()->IsRegularOrGuestSession()) | 274 if (browser_view()->IsRegularOrGuestSession()) |
| 269 LayoutNewStyleAvatar(); | 275 LayoutAvatar(); |
| 270 LayoutIncognitoIcon(); | 276 LayoutIncognitoIcon(); |
| 271 LayoutClientView(); | 277 LayoutClientView(); |
| 272 } | 278 } |
| 273 | 279 |
| 274 /////////////////////////////////////////////////////////////////////////////// | 280 /////////////////////////////////////////////////////////////////////////////// |
| 275 // GlassBrowserFrameView, protected: | 281 // GlassBrowserFrameView, protected: |
| 276 | 282 |
| 277 // BrowserNonClientFrameView: | 283 // BrowserNonClientFrameView: |
| 278 void GlassBrowserFrameView::UpdateAvatar() { | 284 void GlassBrowserFrameView::UpdateAvatar() { |
| 279 if (browser_view()->IsRegularOrGuestSession()) | 285 if (browser_view()->IsRegularOrGuestSession()) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 291 CHECK_EQ(target, this); | 297 CHECK_EQ(target, this); |
| 292 bool hit_incognito_icon = avatar_button() && | 298 bool hit_incognito_icon = avatar_button() && |
| 293 avatar_button()->GetMirroredBounds().Intersects(rect); | 299 avatar_button()->GetMirroredBounds().Intersects(rect); |
| 294 bool hit_new_avatar_button = | 300 bool hit_new_avatar_button = |
| 295 profile_switcher_.view() && | 301 profile_switcher_.view() && |
| 296 profile_switcher_.view()->GetMirroredBounds().Intersects(rect); | 302 profile_switcher_.view()->GetMirroredBounds().Intersects(rect); |
| 297 return hit_incognito_icon || hit_new_avatar_button || | 303 return hit_incognito_icon || hit_new_avatar_button || |
| 298 !frame()->client_view()->bounds().Intersects(rect); | 304 !frame()->client_view()->bounds().Intersects(rect); |
| 299 } | 305 } |
| 300 | 306 |
| 301 int GlassBrowserFrameView::FrameBorderThickness() const { | 307 int GlassBrowserFrameView::NonClientBorderThickness() const { |
| 302 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? | 308 return (frame()->IsMaximized() || frame()->IsFullscreen()) ? |
| 303 0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); | 309 0 : gfx::win::GetSystemMetricsInDIP(SM_CXSIZEFRAME); |
| 304 } | 310 } |
| 305 | 311 |
| 306 int GlassBrowserFrameView::FrameTopBorderHeight(bool restored) const { | 312 int GlassBrowserFrameView::NonClientTopBorderThickness(bool restored) const { |
|
ananta
2016/04/11 21:12:11
Can we replace this boolean flag with an enum?. Wo
Bret
2016/04/11 23:44:47
I agree that this is hard to read but I don't thin
| |
| 307 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 313 // Distinct from ::NonClientBorderThickness() because we need a border at the |
| 308 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border | 314 // top when maximized to avoid having UI elements drift off the top of the |
| 309 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 315 // screen. |
| 310 return (frame()->IsFullscreen() && !restored) ? | 316 return (frame()->IsFullscreen() && !restored) ? |
| 311 0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME); | 317 0 : gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME); |
| 312 } | 318 } |
| 313 | 319 |
| 314 int GlassBrowserFrameView::NonClientBorderThickness(bool restored) const { | 320 int GlassBrowserFrameView::ClientBorderThickness(bool restored) const { |
|
ananta
2016/04/11 21:12:11
Ditto for bool restored.
Bret
2016/04/11 23:44:47
See above.
| |
| 315 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) | 321 if ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) |
| 316 return 0; | 322 return 0; |
| 317 | 323 |
| 318 return (base::win::GetVersion() < base::win::VERSION_WIN10) | 324 return (base::win::GetVersion() < base::win::VERSION_WIN10) |
| 319 ? kNonClientBorderThicknessPreWin10 | 325 ? kClientBorderThicknessPreWin10 |
| 320 : kNonClientBorderThicknessWin10; | 326 : kClientBorderThicknessWin10; |
| 321 } | 327 } |
| 322 | 328 |
| 323 int GlassBrowserFrameView::NonClientTopBorderHeight(bool restored) const { | 329 int GlassBrowserFrameView::NonClientTopHeight(bool restored) const { |
| 324 if (frame()->IsFullscreen() && !restored) | 330 if (frame()->IsFullscreen() && !restored) |
| 325 return 0; | 331 return 0; |
| 326 | 332 |
| 327 const int top = FrameTopBorderHeight(restored); | 333 const int top = NonClientTopBorderThickness(restored); |
| 328 // The tab top inset is equal to the height of any shadow region above the | 334 // The tab top inset is equal to the height of any shadow region above the |
| 329 // tabs, plus a 1 px top stroke. In maximized mode, we want to push the | 335 // tabs, plus a 1 px top stroke. In maximized mode, we want to push the |
| 330 // shadow region off the top of the screen but leave the top stroke. | 336 // shadow region off the top of the screen but leave the top stroke. |
| 331 // Annoyingly, the pre-MD layout uses different heights for the hit-test | 337 // Annoyingly, the pre-MD layout uses different heights for the hit-test |
| 332 // exclusion region (which we want here, since we're trying to size the border | 338 // exclusion region (which we want here, since we're trying to size the border |
| 333 // so that the region above the tab's hit-test zone matches) versus the shadow | 339 // so that the region above the tab's hit-test zone matches) versus the shadow |
| 334 // thickness. | 340 // thickness. |
| 335 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); | 341 const int exclusion = GetLayoutConstant(TAB_TOP_EXCLUSION_HEIGHT); |
| 336 return (frame()->IsMaximized() && !restored) ? | 342 return (frame()->IsMaximized() && !restored) ? |
| 337 (top - GetLayoutInsets(TAB).top() + 1) : | 343 (top - GetLayoutInsets(TAB).top() + 1) : |
| 338 (top + kNonClientRestoredExtraThickness - exclusion); | 344 (top + kNonClientRestoredExtraThickness - exclusion); |
| 339 } | 345 } |
| 340 | 346 |
| 341 bool GlassBrowserFrameView::IsToolbarVisible() const { | 347 bool GlassBrowserFrameView::IsToolbarVisible() const { |
| 342 return browser_view()->IsToolbarVisible() && | 348 return browser_view()->IsToolbarVisible() && |
| 343 !browser_view()->toolbar()->GetPreferredSize().IsEmpty(); | 349 !browser_view()->toolbar()->GetPreferredSize().IsEmpty(); |
| 344 } | 350 } |
| 345 | 351 |
| 352 bool GlassBrowserFrameView::RTLSpecialLayout() const { | |
| 353 return base::i18n::IsRTL(); | |
| 354 } | |
| 355 | |
| 356 int GlassBrowserFrameView::WindowTopY() const { | |
| 357 // When maximized this is flush with the top of the screen because we've | |
| 358 // extended the frame ::NonClientTopBorderThickness() beyond the visible area. | |
|
ananta
2016/04/11 21:12:11
Remove the ::
Bret
2016/04/11 23:44:47
Done everywhere.
| |
| 359 // When restored this is 1 pixel below the top of the window, leaving a | |
| 360 // border. This is the same positioning as the Windows caption buttons. | |
| 361 return frame()->IsMaximized() ? NonClientTopBorderThickness(false) : 1; | |
| 362 } | |
| 363 | |
| 346 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { | 364 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) const { |
| 347 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 365 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 348 if (toolbar_bounds.IsEmpty()) | 366 if (toolbar_bounds.IsEmpty()) |
| 349 return; | 367 return; |
| 350 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 368 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
| 351 ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 369 ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
| 352 toolbar_bounds.set_origin(toolbar_origin); | 370 toolbar_bounds.set_origin(toolbar_origin); |
| 353 | 371 |
| 354 const ui::ThemeProvider* tp = GetThemeProvider(); | 372 const ui::ThemeProvider* tp = GetThemeProvider(); |
| 355 const gfx::ImageSkia* const bg = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 373 const gfx::ImageSkia* const bg = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 // Pre-Material Design, the client edge images start below the toolbar. In MD | 460 // Pre-Material Design, the client edge images start below the toolbar. In MD |
| 443 // the client edge images start at the top of the toolbar. | 461 // the client edge images start at the top of the toolbar. |
| 444 gfx::Rect client_bounds = CalculateClientAreaBounds(); | 462 gfx::Rect client_bounds = CalculateClientAreaBounds(); |
| 445 const int x = client_bounds.x(); | 463 const int x = client_bounds.x(); |
| 446 const bool md = ui::MaterialDesignController::IsModeMaterial(); | 464 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
| 447 const gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 465 const gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
| 448 const int y = | 466 const int y = |
| 449 client_bounds.y() + (md ? toolbar_bounds.y() : toolbar_bounds.bottom()); | 467 client_bounds.y() + (md ? toolbar_bounds.y() : toolbar_bounds.bottom()); |
| 450 const int w = client_bounds.width(); | 468 const int w = client_bounds.width(); |
| 451 const int right = client_bounds.right(); | 469 const int right = client_bounds.right(); |
| 452 const int bottom = std::max(y, height() - NonClientBorderThickness(false)); | 470 const int bottom = std::max(y, height() - ClientBorderThickness(false)); |
| 453 const int height = bottom - y; | 471 const int height = bottom - y; |
| 454 | 472 |
| 455 // Draw the client edge images. For non-MD, we fill the toolbar color | 473 // Draw the client edge images. For non-MD, we fill the toolbar color |
| 456 // underneath these images so they will lighten/darken it appropriately to | 474 // underneath these images so they will lighten/darken it appropriately to |
| 457 // create a "3D shaded" effect. For MD, where we want a flatter appearance, | 475 // create a "3D shaded" effect. For MD, where we want a flatter appearance, |
| 458 // we do the filling afterwards so the user sees the unmodified toolbar color. | 476 // we do the filling afterwards so the user sees the unmodified toolbar color. |
| 459 const ui::ThemeProvider* tp = GetThemeProvider(); | 477 const ui::ThemeProvider* tp = GetThemeProvider(); |
| 460 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); | 478 const SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR); |
| 461 if (!md) | 479 if (!md) |
| 462 FillClientEdgeRects(x, y, right, bottom, toolbar_color, canvas); | 480 FillClientEdgeRects(x, y, right, bottom, toolbar_color, canvas); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 485 gfx::Canvas* canvas) const { | 503 gfx::Canvas* canvas) const { |
| 486 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, | 504 gfx::Rect side(x - kClientEdgeThickness, y, kClientEdgeThickness, |
| 487 bottom + kClientEdgeThickness - y); | 505 bottom + kClientEdgeThickness - y); |
| 488 canvas->FillRect(side, color); | 506 canvas->FillRect(side, color); |
| 489 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), | 507 canvas->FillRect(gfx::Rect(x, bottom, right - x, kClientEdgeThickness), |
| 490 color); | 508 color); |
| 491 side.set_x(right); | 509 side.set_x(right); |
| 492 canvas->FillRect(side, color); | 510 canvas->FillRect(side, color); |
| 493 } | 511 } |
| 494 | 512 |
| 495 void GlassBrowserFrameView::LayoutNewStyleAvatar() { | 513 void GlassBrowserFrameView::LayoutAvatar() { |
| 496 DCHECK(browser_view()->IsRegularOrGuestSession()); | 514 DCHECK(browser_view()->IsRegularOrGuestSession()); |
| 497 if (!profile_switcher_.view()) | 515 if (!profile_switcher_.view()) |
| 498 return; | 516 return; |
| 499 | 517 |
| 500 gfx::Size label_size = profile_switcher_.view()->GetPreferredSize(); | 518 gfx::Size label_size = profile_switcher_.view()->GetPreferredSize(); |
| 501 | 519 |
| 502 int button_x = frame()->GetMinimizeButtonOffset() - | 520 int button_x = frame()->GetMinimizeButtonOffset() - |
| 503 kNewAvatarButtonOffset - label_size.width(); | 521 kNewAvatarButtonOffset - label_size.width(); |
| 504 if (base::i18n::IsRTL()) | 522 if (RTLSpecialLayout()) |
| 505 button_x = width() - frame()->GetMinimizeButtonOffset() + | 523 button_x = width() - frame()->GetMinimizeButtonOffset() + |
| 506 kNewAvatarButtonOffset; | 524 kNewAvatarButtonOffset; |
| 507 | 525 |
| 508 // The caption button position and size is confusing. In maximized mode, the | 526 const int button_y = WindowTopY(); |
| 509 // caption buttons are SM_CYMENUSIZE pixels high and are placed | 527 const int button_h = frame()->IsMaximized() ? kAvatarButtonHeightMaximized |
| 510 // FrameTopBorderHeight() pixels from the top of the window; all those top | 528 : kAvatarButtonHeightRestored; |
| 511 // border pixels are offscreen, so this result in caption buttons flush with | 529 profile_switcher_.view()->SetBounds(button_x, button_y, label_size.width(), |
| 512 // the top of the screen. In restored mode, the caption buttons are first | 530 button_h); |
| 513 // placed just below a 2 px border at the top of the window (which is the | |
| 514 // first two pixels' worth of FrameTopBorderHeight()), then extended upwards | |
| 515 // one extra pixel to overlap part of this border. | |
| 516 // | |
| 517 // To match both of these, we size the button as if it's always the extra one | |
| 518 // pixel in height, then we place it at the correct position in restored mode, | |
| 519 // or one pixel above the top of the screen in maximized mode. | |
| 520 int button_y = frame()->IsMaximized() ? (FrameTopBorderHeight(false) - 1) : 1; | |
| 521 profile_switcher_.view()->SetBounds( | |
| 522 button_x, button_y, label_size.width(), | |
| 523 gfx::win::GetSystemMetricsInDIP(SM_CYMENUSIZE) + 1); | |
| 524 } | 531 } |
| 525 | 532 |
| 526 void GlassBrowserFrameView::LayoutIncognitoIcon() { | 533 void GlassBrowserFrameView::LayoutIncognitoIcon() { |
| 527 const bool md = ui::MaterialDesignController::IsModeMaterial(); | 534 const bool md = ui::MaterialDesignController::IsModeMaterial(); |
|
ananta
2016/04/11 21:12:11
Better name than md please.
Peter Kasting
2016/04/11 21:22:11
FWIW we use this name pretty consistently across a
Bret
2016/04/11 23:44:47
I agree with Peter. It's a local bool so I think i
| |
| 528 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); | 535 const gfx::Insets insets(GetLayoutInsets(AVATAR_ICON)); |
| 529 const gfx::Size size(GetOTRAvatarIcon().size()); | 536 const gfx::Size size(GetOTRAvatarIcon().size()); |
| 530 int x = NonClientBorderThickness(false); | 537 int x = ClientBorderThickness(false); |
| 531 // In RTL, the icon needs to start after the caption buttons. | 538 // In RTL, the icon needs to start after the caption buttons. |
| 532 if (base::i18n::IsRTL()) { | 539 if (RTLSpecialLayout()) { |
| 533 x = width() - frame()->GetMinimizeButtonOffset() + | 540 x = width() - frame()->GetMinimizeButtonOffset() + |
| 534 (profile_switcher_.view() | 541 (profile_switcher_.view() |
| 535 ? (profile_switcher_.view()->width() + kNewAvatarButtonOffset) | 542 ? (profile_switcher_.view()->width() + kNewAvatarButtonOffset) |
| 536 : 0); | 543 : 0); |
| 537 } else if (!md && !avatar_button() && IsToolbarVisible() && | 544 } else if (!md && !avatar_button() && IsToolbarVisible() && |
| 538 (base::win::GetVersion() < base::win::VERSION_WIN10)) { | 545 (base::win::GetVersion() < base::win::VERSION_WIN10)) { |
| 539 // In non-MD before Win 10, the toolbar has a rounded corner that we don't | 546 // In non-MD before Win 10, the toolbar has a rounded corner that we don't |
| 540 // want the tabstrip to overlap. | 547 // want the tabstrip to overlap. |
| 541 x += browser_view()->GetToolbarBounds().x() - kContentEdgeShadowThickness + | 548 x += browser_view()->GetToolbarBounds().x() - kContentEdgeShadowThickness + |
| 542 GetThemeProvider()->GetImageSkiaNamed( | 549 GetThemeProvider()->GetImageSkiaNamed( |
| 543 IDR_CONTENT_TOP_LEFT_CORNER)->width(); | 550 IDR_CONTENT_TOP_LEFT_CORNER)->width(); |
| 544 } | 551 } |
| 545 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - | 552 const int bottom = GetTopInset(false) + browser_view()->GetTabStripHeight() - |
| 546 insets.bottom(); | 553 insets.bottom(); |
| 547 const int y = (md || !frame()->IsMaximized()) ? | 554 const int y = (md || !frame()->IsMaximized()) |
| 548 (bottom - size.height()) : FrameTopBorderHeight(false); | 555 ? (bottom - size.height()) |
| 556 : NonClientTopBorderThickness(false); | |
| 549 incognito_bounds_.SetRect(x + (avatar_button() ? insets.left() : 0), y, | 557 incognito_bounds_.SetRect(x + (avatar_button() ? insets.left() : 0), y, |
| 550 avatar_button() ? size.width() : 0, bottom - y); | 558 avatar_button() ? size.width() : 0, bottom - y); |
| 551 if (avatar_button()) | 559 if (avatar_button()) |
| 552 avatar_button()->SetBoundsRect(incognito_bounds_); | 560 avatar_button()->SetBoundsRect(incognito_bounds_); |
| 553 } | 561 } |
| 554 | 562 |
| 555 void GlassBrowserFrameView::LayoutClientView() { | 563 void GlassBrowserFrameView::LayoutClientView() { |
| 556 client_view_bounds_ = CalculateClientAreaBounds(); | 564 client_view_bounds_ = CalculateClientAreaBounds(); |
| 557 } | 565 } |
| 558 | 566 |
| 559 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets(bool restored) const { | 567 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets(bool restored) const { |
| 560 if (!browser_view()->IsTabStripVisible()) | 568 if (!browser_view()->IsTabStripVisible()) |
| 561 return gfx::Insets(); | 569 return gfx::Insets(); |
| 562 | 570 |
| 563 const int top_height = NonClientTopBorderHeight(restored); | 571 const int top_height = NonClientTopHeight(restored); |
| 564 const int border_thickness = NonClientBorderThickness(restored); | 572 const int border_thickness = ClientBorderThickness(restored); |
| 565 return gfx::Insets(top_height, | 573 return gfx::Insets(top_height, |
| 566 border_thickness, | 574 border_thickness, |
| 567 border_thickness, | 575 border_thickness, |
| 568 border_thickness); | 576 border_thickness); |
| 569 } | 577 } |
| 570 | 578 |
| 571 gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds() const { | 579 gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds() const { |
| 572 gfx::Rect bounds(GetLocalBounds()); | 580 gfx::Rect bounds(GetLocalBounds()); |
| 573 bounds.Inset(GetClientAreaInsets(false)); | 581 bounds.Inset(GetClientAreaInsets(false)); |
| 574 return bounds; | 582 return bounds; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 648 static bool initialized = false; | 656 static bool initialized = false; |
| 649 if (!initialized) { | 657 if (!initialized) { |
| 650 for (int i = 0; i < kThrobberIconCount; ++i) { | 658 for (int i = 0; i < kThrobberIconCount; ++i) { |
| 651 throbber_icons_[i] = | 659 throbber_icons_[i] = |
| 652 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 660 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
| 653 DCHECK(throbber_icons_[i]); | 661 DCHECK(throbber_icons_[i]); |
| 654 } | 662 } |
| 655 initialized = true; | 663 initialized = true; |
| 656 } | 664 } |
| 657 } | 665 } |
| OLD | NEW |