| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
| 10 #include "chrome/browser/themes/browser_theme_provider.h" | 10 #include "chrome/browser/themes/browser_theme_provider.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 int frame_component = | 284 int frame_component = |
| 285 frame_->GetWindow()->GetClientView()->NonClientHitTest(point); | 285 frame_->GetWindow()->GetClientView()->NonClientHitTest(point); |
| 286 | 286 |
| 287 // See if we're in the sysmenu region. We still have to check the tabstrip | 287 // See if we're in the sysmenu region. We still have to check the tabstrip |
| 288 // first so that clicks in a tab don't get treated as sysmenu clicks. | 288 // first so that clicks in a tab don't get treated as sysmenu clicks. |
| 289 gfx::Rect sysmenu_rect(IconBounds()); | 289 gfx::Rect sysmenu_rect(IconBounds()); |
| 290 // In maximized mode we extend the rect to the screen corner to take advantage | 290 // In maximized mode we extend the rect to the screen corner to take advantage |
| 291 // of Fitts' Law. | 291 // of Fitts' Law. |
| 292 if (frame_->GetWindow()->IsMaximized()) | 292 if (frame_->GetWindow()->IsMaximized()) |
| 293 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); | 293 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); |
| 294 sysmenu_rect.set_x(MirroredLeftPointForRect(sysmenu_rect)); | 294 sysmenu_rect.set_x(GetMirroredXForRect(sysmenu_rect)); |
| 295 if (sysmenu_rect.Contains(point)) | 295 if (sysmenu_rect.Contains(point)) |
| 296 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 296 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
| 297 | 297 |
| 298 if (frame_component != HTNOWHERE) | 298 if (frame_component != HTNOWHERE) |
| 299 return frame_component; | 299 return frame_component; |
| 300 | 300 |
| 301 // Then see if the point is within any of the window controls. | 301 // Then see if the point is within any of the window controls. |
| 302 if (close_button_->IsVisible() && | 302 if (close_button_->IsVisible() && |
| 303 close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 303 close_button_->GetMirroredBounds().Contains(point)) |
| 304 return HTCLOSE; | 304 return HTCLOSE; |
| 305 if (restore_button_->IsVisible() && | 305 if (restore_button_->IsVisible() && |
| 306 restore_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 306 restore_button_->GetMirroredBounds().Contains(point)) |
| 307 point)) | |
| 308 return HTMAXBUTTON; | 307 return HTMAXBUTTON; |
| 309 if (maximize_button_->IsVisible() && | 308 if (maximize_button_->IsVisible() && |
| 310 maximize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 309 maximize_button_->GetMirroredBounds().Contains(point)) |
| 311 point)) | |
| 312 return HTMAXBUTTON; | 310 return HTMAXBUTTON; |
| 313 if (minimize_button_->IsVisible() && | 311 if (minimize_button_->IsVisible() && |
| 314 minimize_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains( | 312 minimize_button_->GetMirroredBounds().Contains(point)) |
| 315 point)) | |
| 316 return HTMINBUTTON; | 313 return HTMINBUTTON; |
| 317 | 314 |
| 318 views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate(); | 315 views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate(); |
| 319 if (delegate == NULL) { | 316 if (delegate == NULL) { |
| 320 LOG(WARNING) << "delegate is NULL, returning safe default."; | 317 LOG(WARNING) << "delegate is NULL, returning safe default."; |
| 321 return HTCAPTION; | 318 return HTCAPTION; |
| 322 } | 319 } |
| 323 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), | 320 int window_component = GetHTComponentForFrame(point, TopResizeHeight(), |
| 324 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, | 321 NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, |
| 325 delegate->CanResize()); | 322 delegate->CanResize()); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { | 704 void OpaqueBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { |
| 708 // The window icon is painted by the TabIconView. | 705 // The window icon is painted by the TabIconView. |
| 709 views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate(); | 706 views::WindowDelegate* delegate = frame_->GetWindow()->GetDelegate(); |
| 710 if (delegate == NULL) { | 707 if (delegate == NULL) { |
| 711 LOG(WARNING) << "delegate is NULL"; | 708 LOG(WARNING) << "delegate is NULL"; |
| 712 return; | 709 return; |
| 713 } | 710 } |
| 714 if (delegate->ShouldShowWindowTitle()) { | 711 if (delegate->ShouldShowWindowTitle()) { |
| 715 canvas->DrawStringInt(WideToUTF16Hack(delegate->GetWindowTitle()), | 712 canvas->DrawStringInt(WideToUTF16Hack(delegate->GetWindowTitle()), |
| 716 BrowserFrame::GetTitleFont(), | 713 BrowserFrame::GetTitleFont(), |
| 717 SK_ColorWHITE, MirroredLeftPointForRect(title_bounds_), | 714 SK_ColorWHITE, GetMirroredXForRect(title_bounds_), |
| 718 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); | 715 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); |
| 719 /* TODO(pkasting): If this window is active, we should also draw a drop | 716 /* TODO(pkasting): If this window is active, we should also draw a drop |
| 720 * shadow on the title. This is tricky, because we don't want to hardcode a | 717 * shadow on the title. This is tricky, because we don't want to hardcode a |
| 721 * shadow color (since we want to work with various themes), but we can't | 718 * shadow color (since we want to work with various themes), but we can't |
| 722 * alpha-blend either (since the Windows text APIs don't really do this). | 719 * alpha-blend either (since the Windows text APIs don't really do this). |
| 723 * So we'd need to sample the background color at the right location and | 720 * So we'd need to sample the background color at the right location and |
| 724 * synthesize a good shadow color. */ | 721 * synthesize a good shadow color. */ |
| 725 } | 722 } |
| 726 } | 723 } |
| 727 | 724 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 | 1060 |
| 1064 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1061 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
| 1065 int height) const { | 1062 int height) const { |
| 1066 int top_height = NonClientTopBorderHeight(false, false); | 1063 int top_height = NonClientTopBorderHeight(false, false); |
| 1067 int border_thickness = NonClientBorderThickness(); | 1064 int border_thickness = NonClientBorderThickness(); |
| 1068 return gfx::Rect(border_thickness, top_height, | 1065 return gfx::Rect(border_thickness, top_height, |
| 1069 std::max(0, width - (2 * border_thickness)), | 1066 std::max(0, width - (2 * border_thickness)), |
| 1070 std::max(0, height - GetReservedHeight() - | 1067 std::max(0, height - GetReservedHeight() - |
| 1071 top_height - border_thickness)); | 1068 top_height - border_thickness)); |
| 1072 } | 1069 } |
| OLD | NEW |