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/tabs | |
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/tabs')
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_view.cc | 56 | ||||
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_view.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.cc | 13 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_renderer.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 19 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 2 |
6 files changed, 42 insertions, 52 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc index 6e3fead..5b43500 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/views/tabs/dragged_tab_view.cc @@ -63,9 +63,8 @@ void DraggedTabView::MoveTo(const gfx::Point& screen_point) { // On RTL locales, a dragged tab (when it is not attached to a tab strip) // is rendered using a right-to-left orientation so we should calculate the // window position differently. - CSize ps; - GetPreferredSize(&ps); - x = screen_point.x() - ScaleValue(ps.cx) + mouse_tab_offset_.x() + + gfx::Size ps = GetPreferredSize(); + x = screen_point.x() - ScaleValue(ps.width()) + mouse_tab_offset_.x() + ScaleValue( renderer_->MirroredXCoordinateInsideView(mouse_tab_offset_.x())); } else { @@ -150,30 +149,26 @@ void DraggedTabView::Paint(ChromeCanvas* canvas) { } void DraggedTabView::Layout() { - CSize ps; - GetPreferredSize(&ps); if (attached_) { - renderer_->SetBounds(CRect(0, 0, ps.cx, ps.cy)); + renderer_->SetBounds(gfx::Point(), GetPreferredSize()); } else { int left = 0; if (UILayoutIsRightToLeft()) - left = ps.cx - attached_tab_size_.width(); + left = GetPreferredSize().width() - attached_tab_size_.width(); renderer_->SetBounds(CRect(left, 0, left + attached_tab_size_.width(), attached_tab_size_.height())); } } -void DraggedTabView::GetPreferredSize(CSize* out) { - DCHECK(out); - if (attached_) { - *out = attached_tab_size_.ToSIZE(); - } else { - int width = std::max(attached_tab_size_.width(), contents_size_.width()) + - kTwiceDragFrameBorderSize; - int height = attached_tab_size_.height() + kDragFrameBorderSize + - contents_size_.height(); - *out = CSize(width, height); - } +gfx::Size DraggedTabView::GetPreferredSize() { + if (attached_) + return attached_tab_size_; + + int width = std::max(attached_tab_size_.width(), contents_size_.width()) + + kTwiceDragFrameBorderSize; + int height = attached_tab_size_.height() + kDragFrameBorderSize + + contents_size_.height(); + return gfx::Size(width, height); } //////////////////////////////////////////////////////////////////////////////// @@ -184,21 +179,20 @@ void DraggedTabView::PaintAttachedTab(ChromeCanvas* canvas) { } void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) { - CSize ps; - GetPreferredSize(&ps); - ChromeCanvas scale_canvas(ps.cx, ps.cy, false); + gfx::Size ps = GetPreferredSize(); + ChromeCanvas scale_canvas(ps.width(), ps.height(), false); SkBitmap& bitmap_device = const_cast<SkBitmap&>( scale_canvas.getTopPlatformDevice().accessBitmap(true)); bitmap_device.eraseARGB(0, 0, 0, 0); scale_canvas.FillRectInt(kDraggedTabBorderColor, 0, attached_tab_size_.height() - kDragFrameBorderSize, - ps.cx, ps.cy - attached_tab_size_.height()); + ps.width(), ps.height() - attached_tab_size_.height()); int image_x = kDragFrameBorderSize; int image_y = attached_tab_size_.height(); - int image_w = ps.cx - kTwiceDragFrameBorderSize; + int image_w = ps.width() - kTwiceDragFrameBorderSize; int image_h = - ps.cy - kTwiceDragFrameBorderSize - attached_tab_size_.height(); + ps.height() - kTwiceDragFrameBorderSize - attached_tab_size_.height(); scale_canvas.FillRectInt(SK_ColorBLACK, image_x, image_y, image_w, image_h); photobooth_->PaintScreenshotIntoCanvas( &scale_canvas, @@ -206,7 +200,7 @@ void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) { renderer_->ProcessPaint(&scale_canvas); SkIRect subset; - subset.set(0, 0, ps.cx, ps.cy); + subset.set(0, 0, ps.width(), ps.height()); SkBitmap mipmap = scale_canvas.ExtractBitmap(); mipmap.buildMipMap(true); @@ -226,16 +220,16 @@ void DraggedTabView::PaintDetachedView(ChromeCanvas* canvas) { SkRect rc; rc.fLeft = 0; rc.fTop = 0; - rc.fRight = SkIntToScalar(ps.cx); - rc.fBottom = SkIntToScalar(ps.cy); + rc.fRight = SkIntToScalar(ps.width()); + rc.fBottom = SkIntToScalar(ps.height()); canvas->drawRect(rc, paint); } void DraggedTabView::ResizeContainer() { - CSize ps; - GetPreferredSize(&ps); - SetWindowPos(container_->GetHWND(), HWND_TOPMOST, 0, 0, ScaleValue(ps.cx), - ScaleValue(ps.cy), SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); + gfx::Size ps = GetPreferredSize(); + SetWindowPos(container_->GetHWND(), HWND_TOPMOST, 0, 0, + ScaleValue(ps.width()), ScaleValue(ps.height()), + SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } int DraggedTabView::ScaleValue(int value) { diff --git a/chrome/browser/views/tabs/dragged_tab_view.h b/chrome/browser/views/tabs/dragged_tab_view.h index e59582c..14ba7ec 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.h +++ b/chrome/browser/views/tabs/dragged_tab_view.h @@ -61,7 +61,7 @@ class DraggedTabView : public ChromeViews::View, // Overridden from ChromeViews::View: virtual void Paint(ChromeCanvas* canvas); virtual void Layout(); - virtual void GetPreferredSize(CSize* out); + virtual gfx::Size GetPreferredSize(); // Paint the view, when it's attached to a TabStrip. void PaintAttachedTab(ChromeCanvas* canvas); diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index 44cd363..876c57e 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -330,7 +330,7 @@ void TabRenderer::StopPulse() { } // static -gfx::Size TabRenderer::GetMinimumSize() { +gfx::Size TabRenderer::GetMinimumUnselectedSize() { InitResources(); gfx::Size minimum_size; @@ -343,14 +343,14 @@ gfx::Size TabRenderer::GetMinimumSize() { // static gfx::Size TabRenderer::GetMinimumSelectedSize() { - gfx::Size minimum_size = GetMinimumSize(); + gfx::Size minimum_size = GetMinimumUnselectedSize(); minimum_size.set_width(kLeftPadding + kFaviconSize + kRightPadding); return minimum_size; } // static gfx::Size TabRenderer::GetStandardSize() { - gfx::Size standard_size = GetMinimumSize(); + gfx::Size standard_size = GetMinimumUnselectedSize(); standard_size.set_width( standard_size.width() + kFavIconTitleSpacing + kStandardTitleWidth); return standard_size; @@ -369,7 +369,7 @@ std::wstring TabRenderer::GetTitle() const { void TabRenderer::Paint(ChromeCanvas* canvas) { // Don't paint if we're narrower than we can render correctly. (This should // only happen during animations). - if (width() < GetMinimumSize().width()) + if (width() < GetMinimumUnselectedSize().width()) return; // See if the model changes whether the icons should be painted. @@ -492,7 +492,7 @@ void TabRenderer::Layout() { // If the user has big fonts, the title will appear rendered too far down on // the y-axis if we use the regular top padding, so we need to adjust it so // that the text appears centered. - gfx::Size minimum_size = GetMinimumSize(); + gfx::Size minimum_size = GetMinimumUnselectedSize(); int text_height = title_top + title_font_height + kBottomPadding; if (text_height > minimum_size.height()) title_top -= (text_height - minimum_size.height()) / 2; @@ -635,9 +635,8 @@ void TabRenderer::PaintLoadingAnimation(ChromeCanvas* canvas) { } int TabRenderer::IconCapacity() const { - if (height() < GetMinimumSize().height()) { + if (height() < GetMinimumUnselectedSize().height()) return 0; - } return (width() - kLeftPadding - kRightPadding) / kFaviconSize; } diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h index cb92574..1c0a9f5 100644 --- a/chrome/browser/views/tabs/tab_renderer.h +++ b/chrome/browser/views/tabs/tab_renderer.h @@ -54,7 +54,7 @@ class TabRenderer : public ChromeViews::View, void StopPulse(); // Returns the minimum possible size of a single unselected Tab. - static gfx::Size GetMinimumSize(); + static gfx::Size GetMinimumUnselectedSize(); // Returns the minimum possible size of a selected Tab. Selected tabs must // always show a close button and have a larger minimum size than unselected // tabs. diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 835ffa6..7158bf0 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -197,7 +197,7 @@ class TabStrip::TabAnimation : public AnimationDelegate { if (start_tab_count < end_tab_count && start_unselected_width_ < standard_tab_width) { double minimum_tab_width = - static_cast<double>(TabRenderer::GetMinimumSize().width()); + static_cast<double>(TabRenderer::GetMinimumUnselectedSize().width()); start_unselected_width_ -= minimum_tab_width / start_tab_count; } tabstrip_->GenerateIdealBounds(); @@ -247,7 +247,7 @@ class InsertTabAnimation : public TabStrip::TabAnimation { double target_width = is_selected ? end_unselected_width_ : end_selected_width_; double start_width = is_selected ? Tab::GetMinimumSelectedSize().width() : - Tab::GetMinimumSize().width(); + Tab::GetMinimumUnselectedSize().width(); double delta = target_width - start_width; if (delta > 0) return start_width + (delta * animation_.GetCurrentValue()); @@ -294,7 +294,8 @@ class RemoveTabAnimation : public TabStrip::TabAnimation { // of the animation. // Removed animated Tabs are never selected. double start_width = start_unselected_width_; - double target_width = Tab::GetMinimumSize().width() + kTabHOffset; + double target_width = + Tab::GetMinimumUnselectedSize().width() + kTabHOffset; double delta = start_width - target_width; return start_width - (delta * animation_.GetCurrentValue()); } @@ -508,9 +509,7 @@ TabStrip::~TabStrip() { } int TabStrip::GetPreferredHeight() { - CSize preferred_size; - GetPreferredSize(&preferred_size); - return preferred_size.cy; + return GetPreferredSize().height(); } bool TabStrip::HasAvailableDragActions() const { @@ -676,10 +675,8 @@ void TabStrip::Layout() { SchedulePaint(); } -void TabStrip::GetPreferredSize(CSize* preferred_size) { - DCHECK(preferred_size); - preferred_size->cx = 0; - preferred_size->cy = Tab::GetMinimumSize().height(); +gfx::Size TabStrip::GetPreferredSize() { + return gfx::Size(0, Tab::GetMinimumUnselectedSize().height()); } void TabStrip::OnDragEntered(const DropTargetEvent& event) { @@ -1157,7 +1154,7 @@ void TabStrip::GetCurrentTabWidths(double* unselected_width, void TabStrip::GetDesiredTabWidths(int tab_count, double* unselected_width, double* selected_width) const { - const double min_unselected_width = Tab::GetMinimumSize().width(); + const double min_unselected_width = Tab::GetMinimumUnselectedSize().width(); const double min_selected_width = Tab::GetMinimumSelectedSize().width(); if (tab_count == 0) { // Return immediately to avoid divide-by-zero below. diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 4d53fa1..f30f59b 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -101,7 +101,7 @@ class TabStrip : public ChromeViews::View, virtual void DidChangeBounds(const CRect& previous, const CRect& current); virtual ChromeViews::View* GetViewByID(int id) const; virtual void Layout(); - virtual void GetPreferredSize(CSize* preferred_size); + virtual gfx::Size GetPreferredSize(); // NOTE: the drag and drop methods are invoked from FrameView. This is done to // allow for a drop region that extends outside the bounds of the TabStrip. virtual void OnDragEntered(const ChromeViews::DropTargetEvent& event); |