diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 01:52:16 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 01:52:16 +0000 |
commit | 87bedee2af894c69b6496477228ec97d43ef0739 (patch) | |
tree | 92f474b7d53d6b8692afac71f7b544b41be06f62 /chrome/browser/views | |
parent | 7b3cd164793d6dbf31dd340ad19f0bce61c8a2bc (diff) | |
download | chromium_src-87bedee2af894c69b6496477228ec97d43ef0739.zip chromium_src-87bedee2af894c69b6496477228ec97d43ef0739.tar.gz chromium_src-87bedee2af894c69b6496477228ec97d43ef0739.tar.bz2 |
Fix the remaining issues with showing the app menu for the top left part of the window:
* Works on opaque mode frames
* Miscalculated bounds on glass frame now fixed
BUG=6961
TEST=Clicking in the upper left corner of any Chrome window, where an icon would normally be, should show the app menu. Double-clicking should close the window.
Review URL: http://codereview.chromium.org/596073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
3 files changed, 64 insertions, 40 deletions
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index 6ed2217..0d82821 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -97,8 +97,8 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( if (UILayoutIsRightToLeft()) tabstrip_x += (width() - minimize_button_offset); int tabstrip_width = minimize_button_offset - tabstrip_x - - (frame_->GetWindow()->IsMaximized() ? kNewTabCaptionMaximizedSpacing - : kNewTabCaptionRestoredSpacing); + (frame_->GetWindow()->IsMaximized() ? + kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); if (UILayoutIsRightToLeft()) tabstrip_width += tabstrip_x; return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(), @@ -161,9 +161,9 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { // See if we're in the sysmenu region. We still have to check the tabstrip // first so that clicks in a tab don't get treated as sysmenu clicks. - int frame_border_thickness = FrameBorderThickness(); int nonclient_border_thickness = NonClientBorderThickness(); - gfx::Rect sysmenu_rect(nonclient_border_thickness, frame_border_thickness, + gfx::Rect sysmenu_rect(nonclient_border_thickness, + GetSystemMetrics(SM_CXSIZEFRAME), GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); bool in_sysmenu = sysmenu_rect.Contains(point); @@ -175,6 +175,7 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { if (frame_component != HTNOWHERE) return frame_component; + int frame_border_thickness = FrameBorderThickness(); int window_component = GetHTComponentForFrame(point, frame_border_thickness, nonclient_border_thickness, frame_border_thickness, kResizeAreaCornerSize - frame_border_thickness, @@ -224,9 +225,8 @@ int GlassBrowserFrameView::NonClientTopBorderHeight() const { // We'd like to use FrameBorderThickness() here, but the maximized Aero glass // frame has a 0 frame border around most edges and a CXSIZEFRAME-thick border // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). - const int kRestoredHeight = browser_view_->UsingSideTabs() - ? GetSystemMetrics(SM_CYCAPTION) - : kNonClientRestoredExtraThickness; + const int kRestoredHeight = browser_view_->UsingSideTabs() ? + GetSystemMetrics(SM_CYCAPTION) : kNonClientRestoredExtraThickness; return GetSystemMetrics(SM_CXSIZEFRAME) + (browser_view_->IsMaximized() ? -kTabstripTopShadowThickness : kRestoredHeight); } @@ -373,8 +373,7 @@ void GlassBrowserFrameView::LayoutOTRAvatar() { if (browser_view_->IsTabStripVisible()) { tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; otr_height = frame_->GetWindow()->IsMaximized() ? - (tabstrip_height - kOTRMaximizedTopSpacing) : - otr_avatar_icon.height(); + (tabstrip_height - kOTRMaximizedTopSpacing) : otr_avatar_icon.height(); } else { tabstrip_height = otr_height = 0; } diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index e8a1f40..aa46c38 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -275,8 +275,19 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { if (!bounds().Contains(point)) return HTNOWHERE; + // See if we're in the sysmenu region. We still have to check the tabstrip + // first so that clicks in a tab don't get treated as sysmenu clicks. + gfx::Rect sysmenu_rect(IconBounds()); + // In maximized mode we extend the rect to the screen corner to take advantage + // of Fitts' Law. + if (frame_->GetWindow()->IsMaximized()) + sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); + bool in_sysmenu = sysmenu_rect.Contains(point); + int frame_component = frame_->GetWindow()->GetClientView()->NonClientHitTest(point); + if (in_sysmenu) + return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; if (frame_component != HTNOWHERE) return frame_component; @@ -529,6 +540,40 @@ int OpaqueBrowserFrameView::IconSize() const { #endif } +gfx::Rect OpaqueBrowserFrameView::IconBounds() const { + int size = IconSize(); + int frame_thickness = FrameBorderThickness(); + int y; + if (frame_->GetWindow()->GetDelegate()->ShouldShowWindowIcon()) { + // This next statement handles two things: + // (1) Vertically centering the icon when the icon is shorter than the + // minimum space we reserve for the caption button. Practically, this + // only occurs in maximized mode, since otherwise the minimum icon + // size supplied by Windows (16) + the frame border height (4) >= the + // minimum caption button space (19 + the frame shadow thickness (1)). + // In maximized mode we want to bias rounding to put extra space above + // the icon, since below it is the 2 px 3D edge, which looks to the + // eye like additional space; hence the + 1 below. + // (2) Our frame border has a different "3D look" than Windows'. Theirs + // has a more complex gradient on the top that they push their + // icon/title below; then the maximized window cuts this off and the + // icon/title are centered in the remaining space. Because the + // apparent shape of our border is simpler, using the same positioning + // makes things look slightly uncentered with restored windows, so we + // come up to compensate. The frame border has a 2 px 3D edge plus + // some empty space, so we adjust by half the width of the empty space + // to center things. + y = (NonClientTopBorderHeight() - size - TitlebarBottomThickness() + 1 + + (frame_->GetWindow()->IsMaximized() ? + frame_thickness : kTitlebarTopAndBottomEdgeThickness)) / 2; + } else { + // For "browser mode" windows, we use the native positioning, which is just + // below the top frame border. + y = frame_thickness; + } + return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); +} + void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { ThemeProvider* tp = GetThemeProvider(); @@ -962,43 +1007,19 @@ void OpaqueBrowserFrameView::LayoutDistributorLogo() { void OpaqueBrowserFrameView::LayoutTitleBar() { // Always lay out the icon, even when it's not present, so we can lay out the // window title based on its position. - int frame_thickness = FrameBorderThickness(); - int icon_x = frame_thickness + kIconLeftSpacing; - int icon_size = IconSize(); - // This next statement handles vertically centering the icon when the icon is - // shorter than the minimum space we reserve for the caption button. - // Practically, this never occurs except in maximized mode, since otherwise - // the minimum icon size supplied by Windows (16) + the frame border height - // (4) >= the minimum caption button space (19 + the frame shadow thickness - // (1)). In maximized mode we want to bias rounding to put extra space above - // the icon, since below it is the 2 px 3D edge, which looks to the eye like - // additional space; hence the + 1 below. - int icon_y = frame_thickness + ((NonClientTopBorderHeight() - - frame_thickness - icon_size - TitlebarBottomThickness() + 1) / 2); - + gfx::Rect icon_bounds(IconBounds()); views::WindowDelegate* d = frame_->GetWindow()->GetDelegate(); - if (d->ShouldShowWindowIcon()) { - // Hack: Our frame border has a different "3D look" than Windows'. Theirs - // has a more complex gradient on the top that they push their icon/title - // below; then the maximized window cuts this off and the icon/title are - // centered in the remaining space. Because the apparent shape of our - // border is simpler, using the same positioning makes things look slightly - // uncentered with restored windows, so we come up to compensate. The frame - // border has a 2 px 3D edge plus some empty space, so we adjust by half the - // width of the empty space to center things. - if (!frame_->GetWindow()->IsMaximized()) - icon_y -= (frame_thickness - kTitlebarTopAndBottomEdgeThickness) / 2; - - window_icon_->SetBounds(icon_x, icon_y, icon_size, icon_size); - } + if (d->ShouldShowWindowIcon()) + window_icon_->SetBounds(icon_bounds); // Size the title, if visible. if (d->ShouldShowWindowTitle()) { InitAppWindowResources(); // To make sure the title_font_ is loaded. - int title_x = icon_x + - (d->ShouldShowWindowIcon() ? icon_size + kIconTitleSpacing : 0); + int title_x = d->ShouldShowWindowIcon() ? + icon_bounds.right() + kIconTitleSpacing : icon_bounds.x(); int title_height = title_font_->height(); - title_bounds_.SetRect(title_x, icon_y + ((icon_size - title_height) / 2), + title_bounds_.SetRect(title_x, + icon_bounds.y() + ((icon_bounds.height() - title_height) / 2), std::max(0, logo_icon_->x() - kTitleLogoSpacing - title_x), title_height); } diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h index 2aa7658..0ef2246 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/views/frame/opaque_browser_frame_view.h @@ -98,6 +98,10 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, // not shown, e.g. to set the titlebar height. int IconSize() const; + // Returns the bounds of the titlebar icon (or where the icon would be if + // there was one). + gfx::Rect IconBounds() const; + // Paint various sub-components of this view. The *FrameBorder() functions // also paint the background of the titlebar area, since the top frame border // and titlebar background are a contiguous component. |