summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 19:37:16 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 19:37:16 +0000
commit7fce6e9a1e243fe31b686ef2123c453f7f210450 (patch)
treecb33cff8a611e8b79e1790cf488ef20d7eecbe9e
parent53af24fa6d03dd0d5d505fd7994b2b5ea2feff9c (diff)
downloadchromium_src-7fce6e9a1e243fe31b686ef2123c453f7f210450.zip
chromium_src-7fce6e9a1e243fe31b686ef2123c453f7f210450.tar.gz
chromium_src-7fce6e9a1e243fe31b686ef2123c453f7f210450.tar.bz2
Clean up some of the frame code a bit.
The only functional change should be that the app panel close button width is now its preferred width, not its preferred width + 4. BUG=none TEST=none Review URL: http://codereview.chromium.org/660128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40407 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/frame/normal_browser_frame_view.cc131
-rw-r--r--chrome/browser/chromeos/frame/normal_browser_frame_view.h17
-rw-r--r--chrome/browser/views/constrained_window_win.cc66
-rwxr-xr-xchrome/browser/views/frame/app_panel_browser_frame_view.cc57
-rwxr-xr-xchrome/browser/views/frame/app_panel_browser_frame_view.h5
-rw-r--r--chrome/browser/views/frame/glass_browser_frame_view.cc16
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.cc140
-rw-r--r--chrome/browser/views/frame/opaque_browser_frame_view.h5
8 files changed, 157 insertions, 280 deletions
diff --git a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
index a2e202c..0b49df2 100644
--- a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
+++ b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
@@ -41,10 +41,10 @@
const int kCustomFrameBackgroundVerticalOffset = 15;
namespace {
+
// The frame border is usually 0 as chromeos has no border. The border
// can be enabled (4px fixed) with the command line option
// "--chromeos-frame" so that one can resize the window on dev machine.
-const int kFrameBorderThickness = 0;
const int kFrameBorderThicknessForDev = 4;
// While resize areas on Windows are normally the same size as the window
@@ -52,22 +52,19 @@ const int kFrameBorderThicknessForDev = 4;
// around with our thinner top grabbable strip. (Incidentally, our side and
// bottom resize areas don't match the frame border thickness either -- they
// span the whole nonclient area, so there's no "dead zone" for the mouse.)
-
const int kTopResizeAdjust = 1;
+
// In the window corners, the resize areas don't actually expand bigger, but the
// 16 px at the end of each edge triggers diagonal resizing.
-
const int kResizeAreaCornerSize = 16;
-// The icon is inset 2 px from the left frame border.
+// The icon is inset 2 px from the left frame border.
const int kIconLeftSpacing = 2;
-// The titlebar has a 2 px 3D edge along the top and bottom.
-
-const int kTitlebarTopAndBottomEdgeThickness = 2;
// The top 1 px of the tabstrip is shadow; in maximized mode we push this off
// the top of the screen so the tabs appear flush against the screen edge.
const int kTabstripTopShadowThickness = 1;
+
} // namespace
namespace chromeos {
@@ -95,12 +92,9 @@ NormalBrowserFrameView::~NormalBrowserFrameView() {
gfx::Rect NormalBrowserFrameView::GetBoundsForTabStrip(
BaseTabStrip* tabstrip) const {
- int x_offset = 0;
- int tabstrip_x = NonClientBorderThickness() + x_offset;
- int tabstrip_width = RightEdge() - tabstrip_x;
-
- return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(),
- std::max(0, tabstrip_width),
+ int border_thickness = FrameBorderThickness();
+ return gfx::Rect(border_thickness, NonClientTopBorderHeight(),
+ std::max(0, width() - (2 * border_thickness)),
tabstrip->GetPreferredHeight());
}
@@ -110,11 +104,11 @@ void NormalBrowserFrameView::UpdateThrobber(bool running) {
gfx::Size NormalBrowserFrameView::GetMinimumSize() {
gfx::Size min_size(browser_view_->GetMinimumSize());
- int border_thickness = NonClientBorderThickness();
+ int border_thickness = FrameBorderThickness();
min_size.Enlarge(2 * border_thickness,
NonClientTopBorderHeight() + border_thickness);
- int min_titlebar_width = (2 * FrameBorderThickness()) + kIconLeftSpacing;
+ int min_titlebar_width = (2 * border_thickness) + kIconLeftSpacing;
min_size.set_width(std::max(min_size.width(), min_titlebar_width));
return min_size;
}
@@ -133,7 +127,7 @@ bool NormalBrowserFrameView::AlwaysUseNativeFrame() const {
gfx::Rect NormalBrowserFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
int top_height = NonClientTopBorderHeight();
- int border_thickness = NonClientBorderThickness();
+ int border_thickness = FrameBorderThickness();
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),
@@ -147,8 +141,10 @@ int NormalBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
if (frame_component != HTNOWHERE)
return frame_component;
- int window_component = GetHTComponentForFrame(point, TopResizeHeight(),
- NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
+ int border_thickness = FrameBorderThickness();
+ int window_component = GetHTComponentForFrame(point,
+ std::max(0, border_thickness - kTopResizeAdjust), border_thickness,
+ kResizeAreaCornerSize, kResizeAreaCornerSize,
frame_->GetWindow()->GetDelegate()->CanResize());
// Fall back to the caption if no other component matches.
return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
@@ -180,14 +176,17 @@ void NormalBrowserFrameView::Paint(gfx::Canvas* canvas) {
}
void NormalBrowserFrameView::Layout() {
- LayoutClientView();
+ int top_height = NonClientTopBorderHeight();
+ int border_thickness = FrameBorderThickness();
+ client_view_bounds_ = gfx::Rect(border_thickness, top_height,
+ std::max(0, width() - (2 * border_thickness)),
+ std::max(0, height() - top_height - border_thickness));
}
bool NormalBrowserFrameView::HitTest(const gfx::Point& l) const {
// If the point is outside the bounds of the client area, claim it.
- bool in_nonclient = NonClientFrameView::HitTest(l);
- if (in_nonclient)
- return in_nonclient;
+ if (NonClientFrameView::HitTest(l))
+ return true;
// Otherwise claim it only if it's in a non-tab portion of the tabstrip.
if (l.y() > browser_view_->tabstrip()->bounds().bottom())
@@ -253,27 +252,13 @@ SkBitmap NormalBrowserFrameView::GetFavIconForTabIconView() {
int NormalBrowserFrameView::FrameBorderThickness() const {
static int border_thickness_ =
CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeosFrame) ?
- kFrameBorderThicknessForDev : kFrameBorderThickness;
+ kFrameBorderThicknessForDev : 0;
return border_thickness_;
}
-int NormalBrowserFrameView::TopResizeHeight() const {
- return FrameBorderThickness() - kTopResizeAdjust;
-}
-
-int NormalBrowserFrameView::NonClientBorderThickness() const {
- return FrameBorderThickness();
-}
-
int NormalBrowserFrameView::NonClientTopBorderHeight() const {
- if (browser_view_->IsTabStripVisible())
- return FrameBorderThickness() - kTabstripTopShadowThickness;
-
- return FrameBorderThickness();
-}
-
-int NormalBrowserFrameView::RightEdge() const {
- return width() - FrameBorderThickness();
+ return std::max(0, FrameBorderThickness() -
+ (browser_view_->IsTabStripVisible() ? kTabstripTopShadowThickness : 0));
}
void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
@@ -286,14 +271,11 @@ void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Never theme app and popup windows.
if (!browser_view_->IsBrowserTypeNormal()) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- if (ShouldPaintAsActive())
- theme_frame = rb.GetBitmapNamed(IDR_FRAME);
- else
- theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
+ theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_FRAME : IDR_FRAME_INACTIVE);
} else if (!browser_view_->IsOffTheRecord()) {
- theme_frame = ShouldPaintAsActive() ?
- tp->GetBitmapNamed(IDR_THEME_FRAME) :
- tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
+ theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE);
// TODO(oshima): gtk based CHROMEOS is using non custom frame
// mode which does this adjustment. This should be removed
// once it's fully migrated to views. -1 is due to the layout
@@ -301,9 +283,8 @@ void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// See http://crbug.com/28580.
y = -kCustomFrameBackgroundVerticalOffset - 1;
} else {
- theme_frame = ShouldPaintAsActive() ?
- tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO) :
- tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE);
+ theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME_INCOGNITO: IDR_THEME_FRAME_INCOGNITO_INACTIVE);
y = -kCustomFrameBackgroundVerticalOffset - 1;
}
// Draw the theme frame.
@@ -312,9 +293,8 @@ void NormalBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Draw the theme frame overlay
if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
browser_view_->IsBrowserTypeNormal()) {
- SkBitmap* theme_overlay = ShouldPaintAsActive() ?
- tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY) :
- tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY_INACTIVE);
+ SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
canvas->DrawBitmapInt(*theme_overlay, 0, 0);
}
@@ -344,32 +324,32 @@ void NormalBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
- SkColor theme_toolbar_color =
- tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
- canvas->FillRectInt(theme_toolbar_color,
- toolbar_bounds.x(), toolbar_bounds.y() + 2,
- toolbar_bounds.width(), toolbar_bounds.height() - 2);
-
- int strip_height = browser_view_->GetTabStripHeight();
- SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
-
- canvas->TileImageInt(*theme_toolbar,
- toolbar_bounds.x() - 1, strip_height - 1, // crop src
- toolbar_bounds.x() - 1, toolbar_bounds.y() + 2,
- toolbar_bounds.width() + 2, theme_toolbar->height());
-
- SkBitmap* toolbar_left =
- tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
-
// Gross hack: We split the toolbar images 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;
int bottom_y = toolbar_bounds.y() + split_point;
+ SkBitmap* toolbar_left =
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
int bottom_edge_height =
std::min(toolbar_left->height(), toolbar_bounds.height()) - split_point;
+ SkColor theme_toolbar_color =
+ tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
+ canvas->FillRectInt(theme_toolbar_color, toolbar_bounds.x(), bottom_y,
+ toolbar_bounds.width(), bottom_edge_height);
+
+ int strip_height = browser_view_->GetTabStripHeight();
+ SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
+
+ canvas->TileImageInt(*theme_toolbar,
+ toolbar_bounds.x() - kClientEdgeThickness,
+ strip_height - kFrameShadowThickness,
+ toolbar_bounds.x() - kClientEdgeThickness, bottom_y,
+ toolbar_bounds.width() + (2 * kClientEdgeThickness),
+ theme_toolbar->height());
+
canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
toolbar_bounds.x() - toolbar_left->width(), toolbar_bounds.y(),
toolbar_left->width(), split_point, false);
@@ -398,17 +378,4 @@ void NormalBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
toolbar_bounds.right() - 1, toolbar_bounds.bottom() - 1);
}
-void NormalBrowserFrameView::LayoutClientView() {
- client_view_bounds_ = CalculateClientAreaBounds(width(), height());
-}
-
-gfx::Rect NormalBrowserFrameView::CalculateClientAreaBounds(int width,
- int height) const {
- int top_height = NonClientTopBorderHeight();
- 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));
-}
-
} // namespace chromeos
diff --git a/chrome/browser/chromeos/frame/normal_browser_frame_view.h b/chrome/browser/chromeos/frame/normal_browser_frame_view.h
index b6838ee..27ea85d 100644
--- a/chrome/browser/chromeos/frame/normal_browser_frame_view.h
+++ b/chrome/browser/chromeos/frame/normal_browser_frame_view.h
@@ -67,33 +67,16 @@ class NormalBrowserFrameView : public BrowserNonClientFrameView,
// 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 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 right edge.
- int RightEdge() 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.
void PaintMaximizedFrameBorder(gfx::Canvas* canvas);
void PaintToolbarBackground(gfx::Canvas* canvas);
- // Layout various sub-components of this view.
- void LayoutClientView();
-
- // Returns the bounds of the client area for the specified view size.
- gfx::Rect CalculateClientAreaBounds(int width, int height) const;
-
// The frame that hosts this view.
BrowserFrame* frame_;
diff --git a/chrome/browser/views/constrained_window_win.cc b/chrome/browser/views/constrained_window_win.cc
index ada759b..995cf60 100644
--- a/chrome/browser/views/constrained_window_win.cc
+++ b/chrome/browser/views/constrained_window_win.cc
@@ -208,7 +208,6 @@ class ConstrainedWindowFrameView
// Layout various sub-components of this view.
void LayoutWindowControls();
void LayoutTitleBar();
- void LayoutClientView();
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
@@ -255,15 +254,14 @@ const int kResizeAreaCornerSize = 16;
// The titlebar never shrinks to less than 20 px tall, including the height of
// the frame border and client edge.
const int kTitlebarMinimumHeight = 20;
-// The icon is inset 2 px from the left frame border.
-const int kIconLeftSpacing = 2;
+// The title text starts 2 px from the right edge of the left frame border.
+const int kTitleLeftSpacing = 2;
// The title text starts 2 px below the bottom of the top frame border.
const int kTitleTopSpacing = 2;
// There is a 5 px gap between the title text and the caption buttons.
const int kTitleCaptionSpacing = 5;
// The caption buttons are always drawn 1 px down from the visible top of the
-// window (the true top in restored mode, or the top of the screen in maximized
-// mode).
+// window.
const int kCaptionTopSpacing = 1;
const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0);
@@ -379,7 +377,7 @@ void ConstrainedWindowFrameView::Paint(gfx::Canvas* canvas) {
void ConstrainedWindowFrameView::Layout() {
LayoutWindowControls();
LayoutTitleBar();
- LayoutClientView();
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height());
}
void ConstrainedWindowFrameView::ThemeChanged() {
@@ -445,13 +443,12 @@ void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) {
// Fill with the frame color first so we have a constant background for
// areas not covered by the theme image.
canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height());
- // Now fill down the sides
- canvas->FillRectInt(frame_color,
- 0, theme_frame->height(),
- left_edge->width(), height() - theme_frame->height());
- canvas->FillRectInt(frame_color,
- width() - right_edge->width(), theme_frame->height(),
- right_edge->width(), height() - theme_frame->height());
+ // Now fill down the sides.
+ canvas->FillRectInt(frame_color, 0, theme_frame->height(), left_edge->width(),
+ height() - theme_frame->height());
+ canvas->FillRectInt(frame_color, width() - right_edge->width(),
+ theme_frame->height(), right_edge->width(),
+ height() - theme_frame->height());
// Now fill the bottom area.
canvas->FillRectInt(frame_color,
left_edge->width(), height() - bottom_edge->height(),
@@ -470,19 +467,17 @@ void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) {
// Right.
canvas->TileImageInt(*right_edge, width() - right_edge->width(),
- top_right_corner->height(), right_edge->width(),
- height() - top_right_corner->height() -
- bottom_right_corner->height());
+ top_right_corner->height(), right_edge->width(),
+ height() - top_right_corner->height() - bottom_right_corner->height());
// Bottom.
canvas->DrawBitmapInt(*bottom_right_corner,
width() - bottom_right_corner->width(),
height() - bottom_right_corner->height());
canvas->TileImageInt(*bottom_edge, bottom_left_corner->width(),
- height() - bottom_edge->height(),
- width() - bottom_left_corner->width() -
- bottom_right_corner->width(),
- bottom_edge->height());
+ height() - bottom_edge->height(),
+ width() - bottom_left_corner->width() - bottom_right_corner->width(),
+ bottom_edge->height());
canvas->DrawBitmapInt(*bottom_left_corner, 0,
height() - bottom_left_corner->height());
@@ -516,14 +511,14 @@ void ConstrainedWindowFrameView::PaintClientEdge(gfx::Canvas* canvas) {
void ConstrainedWindowFrameView::LayoutWindowControls() {
gfx::Size close_button_size = close_button_->GetPreferredSize();
close_button_->SetBounds(
- width() - close_button_size.width() - FrameBorderThickness(),
+ width() - FrameBorderThickness() - close_button_size.width(),
kCaptionTopSpacing, close_button_size.width(),
close_button_size.height());
}
void ConstrainedWindowFrameView::LayoutTitleBar() {
// Size the title.
- int title_x = FrameBorderThickness() + kIconLeftSpacing;
+ int title_x = FrameBorderThickness() + kTitleLeftSpacing;
int title_top_spacing, title_thickness;
TitleCoordinates(&title_top_spacing, &title_thickness);
title_bounds_.SetRect(title_x,
@@ -532,10 +527,6 @@ void ConstrainedWindowFrameView::LayoutTitleBar() {
title_font_->height());
}
-void ConstrainedWindowFrameView::LayoutClientView() {
- client_view_bounds_ = CalculateClientAreaBounds(width(), height());
-}
-
gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds(
int width,
int height) const {
@@ -547,11 +538,9 @@ gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds(
}
void ConstrainedWindowFrameView::InitWindowResources() {
- if (win_util::ShouldUseVistaFrame()) {
- resources_.reset(new VistaWindowResources);
- } else {
- resources_.reset(new XPWindowResources);
- }
+ resources_.reset(win_util::ShouldUseVistaFrame() ?
+ static_cast<views::WindowResources*>(new VistaWindowResources) :
+ new XPWindowResources);
}
// static
@@ -559,7 +548,6 @@ void ConstrainedWindowFrameView::InitClass() {
static bool initialized = false;
if (!initialized) {
title_font_ = new gfx::Font(win_util::GetWindowTitleFont());
-
initialized = true;
}
}
@@ -567,11 +555,6 @@ void ConstrainedWindowFrameView::InitClass() {
////////////////////////////////////////////////////////////////////////////////
// ConstrainedWindowWin, public:
-// The space (in pixels) between minimized pop-ups stacked horizontally and
-// vertically.
-static const int kPopupRepositionOffset = 5;
-static const int kConstrainedWindowEdgePadding = 10;
-
ConstrainedWindowWin::~ConstrainedWindowWin() {
}
@@ -604,13 +587,12 @@ void ConstrainedWindowWin::CloseConstrainedWindow() {
}
std::wstring ConstrainedWindowWin::GetWindowTitle() const {
- std::wstring display_title;
if (GetDelegate())
- display_title = GetDelegate()->GetWindowTitle();
- else
- display_title = L"Untitled";
+ return GetDelegate()->GetWindowTitle();
- return display_title;
+ // TODO(pkasting): Shouldn't this be using a localized string, or else calling
+ // NOTREACHED()?
+ return std::wstring(L"Untitled");
}
const gfx::Rect& ConstrainedWindowWin::GetCurrentBounds() const {
diff --git a/chrome/browser/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/views/frame/app_panel_browser_frame_view.cc
index 0fee915..5e2af07 100755
--- a/chrome/browser/views/frame/app_panel_browser_frame_view.cc
+++ b/chrome/browser/views/frame/app_panel_browser_frame_view.cc
@@ -110,8 +110,7 @@ gfx::Rect AppPanelBrowserFrameView::GetBoundsForTabStrip(
}
void AppPanelBrowserFrameView::UpdateThrobber(bool running) {
- if (window_icon_)
- window_icon_->Update();
+ window_icon_->Update();
}
gfx::Size AppPanelBrowserFrameView::GetMinimumSize() {
@@ -159,6 +158,11 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
int frame_component =
frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
+
+ // See if we're in the sysmenu region.
+ if (window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point))
+ return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
+
if (frame_component != HTNOWHERE)
return frame_component;
@@ -166,9 +170,6 @@ int AppPanelBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (close_button_->IsVisible() &&
close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point))
return HTCLOSE;
- if (window_icon_ &&
- window_icon_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point))
- return HTSYSMENU;
int window_component = GetHTComponentForFrame(point, FrameBorderThickness(),
NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize,
@@ -222,7 +223,7 @@ void AppPanelBrowserFrameView::Paint(gfx::Canvas* canvas) {
void AppPanelBrowserFrameView::Layout() {
LayoutWindowControls();
LayoutTitleBar();
- LayoutClientView();
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height());
}
///////////////////////////////////////////////////////////////////////////////
@@ -295,10 +296,6 @@ int AppPanelBrowserFrameView::TitleCoordinates(int* title_top_spacing_ptr,
UnavailablePixelsAtBottomOfNonClientHeight();
}
-int AppPanelBrowserFrameView::RightEdge() const {
- return width() - FrameBorderThickness();
-}
-
int AppPanelBrowserFrameView::IconSize(int* title_top_spacing_ptr,
int* title_thickness_ptr,
int* available_height_ptr) const {
@@ -322,17 +319,9 @@ void AppPanelBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
// Window frame mode.
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- SkBitmap* frame_image;
- SkColor frame_color;
-
- if (ShouldPaintAsActive()) {
- frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL);
- frame_color = ResourceBundle::frame_color_app_panel;
- } else {
- // TODO: Differentiate inactive
- frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL);
- frame_color = ResourceBundle::frame_color_app_panel;
- }
+ // TODO: Differentiate inactive.
+ SkBitmap* frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL);
+ SkColor frame_color = ResourceBundle::frame_color_app_panel;
SkBitmap* top_left_corner = rb.GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER);
SkBitmap* top_right_corner =
@@ -449,26 +438,20 @@ void AppPanelBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
// Draw the toolbar color to fill in the edges.
canvas->DrawRectInt(ResourceBundle::toolbar_color,
- client_area_bounds.x() - 1, client_area_top - 1,
- client_area_bounds.width() + 1, client_area_bottom - client_area_top + 1);
+ client_area_bounds.x() - kClientEdgeThickness,
+ client_area_top - kClientEdgeThickness,
+ client_area_bounds.width() + kClientEdgeThickness,
+ client_area_bottom - client_area_top + kClientEdgeThickness);
}
void AppPanelBrowserFrameView::LayoutWindowControls() {
close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
views::ImageButton::ALIGN_BOTTOM);
- // 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.
- int caption_y = kFrameShadowThickness;
- // 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 = kCloseButtonHorzSpacing;
gfx::Size close_button_size = close_button_->GetPreferredSize();
- close_button_->SetBounds(
- RightEdge() - close_button_size.width() - right_extra_width,
- caption_y + kCloseButtonVertSpacing,
- close_button_size.width() + right_extra_width,
- close_button_size.height());
+ close_button_->SetBounds(width() - FrameBorderThickness() -
+ kCloseButtonHorzSpacing - close_button_size.width(),
+ kFrameShadowThickness + kCloseButtonVertSpacing,
+ close_button_size.width(), close_button_size.height());
}
void AppPanelBrowserFrameView::LayoutTitleBar() {
@@ -502,10 +485,6 @@ void AppPanelBrowserFrameView::LayoutTitleBar() {
title_font_height);
}
-void AppPanelBrowserFrameView::LayoutClientView() {
- client_view_bounds_ = CalculateClientAreaBounds(width(), height());
-}
-
gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width,
int height) const {
int top_height = NonClientTopBorderHeight();
diff --git a/chrome/browser/views/frame/app_panel_browser_frame_view.h b/chrome/browser/views/frame/app_panel_browser_frame_view.h
index 5530806..3c5fa4e 100755
--- a/chrome/browser/views/frame/app_panel_browser_frame_view.h
+++ b/chrome/browser/views/frame/app_panel_browser_frame_view.h
@@ -84,10 +84,6 @@ class AppPanelBrowserFrameView : public BrowserNonClientFrameView,
int TitleCoordinates(int* title_top_spacing_ptr,
int* title_thickness_ptr) const;
- // Returns the right edge. This is the end the close button starts at (if a
- // close button is shown).
- int RightEdge() const;
-
// Calculates multiple values related to icon layout. Returns the size of the
// icon (along one edge).
int IconSize(int* title_top_spacing_ptr,
@@ -105,7 +101,6 @@ class AppPanelBrowserFrameView : public BrowserNonClientFrameView,
// Layout various sub-components of this view.
void LayoutWindowControls();
void LayoutTitleBar();
- void LayoutClientView();
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;
diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc
index 0d82821..a2d219b 100644
--- a/chrome/browser/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/views/frame/glass_browser_frame_view.cc
@@ -159,19 +159,17 @@ int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point))
return HTNOWHERE;
+ int frame_component =
+ frame_->GetWindow()->GetClientView()->NonClientHitTest(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 nonclient_border_thickness = NonClientBorderThickness();
- gfx::Rect sysmenu_rect(nonclient_border_thickness,
- GetSystemMetrics(SM_CXSIZEFRAME),
- GetSystemMetrics(SM_CXSMICON),
- GetSystemMetrics(SM_CYSMICON));
- bool in_sysmenu = sysmenu_rect.Contains(point);
-
- int frame_component =
- frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
- if (in_sysmenu)
+ if (gfx::Rect(nonclient_border_thickness, GetSystemMetrics(SM_CXSIZEFRAME),
+ GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON)).Contains(point))
return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
+
if (frame_component != HTNOWHERE)
return frame_component;
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc
index 1acb462..c859c7f 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc
@@ -273,6 +273,9 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (!bounds().Contains(point))
return HTNOWHERE;
+ int frame_component =
+ frame_->GetWindow()->GetClientView()->NonClientHitTest(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.
gfx::Rect sysmenu_rect(IconBounds());
@@ -281,12 +284,9 @@ int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
if (frame_->GetWindow()->IsMaximized())
sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom());
sysmenu_rect.set_x(MirroredLeftPointForRect(sysmenu_rect));
- bool in_sysmenu = sysmenu_rect.Contains(point);
-
- int frame_component =
- frame_->GetWindow()->GetClientView()->NonClientHitTest(point);
- if (in_sysmenu)
+ if (sysmenu_rect.Contains(point))
return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
+
if (frame_component != HTNOWHERE)
return frame_component;
@@ -374,7 +374,7 @@ void OpaqueBrowserFrameView::Layout() {
LayoutDistributorLogo();
LayoutTitleBar();
LayoutOTRAvatar();
- LayoutClientView();
+ client_view_bounds_ = CalculateClientAreaBounds(width(), height());
}
bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const {
@@ -510,10 +510,6 @@ int OpaqueBrowserFrameView::TitlebarBottomThickness() const {
(frame_->GetWindow()->IsMaximized() ? 0 : kClientEdgeThickness);
}
-int OpaqueBrowserFrameView::RightEdge() const {
- return width() - FrameBorderThickness();
-}
-
int OpaqueBrowserFrameView::IconSize() const {
#if defined(OS_WIN)
// This metric scales up if either the titlebar height or the titlebar font
@@ -585,7 +581,7 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
SkBitmap* bottom_edge = tp->GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER);
- // Window frame mode and color
+ // Window frame mode and color.
SkBitmap* theme_frame;
SkColor frame_color;
@@ -615,32 +611,29 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INACTIVE);
}
+ } else if (ShouldPaintAsActive()) {
+ theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO);
+ frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO);
} else {
- if (ShouldPaintAsActive()) {
- theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO);
- frame_color = tp->GetColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO);
- } else {
- theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE);
- frame_color = tp->GetColor(
- BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE);
- }
+ theme_frame = tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE);
+ frame_color = tp->GetColor(
+ BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE);
}
// Fill with the frame color first so we have a constant background for
// areas not covered by the theme image.
canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height());
- // Now fill down the sides
- canvas->FillRectInt(frame_color,
- 0, theme_frame->height(),
- left_edge->width(), height() - theme_frame->height());
- canvas->FillRectInt(frame_color,
- width() - right_edge->width(), theme_frame->height(),
- right_edge->width(), height() - theme_frame->height());
+ // Now fill down the sides.
+ canvas->FillRectInt(frame_color, 0, theme_frame->height(), left_edge->width(),
+ height() - theme_frame->height());
+ canvas->FillRectInt(frame_color, width() - right_edge->width(),
+ theme_frame->height(), right_edge->width(),
+ height() - theme_frame->height());
// Now fill the bottom area.
- canvas->FillRectInt(frame_color,
- left_edge->width(), height() - bottom_edge->height(),
- width() - left_edge->width() - right_edge->width(),
- bottom_edge->height());
+ canvas->FillRectInt(frame_color, left_edge->width(),
+ height() - bottom_edge->height(),
+ width() - left_edge->width() - right_edge->width(),
+ bottom_edge->height());
// Draw the theme frame.
canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height());
@@ -649,12 +642,8 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
browser_view_->IsBrowserTypeNormal() &&
!browser_view_->IsOffTheRecord()) {
- SkBitmap* theme_overlay;
- if (ShouldPaintAsActive())
- theme_overlay = tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY);
- else
- theme_overlay = tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY_INACTIVE);
- canvas->DrawBitmapInt(*theme_overlay, 0, 0);
+ canvas->DrawBitmapInt(*tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE), 0, 0);
}
// Top.
@@ -684,10 +673,9 @@ void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
width() - bottom_right_corner->width(),
height() - bottom_right_corner->height());
canvas->TileImageInt(*bottom_edge, bottom_left_corner->width(),
- height() - bottom_edge->height(),
- width() - bottom_left_corner->width() -
- bottom_right_corner->width(),
- bottom_edge->height());
+ height() - bottom_edge->height(),
+ width() - bottom_left_corner->width() - bottom_right_corner->width(),
+ bottom_edge->height());
canvas->DrawBitmapInt(*bottom_left_corner, 0,
height() - bottom_left_corner->height());
@@ -707,14 +695,11 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Never theme app and popup windows.
if (!browser_view_->IsBrowserTypeNormal()) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- if (ShouldPaintAsActive())
- theme_frame = rb.GetBitmapNamed(IDR_FRAME);
- else
- theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
+ theme_frame = rb.GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_FRAME : IDR_FRAME_INACTIVE);
} else if (!browser_view_->IsOffTheRecord()) {
- theme_frame = ShouldPaintAsActive() ?
- tp->GetBitmapNamed(IDR_THEME_FRAME) :
- tp->GetBitmapNamed(IDR_THEME_FRAME_INACTIVE);
+ theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME : IDR_THEME_FRAME_INACTIVE);
#if defined(OS_CHROMEOS)
// TODO:(oshima): gtk based CHROMEOS is using non custom frame
// mode which does this adjustment. This should be removed
@@ -724,9 +709,8 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
y = -kCustomFrameBackgroundVerticalOffset - 1;
#endif
} else {
- theme_frame = ShouldPaintAsActive() ?
- tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO) :
- tp->GetBitmapNamed(IDR_THEME_FRAME_INCOGNITO_INACTIVE);
+ theme_frame = tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME_INCOGNITO: IDR_THEME_FRAME_INCOGNITO_INACTIVE);
#if defined(OS_CHROMEOS)
y = -kCustomFrameBackgroundVerticalOffset - 1;
#endif
@@ -737,9 +721,8 @@ void OpaqueBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
// Draw the theme frame overlay
if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
browser_view_->IsBrowserTypeNormal()) {
- SkBitmap* theme_overlay = ShouldPaintAsActive() ?
- tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY) :
- tp->GetBitmapNamed(IDR_THEME_FRAME_OVERLAY_INACTIVE);
+ SkBitmap* theme_overlay = tp->GetBitmapNamed(ShouldPaintAsActive() ?
+ IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
canvas->DrawBitmapInt(*theme_overlay, 0, 0);
}
@@ -786,32 +769,32 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
this, &toolbar_origin);
toolbar_bounds.set_origin(toolbar_origin);
- SkColor theme_toolbar_color =
- tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
- canvas->FillRectInt(theme_toolbar_color,
- toolbar_bounds.x(), toolbar_bounds.y() + 2,
- toolbar_bounds.width(), toolbar_bounds.height() - 2);
-
- int strip_height = browser_view_->GetTabStripHeight();
- SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
-
- canvas->TileImageInt(*theme_toolbar,
- toolbar_bounds.x() - 1, strip_height - 1, // crop src
- toolbar_bounds.x() - 1, toolbar_bounds.y() + 2,
- toolbar_bounds.width() + 2, theme_toolbar->height());
-
- SkBitmap* toolbar_left =
- tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
-
// Gross hack: We split the toolbar images 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;
int bottom_y = toolbar_bounds.y() + split_point;
+ SkBitmap* toolbar_left =
+ tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER);
int bottom_edge_height =
std::min(toolbar_left->height(), toolbar_bounds.height()) - split_point;
+ SkColor theme_toolbar_color =
+ tp->GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
+ canvas->FillRectInt(theme_toolbar_color, toolbar_bounds.x(), bottom_y,
+ toolbar_bounds.width(), bottom_edge_height);
+
+ int strip_height = browser_view_->GetTabStripHeight();
+ SkBitmap* theme_toolbar = tp->GetBitmapNamed(IDR_THEME_TOOLBAR);
+
+ canvas->TileImageInt(*theme_toolbar,
+ toolbar_bounds.x() - kClientEdgeThickness,
+ strip_height - kFrameShadowThickness,
+ toolbar_bounds.x() - kClientEdgeThickness, bottom_y,
+ toolbar_bounds.width() + (2 * kClientEdgeThickness),
+ theme_toolbar->height());
+
canvas->DrawBitmapInt(*toolbar_left, 0, 0, toolbar_left->width(), split_point,
toolbar_bounds.x() - toolbar_left->width(), toolbar_bounds.y(),
toolbar_left->width(), split_point, false);
@@ -836,8 +819,9 @@ void OpaqueBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
// Draw the content/toolbar separator.
canvas->DrawLineInt(ResourceBundle::toolbar_separator_color,
- toolbar_bounds.x(), toolbar_bounds.bottom() - 1,
- toolbar_bounds.right() - 1, toolbar_bounds.bottom() - 1);
+ toolbar_bounds.x(), toolbar_bounds.bottom() - kClientEdgeThickness,
+ toolbar_bounds.right() - kClientEdgeThickness,
+ toolbar_bounds.bottom() - kClientEdgeThickness);
}
void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
@@ -937,9 +921,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
// of the edge of the view, so that when we remove the spacing it lines
// up with the edge.
minimize_button_->SetBounds(
- RightEdge() + kNewTabCaptionMaximizedSpacing,
- 0,
- 0,
+ width() - FrameBorderThickness() + kNewTabCaptionMaximizedSpacing, 0, 0,
0);
return;
}
@@ -953,8 +935,8 @@ void OpaqueBrowserFrameView::LayoutWindowControls() {
int right_extra_width = is_maximized ?
(kFrameBorderThickness - kFrameShadowThickness) : 0;
gfx::Size close_button_size = close_button_->GetPreferredSize();
- close_button_->SetBounds(RightEdge() - close_button_size.width() -
- right_extra_width, caption_y,
+ close_button_->SetBounds(width() - FrameBorderThickness() -
+ right_extra_width - close_button_size.width(), caption_y,
close_button_size.width() + right_extra_width,
close_button_size.height());
@@ -1045,10 +1027,6 @@ void OpaqueBrowserFrameView::LayoutOTRAvatar() {
preferred_size.width(), otr_height);
}
-void OpaqueBrowserFrameView::LayoutClientView() {
- client_view_bounds_ = CalculateClientAreaBounds(width(), height());
-}
-
gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
int height) const {
int top_height = NonClientTopBorderHeight();
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h
index 6196da9..5a41470 100644
--- a/chrome/browser/views/frame/opaque_browser_frame_view.h
+++ b/chrome/browser/views/frame/opaque_browser_frame_view.h
@@ -88,10 +88,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
// bottom of the titlebar.
int TitlebarBottomThickness() const;
- // Returns the right edge. This is the end the close button starts at (if a
- // close button is shown).
- int RightEdge() const;
-
// Returns the size of the titlebar icon. This is used even when the icon is
// not shown, e.g. to set the titlebar height.
int IconSize() const;
@@ -114,7 +110,6 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView,
void LayoutDistributorLogo();
void LayoutTitleBar();
void LayoutOTRAvatar();
- void LayoutClientView();
// Returns the bounds of the client area for the specified view size.
gfx::Rect CalculateClientAreaBounds(int width, int height) const;