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

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

Issue 14367021: Rename ClampToMin and ClampToMax (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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_border.cc ('k') | ui/views/controls/button/label_button.cc » ('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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 gfx::Size BubbleFrameView::GetPreferredSize() { 140 gfx::Size BubbleFrameView::GetPreferredSize() {
141 const gfx::Size client(GetWidget()->client_view()->GetPreferredSize()); 141 const gfx::Size client(GetWidget()->client_view()->GetPreferredSize());
142 gfx::Size size(GetUpdatedWindowBounds(gfx::Rect(), client, false).size()); 142 gfx::Size size(GetUpdatedWindowBounds(gfx::Rect(), client, false).size());
143 // Accommodate the width of the title bar elements. 143 // Accommodate the width of the title bar elements.
144 int title_bar_width = GetInsets().width() + border()->GetInsets().width() + 144 int title_bar_width = GetInsets().width() + border()->GetInsets().width() +
145 kTitleLeftInset + title_->GetPreferredSize().width() + 145 kTitleLeftInset + title_->GetPreferredSize().width() +
146 close_->width() + 1; 146 close_->width() + 1;
147 if (titlebar_extra_view_ != NULL) 147 if (titlebar_extra_view_ != NULL)
148 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 148 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
149 size.ClampToMin(gfx::Size(title_bar_width, 0)); 149 size.SetToMax(gfx::Size(title_bar_width, 0));
150 return size; 150 return size;
151 } 151 }
152 152
153 void BubbleFrameView::Layout() { 153 void BubbleFrameView::Layout() {
154 gfx::Rect bounds(GetLocalBounds()); 154 gfx::Rect bounds(GetLocalBounds());
155 bounds.Inset(border()->GetInsets()); 155 bounds.Inset(border()->GetInsets());
156 // Small additional insets yield the desired 10px visual close button insets. 156 // Small additional insets yield the desired 10px visual close button insets.
157 bounds.Inset(0, 0, close_->width() + 1, 0); 157 bounds.Inset(0, 0, close_->width() + 1, 0);
158 close_->SetPosition(gfx::Point(bounds.right(), bounds.y() + 2)); 158 close_->SetPosition(gfx::Point(bounds.right(), bounds.y() + 2));
159 159
160 gfx::Rect title_bounds(bounds); 160 gfx::Rect title_bounds(bounds);
161 title_bounds.Inset(kTitleLeftInset, kTitleTopInset, 0, 0); 161 title_bounds.Inset(kTitleLeftInset, kTitleTopInset, 0, 0);
162 gfx::Size title_size(title_->GetPreferredSize()); 162 gfx::Size title_size(title_->GetPreferredSize());
163 const int title_width = std::max(0, close_->bounds().x() - title_bounds.x()); 163 const int title_width = std::max(0, close_->bounds().x() - title_bounds.x());
164 title_size.ClampToMax(gfx::Size(title_width, title_size.height())); 164 title_size.SetToMin(gfx::Size(title_width, title_size.height()));
165 title_bounds.set_size(title_size); 165 title_bounds.set_size(title_size);
166 title_->SetBoundsRect(title_bounds); 166 title_->SetBoundsRect(title_bounds);
167 167
168 if (titlebar_extra_view_) { 168 if (titlebar_extra_view_) {
169 const int extra_width = close_->bounds().x() - title_->bounds().right(); 169 const int extra_width = close_->bounds().x() - title_->bounds().right();
170 gfx::Size size = titlebar_extra_view_->GetPreferredSize(); 170 gfx::Size size = titlebar_extra_view_->GetPreferredSize();
171 size.ClampToMax(gfx::Size(std::max(0, extra_width), size.height())); 171 size.SetToMin(gfx::Size(std::max(0, extra_width), size.height()));
172 gfx::Rect titlebar_extra_view_bounds( 172 gfx::Rect titlebar_extra_view_bounds(
173 bounds.right() - size.width(), 173 bounds.right() - size.width(),
174 title_bounds.y(), 174 title_bounds.y(),
175 size.width(), 175 size.width(),
176 title_bounds.height()); 176 title_bounds.height());
177 titlebar_extra_view_bounds.Subtract(title_bounds); 177 titlebar_extra_view_bounds.Subtract(title_bounds);
178 titlebar_extra_view_->SetBoundsRect(titlebar_extra_view_bounds); 178 titlebar_extra_view_->SetBoundsRect(titlebar_extra_view_bounds);
179 } 179 }
180 } 180 }
181 181
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble 304 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble
305 // window needs to be moved to the right and that means we need to move arrow 305 // window needs to be moved to the right and that means we need to move arrow
306 // to the left, and that means negative offset. 306 // to the left, and that means negative offset.
307 bubble_border_->set_arrow_offset( 307 bubble_border_->set_arrow_offset(
308 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); 308 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust);
309 if (offscreen_adjust) 309 if (offscreen_adjust)
310 SchedulePaint(); 310 SchedulePaint();
311 } 311 }
312 312
313 } // namespace views 313 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_border.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698