diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 18:02:30 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-15 18:02:30 +0000 |
commit | 154f8bcac65142d7ae6733204c15ae52cfa320c6 (patch) | |
tree | d7375c1119946c2914ee79ef2c0e8aa195b1fbe9 /chrome/browser/views/old_frames | |
parent | 8144d0cea4e142ff7d7a75c84240a4bb8a7fb3a4 (diff) | |
download | chromium_src-154f8bcac65142d7ae6733204c15ae52cfa320c6.zip chromium_src-154f8bcac65142d7ae6733204c15ae52cfa320c6.tar.gz chromium_src-154f8bcac65142d7ae6733204c15ae52cfa320c6.tar.bz2 |
Convert GetPreferredSize from:
void GetPreferredSize(CSize* out);
to:
gfx::Size GetPreferredSize();
.. and update some other places to use gfx::Size as well.
http://crbug.com/2186
Review URL: http://codereview.chromium.org/7344
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/old_frames')
-rw-r--r-- | chrome/browser/views/old_frames/simple_vista_frame.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/old_frames/simple_xp_frame.cc | 34 | ||||
-rw-r--r-- | chrome/browser/views/old_frames/simple_xp_frame.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/old_frames/vista_frame.cc | 79 | ||||
-rw-r--r-- | chrome/browser/views/old_frames/xp_frame.cc | 127 |
5 files changed, 115 insertions, 132 deletions
diff --git a/chrome/browser/views/old_frames/simple_vista_frame.cc b/chrome/browser/views/old_frames/simple_vista_frame.cc index 884d748..82b246c 100644 --- a/chrome/browser/views/old_frames/simple_vista_frame.cc +++ b/chrome/browser/views/old_frames/simple_vista_frame.cc @@ -203,12 +203,11 @@ void SimpleVistaFrame::Layout() { if (browser_->ShouldDisplayURLField()) { TabContentsContainerView* container = GetTabContentsContainer(); - CSize s; - location_bar_->GetPreferredSize(&s); + gfx::Size s = location_bar_->GetPreferredSize(); location_bar_->SetBounds(container->x() - kLocationBarOutdent, container->y() - kLocationBarOutdent, container->width() + kLocationBarOutdent * 2, - s.cy); + s.height()); container->SetBounds(container->x(), location_bar_->y() + location_bar_->height() - kLocationBarSpacing, container->width(), diff --git a/chrome/browser/views/old_frames/simple_xp_frame.cc b/chrome/browser/views/old_frames/simple_xp_frame.cc index 79046e6..8436b63 100644 --- a/chrome/browser/views/old_frames/simple_xp_frame.cc +++ b/chrome/browser/views/old_frames/simple_xp_frame.cc @@ -79,15 +79,16 @@ void TitleBarMenuButton::SetContents(ChromeViews::View* contents) { contents_ = contents; } -void TitleBarMenuButton::GetPreferredSize(CSize *out) { +gfx::Size TitleBarMenuButton::GetPreferredSize() { + gfx::Size prefsize; if (contents_) - contents_->GetPreferredSize(out); - else - out->cx = out->cy = 0; + prefsize = contents_->GetPreferredSize(); - out->cx += drop_arrow_->width() + kHorizMargin + (2 * kHorizBorderSize); - out->cy = std::max(drop_arrow_->height(), static_cast<int>(out->cy)); - out->cy += (2 * kVertBorderSize); + prefsize.set_height(std::max(drop_arrow_->height(), prefsize.height())); + prefsize.Enlarge( + drop_arrow_->width() + kHorizMargin + (2 * kHorizBorderSize), + 2 * kVertBorderSize); + return prefsize; } void TitleBarMenuButton::Paint(ChromeCanvas* canvas) { @@ -97,17 +98,16 @@ void TitleBarMenuButton::Paint(ChromeCanvas* canvas) { } if (contents_) { - CSize s; - contents_->GetPreferredSize(&s); + gfx::Size s = contents_->GetPreferredSize(); // Note: we use a floating view in this case because we never want the // contents to process any event. PaintFloatingView(canvas, contents_, kVertBorderSize, - (height() - s.cy) / 2, + (height() - s.height()) / 2, width() - kHorizMargin - drop_arrow_->width() - (2 * kHorizBorderSize), - s.cy); + s.height()); } // We can not use the mirroring infrastructure in ChromeViews in order to @@ -205,10 +205,9 @@ void SimpleXPFrameTitleBar::RunMenu(ChromeViews::View* source, } void SimpleXPFrameTitleBar::Layout() { - CSize s; - menu_button_->GetPreferredSize(&s); - menu_button_->SetBounds(kFavIconMargin, (height() - s.cy) / 2, - s.cx, s.cy); + gfx::Size s = menu_button_->GetPreferredSize(); + menu_button_->SetBounds(kFavIconMargin, (height() - s.height()) / 2, + s.width(), s.height()); menu_button_->Layout(); label_->SetBounds(menu_button_->x() + menu_button_->width() + kFavIconPadding, kLabelVerticalOffset, @@ -322,12 +321,11 @@ void SimpleXPFrame::Layout() { if (browser_->ShouldDisplayURLField()) { TabContentsContainerView* container = GetTabContentsContainer(); - CSize s; - location_bar_->GetPreferredSize(&s); + gfx::Size s = location_bar_->GetPreferredSize(); location_bar_->SetBounds(container->x() - kLocationBarOffset, container->y(), container->width() + kLocationBarOffset * 2, - s.cy); + s.height()); container->SetBounds(container->x(), location_bar_->y() + location_bar_->height() + kLocationBarSpacing, container->width(), diff --git a/chrome/browser/views/old_frames/simple_xp_frame.h b/chrome/browser/views/old_frames/simple_xp_frame.h index 24a8a25..2b5b368 100644 --- a/chrome/browser/views/old_frames/simple_xp_frame.h +++ b/chrome/browser/views/old_frames/simple_xp_frame.h @@ -108,7 +108,7 @@ class TitleBarMenuButton : public ChromeViews::MenuButton { void SetContents(ChromeViews::View* contents); // overridden from View - virtual void GetPreferredSize(CSize *out); + virtual gfx::Size GetPreferredSize(); virtual void Paint(ChromeCanvas* canvas); virtual bool OnMousePressed(const ChromeViews::MouseEvent& e); diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc index 6b0d081..fb934ad 100644 --- a/chrome/browser/views/old_frames/vista_frame.cc +++ b/chrome/browser/views/old_frames/vista_frame.cc @@ -181,24 +181,23 @@ void VistaFrame::Layout() { int tabstrip_x = g_bitmaps[CT_LEFT_SIDE]->width(); if (is_off_the_record_) { off_the_record_image_->SetVisible(true); - CSize otr_image_size; - off_the_record_image_->GetPreferredSize(&otr_image_size); - tabstrip_x += otr_image_size.cx + (2 * kOTRImageHorizMargin); + gfx::Size otr_image_size = off_the_record_image_->GetPreferredSize(); + tabstrip_x += otr_image_size.width() + (2 * kOTRImageHorizMargin); gfx::Rect off_the_record_bounds; if (IsZoomed()) { off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), kResizeBorder, - otr_image_size.cx, + otr_image_size.width(), tabstrip_->GetPreferredHeight() - kToolbarOverlapVertOffset + 1); } else { off_the_record_bounds.SetRect(g_bitmaps[CT_LEFT_SIDE]->width(), kResizeBorder + kTitlebarHeight + tabstrip_->GetPreferredHeight() - - otr_image_size.cy - + otr_image_size.height() - kToolbarOverlapVertOffset + 1, - otr_image_size.cx, - otr_image_size.cy); + otr_image_size.width(), + otr_image_size.height()); } if (frame_view_->UILayoutIsRightToLeft()) @@ -233,22 +232,22 @@ void VistaFrame::Layout() { // Hide the distributor logo if we're zoomed. distributor_logo_->SetVisible(false); } else { - CSize distributor_logo_size; - distributor_logo_->GetPreferredSize(&distributor_logo_size); + gfx::Size distributor_logo_size = + distributor_logo_->GetPreferredSize(); int logo_x; // Because of Bug 1128173, our Window controls aren't actually flipped // on Vista, yet all our math and layout presumes that they are. if (frame_view_->UILayoutIsRightToLeft()) - logo_x = width - distributor_logo_size.cx; + logo_x = width - distributor_logo_size.width(); else - logo_x = width - min_offset - distributor_logo_size.cx; + logo_x = width - min_offset - distributor_logo_size.width(); distributor_logo_->SetVisible(true); distributor_logo_->SetBounds(logo_x, kDistributorLogoVerticalOffset, - distributor_logo_size.cx, - distributor_logo_size.cy); + distributor_logo_size.width(), + distributor_logo_size.height()); } } @@ -309,25 +308,25 @@ void VistaFrame::Layout() { browser_h = height; } - CSize preferred_size; + gfx::Size preferred_size; if (shelf_view_) { - shelf_view_->GetPreferredSize(&preferred_size); + preferred_size = shelf_view_->GetPreferredSize(); shelf_view_->SetBounds(browser_x, height - g_bitmaps[CT_BOTTOM_CENTER]->height() - - preferred_size.cy, + preferred_size.height(), browser_w, - preferred_size.cy); - browser_h -= preferred_size.cy; + preferred_size.height()); + browser_h -= preferred_size.height(); } - CSize bookmark_bar_size; - CSize info_bar_size; + gfx::Size bookmark_bar_size; + gfx::Size info_bar_size; if (bookmark_bar_view_.get()) - bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size); + bookmark_bar_size = bookmark_bar_view_->GetPreferredSize(); if (info_bar_view_) - info_bar_view_->GetPreferredSize(&info_bar_size); + info_bar_size = info_bar_view_->GetPreferredSize(); // If we're showing a bookmarks bar in the new tab page style and we // have an infobar showing, we need to flip them. @@ -338,17 +337,17 @@ void VistaFrame::Layout() { info_bar_view_->SetBounds(browser_x, browser_y, browser_w, - info_bar_size.cy); - browser_h -= info_bar_size.cy; + info_bar_size.height()); + browser_h -= info_bar_size.height(); - browser_y += info_bar_size.cy - kSeparationLineHeight; + browser_y += info_bar_size.height() - kSeparationLineHeight; bookmark_bar_view_->SetBounds(browser_x, browser_y, browser_w, - bookmark_bar_size.cy); - browser_h -= bookmark_bar_size.cy - kSeparationLineHeight; - browser_y += bookmark_bar_size.cy; + bookmark_bar_size.height()); + browser_h -= bookmark_bar_size.height() - kSeparationLineHeight; + browser_y += bookmark_bar_size.height(); } else { if (bookmark_bar_view_.get()) { // We want our bookmarks bar to be responsible for drawing its own @@ -358,18 +357,18 @@ void VistaFrame::Layout() { bookmark_bar_view_->SetBounds(browser_x, browser_y, browser_w, - bookmark_bar_size.cy); - browser_h -= bookmark_bar_size.cy - kSeparationLineHeight; - browser_y += bookmark_bar_size.cy; + bookmark_bar_size.height()); + browser_h -= bookmark_bar_size.height() - kSeparationLineHeight; + browser_y += bookmark_bar_size.height(); } if (info_bar_view_) { info_bar_view_->SetBounds(browser_x, browser_y, browser_w, - info_bar_size.cy); - browser_h -= info_bar_size.cy; - browser_y += info_bar_size.cy; + info_bar_size.height()); + browser_h -= info_bar_size.height(); + browser_y += info_bar_size.height(); } } @@ -657,10 +656,8 @@ bool VistaFrame::IsBookmarkBarVisible() const { if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating()) return true; - CSize sz; - bookmark_bar_view_->GetPreferredSize(&sz); // 1 is the minimum in GetPreferredSize for the bookmark bar. - return sz.cy > 1; + return bookmark_bar_view_->GetPreferredSize().height() > 1; } //////////////////////////////////////////////////////////////////////////////// @@ -1446,9 +1443,7 @@ bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view, if (*view == new_view) { // The views haven't changed, if the views pref changed schedule a layout. if (new_view) { - CSize pref_size; - new_view->GetPreferredSize(&pref_size); - if (pref_size.cy != new_view->height()) + if (new_view->GetPreferredSize().height() != new_view->height()) return true; } return false; @@ -1467,9 +1462,7 @@ bool VistaFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view, int new_height = 0; if (new_view) { - CSize preferred_size; - new_view->GetPreferredSize(&preferred_size); - new_height = preferred_size.cy; + new_height = new_view->GetPreferredSize().height(); root_view_.AddChildView(new_view); } diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc index e4a80e7..2512f63 100644 --- a/chrome/browser/views/old_frames/xp_frame.cc +++ b/chrome/browser/views/old_frames/xp_frame.cc @@ -584,69 +584,69 @@ void XPFrame::Layout() { root_view_.SetBounds(0, 0, width, height); frame_view_->SetBounds(0, 0, width, height); - CSize preferred_size; + gfx::Size preferred_size; if (IsZoomed()) { - close_button_->GetPreferredSize(&preferred_size); + preferred_size = close_button_->GetPreferredSize(); close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, ChromeViews::Button::ALIGN_BOTTOM); - close_button_->SetBounds(width - preferred_size.cx - + close_button_->SetBounds(width - preferred_size.width() - kWindowControlsRightZoomedOffset, 0, - preferred_size.cx + + preferred_size.width() + kWindowControlsRightZoomedOffset, - preferred_size.cy + + preferred_size.height() + kWindowControlsTopZoomedOffset); max_button_->SetVisible(false); restore_button_->SetVisible(true); - restore_button_->GetPreferredSize(&preferred_size); + preferred_size = restore_button_->GetPreferredSize(); restore_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, ChromeViews::Button::ALIGN_BOTTOM); - restore_button_->SetBounds(close_button_->x() - preferred_size.cx, + restore_button_->SetBounds(close_button_->x() - preferred_size.width(), 0, - preferred_size.cx, - preferred_size.cy + + preferred_size.width(), + preferred_size.height() + kWindowControlsTopZoomedOffset); - min_button_->GetPreferredSize(&preferred_size); + preferred_size = min_button_->GetPreferredSize(); min_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, ChromeViews::Button::ALIGN_BOTTOM); - min_button_->SetBounds(restore_button_->x() - preferred_size.cx, + min_button_->SetBounds(restore_button_->x() - preferred_size.width(), 0, - preferred_size.cx, - preferred_size.cy + + preferred_size.width(), + preferred_size.height() + kWindowControlsTopZoomedOffset); } else { - close_button_->GetPreferredSize(&preferred_size); + preferred_size = close_button_->GetPreferredSize(); close_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, ChromeViews::Button::ALIGN_TOP); close_button_->SetBounds(width - kWindowControlsRightOffset - - preferred_size.cx, + preferred_size.width(), kWindowControlsTopOffset, - preferred_size.cx, - preferred_size.cy); + preferred_size.width(), + preferred_size.height()); restore_button_->SetVisible(false); max_button_->SetVisible(true); - max_button_->GetPreferredSize(&preferred_size); + preferred_size = max_button_->GetPreferredSize(); max_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, ChromeViews::Button::ALIGN_TOP); - max_button_->SetBounds(close_button_->x() - preferred_size.cx, + max_button_->SetBounds(close_button_->x() - preferred_size.width(), kWindowControlsTopOffset, - preferred_size.cx, - preferred_size.cy); + preferred_size.width(), + preferred_size.height()); - min_button_->GetPreferredSize(&preferred_size); + preferred_size = min_button_->GetPreferredSize(); min_button_->SetImageAlignment(ChromeViews::Button::ALIGN_LEFT, ChromeViews::Button::ALIGN_TOP); - min_button_->SetBounds(max_button_->x() - preferred_size.cx, + min_button_->SetBounds(max_button_->x() - preferred_size.width(), kWindowControlsTopOffset, - preferred_size.cx, - preferred_size.cy); + preferred_size.width(), + preferred_size.height()); } int right_limit = min_button_->x(); @@ -674,23 +674,22 @@ void XPFrame::Layout() { int tab_strip_x = left_margin; if (is_off_the_record_) { - CSize otr_image_size; - off_the_record_image_->GetPreferredSize(&otr_image_size); - tab_strip_x += otr_image_size.cx + (2 * kOTRImageHorizMargin); + gfx::Size otr_image_size = off_the_record_image_->GetPreferredSize(); + tab_strip_x += otr_image_size.width() + (2 * kOTRImageHorizMargin); if (IsZoomed()) { off_the_record_image_->SetBounds(left_margin + kOTRImageHorizMargin, top_margin + 1, - otr_image_size.cx, + otr_image_size.width(), tabstrip_->GetPreferredHeight() - kToolbarOverlapVertOffset - 1); } else { off_the_record_image_->SetBounds(left_margin + kOTRImageHorizMargin, top_margin - 1 + tabstrip_->GetPreferredHeight() - - otr_image_size.cy - + otr_image_size.height() - kOTRImageVertMargin, - otr_image_size.cx, - otr_image_size.cy); + otr_image_size.width(), + otr_image_size.height()); } } @@ -698,15 +697,15 @@ void XPFrame::Layout() { if (IsZoomed()) { distributor_logo_->SetVisible(false); } else { - CSize distributor_logo_size; - distributor_logo_->GetPreferredSize(&distributor_logo_size); + gfx::Size distributor_logo_size = + distributor_logo_->GetPreferredSize(); distributor_logo_->SetVisible(true); distributor_logo_->SetBounds(min_button_->x() - - distributor_logo_size.cx - + distributor_logo_size.width() - kDistributorLogoHorizontalOffset, kDistributorLogoVerticalOffset, - distributor_logo_size.cx, - distributor_logo_size.cy); + distributor_logo_size.width(), + distributor_logo_size.height()); } } @@ -753,26 +752,26 @@ void XPFrame::Layout() { int browser_h = height - last_y - bottom_margin; if (shelf_view_) { - shelf_view_->GetPreferredSize(&preferred_size); + preferred_size = shelf_view_->GetPreferredSize(); shelf_view_->SetBounds(left_margin, - height - bottom_margin - preferred_size.cy, + height - bottom_margin - preferred_size.height(), width - left_margin - right_margin, - preferred_size.cy); - browser_h -= preferred_size.cy; + preferred_size.height()); + browser_h -= preferred_size.height(); } int bookmark_bar_height = 0; - CSize bookmark_bar_size; - CSize info_bar_size; + gfx::Size bookmark_bar_size; + gfx::Size info_bar_size; if (bookmark_bar_view_.get()) { - bookmark_bar_view_->GetPreferredSize(&bookmark_bar_size); - bookmark_bar_height = bookmark_bar_size.cy; + bookmark_bar_size = bookmark_bar_view_->GetPreferredSize(); + bookmark_bar_height = bookmark_bar_size.height(); } if (info_bar_view_) - info_bar_view_->GetPreferredSize(&info_bar_size); + info_bar_size = info_bar_view_->GetPreferredSize(); // If we're showing a bookmarks bar in the new tab page style and we // have an infobar showing, we need to flip them. @@ -783,9 +782,9 @@ void XPFrame::Layout() { info_bar_view_->SetBounds(left_margin, last_y, client_rect.Width() - left_margin - right_margin, - info_bar_size.cy); - browser_h -= info_bar_size.cy; - last_y += info_bar_size.cy; + info_bar_size.height()); + browser_h -= info_bar_size.height(); + last_y += info_bar_size.height(); last_y -= kSeparationLineHeight; @@ -793,9 +792,9 @@ void XPFrame::Layout() { last_y, client_rect.Width() - left_margin - right_margin, - bookmark_bar_size.cy); - browser_h -= (bookmark_bar_size.cy - kSeparationLineHeight); - last_y += bookmark_bar_size.cy; + bookmark_bar_size.height()); + browser_h -= (bookmark_bar_size.height() - kSeparationLineHeight); + last_y += bookmark_bar_size.height(); } else { if (bookmark_bar_view_.get()) { // We want our bookmarks bar to be responsible for drawing its own @@ -806,9 +805,9 @@ void XPFrame::Layout() { last_y, client_rect.Width() - left_margin - right_margin, - bookmark_bar_size.cy); - browser_h -= (bookmark_bar_size.cy - kSeparationLineHeight); - last_y += bookmark_bar_size.cy; + bookmark_bar_size.height()); + browser_h -= (bookmark_bar_size.height() - kSeparationLineHeight); + last_y += bookmark_bar_size.height(); } if (info_bar_view_) { @@ -816,9 +815,9 @@ void XPFrame::Layout() { last_y, client_rect.Width() - left_margin - right_margin, - info_bar_size.cy); - browser_h -= info_bar_size.cy; - last_y += info_bar_size.cy; + info_bar_size.height()); + browser_h -= info_bar_size.height(); + last_y += info_bar_size.height(); } } @@ -1894,10 +1893,8 @@ bool XPFrame::IsBookmarkBarVisible() const { if (bookmark_bar_view_->IsNewTabPage() || bookmark_bar_view_->IsAnimating()) return true; - CSize sz; - bookmark_bar_view_->GetPreferredSize(&sz); // 1 is the minimum in GetPreferredSize for the bookmark bar. - return sz.cy > 1; + return bookmark_bar_view_->GetPreferredSize().height() > 1; } void XPFrame::MoveToFront(bool should_activate) { @@ -2304,9 +2301,7 @@ bool XPFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view, if (*view == new_view) { // The views haven't changed, if the views pref changed schedule a layout. if (new_view) { - CSize pref_size; - new_view->GetPreferredSize(&pref_size); - if (pref_size.cy != new_view->height()) + if (new_view->GetPreferredSize().height() != new_view->height()) return true; } return false; @@ -2325,9 +2320,7 @@ bool XPFrame::UpdateChildViewAndLayout(ChromeViews::View* new_view, int new_height = 0; if (new_view) { - CSize preferred_size; - new_view->GetPreferredSize(&preferred_size); - new_height = preferred_size.cy; + new_height = new_view->GetPreferredSize().height(); root_view_.AddChildView(new_view); } bool changed = false; |