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

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

Issue 18003003: Message center re-organized (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments applied Created 7 years, 5 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 close_->set_border(NULL); 72 close_->set_border(NULL);
73 close_->SetVisible(false); 73 close_->SetVisible(false);
74 AddChildView(close_); 74 AddChildView(close_);
75 } 75 }
76 76
77 BubbleFrameView::~BubbleFrameView() {} 77 BubbleFrameView::~BubbleFrameView() {}
78 78
79 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { 79 gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
80 gfx::Rect client_bounds = GetLocalBounds(); 80 gfx::Rect client_bounds = GetLocalBounds();
81 client_bounds.Inset(GetInsets()); 81 client_bounds.Inset(GetInsets());
82 client_bounds.Inset(bubble_border_->GetInsets()); 82 if (bubble_border_)
83 client_bounds.Inset(bubble_border_->GetInsets());
dewittj 2013/07/02 18:43:32 Why are you changing bubble_frame_view?
sidharthms 2013/07/02 21:01:16 Done. This was not meant to be part of the change.
83 return client_bounds; 84 return client_bounds;
84 } 85 }
85 86
86 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds( 87 gfx::Rect BubbleFrameView::GetWindowBoundsForClientBounds(
87 const gfx::Rect& client_bounds) const { 88 const gfx::Rect& client_bounds) const {
88 return const_cast<BubbleFrameView*>(this)->GetUpdatedWindowBounds( 89 return const_cast<BubbleFrameView*>(this)->GetUpdatedWindowBounds(
89 gfx::Rect(), client_bounds.size(), false); 90 gfx::Rect(), client_bounds.size(), false);
90 } 91 }
91 92
92 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) { 93 int BubbleFrameView::NonClientHitTest(const gfx::Point& point) {
(...skipping 10 matching lines...) Expand all
103 return HTSYSMENU; 104 return HTSYSMENU;
104 if (point.y() < title_->bounds().bottom()) 105 if (point.y() < title_->bounds().bottom())
105 return HTCAPTION; 106 return HTCAPTION;
106 } 107 }
107 108
108 return GetWidget()->client_view()->NonClientHitTest(point); 109 return GetWidget()->client_view()->NonClientHitTest(point);
109 } 110 }
110 111
111 void BubbleFrameView::GetWindowMask(const gfx::Size& size, 112 void BubbleFrameView::GetWindowMask(const gfx::Size& size,
112 gfx::Path* window_mask) { 113 gfx::Path* window_mask) {
113 if (bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER) 114 if (bubble_border_ &&
115 bubble_border_->shadow() != BubbleBorder::NO_SHADOW_OPAQUE_BORDER)
114 return; 116 return;
115 117
116 // Use a window mask roughly matching the border in the image assets. 118 // Use a window mask roughly matching the border in the image assets.
117 static const int kBorderStrokeSize = 1; 119 static const int kBorderStrokeSize = 1;
118 static const SkScalar kCornerRadius = SkIntToScalar(6); 120 static const SkScalar kCornerRadius = SkIntToScalar(6);
119 gfx::Insets border_insets = bubble_border_->GetInsets(); 121 gfx::Insets border_insets = bubble_border_->GetInsets();
120 const SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize), 122 const SkRect rect = { SkIntToScalar(border_insets.left() - kBorderStrokeSize),
121 SkIntToScalar(border_insets.top() - kBorderStrokeSize), 123 SkIntToScalar(border_insets.top() - kBorderStrokeSize),
122 SkIntToScalar(size.width() - border_insets.right() + 124 SkIntToScalar(size.width() - border_insets.right() +
123 kBorderStrokeSize), 125 kBorderStrokeSize),
(...skipping 27 matching lines...) Expand all
151 if (close_->visible()) 153 if (close_->visible())
152 title_bar_width += close_->width() + 1; 154 title_bar_width += close_->width() + 1;
153 if (titlebar_extra_view_ != NULL) 155 if (titlebar_extra_view_ != NULL)
154 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); 156 title_bar_width += titlebar_extra_view_->GetPreferredSize().width();
155 size.SetToMax(gfx::Size(title_bar_width, 0)); 157 size.SetToMax(gfx::Size(title_bar_width, 0));
156 return size; 158 return size;
157 } 159 }
158 160
159 void BubbleFrameView::Layout() { 161 void BubbleFrameView::Layout() {
160 gfx::Rect bounds(GetLocalBounds()); 162 gfx::Rect bounds(GetLocalBounds());
161 bounds.Inset(border()->GetInsets()); 163 if (border())
164 bounds.Inset(border()->GetInsets());
162 // Small additional insets yield the desired 10px visual close button insets. 165 // Small additional insets yield the desired 10px visual close button insets.
163 bounds.Inset(0, 0, close_->width() + 1, 0); 166 bounds.Inset(0, 0, close_->width() + 1, 0);
164 close_->SetPosition(gfx::Point(bounds.right(), bounds.y() + 2)); 167 close_->SetPosition(gfx::Point(bounds.right(), bounds.y() + 2));
165 168
166 gfx::Rect title_bounds(bounds); 169 gfx::Rect title_bounds(bounds);
167 title_bounds.Inset(kTitleLeftInset, kTitleTopInset, 0, 0); 170 title_bounds.Inset(kTitleLeftInset, kTitleTopInset, 0, 0);
168 gfx::Size title_size(title_->GetPreferredSize()); 171 gfx::Size title_size(title_->GetPreferredSize());
169 const int title_width = std::max(0, close_->bounds().x() - title_bounds.x()); 172 const int title_width = std::max(0, close_->bounds().x() - title_bounds.x());
170 title_size.SetToMin(gfx::Size(title_width, title_size.height())); 173 title_size.SetToMin(gfx::Size(title_width, title_size.height()));
171 title_bounds.set_size(title_size); 174 title_bounds.set_size(title_size);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble 313 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble
311 // window needs to be moved to the right and that means we need to move arrow 314 // window needs to be moved to the right and that means we need to move arrow
312 // to the left, and that means negative offset. 315 // to the left, and that means negative offset.
313 bubble_border_->set_arrow_offset( 316 bubble_border_->set_arrow_offset(
314 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); 317 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust);
315 if (offscreen_adjust) 318 if (offscreen_adjust)
316 SchedulePaint(); 319 SchedulePaint();
317 } 320 }
318 321
319 } // namespace views 322 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698