| 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/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" | 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
| 9 #include "ash/wm/frame_border_hit_test_controller.h" | 9 #include "ash/wm/frame_border_hit_test_controller.h" |
| 10 #include "ash/wm/header_painter.h" | 10 #include "ash/wm/header_painter.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 25 #include "ui/base/accessibility/accessible_view_state.h" | 25 #include "ui/base/accessibility/accessible_view_state.h" |
| 26 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/layout.h" | 28 #include "ui/base/layout.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/base/theme_provider.h" | 30 #include "ui/base/theme_provider.h" |
| 31 #include "ui/compositor/layer_animator.h" | 31 #include "ui/compositor/layer_animator.h" |
| 32 #include "ui/gfx/canvas.h" | 32 #include "ui/gfx/canvas.h" |
| 33 #include "ui/gfx/image/image_skia.h" | 33 #include "ui/gfx/image/image_skia.h" |
| 34 #include "ui/gfx/rect_conversions.h" |
| 34 #include "ui/views/controls/label.h" | 35 #include "ui/views/controls/label.h" |
| 35 #include "ui/views/layout/layout_constants.h" | 36 #include "ui/views/layout/layout_constants.h" |
| 36 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
| 37 #include "ui/views/widget/widget_delegate.h" | 38 #include "ui/views/widget/widget_delegate.h" |
| 38 | 39 |
| 39 namespace { | 40 namespace { |
| 40 | 41 |
| 41 // The avatar ends 2 px above the bottom of the tabstrip (which, given the | 42 // The avatar ends 2 px above the bottom of the tabstrip (which, given the |
| 42 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the | 43 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the |
| 43 // user). | 44 // user). |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 296 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 296 return kViewClassName; | 297 return kViewClassName; |
| 297 } | 298 } |
| 298 | 299 |
| 299 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { | 300 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { |
| 300 if (!views::View::HitTestRect(rect)) { | 301 if (!views::View::HitTestRect(rect)) { |
| 301 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 302 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 302 return false; | 303 return false; |
| 303 } | 304 } |
| 304 // If the rect is outside the bounds of the client area, claim it. | 305 // If the rect is outside the bounds of the client area, claim it. |
| 305 // TODO(tdanderson): Implement View::ConvertRectToTarget(). | 306 gfx::RectF rect_in_client_view_coords_f(rect); |
| 306 gfx::Point rect_in_client_view_coords_origin(rect.origin()); | 307 View::ConvertRectToTarget(this, frame()->client_view(), |
| 307 View::ConvertPointToTarget(this, frame()->client_view(), | 308 &rect_in_client_view_coords_f); |
| 308 &rect_in_client_view_coords_origin); | 309 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect( |
| 309 gfx::Rect rect_in_client_view_coords( | 310 rect_in_client_view_coords_f); |
| 310 rect_in_client_view_coords_origin, rect.size()); | |
| 311 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | 311 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
| 312 return true; | 312 return true; |
| 313 | 313 |
| 314 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | 314 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 315 // a non-tab portion. | 315 // a non-tab portion. |
| 316 TabStrip* tabstrip = browser_view()->tabstrip(); | 316 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 317 if (!tabstrip || !browser_view()->IsTabStripVisible()) | 317 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
| 318 return false; | 318 return false; |
| 319 | 319 |
| 320 gfx::Point rect_in_tabstrip_coords_origin(rect.origin()); | 320 gfx::RectF rect_in_tabstrip_coords_f(rect); |
| 321 View::ConvertPointToTarget(this, tabstrip, | 321 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); |
| 322 &rect_in_tabstrip_coords_origin); | 322 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect( |
| 323 gfx::Rect rect_in_tabstrip_coords(rect_in_tabstrip_coords_origin, | 323 rect_in_tabstrip_coords_f); |
| 324 rect.size()); | |
| 325 | 324 |
| 326 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { | 325 if (rect_in_tabstrip_coords.y() > tabstrip->GetLocalBounds().bottom()) { |
| 327 // |rect| is below the tabstrip. | 326 // |rect| is below the tabstrip. |
| 328 return false; | 327 return false; |
| 329 } | 328 } |
| 330 | 329 |
| 331 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | 330 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
| 332 // Claim |rect| if it is in a non-tab portion of the tabstrip. | 331 // Claim |rect| if it is in a non-tab portion of the tabstrip. |
| 333 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center | 332 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 334 // point to TabStrip::IsPositionInWindowCaption() once | |
| 335 // GetEventHandlerForRect() is implemented. | |
| 336 return tabstrip->IsPositionInWindowCaption( | |
| 337 rect_in_tabstrip_coords.CenterPoint()); | |
| 338 } | 333 } |
| 339 | 334 |
| 340 // We claim |rect| because it is above the bottom of the tabstrip, but | 335 // We claim |rect| because it is above the bottom of the tabstrip, but |
| 341 // not in the tabstrip. In particular, the window controls are right of | 336 // not in the tabstrip. In particular, the window controls are right of |
| 342 // the tabstrip. | 337 // the tabstrip. |
| 343 return true; | 338 return true; |
| 344 } | 339 } |
| 345 | 340 |
| 346 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 341 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 347 ui::AccessibleViewState* state) { | 342 ui::AccessibleViewState* state) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { | 564 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { |
| 570 ui::ThemeProvider* tp = GetThemeProvider(); | 565 ui::ThemeProvider* tp = GetThemeProvider(); |
| 571 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 566 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 572 browser_view()->IsBrowserTypeNormal() && | 567 browser_view()->IsBrowserTypeNormal() && |
| 573 !browser_view()->IsOffTheRecord()) { | 568 !browser_view()->IsOffTheRecord()) { |
| 574 return ShouldPaintAsActive() ? | 569 return ShouldPaintAsActive() ? |
| 575 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | 570 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; |
| 576 } | 571 } |
| 577 return 0; | 572 return 0; |
| 578 } | 573 } |
| OLD | NEW |