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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 282 } |
283 | 283 |
284 void OpaqueBrowserFrameView::UpdateWindowTitle() { | 284 void OpaqueBrowserFrameView::UpdateWindowTitle() { |
285 if (!frame()->IsFullscreen()) | 285 if (!frame()->IsFullscreen()) |
286 window_title_->SchedulePaint(); | 286 window_title_->SchedulePaint(); |
287 } | 287 } |
288 | 288 |
289 /////////////////////////////////////////////////////////////////////////////// | 289 /////////////////////////////////////////////////////////////////////////////// |
290 // OpaqueBrowserFrameView, views::View overrides: | 290 // OpaqueBrowserFrameView, views::View overrides: |
291 | 291 |
292 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { | |
293 if (!views::View::HitTestRect(rect)) { | |
294 // |rect| is outside OpaqueBrowserFrameView's bounds. | |
295 return false; | |
296 } | |
297 | |
298 // If the rect is outside the bounds of the client area, claim it. | |
299 gfx::RectF rect_in_client_view_coords_f(rect); | |
300 View::ConvertRectToTarget(this, frame()->client_view(), | |
301 &rect_in_client_view_coords_f); | |
302 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect( | |
303 rect_in_client_view_coords_f); | |
304 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | |
305 return true; | |
306 | |
307 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | |
308 // a non-tab portion. | |
309 TabStrip* tabstrip = browser_view()->tabstrip(); | |
310 if (!tabstrip || !browser_view()->IsTabStripVisible()) | |
311 return false; | |
312 | |
313 gfx::RectF rect_in_tabstrip_coords_f(rect); | |
314 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); | |
315 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect( | |
316 rect_in_tabstrip_coords_f); | |
317 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { | |
318 // |rect| is below the tabstrip. | |
319 return false; | |
320 } | |
321 | |
322 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | |
323 // Claim |rect| if it is in a non-tab portion of the tabstrip. | |
324 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); | |
325 } | |
326 | |
327 // We claim |rect| because it is above the bottom of the tabstrip, but | |
328 // not in the tabstrip itself. In particular, the avatar label/button is left | |
329 // of the tabstrip and the window controls are right of the tabstrip. | |
330 return true; | |
331 } | |
332 | |
333 void OpaqueBrowserFrameView::GetAccessibleState( | 292 void OpaqueBrowserFrameView::GetAccessibleState( |
334 ui::AXViewState* state) { | 293 ui::AXViewState* state) { |
335 state->role = ui::AX_ROLE_TITLE_BAR; | 294 state->role = ui::AX_ROLE_TITLE_BAR; |
336 } | 295 } |
337 | 296 |
338 /////////////////////////////////////////////////////////////////////////////// | 297 /////////////////////////////////////////////////////////////////////////////// |
339 // OpaqueBrowserFrameView, views::ButtonListener implementation: | 298 // OpaqueBrowserFrameView, views::ButtonListener implementation: |
340 | 299 |
341 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, | 300 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, |
342 const ui::Event& event) { | 301 const ui::Event& event) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 473 |
515 if (browser_view()->IsToolbarVisible()) | 474 if (browser_view()->IsToolbarVisible()) |
516 PaintToolbarBackground(canvas); | 475 PaintToolbarBackground(canvas); |
517 if (!layout_->IsTitleBarCondensed()) | 476 if (!layout_->IsTitleBarCondensed()) |
518 PaintRestoredClientEdge(canvas); | 477 PaintRestoredClientEdge(canvas); |
519 } | 478 } |
520 | 479 |
521 /////////////////////////////////////////////////////////////////////////////// | 480 /////////////////////////////////////////////////////////////////////////////// |
522 // OpaqueBrowserFrameView, private: | 481 // OpaqueBrowserFrameView, private: |
523 | 482 |
| 483 // views::NonClientFrameView: |
| 484 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target, |
| 485 const gfx::Rect& rect) const { |
| 486 CHECK_EQ(target, this); |
| 487 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| 488 // |rect| is outside OpaqueBrowserFrameView's bounds. |
| 489 return false; |
| 490 } |
| 491 |
| 492 // If the rect is outside the bounds of the client area, claim it. |
| 493 gfx::RectF rect_in_client_view_coords_f(rect); |
| 494 View::ConvertRectToTarget(this, frame()->client_view(), |
| 495 &rect_in_client_view_coords_f); |
| 496 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect( |
| 497 rect_in_client_view_coords_f); |
| 498 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
| 499 return true; |
| 500 |
| 501 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 502 // a non-tab portion. |
| 503 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 504 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
| 505 return false; |
| 506 |
| 507 gfx::RectF rect_in_tabstrip_coords_f(rect); |
| 508 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); |
| 509 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect( |
| 510 rect_in_tabstrip_coords_f); |
| 511 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { |
| 512 // |rect| is below the tabstrip. |
| 513 return false; |
| 514 } |
| 515 |
| 516 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
| 517 // Claim |rect| if it is in a non-tab portion of the tabstrip. |
| 518 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 519 } |
| 520 |
| 521 // We claim |rect| because it is above the bottom of the tabstrip, but |
| 522 // not in the tabstrip itself. In particular, the avatar label/button is left |
| 523 // of the tabstrip and the window controls are right of the tabstrip. |
| 524 return true; |
| 525 } |
| 526 |
524 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( | 527 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( |
525 int normal_image_id, | 528 int normal_image_id, |
526 int hot_image_id, | 529 int hot_image_id, |
527 int pushed_image_id, | 530 int pushed_image_id, |
528 int mask_image_id, | 531 int mask_image_id, |
529 int accessibility_string_id, | 532 int accessibility_string_id, |
530 ViewID view_id) { | 533 ViewID view_id) { |
531 views::ImageButton* button = new views::ImageButton(this); | 534 views::ImageButton* button = new views::ImageButton(this); |
532 ui::ThemeProvider* tp = frame()->GetThemeProvider(); | 535 ui::ThemeProvider* tp = frame()->GetThemeProvider(); |
533 button->SetImage(views::CustomButton::STATE_NORMAL, | 536 button->SetImage(views::CustomButton::STATE_NORMAL, |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 | 905 |
903 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 906 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
904 gfx::ImageSkia* frame_image = GetFrameImage(); | 907 gfx::ImageSkia* frame_image = GetFrameImage(); |
905 int top_area_height = frame_image->height(); | 908 int top_area_height = frame_image->height(); |
906 if (browser_view()->IsTabStripVisible()) { | 909 if (browser_view()->IsTabStripVisible()) { |
907 top_area_height = std::max(top_area_height, | 910 top_area_height = std::max(top_area_height, |
908 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 911 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
909 } | 912 } |
910 return top_area_height; | 913 return top_area_height; |
911 } | 914 } |
OLD | NEW |