summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/frame
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 17:16:02 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-25 17:16:02 +0000
commit55af4046de847a9f423336d10ac4230c45ac2603 (patch)
treec55c8dfe66703fb2a5c0fe7cdb6352afedde84c0 /chrome/browser/views/frame
parentd5c99b1735e08464682837ac5a61d985de2a7b3c (diff)
downloadchromium_src-55af4046de847a9f423336d10ac4230c45ac2603.zip
chromium_src-55af4046de847a9f423336d10ac4230c45ac2603.tar.gz
chromium_src-55af4046de847a9f423336d10ac4230c45ac2603.tar.bz2
Make non-glass popups match new mockup from Glen.
Unfortunately glass popups can't be made to match the mockup unless we want to completely reimplement Windows titlebar drawing, so I'm leaving them pretty much unchanged :( BUG=7569 Review URL: http://codereview.chromium.org/28072 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/frame')
-rw-r--r--chrome/browser/views/frame/aero_glass_non_client_view.cc18
-rw-r--r--chrome/browser/views/frame/browser_view.cc4
-rw-r--r--chrome/browser/views/frame/browser_view.h3
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.cc72
-rw-r--r--chrome/browser/views/frame/opaque_non_client_view.h10
5 files changed, 43 insertions, 64 deletions
diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.cc b/chrome/browser/views/frame/aero_glass_non_client_view.cc
index f787885..6c5589e 100644
--- a/chrome/browser/views/frame/aero_glass_non_client_view.cc
+++ b/chrome/browser/views/frame/aero_glass_non_client_view.cc
@@ -276,21 +276,13 @@ void AeroGlassNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
}
void AeroGlassNonClientView::PaintClientEdge(ChromeCanvas* canvas) {
+ // The client edges start below the toolbar upper corner images regardless
+ // of how tall the toolbar itself is.
int client_area_top =
- frame_->client_view()->y() + browser_view_->GetToolbarBounds().bottom();
- gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
- // The toolbar draws a client edge along its own bottom edge when it's visible
- // and in normal mode. However, it only draws this for the width of the
- // actual client area, leaving a gap at the left and right edges:
- //
- // | Toolbar | <-- part of toolbar
- // ----- (toolbar client edge) ----- <-- gap
- // | Client area | <-- right client edge
- //
- // To address this, we extend the left and right client edges up to fill the
- // gap, by pretending the toolbar is shorter than it really is.
- client_area_top -= kClientEdgeThickness;
+ frame_->client_view()->y() + browser_view_->GetToolbarBounds().y() +
+ resources_->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height();
+ gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
int client_area_bottom =
std::max(client_area_top, height() - NonClientBorderThickness());
int client_area_height = client_area_bottom - client_area_top;
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 7836e7f..7de9e9d 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -310,10 +310,6 @@ bool BrowserView::IsTabStripVisible() const {
return SupportsWindowFeature(FEATURE_TABSTRIP);
}
-bool BrowserView::IsToolbarDisplayModeNormal() const {
- return toolbar_->IsDisplayModeNormal();
-}
-
bool BrowserView::IsOffTheRecord() const {
return browser_->profile()->IsOffTheRecord();
}
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index d8726d8..f1d0b0d 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -99,9 +99,6 @@ class BrowserView : public BrowserWindow,
bool IsToolbarVisible() const;
bool IsTabStripVisible() const;
- // Returns true if the toolbar is displaying its normal set of controls.
- bool IsToolbarDisplayModeNormal() const;
-
// Returns true if the profile associated with this Browser window is
// off the record.
bool IsOffTheRecord() const;
diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc
index bb4da43..d1bb800 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.cc
+++ b/chrome/browser/views/frame/opaque_non_client_view.cc
@@ -61,10 +61,6 @@ enum {
FRAME_NO_TOOLBAR_TOP_CENTER,
FRAME_NO_TOOLBAR_TOP_RIGHT,
- // Popup-mode toolbar edges.
- FRAME_TOOLBAR_POPUP_EDGE_LEFT,
- FRAME_TOOLBAR_POPUP_EDGE_RIGHT,
-
FRAME_PART_BITMAP_COUNT // Must be last.
};
@@ -99,7 +95,6 @@ class ActiveWindowResources : public views::WindowResources {
IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT,
};
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -145,7 +140,6 @@ class InactiveWindowResources : public views::WindowResources {
IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT,
};
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -191,7 +185,6 @@ class OTRActiveWindowResources : public views::WindowResources {
IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT,
};
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -238,7 +231,6 @@ class OTRInactiveWindowResources : public views::WindowResources {
IDR_CONTENT_BOTTOM_RIGHT_CORNER, IDR_CONTENT_BOTTOM_CENTER,
IDR_CONTENT_BOTTOM_LEFT_CORNER, IDR_CONTENT_LEFT_SIDE,
IDR_APP_TOP_LEFT, IDR_APP_TOP_CENTER, IDR_APP_TOP_RIGHT,
- IDR_LOCATIONBG_POPUPMODE_LEFT, IDR_LOCATIONBG_POPUPMODE_RIGHT,
};
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -695,9 +687,14 @@ int OpaqueNonClientView::NonClientTopBorderHeight() const {
0 : kNonClientRestoredExtraThickness);
}
-int OpaqueNonClientView::BottomEdgeThicknessWithinNonClientHeight() const {
+int OpaqueNonClientView::UnavailablePixelsAtBottomOfNonClientHeight() const {
+ // Tricky: When a toolbar is edging the titlebar, it not only draws its own
+ // shadow and client edge, but an extra, light "shadow" pixel as well, which
+ // is treated as available space. Thus the nonclient area actually _fails_ to
+ // include some available pixels, leading to a negative number here.
if (browser_view_->IsToolbarVisible())
- return 0;
+ return -kFrameShadowThickness;
+
return kFrameShadowThickness +
(frame_->IsMaximized() ? 0 : kClientEdgeThickness);
}
@@ -726,7 +723,7 @@ int OpaqueNonClientView::TitleCoordinates(int* title_top_spacing,
*title_thickness = std::max(title_font_.height(),
min_titlebar_height - *title_top_spacing - title_bottom_spacing);
return *title_top_spacing + *title_thickness + title_bottom_spacing +
- BottomEdgeThicknessWithinNonClientHeight();
+ UnavailablePixelsAtBottomOfNonClientHeight();
}
void OpaqueNonClientView::PaintRestoredFrameBorder(ChromeCanvas* canvas) {
@@ -822,28 +819,34 @@ void OpaqueNonClientView::PaintTitleBar(ChromeCanvas* canvas) {
void OpaqueNonClientView::PaintToolbarBackground(ChromeCanvas* canvas) {
if (!browser_view_->IsToolbarVisible())
return;
-
+
gfx::Rect toolbar_bounds(browser_view_->GetToolbarBounds());
gfx::Point toolbar_origin(toolbar_bounds.origin());
View::ConvertPointToView(frame_->client_view(), this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
- bool normal_mode = browser_view_->IsToolbarDisplayModeNormal();
- SkBitmap* toolbar_left = resources()->GetPartBitmap(normal_mode ?
- FRAME_CLIENT_EDGE_TOP_LEFT : FRAME_TOOLBAR_POPUP_EDGE_LEFT);
+ SkBitmap* toolbar_left =
+ resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT);
canvas->DrawBitmapInt(*toolbar_left,
toolbar_bounds.x() - toolbar_left->width(),
toolbar_bounds.y());
- if (normal_mode) {
- SkBitmap* toolbar_center =
- resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP);
- canvas->TileImageInt(*toolbar_center, toolbar_bounds.x(),
- toolbar_bounds.y(), toolbar_bounds.width(), toolbar_center->height());
- }
+ // Gross hack: We split the toolbar image into two pieces, since sometimes
+ // (popup mode) the toolbar isn't tall enough to show the whole image. The
+ // split happens between the top shadow section and the bottom gradient
+ // section so that we never break the gradient.
+ int split_point = kFrameShadowThickness * 2;
+ SkBitmap* toolbar_center =
+ resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP);
+ canvas->TileImageInt(*toolbar_center, 0, 0, toolbar_bounds.x(),
+ toolbar_bounds.y(), toolbar_bounds.width(), split_point);
+ canvas->TileImageInt(*toolbar_center, 0,
+ toolbar_center->height() - toolbar_bounds.height() + split_point,
+ toolbar_bounds.x(), toolbar_bounds.y() + split_point,
+ toolbar_bounds.width(), toolbar_bounds.height() - split_point);
- canvas->DrawBitmapInt(*resources()->GetPartBitmap(normal_mode ?
- FRAME_CLIENT_EDGE_TOP_RIGHT : FRAME_TOOLBAR_POPUP_EDGE_RIGHT),
+ canvas->DrawBitmapInt(
+ *resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_RIGHT),
toolbar_bounds.right(), toolbar_bounds.y());
}
@@ -860,23 +863,14 @@ void OpaqueNonClientView::PaintOTRAvatar(ChromeCanvas* canvas) {
}
void OpaqueNonClientView::PaintRestoredClientEdge(ChromeCanvas* canvas) {
- int client_area_top =
- frame_->client_view()->y() + browser_view_->GetToolbarBounds().bottom();
+ int client_area_top = frame_->client_view()->y();
gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
- if (browser_view_->IsToolbarVisible() &&
- browser_view_->IsToolbarDisplayModeNormal()) {
- // The toolbar draws a client edge along its own bottom edge when it's
- // visible and in normal mode. However, it only draws this for the width of
- // the actual client area, leaving a gap at the left and right edges:
- //
- // | Toolbar | <-- part of toolbar
- // ----- (toolbar client edge) ----- <-- gap
- // | Client area | <-- right client edge
- //
- // To address this, we extend the left and right client edges up to fill the
- // gap, by pretending the toolbar is shorter than it really is.
- client_area_top -= kClientEdgeThickness;
+ if (browser_view_->IsToolbarVisible()) {
+ // The client edges start below the toolbar upper corner images regardless
+ // of how tall the toolbar itself is.
+ client_area_top += browser_view_->GetToolbarBounds().y() +
+ resources()->GetPartBitmap(FRAME_CLIENT_EDGE_TOP_LEFT)->height();
} else {
// The toolbar isn't going to draw a client edge for us, so draw one
// ourselves.
@@ -996,7 +990,7 @@ void OpaqueNonClientView::LayoutTitleBar() {
int title_top_spacing, title_thickness;
int top_height = TitleCoordinates(&title_top_spacing, &title_thickness);
int available_height = top_height - frame_thickness -
- BottomEdgeThicknessWithinNonClientHeight();
+ UnavailablePixelsAtBottomOfNonClientHeight();
// The icon takes up a constant fraction of the available height, down to a
// minimum size, and is always an even number of pixels on a side (presumably
diff --git a/chrome/browser/views/frame/opaque_non_client_view.h b/chrome/browser/views/frame/opaque_non_client_view.h
index 58c5fa1..8caf563 100644
--- a/chrome/browser/views/frame/opaque_non_client_view.h
+++ b/chrome/browser/views/frame/opaque_non_client_view.h
@@ -85,11 +85,11 @@ class OpaqueNonClientView : public views::NonClientView,
// frame, any title area, and any connected client edge.
int NonClientTopBorderHeight() 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
- // titlebar area. This returns the height of any such edge.
- int BottomEdgeThicknessWithinNonClientHeight() const;
+ // The nonclient area at the top of the window may include some "unavailable"
+ // pixels at its bottom: a dark shadow along the bottom of the titlebar and a
+ // client edge. These vary from mode to mode, so this function returns the
+ // number of such pixels the nonclient height includes.
+ int UnavailablePixelsAtBottomOfNonClientHeight() const;
// Calculates multiple values related to title layout. Returns the height of
// the entire titlebar including any connected client edge.