diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-29 22:06:40 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-29 22:06:40 +0000 |
commit | fc81ac2d712a65c951005a8905a1edc114a1c1ef (patch) | |
tree | d295e947157f2bd09fde08334aaa1e1e81c842a0 /chrome/browser/views | |
parent | cad01431b348b5c01ded71f05f2f30f8dcc41d22 (diff) | |
download | chromium_src-fc81ac2d712a65c951005a8905a1edc114a1c1ef.zip chromium_src-fc81ac2d712a65c951005a8905a1edc114a1c1ef.tar.gz chromium_src-fc81ac2d712a65c951005a8905a1edc114a1c1ef.tar.bz2 |
Per Glen, remove the bottom border of maximized windows. I went ahead and also removed support for window frame sizes with unequal widths vs. heights; Windows' UI doesn't actually let you do this and it was making the code more complex than it needed to be.
Review URL: http://codereview.chromium.org/19477
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/constrained_window_impl.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 17 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_non_client_view.cc | 102 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_non_client_view.h | 21 |
4 files changed, 56 insertions, 87 deletions
diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index e7b4c5e..1bc3157 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -375,8 +375,7 @@ int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) { return HTSYSMENU; component = GetHTComponentForFrame(point, kResizeAreaNorthSize, - kResizeAreaSize, kResizeAreaSize, kResizeAreaCornerSize, - window_delegate_->CanResize()); + kResizeAreaSize, kResizeAreaCornerSize, window_delegate_->CanResize()); if (component == HTNOWHERE) { // Finally fall back to the caption. if (bounds().Contains(point)) diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 5197b34..080c044 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -46,6 +46,7 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/views/hwnd_notification_source.h" +#include "chrome/views/non_client_view.h" #include "chrome/views/view.h" #include "chrome/views/window.h" @@ -64,10 +65,8 @@ static const int kToolbarTabStripVerticalOverlap = 3; static const int kTabShadowSize = 2; // The height of the status bubble. static const int kStatusBubbleHeight = 20; -// The overlap of the status bubble with the left edge of the window. -static const int kStatusBubbleHorizontalOverlap = 2; -// The overlap of the status bubble with the bottom edge of the window. -static const int kStatusBubbleVerticalOverlap = 2; +// The overlap of the status bubble with the window frame. +static const int kStatusBubbleOverlap = 1; // An offset distance between certain toolbars and the toolbar that preceded // them in layout. static const int kSeparationLineHeight = 1; @@ -890,7 +889,6 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { // might be a popup window without a TabStrip, or the TabStrip could be // animating. if (IsTabStripVisible() && tabstrip_->CanProcessInputEvents()) { - views::Window* window = frame_->GetWindow(); gfx::Point point_in_view_coords(point); View::ConvertPointToView(GetParent(), this, &point_in_view_coords); @@ -906,7 +904,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { // The top few pixels of the TabStrip are a drop-shadow - as we're pretty // starved of dragable area, let's give it to window dragging (this also // makes sense visually). - if (!window->IsMaximized() && + if (!IsMaximized() && (point_in_view_coords.y() < tabstrip_->y() + kTabShadowSize)) { // We return HTNOWHERE as this is a signal to our containing // NonClientView that it should figure out what the correct hit-test @@ -1172,8 +1170,11 @@ int BrowserView::LayoutDownloadShelf() { } void BrowserView::LayoutStatusBubble(int top) { - gfx::Point origin(-kStatusBubbleHorizontalOverlap, - top - kStatusBubbleHeight + kStatusBubbleVerticalOverlap); + // In restored mode, the client area has a client edge between it and the + // frame. + int overlap = kStatusBubbleOverlap + + (IsMaximized() ? 0 : views::NonClientView::kClientEdgeThickness); + gfx::Point origin(-overlap, top - kStatusBubbleHeight + overlap); ConvertPointToView(this, GetParent(), &origin); status_bubble_->SetBounds(origin.x(), origin.y(), width() / 3, kStatusBubbleHeight); diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc index 89efb7f..d12488c 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.cc +++ b/chrome/browser/views/frame/opaque_non_client_view.cc @@ -290,9 +290,6 @@ namespace { // The frame border is only visible in restored mode and is hardcoded to 4 px on // each side regardless of the system window border size. const int kFrameBorderThickness = 4; -// In maximized mode, where no frame border is otherwise visible, we draw a -// different, 1 px high border along the bottom of the screen. -const int kFrameBorderMaximizedExtraBottomThickness = 1; // Various edges of the frame border have a 1 px shadow along their edges; in a // few cases we shift elements based on this amount for visual appeal. const int kFrameShadowThickness = 1; @@ -460,18 +457,17 @@ OpaqueNonClientView::~OpaqueNonClientView() { gfx::Rect OpaqueNonClientView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) { int top_height = NonClientTopBorderHeight(); - int border_width = NonClientBorderWidth(); - int window_x = std::max(0, client_bounds.x() - border_width); - int window_y = std::max(0, client_bounds.y() - top_height); - int window_w = client_bounds.width() + (2 * border_width); - int window_h = - client_bounds.height() + top_height + NonClientBottomBorderHeight(); - return gfx::Rect(window_x, window_y, window_w, window_h); + int border_thickness = NonClientBorderThickness(); + return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), + std::max(0, client_bounds.y() - top_height), + client_bounds.width() + (2 * border_thickness), + client_bounds.height() + top_height + border_thickness); } gfx::Rect OpaqueNonClientView::GetBoundsForTabStrip(TabStrip* tabstrip) { int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? - (otr_avatar_bounds_.right() + kOTRSideSpacing) : NonClientBorderWidth(); + (otr_avatar_bounds_.right() + kOTRSideSpacing) : + NonClientBorderThickness(); int tabstrip_width = minimize_button_->x() - tabstrip_x - (frame_->IsMaximized() ? kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing); @@ -490,17 +486,18 @@ void OpaqueNonClientView::UpdateWindowIcon() { gfx::Rect OpaqueNonClientView::CalculateClientAreaBounds(int width, int height) const { int top_height = NonClientTopBorderHeight(); - int border_width = NonClientBorderWidth(); - return gfx::Rect(border_width, top_height, - std::max(0, width - (2 * border_width)), - std::max(0, height - top_height - NonClientBottomBorderHeight())); + int border_thickness = NonClientBorderThickness(); + return gfx::Rect(border_thickness, top_height, + std::max(0, width - (2 * border_thickness)), + std::max(0, height - top_height - border_thickness)); } gfx::Size OpaqueNonClientView::CalculateWindowSizeForClientSize( int width, int height) const { - return gfx::Size(width + (2 * NonClientBorderWidth()), - height + NonClientTopBorderHeight() + NonClientBottomBorderHeight()); + int border_thickness = NonClientBorderThickness(); + return gfx::Size(width + (2 * border_thickness), + height + NonClientTopBorderHeight() + border_thickness); } CPoint OpaqueNonClientView::GetSystemMenuPoint() const { @@ -534,9 +531,9 @@ int OpaqueNonClientView::NonClientHitTest(const gfx::Point& point) { window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) return HTSYSMENU; - int window_component = GetHTComponentForFrame(point, - TopResizeHeight(), NonClientBorderWidth(), NonClientBottomBorderHeight(), - kResizeAreaCornerSize, frame_->window_delegate()->CanResize()); + int window_component = GetHTComponentForFrame(point, TopResizeHeight(), + NonClientBorderThickness(), kResizeAreaCornerSize, + frame_->window_delegate()->CanResize()); // Fall back to the caption if no other component matches. return ((window_component == HTNOWHERE) && bounds().Contains(point)) ? HTCAPTION : window_component; @@ -602,8 +599,9 @@ void OpaqueNonClientView::Layout() { gfx::Size OpaqueNonClientView::GetPreferredSize() { gfx::Size prefsize(frame_->client_view()->GetPreferredSize()); - prefsize.Enlarge(2 * NonClientBorderWidth(), - NonClientTopBorderHeight() + NonClientBottomBorderHeight()); + int border_thickness = NonClientBorderThickness(); + prefsize.Enlarge(2 * border_thickness, + NonClientTopBorderHeight() + border_thickness); return prefsize; } @@ -692,23 +690,18 @@ SkBitmap OpaqueNonClientView::GetFavIconForTabIconView() { /////////////////////////////////////////////////////////////////////////////// // OpaqueNonClientView, private: -int OpaqueNonClientView::FrameBorderWidth() const { +int OpaqueNonClientView::FrameBorderThickness() const { return frame_->IsMaximized() ? GetSystemMetrics(SM_CXSIZEFRAME) : kFrameBorderThickness; } -int OpaqueNonClientView::FrameTopBorderHeight() const { - return frame_->IsMaximized() ? - GetSystemMetrics(SM_CYSIZEFRAME) : kFrameBorderThickness; -} - int OpaqueNonClientView::TopResizeHeight() const { - return FrameTopBorderHeight() - kTopResizeAdjust; + return FrameBorderThickness() - kTopResizeAdjust; } -int OpaqueNonClientView::NonClientBorderWidth() const { +int OpaqueNonClientView::NonClientBorderThickness() const { // In maximized mode, we don't show a client edge. - return FrameBorderWidth() + + return FrameBorderThickness() + (frame_->IsMaximized() ? 0 : kClientEdgeThickness); } @@ -718,18 +711,10 @@ int OpaqueNonClientView::NonClientTopBorderHeight() const { return TitleCoordinates(&title_top_spacing, &title_thickness); } - return FrameTopBorderHeight() + + return FrameBorderThickness() + (frame_->IsMaximized() ? 0 : kNonClientRestoredExtraThickness); } -int OpaqueNonClientView::NonClientBottomBorderHeight() const { - // In maximized mode, we don't show a client edge, but the frame border is - // extended slightly. - return frame_->IsMaximized() ? (GetSystemMetrics(SM_CYSIZEFRAME) + - kFrameBorderMaximizedExtraBottomThickness) : - (kFrameBorderThickness + kClientEdgeThickness); -} - int OpaqueNonClientView::BottomEdgeThicknessWithinNonClientHeight() const { if (browser_view_->IsToolbarVisible()) return 0; @@ -739,9 +724,9 @@ int OpaqueNonClientView::BottomEdgeThicknessWithinNonClientHeight() const { int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing, int* title_thickness) const { - int top_height = FrameTopBorderHeight(); - int min_titlebar_height = kTitlebarMinimumHeight + top_height; - *title_top_spacing = top_height + kTitleTopSpacing; + int frame_thickness = FrameBorderThickness(); + int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; + *title_top_spacing = frame_thickness + kTitleTopSpacing; // The bottom spacing should be the same apparent height as the top spacing. // Because the actual top spacing height varies based on the system border // thickness, we calculate this based on the restored top spacing and then @@ -814,7 +799,7 @@ void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) { void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { SkBitmap* top_edge = resources()->GetPartBitmap(FRAME_TOP_EDGE); - canvas->TileImageInt(*top_edge, 0, FrameTopBorderHeight(), width(), + canvas->TileImageInt(*top_edge, 0, FrameBorderThickness(), width(), top_edge->height()); if (!browser_view_->IsToolbarVisible()) { @@ -825,13 +810,6 @@ void OpaqueNonClientView::PaintMaximizedFrameBorder(ChromeCanvas* canvas) { canvas->TileImageInt(app_top_center_, 0, frame_->client_view()->y() - edge_height, width(), edge_height); } - - SkBitmap* bottom_edge = resources()->GetPartBitmap(FRAME_BOTTOM_EDGE); - // We draw the bottom edge of this image. - canvas->TileImageInt(*bottom_edge, 0, - bottom_edge->height() - kFrameBorderMaximizedExtraBottomThickness, 0, - height() - NonClientBottomBorderHeight(), width(), - kFrameBorderMaximizedExtraBottomThickness); } void OpaqueNonClientView::PaintDistributorLogo(ChromeCanvas* canvas) { @@ -936,7 +914,7 @@ void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) { } int client_area_bottom = - std::max(client_area_top, height() - NonClientBottomBorderHeight()); + std::max(client_area_top, height() - NonClientBorderThickness()); int client_area_height = client_area_bottom - client_area_top; SkBitmap* right = resources()->GetPartBitmap(FRAME_CLIENT_EDGE_RIGHT); canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, @@ -967,15 +945,16 @@ void OpaqueNonClientView::LayoutWindowControls() { // Maximized buttons start at window top so that even if their images aren't // drawn flush with the screen edge, they still obey Fitts' Law. bool is_maximized = frame_->IsMaximized(); - int caption_y = is_maximized ? FrameTopBorderHeight() : kCaptionTopSpacing; + int frame_thickness = FrameBorderThickness(); + int caption_y = is_maximized ? frame_thickness : kCaptionTopSpacing; int top_extra_height = is_maximized ? kCaptionTopSpacing : 0; // There should always be the same number of non-shadow pixels visible to the // side of the caption buttons. In maximized mode we extend the rightmost // button to the screen corner to obey Fitts' Law. int right_extra_width = is_maximized ? (kFrameBorderThickness - kFrameShadowThickness) : 0; - int right_spacing = is_maximized ? (GetSystemMetrics(SM_CXSIZEFRAME) + - right_extra_width) : FrameBorderWidth(); + int right_spacing = is_maximized ? + (GetSystemMetrics(SM_CXSIZEFRAME) + right_extra_width) : frame_thickness; gfx::Size close_button_size = close_button_->GetPreferredSize(); close_button_->SetBounds(width() - close_button_size.width() - right_spacing, caption_y, @@ -1021,14 +1000,14 @@ void OpaqueNonClientView::LayoutDistributorLogo() { void OpaqueNonClientView::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 icon_x = FrameBorderWidth() + kIconLeftSpacing; + int frame_thickness = FrameBorderThickness(); + int icon_x = frame_thickness + kIconLeftSpacing; // The usable height of the titlebar area is the total height minus the top // resize border and any edge area we draw at its bottom. int title_top_spacing, title_thickness; int top_height = TitleCoordinates(&title_top_spacing, &title_thickness); - int top_border_height = FrameTopBorderHeight(); - int available_height = top_height - top_border_height - + int available_height = top_height - frame_thickness - BottomEdgeThicknessWithinNonClientHeight(); // The icon takes up a constant fraction of the available height, down to a @@ -1036,7 +1015,7 @@ void OpaqueNonClientView::LayoutTitleBar() { // to make scaled icons look better). It's centered within the usable height. int icon_size = std::max((available_height * kIconHeightFractionNumerator / kIconHeightFractionDenominator) / 2 * 2, kIconMinimumSize); - int icon_y = ((available_height - icon_size) / 2) + top_border_height; + int icon_y = ((available_height - icon_size) / 2) + frame_thickness; // 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; @@ -1070,12 +1049,11 @@ void OpaqueNonClientView::LayoutOTRAvatar() { SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); int top_height = NonClientTopBorderHeight(); int tabstrip_height = browser_view_->GetTabStripHeight() - kOTRBottomSpacing; - int otr_bottom = top_height + tabstrip_height; int otr_height = frame_->IsMaximized() ? (tabstrip_height - kOTRMaximizedTopSpacing) : otr_avatar_icon.height(); - int otr_y = otr_bottom - otr_height; - otr_avatar_bounds_.SetRect(NonClientBorderWidth() + kOTRSideSpacing, otr_y, + otr_avatar_bounds_.SetRect(NonClientBorderThickness() + kOTRSideSpacing, + top_height + tabstrip_height - otr_height, otr_avatar_icon.width(), otr_height); } diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h index a38edf2..4f71cae 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.h +++ b/chrome/browser/views/frame/opaque_non_client_view.h @@ -70,31 +70,22 @@ class OpaqueNonClientView : public views::NonClientView, virtual SkBitmap GetFavIconForTabIconView(); private: - // Returns the width of the border that makes up the window frame left and - // right edges. This does not include any client edge. - int FrameBorderWidth() const; - - // Returns the height of the border that makes up the window frame top edge. - // Because this border is graphically one component with the rest of the - // nonclient top border, this is rarely useful directly. - int FrameTopBorderHeight() const; + // Returns the thickness of the border that makes up the window frame edges. + // This does not include any client edge. + int FrameBorderThickness() const; // Returns the height of the top resize area. This is smaller than the frame // border height in order to increase the window draggable area. int TopResizeHeight() const; - // Returns the width of the entire nonclient left and right borders, including - // both the window frame and any client edge. - int NonClientBorderWidth() const; + // Returns the thickness of the entire nonclient left, right, and bottom + // borders, including both the window frame and any client edge. + int NonClientBorderThickness() const; // Returns the height of the entire nonclient top border, including the window // frame, any title area, and any connected client edge. int NonClientTopBorderHeight() const; - // Returns the height of the entire nonclient bottom border, including both - // the window frame and the client edge. - int NonClientBottomBorderHeight() const; - // For windows without a toolbar, a bottom border, and, in restored mode, a // client edge are drawn at the bottom of the titlebar. When a toolbar is // present, neither of these are drawn, as the toolbar itself will edge the |