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

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

Issue 1773393002: Address some bubble clipping issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ClipRect Created 4 years, 9 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
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/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 #include <utility> 8 #include <utility>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "ui/base/default_style.h" 11 #include "ui/base/default_style.h"
12 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 14 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/compositor/paint_context.h"
16 #include "ui/compositor/paint_recorder.h"
15 #include "ui/gfx/geometry/vector2d.h" 17 #include "ui/gfx/geometry/vector2d.h"
16 #include "ui/gfx/path.h" 18 #include "ui/gfx/path.h"
17 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
18 #include "ui/gfx/skia_util.h" 20 #include "ui/gfx/skia_util.h"
19 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
20 #include "ui/resources/grit/ui_resources.h" 22 #include "ui/resources/grit/ui_resources.h"
21 #include "ui/strings/grit/ui_strings.h" 23 #include "ui/strings/grit/ui_strings.h"
22 #include "ui/views/bubble/bubble_border.h" 24 #include "ui/views/bubble/bubble_border.h"
23 #include "ui/views/controls/button/label_button.h" 25 #include "ui/views/controls/button/label_button.h"
24 #include "ui/views/controls/image_view.h" 26 #include "ui/views/controls/image_view.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 129 }
128 return client_bounds; 130 return client_bounds;
129 } 131 }
130 132
131 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( 133 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds(
132 const gfx::Rect& client_bounds) const { 134 const gfx::Rect& client_bounds) const {
133 gfx::Size size(GetSizeForClientSize(client_bounds.size())); 135 gfx::Size size(GetSizeForClientSize(client_bounds.size()));
134 return bubble_border_->GetBounds(gfx::Rect(), size); 136 return bubble_border_->GetBounds(gfx::Rect(), size);
135 } 137 }
136 138
139 bool BubbleFrameView::GetClientMask(const gfx::Size& size,
140 gfx::Path* path) const {
141 const int radius = bubble_border_->GetBorderCornerRadius();
142 path->addRoundRect(gfx::RectToSkRect(gfx::Rect(gfx::Point(), size)), radius,
msw 2016/03/22 18:42:45 nit: use gfx::Rect(size))
Evan Stade 2016/03/22 20:00:45 Done.
143 radius);
144 return true;
145 }
146
137 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { 147 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
138 if (!bounds().Contains(point)) 148 if (!bounds().Contains(point))
139 return HTNOWHERE; 149 return HTNOWHERE;
140 if (close_->visible() && close_->GetMirroredBounds().Contains(point)) 150 if (close_->visible() && close_->GetMirroredBounds().Contains(point))
141 return HTCLOSE; 151 return HTCLOSE;
142 152
143 // Allow dialogs to show the system menu and be dragged. 153 // Allow dialogs to show the system menu and be dragged.
144 if (GetWidget()->widget_delegate()->AsDialogDelegate() && 154 if (GetWidget()->widget_delegate()->AsDialogDelegate() &&
145 !GetWidget()->widget_delegate()->AsBubbleDialogDelegate()) { 155 !GetWidget()->widget_delegate()->AsBubbleDialogDelegate()) {
146 gfx::Rect sys_rect(0, 0, title_->x(), title_->y()); 156 gfx::Rect sys_rect(0, 0, title_->x(), title_->y());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 title_->SetText(GetWidget()->widget_delegate()->GetWindowTitle()); 220 title_->SetText(GetWidget()->widget_delegate()->GetWindowTitle());
211 title_->SetVisible(GetWidget()->widget_delegate()->ShouldShowWindowTitle()); 221 title_->SetVisible(GetWidget()->widget_delegate()->ShouldShowWindowTitle());
212 } 222 }
213 223
214 void BubbleFrameView::SizeConstraintsChanged() {} 224 void BubbleFrameView::SizeConstraintsChanged() {}
215 225
216 void BubbleFrameView::SetTitleFontList(const gfx::FontList& font_list) { 226 void BubbleFrameView::SetTitleFontList(const gfx::FontList& font_list) {
217 title_->SetFontList(font_list); 227 title_->SetFontList(font_list);
218 } 228 }
219 229
230 const char* BubbleFrameView::GetClassName() const {
231 return kViewClassName;
232 }
233
220 gfx::Insets BubbleFrameView::GetInsets() const { 234 gfx::Insets BubbleFrameView::GetInsets() const {
221 gfx::Insets insets = content_margins_; 235 gfx::Insets insets = content_margins_;
222 236
223 const int icon_height = title_icon_->GetPreferredSize().height(); 237 const int icon_height = title_icon_->GetPreferredSize().height();
224 const int label_height = title_->GetPreferredSize().height(); 238 const int label_height = title_->GetPreferredSize().height();
225 const bool has_title = icon_height > 0 || label_height > 0; 239 const bool has_title = icon_height > 0 || label_height > 0;
226 const int title_padding = has_title ? title_margins_.height() : 0; 240 const int title_padding = has_title ? title_margins_.height() : 0;
227 const int title_height = std::max(icon_height, label_height) + title_padding; 241 const int title_height = std::max(icon_height, label_height) + title_padding;
228 const int close_height = close_->visible() ? close_->height() : 0; 242 const int close_height = close_->visible() ? close_->height() : 0;
229 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); 243 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 324
311 if (footnote_container_) { 325 if (footnote_container_) {
312 gfx::Rect local_bounds = GetContentsBounds(); 326 gfx::Rect local_bounds = GetContentsBounds();
313 int height = footnote_container_->GetHeightForWidth(local_bounds.width()); 327 int height = footnote_container_->GetHeightForWidth(local_bounds.width());
314 footnote_container_->SetBounds(local_bounds.x(), 328 footnote_container_->SetBounds(local_bounds.x(),
315 local_bounds.bottom() - height, 329 local_bounds.bottom() - height,
316 local_bounds.width(), height); 330 local_bounds.width(), height);
317 } 331 }
318 } 332 }
319 333
320 const char* BubbleFrameView::GetClassName() const {
321 return kViewClassName;
322 }
323
324 void BubbleFrameView::OnThemeChanged() { 334 void BubbleFrameView::OnThemeChanged() {
325 UpdateWindowTitle(); 335 UpdateWindowTitle();
326 ResetWindowControls(); 336 ResetWindowControls();
327 UpdateWindowIcon(); 337 UpdateWindowIcon();
328 } 338 }
329 339
330 void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 340 void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
331 if (bubble_border_ && bubble_border_->use_theme_background_color()) { 341 if (bubble_border_ && bubble_border_->use_theme_background_color()) {
332 bubble_border_->set_background_color(GetNativeTheme()-> 342 bubble_border_->set_background_color(GetNativeTheme()->
333 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)); 343 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground));
334 SchedulePaint(); 344 SchedulePaint();
335 } 345 }
336 } 346 }
337 347
348 void BubbleFrameView::OnPaint(gfx::Canvas* canvas) {
349 OnPaintBackground(canvas);
350 // Border comes after children.
351 }
352
353 void BubbleFrameView::PaintChildren(const ui::PaintContext& context) {
354 NonClientFrameView::PaintChildren(context);
355
356 ui::PaintCache paint_cache;
357 ui::PaintRecorder recorder(context, size(), &paint_cache);
358 OnPaintBorder(recorder.canvas());
359 }
360
338 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) { 361 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) {
339 if (sender == close_) { 362 if (sender == close_) {
340 close_button_clicked_ = true; 363 close_button_clicked_ = true;
341 GetWidget()->Close(); 364 GetWidget()->Close();
342 } 365 }
343 } 366 }
344 367
345 void BubbleFrameView::SetBubbleBorder(scoped_ptr<BubbleBorder> border) { 368 void BubbleFrameView::SetBubbleBorder(scoped_ptr<BubbleBorder> border) {
346 bubble_border_ = border.get(); 369 bubble_border_ = border.get();
347 SetBorder(std::move(border)); 370 SetBorder(std::move(border));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 size.Enlarge(client_insets.width(), client_insets.height()); 512 size.Enlarge(client_insets.width(), client_insets.height());
490 size.SetToMax(gfx::Size(title_bar_width, 0)); 513 size.SetToMax(gfx::Size(title_bar_width, 0));
491 514
492 if (footnote_container_) 515 if (footnote_container_)
493 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); 516 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width()));
494 517
495 return size; 518 return size;
496 } 519 }
497 520
498 } // namespace views 521 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698