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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout.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: Moved the implementation to OapqueBrowserFrameView and BrowserNonClientFrameViewAsh 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_view_layout.h" 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
6 6
7 #include "base/observer_list.h" 7 #include "base/observer_list.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // Finally decrease the width of the bounding box by the width of 240 // Finally decrease the width of the bounding box by the width of
241 // the vertical scroll bar. 241 // the vertical scroll bar.
242 int scrollbar_width = gfx::scrollbar_size(); 242 int scrollbar_width = gfx::scrollbar_size();
243 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); 243 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width));
244 if (base::i18n::IsRTL()) 244 if (base::i18n::IsRTL())
245 bounding_box.set_x(bounding_box.x() + scrollbar_width); 245 bounding_box.set_x(bounding_box.x() + scrollbar_width);
246 246
247 return bounding_box; 247 return bounding_box;
248 } 248 }
249 249
250 bool BrowserViewLayout::IsPositionInWindowCaption( 250 int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
251 const gfx::Point& point) {
252 // Tab strip may transiently have no parent between the RemoveChildView() and
253 // AddChildView() caused by reparenting during an immersive mode reveal.
254 // During this window report that the point didn't hit a tab.
255 if (!tab_strip_->parent())
256 return true;
257 gfx::Point tabstrip_point(point);
258 views::View::ConvertPointToTarget(browser_view_, tab_strip_, &tabstrip_point);
259 return tab_strip_->IsPositionInWindowCaption(tabstrip_point);
260 }
261
262 int BrowserViewLayout::NonClientHitTest(
263 const gfx::Point& point) {
264 // Since the TabStrip only renders in some parts of the top of the window, 251 // Since the TabStrip only renders in some parts of the top of the window,
265 // the un-obscured area is considered to be part of the non-client caption 252 // the un-obscured area is considered to be part of the non-client caption
266 // area of the window. So we need to treat hit-tests in these regions as 253 // area of the window. So we need to treat hit-tests in these regions as
267 // hit-tests of the titlebar. 254 // hit-tests of the titlebar.
268 255
269 views::View* parent = browser_view_->parent(); 256 views::View* parent = browser_view_->parent();
270 257
271 gfx::Point point_in_browser_view_coords(point); 258 gfx::Point point_in_browser_view_coords(point);
272 views::View::ConvertPointToTarget( 259 views::View::ConvertPointToTarget(
273 parent, browser_view_, &point_in_browser_view_coords); 260 parent, browser_view_, &point_in_browser_view_coords);
274 gfx::Point test_point(point); 261 gfx::Point test_point(point);
275 262
276 // Determine if the TabStrip exists and is capable of being clicked on. We 263 // Determine if the TabStrip exists and is capable of being clicked on. We
277 // might be a popup window without a TabStrip. 264 // might be a popup window without a TabStrip.
278 if (browser_view_->IsTabStripVisible()) { 265 if (browser_view_->IsTabStripVisible()) {
279 // See if the mouse pointer is within the bounds of the TabStrip. 266 // See if the mouse pointer is within the bounds of the TabStrip.
280 if (ConvertedHitTest(parent, tab_strip_, &test_point)) { 267 if (ConvertedHitTest(parent, tab_strip_, &test_point)) {
281 if (tab_strip_->IsPositionInWindowCaption(test_point)) 268 if (tab_strip_->IsPositionInWindowCaption(test_point))
282 return HTCAPTION; 269 return HTCAPTION;
283 return HTCLIENT; 270 return HTCLIENT;
284 } 271 }
285 272
286 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty 273 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty
287 // starved of dragable area, let's give it to window dragging (this also 274 // starved of dragable area, let's give it to window dragging (this also
288 // makes sense visually). 275 // makes sense visually).
289 if (!browser_view_->IsMaximized() && 276 if (!(browser_view_->IsMaximized() || browser_view_->IsFullscreen()) &&
290 (point_in_browser_view_coords.y() < 277 (point_in_browser_view_coords.y() <
291 (tab_strip_->y() + kTabShadowSize))) { 278 (tab_strip_->y() + kTabShadowSize))) {
292 // We return HTNOWHERE as this is a signal to our containing 279 // We return HTNOWHERE as this is a signal to our containing
293 // NonClientView that it should figure out what the correct hit-test 280 // NonClientView that it should figure out what the correct hit-test
294 // code is given the mouse position... 281 // code is given the mouse position...
295 return HTNOWHERE; 282 return HTNOWHERE;
296 } 283 }
297 } 284 }
298 285
299 // If the point's y coordinate is below the top of the toolbar and otherwise 286 // If the point's y coordinate is below the top of the toolbar and otherwise
300 // within the bounds of this view, the point is considered to be within the 287 // within the bounds of this view, the point is considered to be within the
301 // client area. 288 // client area.
302 gfx::Rect bv_bounds = browser_view_->bounds(); 289 gfx::Rect bv_bounds = browser_view_->bounds();
303 bv_bounds.Offset(0, toolbar_->y()); 290 bv_bounds.Offset(0, toolbar_->y());
304 bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); 291 bv_bounds.set_height(bv_bounds.height() - toolbar_->y());
305 if (bv_bounds.Contains(point)) 292 if (bv_bounds.Contains(point))
306 return HTCLIENT; 293 return HTCLIENT;
307 294
308 // If the point's y coordinate is above the top of the toolbar, but not in 295 // If the point is within the bounds of the window switcher button, the point
309 // the tabstrip (per previous checking in this function), then we consider it 296 // is considered to be within the client area.
310 // in the window caption (e.g. the area to the right of the tabstrip 297 views::View* window_switcher_button = delegate_->GetWindowSwitcherButton();
311 // underneath the window controls). However, note that we DO NOT return 298 if (window_switcher_button) {
312 // HTCAPTION here, because when the window is maximized the window controls 299 gfx::Point window_switcher_point(point_in_browser_view_coords);
313 // will fall into this space (since the BrowserView is sized to entire size 300 views::View::ConvertPointToTarget(browser_view_, window_switcher_button,
314 // of the window at that point), and the HTCAPTION value will cause the 301 &window_switcher_point);
315 // window controls not to work. So we return HTNOWHERE so that the caller 302 if (window_switcher_button->HitTestPoint(window_switcher_point))
316 // will hit-test the window controls before finally falling back to 303 return HTCLIENT;
317 // HTCAPTION. 304 }
305
306 // If the point's y coordinate is above the top of the toolbar, but neither
307 // over the tabstrip nor over the window switcher button (per previous
308 // checking in this function), then we consider it in the window caption
309 // (e.g. the area to the right of the tabstrip underneath the window
310 // controls). However, note that we DO NOT return HTCAPTION here, because
311 // when the window is maximized the window controls will fall into this
312 // space (since the BrowserView is sized to entire size of the window at that
313 // point), and the HTCAPTION value will cause the window controls not to work.
314 // So we return HTNOWHERE so that the caller will hit-test the window controls
315 // before finally falling back to HTCAPTION.
318 bv_bounds = browser_view_->bounds(); 316 bv_bounds = browser_view_->bounds();
319 bv_bounds.set_height(toolbar_->y()); 317 bv_bounds.set_height(toolbar_->y());
320 if (bv_bounds.Contains(point)) 318 if (bv_bounds.Contains(point))
321 return HTNOWHERE; 319 return HTNOWHERE;
322 320
323 // If the point is somewhere else, delegate to the default implementation. 321 // If the point is somewhere else, delegate to the default implementation.
324 return browser_view_->views::ClientView::NonClientHitTest(point); 322 return browser_view_->views::ClientView::NonClientHitTest(point);
325 } 323 }
326 324
327 ////////////////////////////////////////////////////////////////////////////// 325 //////////////////////////////////////////////////////////////////////////////
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 return bottom; 639 return bottom;
642 } 640 }
643 641
644 bool BrowserViewLayout::InfobarVisible() const { 642 bool BrowserViewLayout::InfobarVisible() const {
645 // Cast to a views::View to access GetPreferredSize(). 643 // Cast to a views::View to access GetPreferredSize().
646 views::View* infobar_container = infobar_container_; 644 views::View* infobar_container = infobar_container_;
647 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 645 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
648 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 646 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
649 (infobar_container->GetPreferredSize().height() != 0); 647 (infobar_container->GetPreferredSize().height() != 0);
650 } 648 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698