| Index: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
|
| diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
|
| index e43a5179e70e2a0afc0807a4d03722fc6899c9c2..7f854d766a71099aebb13becf75252df8c698c60 100644
|
| --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
|
| +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
|
| @@ -17,6 +17,7 @@
|
| #include "chrome/browser/ui/views/avatar_menu_button.h"
|
| #include "chrome/browser/ui/views/frame/browser_frame.h"
|
| #include "chrome/browser/ui/views/frame/browser_view.h"
|
| +#include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h"
|
| #include "chrome/browser/ui/views/tab_icon_view.h"
|
| #include "chrome/browser/ui/views/tabs/tab_strip.h"
|
| #include "chrome/browser/ui/views/toolbar_view.h"
|
| @@ -46,66 +47,30 @@
|
| #include "ui/views/window/frame_background.h"
|
| #include "ui/views/window/window_shape.h"
|
|
|
| -#if defined(OS_WIN)
|
| -#include "win8/util/win8_util.h"
|
| -#endif // OS_WIN
|
| -
|
| using content::WebContents;
|
|
|
| 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;
|
| -// Besides the frame border, there's another 9 px of empty space atop the
|
| -// window in restored mode, to use to drag the window around.
|
| -const int kNonClientRestoredExtraThickness = 9;
|
| // While resize areas on Windows are normally the same size as the window
|
| // borders, our top area is shrunk by 1 px to make it easier to move the window
|
| // 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 titlebar never shrinks too short to show the caption button plus some
|
| -// padding below it.
|
| -const int kCaptionButtonHeightWithPadding = 19;
|
| +
|
| // The content left/right images have a shadow built into them.
|
| const int kContentEdgeShadowThickness = 2;
|
| -// The titlebar has a 2 px 3D edge along the top and bottom.
|
| -const int kTitlebarTopAndBottomEdgeThickness = 2;
|
| -// The icon is inset 2 px from the left frame border.
|
| -const int kIconLeftSpacing = 2;
|
| +
|
| // The icon never shrinks below 16 px on a side.
|
| const int kIconMinimumSize = 16;
|
| -// There is a 4 px gap between the icon and the title text.
|
| -const int kIconTitleSpacing = 4;
|
| -// There is a 5 px gap between the title text and the caption buttons.
|
| -const int kTitleLogoSpacing = 5;
|
| -// The avatar ends 2 px above the bottom of the tabstrip (which, given the
|
| -// way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
|
| -// user).
|
| -const int kAvatarBottomSpacing = 2;
|
| -// Space between the frame border and the left edge of the avatar.
|
| -const int kAvatarLeftSpacing = 2;
|
| -// Space between the right edge of the avatar and the tabstrip.
|
| -const int kAvatarRightSpacing = -2;
|
| +
|
| // The top 3 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 = 3;
|
| -// In restored mode, the New Tab button isn't at the same height as the caption
|
| -// buttons, but the space will look cluttered if it actually slides under them,
|
| -// so we stop it when the gap between the two is down to 5 px.
|
| -const int kNewTabCaptionRestoredSpacing = 5;
|
| -// In maximized mode, where the New Tab button and the caption buttons are at
|
| -// similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid
|
| -// looking too cluttered.
|
| -const int kNewTabCaptionMaximizedSpacing = 16;
|
| -// How far to indent the tabstrip from the left side of the screen when there
|
| -// is no avatar icon.
|
| -const int kTabStripIndent = -6;
|
|
|
| // Converts |bounds| from |src|'s coordinate system to |dst|, and checks if
|
| // |pt| is contained within.
|
| @@ -119,13 +84,6 @@ bool ConvertedContainsCheck(gfx::Rect bounds, const views::View* src,
|
| return bounds.Contains(pt);
|
| }
|
|
|
| -bool ShouldAddDefaultCaptionButtons() {
|
| -#if defined(OS_WIN)
|
| - return !win8::IsSingleWindowMetroMode();
|
| -#endif // OS_WIN
|
| - return true;
|
| -}
|
| -
|
| } // namespace
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -134,6 +92,7 @@ bool ShouldAddDefaultCaptionButtons() {
|
| OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
|
| BrowserView* browser_view)
|
| : BrowserNonClientFrameView(frame, browser_view),
|
| + layout_(new OpaqueBrowserFrameViewLayout(this)),
|
| minimize_button_(NULL),
|
| maximize_button_(NULL),
|
| restore_button_(NULL),
|
| @@ -141,33 +100,40 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
|
| window_icon_(NULL),
|
| window_title_(NULL),
|
| frame_background_(new views::FrameBackground()) {
|
| - if (ShouldAddDefaultCaptionButtons()) {
|
| + SetLayoutManager(layout_);
|
| +
|
| + if (OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons()) {
|
| minimize_button_ = InitWindowCaptionButton(IDR_MINIMIZE,
|
| IDR_MINIMIZE_H,
|
| IDR_MINIMIZE_P,
|
| IDR_MINIMIZE_BUTTON_MASK,
|
| - IDS_ACCNAME_MINIMIZE);
|
| + IDS_ACCNAME_MINIMIZE,
|
| + VIEW_ID_MINIMIZE_BUTTON);
|
| maximize_button_ = InitWindowCaptionButton(IDR_MAXIMIZE,
|
| IDR_MAXIMIZE_H,
|
| IDR_MAXIMIZE_P,
|
| IDR_MAXIMIZE_BUTTON_MASK,
|
| - IDS_ACCNAME_MAXIMIZE);
|
| + IDS_ACCNAME_MAXIMIZE,
|
| + VIEW_ID_MAXIMIZE_BUTTON);
|
| restore_button_ = InitWindowCaptionButton(IDR_RESTORE,
|
| IDR_RESTORE_H,
|
| IDR_RESTORE_P,
|
| IDR_RESTORE_BUTTON_MASK,
|
| - IDS_ACCNAME_RESTORE);
|
| + IDS_ACCNAME_RESTORE,
|
| + VIEW_ID_RESTORE_BUTTON);
|
| close_button_ = InitWindowCaptionButton(IDR_CLOSE,
|
| IDR_CLOSE_H,
|
| IDR_CLOSE_P,
|
| IDR_CLOSE_BUTTON_MASK,
|
| - IDS_ACCNAME_CLOSE);
|
| + IDS_ACCNAME_CLOSE,
|
| + VIEW_ID_CLOSE_BUTTON);
|
| }
|
|
|
| // Initializing the TabIconView is expensive, so only do it if we need to.
|
| if (browser_view->ShouldShowWindowIcon()) {
|
| window_icon_ = new TabIconView(this);
|
| window_icon_->set_is_light(true);
|
| + window_icon_->set_id(VIEW_ID_WINDOW_ICON);
|
| AddChildView(window_icon_);
|
| window_icon_->Update();
|
| }
|
| @@ -180,6 +146,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame,
|
| // gfx::Canvas::NO_SUBPIXEL_RENDERING flag and avoid some visual artifacts.
|
| window_title_->SetBackgroundColor(0x00000000);
|
| window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| + window_title_->set_id(VIEW_ID_WINDOW_TITLE);
|
| AddChildView(window_title_);
|
|
|
| UpdateAvatarInfo();
|
| @@ -193,40 +160,6 @@ OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| -// OpaqueBrowserFrameView, protected:
|
| -
|
| -int OpaqueBrowserFrameView::GetReservedHeight() const {
|
| - return 0;
|
| -}
|
| -
|
| -gfx::Rect OpaqueBrowserFrameView::GetBoundsForReservedArea() const {
|
| - gfx::Rect client_view_bounds = CalculateClientAreaBounds(width(), height());
|
| - return gfx::Rect(
|
| - client_view_bounds.x(),
|
| - client_view_bounds.y() + client_view_bounds.height(),
|
| - client_view_bounds.width(),
|
| - GetReservedHeight());
|
| -}
|
| -
|
| -int OpaqueBrowserFrameView::NonClientTopBorderHeight(
|
| - bool restored) const {
|
| - views::WidgetDelegate* delegate = frame()->widget_delegate();
|
| - // |delegate| may be NULL if called from callback of InputMethodChanged while
|
| - // a window is being destroyed.
|
| - // See more discussion at http://crosbug.com/8958
|
| - if (delegate && delegate->ShouldShowWindowTitle()) {
|
| - return std::max(FrameBorderThickness(restored) + IconSize(),
|
| - CaptionButtonY(restored) + kCaptionButtonHeightWithPadding) +
|
| - TitlebarBottomThickness(restored);
|
| - }
|
| -
|
| - return FrameBorderThickness(restored) -
|
| - ((browser_view()->IsTabStripVisible() &&
|
| - !restored && !frame()->ShouldLeaveOffsetNearTopBorder())
|
| - ? kTabstripTopShadowThickness : 0);
|
| -}
|
| -
|
| -///////////////////////////////////////////////////////////////////////////////
|
| // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation:
|
|
|
| gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
|
| @@ -234,31 +167,13 @@ gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip(
|
| if (!tabstrip)
|
| return gfx::Rect();
|
|
|
| - gfx::Rect bounds = GetBoundsForTabStripAndAvatarArea(tabstrip);
|
| - int space_left_of_tabstrip = kTabStripIndent;
|
| - if (browser_view()->ShouldShowAvatar()) {
|
| - if (avatar_label() && avatar_label()->bounds().width()) {
|
| - // Space between the right edge of the avatar label and the tabstrip.
|
| - const int kAvatarLabelRightSpacing = -10;
|
| - space_left_of_tabstrip =
|
| - avatar_label()->bounds().right() + kAvatarLabelRightSpacing;
|
| - } else {
|
| - space_left_of_tabstrip =
|
| - kAvatarLeftSpacing + avatar_bounds_.width() + kAvatarRightSpacing;
|
| - }
|
| - }
|
| - bounds.Inset(space_left_of_tabstrip, 0, 0, 0);
|
| - return bounds;
|
| + return layout_->GetBoundsForTabStrip(tabstrip->GetPreferredSize(), width());
|
| }
|
|
|
| BrowserNonClientFrameView::TabStripInsets
|
| OpaqueBrowserFrameView::GetTabStripInsets(bool restored) const {
|
| - int top = NonClientTopBorderHeight(restored) + ((!restored &&
|
| - (!frame()->ShouldLeaveOffsetNearTopBorder() ||
|
| - frame()->IsFullscreen())) ?
|
| - 0 : kNonClientRestoredExtraThickness);
|
| // TODO: include OTR and caption.
|
| - return TabStripInsets(top, 0, 0);
|
| + return TabStripInsets(layout_->GetTabStripInsetsTop(restored), 0, 0);
|
| }
|
|
|
| int OpaqueBrowserFrameView::GetThemeBackgroundXInset() const {
|
| @@ -271,56 +186,19 @@ void OpaqueBrowserFrameView::UpdateThrobber(bool running) {
|
| }
|
|
|
| gfx::Size OpaqueBrowserFrameView::GetMinimumSize() {
|
| - gfx::Size min_size(browser_view()->GetMinimumSize());
|
| - int border_thickness = NonClientBorderThickness();
|
| - min_size.Enlarge(2 * border_thickness,
|
| - NonClientTopBorderHeight(false) + border_thickness);
|
| -
|
| - views::WidgetDelegate* delegate = frame()->widget_delegate();
|
| - int min_titlebar_width = (2 * FrameBorderThickness(false)) +
|
| - kIconLeftSpacing +
|
| - (delegate && delegate->ShouldShowWindowIcon() ?
|
| - (IconSize() + kTitleLogoSpacing) : 0);
|
| -#if !defined(OS_CHROMEOS)
|
| - if (ShouldAddDefaultCaptionButtons()) {
|
| - min_titlebar_width +=
|
| - minimize_button_->GetMinimumSize().width() +
|
| - restore_button_->GetMinimumSize().width() +
|
| - close_button_->GetMinimumSize().width();
|
| - }
|
| -#endif
|
| - min_size.set_width(std::max(min_size.width(), min_titlebar_width));
|
| -
|
| - // Ensure that the minimum width is enough to hold a minimum width tab strip
|
| - // and avatar icon at their usual insets.
|
| - if (browser_view()->IsTabStripVisible()) {
|
| - TabStrip* tabstrip = browser_view()->tabstrip();
|
| - const int min_tabstrip_width = tabstrip->GetMinimumSize().width();
|
| - const int min_tabstrip_area_width =
|
| - width() - GetBoundsForTabStripAndAvatarArea(tabstrip).width() +
|
| - min_tabstrip_width + browser_view()->GetOTRAvatarIcon().width() +
|
| - kAvatarLeftSpacing + kAvatarRightSpacing;
|
| - min_size.set_width(std::max(min_size.width(), min_tabstrip_area_width));
|
| - }
|
| -
|
| - return min_size;
|
| + return layout_->GetMinimumSize(width());
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // OpaqueBrowserFrameView, views::NonClientFrameView implementation:
|
|
|
| gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const {
|
| - return client_view_bounds_;
|
| + return layout_->client_view_bounds();
|
| }
|
|
|
| gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds(
|
| const gfx::Rect& client_bounds) const {
|
| - int top_height = NonClientTopBorderHeight(false);
|
| - 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);
|
| + return layout_->GetWindowBoundsForClientBounds(client_bounds);
|
| }
|
|
|
| int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
|
| @@ -387,7 +265,7 @@ void OpaqueBrowserFrameView::GetWindowMask(const gfx::Size& size,
|
| }
|
|
|
| void OpaqueBrowserFrameView::ResetWindowControls() {
|
| - if (!ShouldAddDefaultCaptionButtons())
|
| + if (!OpaqueBrowserFrameViewLayout::ShouldAddDefaultCaptionButtons())
|
| return;
|
| restore_button_->SetState(views::CustomButton::STATE_NORMAL);
|
| minimize_button_->SetState(views::CustomButton::STATE_NORMAL);
|
| @@ -430,13 +308,6 @@ void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
|
| PaintRestoredClientEdge(canvas);
|
| }
|
|
|
| -void OpaqueBrowserFrameView::Layout() {
|
| - LayoutWindowControls();
|
| - LayoutTitleBar();
|
| - LayoutAvatar();
|
| - client_view_bounds_ = CalculateClientAreaBounds(width(), height());
|
| -}
|
| -
|
| bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
|
| if (!views::View::HitTestRect(rect)) {
|
| // |rect| is outside OpaqueBrowserFrameView's bounds.
|
| @@ -559,6 +430,86 @@ void OpaqueBrowserFrameView::Observe(
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| +// OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation:
|
| +
|
| +bool OpaqueBrowserFrameView::ShouldShowWindowIcon() const {
|
| + views::WidgetDelegate* delegate = frame()->widget_delegate();
|
| + return delegate && delegate->ShouldShowWindowIcon();
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::ShouldShowWindowTitle() const {
|
| + // |delegate| may be NULL if called from callback of InputMethodChanged while
|
| + // a window is being destroyed.
|
| + // See more discussion at http://crosbug.com/8958
|
| + views::WidgetDelegate* delegate = frame()->widget_delegate();
|
| + return delegate && delegate->ShouldShowWindowTitle();
|
| +}
|
| +
|
| +string16 OpaqueBrowserFrameView::GetWindowTitle() const {
|
| + return frame()->widget_delegate()->GetWindowTitle();
|
| +}
|
| +
|
| +int OpaqueBrowserFrameView::GetIconSize() const {
|
| +#if defined(OS_WIN)
|
| + // This metric scales up if either the titlebar height or the titlebar font
|
| + // size are increased.
|
| + return GetSystemMetrics(SM_CYSMICON);
|
| +#else
|
| + return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize);
|
| +#endif
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::ShouldLeaveOffsetNearTopBorder() const {
|
| + return frame()->ShouldLeaveOffsetNearTopBorder();
|
| +}
|
| +
|
| +gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const {
|
| + return browser_view()->GetMinimumSize();
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::ShouldShowAvatar() const {
|
| + return browser_view()->ShouldShowAvatar();
|
| +}
|
| +
|
| +gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const {
|
| + return browser_view()->GetOTRAvatarIcon();
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::IsMaximized() const {
|
| + return frame()->IsMaximized();
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::IsMinimized() const {
|
| + return frame()->IsMinimized();
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::IsFullscreen() const {
|
| + return frame()->IsFullscreen();
|
| +}
|
| +
|
| +bool OpaqueBrowserFrameView::IsTabStripVisible() const {
|
| + return browser_view()->IsTabStripVisible();
|
| +}
|
| +
|
| +int OpaqueBrowserFrameView::GetTabStripHeight() const {
|
| + return browser_view()->GetTabStripHeight();
|
| +}
|
| +
|
| +int OpaqueBrowserFrameView::GetAdditionalReservedSpaceInTabStrip() const {
|
| + // We don't have the sysmenu buttons in Windows 8 metro mode. However there
|
| + // are buttons like the window switcher which are drawn in the non client
|
| + // are in the BrowserView. We need to ensure that the tab strip does not
|
| + // draw on the window switcher button.
|
| + views::View* button = browser_view()->window_switcher_button();
|
| + return button ? button->width() : 0;
|
| +}
|
| +
|
| +gfx::Size OpaqueBrowserFrameView::GetTabstripPreferredSize() const {
|
| + gfx::Size s = browser_view()->tabstrip()->GetPreferredSize();
|
| + return s;
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| // OpaqueBrowserFrameView, private:
|
|
|
| views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton(
|
| @@ -566,7 +517,8 @@ views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton(
|
| int hot_image_id,
|
| int pushed_image_id,
|
| int mask_image_id,
|
| - int accessibility_string_id) {
|
| + int accessibility_string_id,
|
| + ViewID view_id) {
|
| views::ImageButton* button = new views::ImageButton(this);
|
| ui::ThemeProvider* tp = frame()->GetThemeProvider();
|
| button->SetImage(views::CustomButton::STATE_NORMAL,
|
| @@ -583,13 +535,13 @@ views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton(
|
| }
|
| button->SetAccessibleName(
|
| l10n_util::GetStringUTF16(accessibility_string_id));
|
| + button->set_id(view_id);
|
| AddChildView(button);
|
| return button;
|
| }
|
|
|
| int OpaqueBrowserFrameView::FrameBorderThickness(bool restored) const {
|
| - return (!restored && (frame()->IsMaximized() || frame()->IsFullscreen())) ?
|
| - 0 : kFrameBorderThickness;
|
| + return layout_->FrameBorderThickness(restored);
|
| }
|
|
|
| int OpaqueBrowserFrameView::TopResizeHeight() const {
|
| @@ -597,86 +549,11 @@ int OpaqueBrowserFrameView::TopResizeHeight() const {
|
| }
|
|
|
| int OpaqueBrowserFrameView::NonClientBorderThickness() const {
|
| - // When we fill the screen, we don't show a client edge.
|
| - return FrameBorderThickness(false) +
|
| - ((frame()->IsMaximized() || frame()->IsFullscreen()) ?
|
| - 0 : kClientEdgeThickness);
|
| -}
|
| -
|
| -int OpaqueBrowserFrameView::CaptionButtonY(bool restored) const {
|
| - // 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.
|
| - return (!restored && frame()->IsMaximized()) ?
|
| - FrameBorderThickness(false) : kFrameShadowThickness;
|
| -}
|
| -
|
| -int OpaqueBrowserFrameView::TitlebarBottomThickness(bool restored) const {
|
| - return kTitlebarTopAndBottomEdgeThickness +
|
| - ((!restored && frame()->IsMaximized()) ? 0 : kClientEdgeThickness);
|
| -}
|
| -
|
| -int OpaqueBrowserFrameView::IconSize() const {
|
| -#if defined(OS_WIN)
|
| - // This metric scales up if either the titlebar height or the titlebar font
|
| - // size are increased.
|
| - return GetSystemMetrics(SM_CYSMICON);
|
| -#else
|
| - return std::max(BrowserFrame::GetTitleFont().GetHeight(), kIconMinimumSize);
|
| -#endif
|
| + return layout_->NonClientBorderThickness();
|
| }
|
|
|
| gfx::Rect OpaqueBrowserFrameView::IconBounds() const {
|
| - int size = IconSize();
|
| - int frame_thickness = FrameBorderThickness(false);
|
| - int y;
|
| - views::WidgetDelegate* delegate = frame()->widget_delegate();
|
| - if (delegate && (delegate->ShouldShowWindowIcon() ||
|
| - delegate->ShouldShowWindowTitle())) {
|
| - // 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 when the window is restored, instead of
|
| - // calculating the remaining space from below the frame border, we calculate
|
| - // from below the 3D edge.
|
| - int unavailable_px_at_top = frame()->IsMaximized() ?
|
| - frame_thickness : kTitlebarTopAndBottomEdgeThickness;
|
| - // When the icon is shorter than the minimum space we reserve for the
|
| - // caption button, we vertically center it. We want to bias rounding to put
|
| - // extra space above the icon, since the 3D edge (+ client edge, for
|
| - // restored windows) below looks (to the eye) more like additional space
|
| - // than does the 3D edge (or nothing at all, for maximized windows) above;
|
| - // hence the +1.
|
| - y = unavailable_px_at_top + (NonClientTopBorderHeight(false) -
|
| - unavailable_px_at_top - size - TitlebarBottomThickness(false) + 1) / 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);
|
| -}
|
| -
|
| -gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStripAndAvatarArea(
|
| - views::View* tabstrip) const {
|
| - int available_width = width();
|
| - if (minimize_button_) {
|
| - available_width = minimize_button_->x();
|
| - } else if (browser_view()->window_switcher_button()) {
|
| - // We don't have the sysmenu buttons in Windows 8 metro mode. However there
|
| - // are buttons like the window switcher which are drawn in the non client
|
| - // are in the BrowserView. We need to ensure that the tab strip does not
|
| - // draw on the window switcher button.
|
| - available_width -= browser_view()->window_switcher_button()->width();
|
| - }
|
| - const int caption_spacing = frame()->IsMaximized() ?
|
| - kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing;
|
| - const int tabstrip_x = NonClientBorderThickness();
|
| - const int tabstrip_width = available_width - tabstrip_x - caption_spacing;
|
| - return gfx::Rect(tabstrip_x, GetTabStripInsets(false).top,
|
| - std::max(0, tabstrip_width),
|
| - tabstrip->GetPreferredSize().height());
|
| + return layout_->IconBounds();
|
| }
|
|
|
| void OpaqueBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
|
| @@ -845,7 +722,8 @@ void OpaqueBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
|
| int client_area_top = frame()->client_view()->y();
|
| int image_top = client_area_top;
|
|
|
| - gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
|
| + gfx::Rect client_area_bounds =
|
| + layout_->CalculateClientAreaBounds(width(), height());
|
| SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR);
|
|
|
| if (browser_view()->IsToolbarVisible()) {
|
| @@ -989,111 +867,3 @@ int OpaqueBrowserFrameView::GetTopAreaHeight() const {
|
| }
|
| return top_area_height;
|
| }
|
| -
|
| -void OpaqueBrowserFrameView::LayoutWindowControls() {
|
| - if (!ShouldAddDefaultCaptionButtons())
|
| - return;
|
| - bool is_maximized = frame()->IsMaximized();
|
| - close_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
|
| - views::ImageButton::ALIGN_BOTTOM);
|
| - int caption_y = CaptionButtonY(false);
|
| - // 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;
|
| - gfx::Size close_button_size = close_button_->GetPreferredSize();
|
| - close_button_->SetBounds(width() - FrameBorderThickness(false) -
|
| - right_extra_width - close_button_size.width(), caption_y,
|
| - close_button_size.width() + right_extra_width,
|
| - close_button_size.height());
|
| -
|
| - // When the window is restored, we show a maximized button; otherwise, we show
|
| - // a restore button.
|
| - bool is_restored = !is_maximized && !frame()->IsMinimized();
|
| - views::ImageButton* invisible_button = is_restored ?
|
| - restore_button_ : maximize_button_;
|
| - invisible_button->SetVisible(false);
|
| -
|
| - views::ImageButton* visible_button = is_restored ?
|
| - maximize_button_ : restore_button_;
|
| - visible_button->SetVisible(true);
|
| - visible_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
|
| - views::ImageButton::ALIGN_BOTTOM);
|
| - gfx::Size visible_button_size = visible_button->GetPreferredSize();
|
| - visible_button->SetBounds(close_button_->x() - visible_button_size.width(),
|
| - caption_y, visible_button_size.width(),
|
| - visible_button_size.height());
|
| -
|
| - minimize_button_->SetVisible(true);
|
| - minimize_button_->SetImageAlignment(views::ImageButton::ALIGN_LEFT,
|
| - views::ImageButton::ALIGN_BOTTOM);
|
| - gfx::Size minimize_button_size = minimize_button_->GetPreferredSize();
|
| - minimize_button_->SetBounds(
|
| - visible_button->x() - minimize_button_size.width(), caption_y,
|
| - minimize_button_size.width(),
|
| - minimize_button_size.height());
|
| -}
|
| -
|
| -void OpaqueBrowserFrameView::LayoutTitleBar() {
|
| - const views::WidgetDelegate* delegate = frame()->widget_delegate();
|
| - if (delegate) {
|
| - gfx::Rect icon_bounds(IconBounds());
|
| - if (delegate->ShouldShowWindowIcon())
|
| - window_icon_->SetBoundsRect(icon_bounds);
|
| -
|
| - window_title_->SetVisible(delegate->ShouldShowWindowTitle());
|
| - if (delegate->ShouldShowWindowTitle()) {
|
| - window_title_->SetText(delegate->GetWindowTitle());
|
| - const int title_x = delegate->ShouldShowWindowIcon() ?
|
| - icon_bounds.right() + kIconTitleSpacing : icon_bounds.x();
|
| - window_title_->SetBounds(title_x, icon_bounds.y(),
|
| - std::max(0, minimize_button_->x() - kTitleLogoSpacing - title_x),
|
| - icon_bounds.height());
|
| - }
|
| - }
|
| -}
|
| -
|
| -void OpaqueBrowserFrameView::LayoutAvatar() {
|
| - // Even though the avatar is used for both incognito and profiles we always
|
| - // use the incognito icon to layout the avatar button. The profile icon
|
| - // can be customized so we can't depend on its size to perform layout.
|
| - gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
|
| -
|
| - int avatar_bottom = GetTabStripInsets(false).top +
|
| - browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
|
| - int avatar_restored_y = avatar_bottom - incognito_icon.height();
|
| - int avatar_y = frame()->IsMaximized() ?
|
| - (NonClientTopBorderHeight(false) + kTabstripTopShadowThickness) :
|
| - avatar_restored_y;
|
| - avatar_bounds_.SetRect(NonClientBorderThickness() + kAvatarLeftSpacing,
|
| - avatar_y, incognito_icon.width(),
|
| - browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
|
| - if (avatar_button())
|
| - avatar_button()->SetBoundsRect(avatar_bounds_);
|
| -
|
| - if (avatar_label()) {
|
| - // Space between the bottom of the avatar and the bottom of the avatar
|
| - // label.
|
| - const int kAvatarLabelBottomSpacing = 3;
|
| - // Space between the frame border and the left edge of the avatar label.
|
| - const int kAvatarLabelLeftSpacing = -1;
|
| - gfx::Size label_size = avatar_label()->GetPreferredSize();
|
| - gfx::Rect label_bounds(
|
| - FrameBorderThickness(false) + kAvatarLabelLeftSpacing,
|
| - avatar_bottom - kAvatarLabelBottomSpacing - label_size.height(),
|
| - label_size.width(),
|
| - browser_view()->ShouldShowAvatar() ? label_size.height() : 0);
|
| - avatar_label()->SetBoundsRect(label_bounds);
|
| - }
|
| -}
|
| -
|
| -gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width,
|
| - int height) const {
|
| - int top_height = NonClientTopBorderHeight(false);
|
| - int border_thickness = NonClientBorderThickness();
|
| - return gfx::Rect(border_thickness, top_height,
|
| - std::max(0, width - (2 * border_thickness)),
|
| - std::max(0, height - GetReservedHeight() -
|
| - top_height - border_thickness));
|
| -}
|
|
|