Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: ui/views/bubble/bubble_frame_view.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/bubble/tray_bubble_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/bubble/bubble_frame_view.h" 5 #include "ui/views/bubble/bubble_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/hit_test.h" 10 #include "ui/base/hit_test.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 gfx::Insets BubbleFrameView::GetInsets() const { 164 gfx::Insets BubbleFrameView::GetInsets() const {
165 gfx::Insets insets = content_margins_; 165 gfx::Insets insets = content_margins_;
166 const int title_height = title_->text().empty() ? 0 : 166 const int title_height = title_->text().empty() ? 0 :
167 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; 167 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset;
168 const int close_height = close_->visible() ? close_->height() : 0; 168 const int close_height = close_->visible() ? close_->height() : 0;
169 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); 169 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0);
170 return insets; 170 return insets;
171 } 171 }
172 172
173 gfx::Size BubbleFrameView::GetPreferredSize() { 173 gfx::Size BubbleFrameView::GetPreferredSize() const {
174 return GetSizeForClientSize(GetWidget()->client_view()->GetPreferredSize()); 174 return GetSizeForClientSize(GetWidget()->client_view()->GetPreferredSize());
175 } 175 }
176 176
177 gfx::Size BubbleFrameView::GetMinimumSize() { 177 gfx::Size BubbleFrameView::GetMinimumSize() const {
178 return GetSizeForClientSize(GetWidget()->client_view()->GetMinimumSize()); 178 return GetSizeForClientSize(GetWidget()->client_view()->GetMinimumSize());
179 } 179 }
180 180
181 void BubbleFrameView::Layout() { 181 void BubbleFrameView::Layout() {
182 gfx::Rect bounds(GetContentsBounds()); 182 gfx::Rect bounds(GetContentsBounds());
183 if (bounds.IsEmpty()) 183 if (bounds.IsEmpty())
184 return; 184 return;
185 185
186 // Small additional insets yield the desired 10px visual close button insets. 186 // Small additional insets yield the desired 10px visual close button insets.
187 bounds.Inset(0, 0, close_->width() + 1, 0); 187 bounds.Inset(0, 0, close_->width() + 1, 0);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // For center arrows, arrows are moved in the opposite direction of 338 // For center arrows, arrows are moved in the opposite direction of
339 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble 339 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble
340 // window needs to be moved to the right and that means we need to move arrow 340 // window needs to be moved to the right and that means we need to move arrow
341 // to the left, and that means negative offset. 341 // to the left, and that means negative offset.
342 bubble_border_->set_arrow_offset( 342 bubble_border_->set_arrow_offset(
343 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); 343 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust);
344 if (offscreen_adjust) 344 if (offscreen_adjust)
345 SchedulePaint(); 345 SchedulePaint();
346 } 346 }
347 347
348 gfx::Size BubbleFrameView::GetSizeForClientSize(const gfx::Size& client_size) { 348 gfx::Size BubbleFrameView::GetSizeForClientSize(
349 const gfx::Size& client_size) const {
349 // Accommodate the width of the title bar elements. 350 // Accommodate the width of the title bar elements.
350 int title_bar_width = GetInsets().width() + border()->GetInsets().width(); 351 int title_bar_width = GetInsets().width() + border()->GetInsets().width();
351 if (!title_->text().empty()) 352 if (!title_->text().empty())
352 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width(); 353 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width();
353 if (close_->visible()) 354 if (close_->visible())
354 title_bar_width += close_->width() + 1; 355 title_bar_width += close_->width() + 1;
355 if (titlebar_extra_view_ != NULL) 356 if (titlebar_extra_view_ != NULL)
356 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 357 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
357 gfx::Size size(client_size); 358 gfx::Size size(client_size);
358 size.SetToMax(gfx::Size(title_bar_width, 0)); 359 size.SetToMax(gfx::Size(title_bar_width, 0));
359 const gfx::Insets insets(GetInsets()); 360 const gfx::Insets insets(GetInsets());
360 size.Enlarge(insets.width(), insets.height()); 361 size.Enlarge(insets.width(), insets.height());
361 return size; 362 return size;
362 } 363 }
363 364
364 } // namespace views 365 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/bubble/tray_bubble_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698