Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 19115003: Make the maximize button more easily hittable when there is a huge amount of tabs present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed completely Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( 316 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds(
317 const gfx::Rect& client_bounds) const { 317 const gfx::Rect& client_bounds) const {
318 int top_height = NonClientTopBorderHeight(false); 318 int top_height = NonClientTopBorderHeight(false);
319 int border_thickness = NonClientBorderThickness(); 319 int border_thickness = NonClientBorderThickness();
320 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), 320 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness),
321 std::max(0, client_bounds.y() - top_height), 321 std::max(0, client_bounds.y() - top_height),
322 client_bounds.width() + (2 * border_thickness), 322 client_bounds.width() + (2 * border_thickness),
323 client_bounds.height() + top_height + border_thickness); 323 client_bounds.height() + top_height + border_thickness);
324 } 324 }
325 325
326 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { 326 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) const {
327 if (!bounds().Contains(point)) 327 if (!bounds().Contains(point))
328 return HTNOWHERE; 328 return HTNOWHERE;
329 329
330 // See if the point is within the avatar menu button or within the avatar 330 // See if the point is within the avatar menu button or within the avatar
331 // label. 331 // label.
332 if ((avatar_button() && 332 if ((avatar_button() &&
333 avatar_button()->GetMirroredBounds().Contains(point)) || 333 avatar_button()->GetMirroredBounds().Contains(point)) ||
334 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point))) 334 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))
335 return HTCLIENT; 335 return HTCLIENT;
336 336
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 void OpaqueBrowserFrameView::Layout() { 433 void OpaqueBrowserFrameView::Layout() {
434 LayoutWindowControls(); 434 LayoutWindowControls();
435 LayoutTitleBar(); 435 LayoutTitleBar();
436 LayoutAvatar(); 436 LayoutAvatar();
437 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); 437 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
438 } 438 }
439 439
440 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { 440 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
441 // If |rect| does not intersect the bounds of the client area, claim it. 441 // NonClientHitTest() returns HTCLIENT for the avatar menu button and avatar
James Cook 2013/07/16 19:25:52 I presume this block of code moved from somewhere
442 bool in_nonclient = NonClientFrameView::HitTestRect(rect); 442 // label. They are parented to OpaqueBrowserFrameView so HitTestRect() needs
443 if (in_nonclient) 443 // to return true.
444 return in_nonclient; 444 if ((avatar_button() &&
445 avatar_button()->GetMirroredBounds().Contains(rect)) ||
446 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(rect))) {
447 return true;
448 }
445 449
446 // Otherwise claim it only if it's in a non-tab portion of the tabstrip.
447 if (!browser_view()->tabstrip())
448 return false;
449 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
450 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
451 View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin);
452 tabstrip_bounds.set_origin(tabstrip_origin);
453 if (rect.bottom() > tabstrip_bounds.bottom())
454 return false;
455
456 // We convert from our parent's coordinates since we assume we fill its bounds
457 // completely. We need to do this since we're not a parent of the tabstrip,
458 // meaning ConvertPointToTarget would otherwise return something bogus.
459 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of 450 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of
460 // its center point once GetEventHandlerForRect() is implemented. 451 // its center point once GetEventHandlerForRect() is implemented.
461 gfx::Point browser_view_point(rect.CenterPoint()); 452 gfx::Point browser_view_point(rect.CenterPoint());
462 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point); 453 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point);
463 return browser_view()->IsPositionInWindowCaption(browser_view_point); 454 return NonClientHitTest(browser_view_point) != HTCLIENT;
464 } 455 }
465 456
466 void OpaqueBrowserFrameView::GetAccessibleState( 457 void OpaqueBrowserFrameView::GetAccessibleState(
467 ui::AccessibleViewState* state) { 458 ui::AccessibleViewState* state) {
468 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; 459 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR;
469 } 460 }
470 461
471 /////////////////////////////////////////////////////////////////////////////// 462 ///////////////////////////////////////////////////////////////////////////////
472 // OpaqueBrowserFrameView, views::ButtonListener implementation: 463 // OpaqueBrowserFrameView, views::ButtonListener implementation:
473 464
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 1043
1053 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, 1044 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
1054 int height) const { 1045 int height) const {
1055 int top_height = NonClientTopBorderHeight(false); 1046 int top_height = NonClientTopBorderHeight(false);
1056 int border_thickness = NonClientBorderThickness(); 1047 int border_thickness = NonClientBorderThickness();
1057 return gfx::Rect(border_thickness, top_height, 1048 return gfx::Rect(border_thickness, top_height,
1058 std::max(0, width - (2 * border_thickness)), 1049 std::max(0, width - (2 * border_thickness)),
1059 std::max(0, height - GetReservedHeight() - 1050 std::max(0, height - GetReservedHeight() -
1060 top_height - border_thickness)); 1051 top_height - border_thickness));
1061 } 1052 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698