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

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

Issue 10025039: Reland Propagate OnNativeWidgetMove to delegate/observers, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename views::Widget::Observer::OnWidgetMoved to avoid conflicts with WidgetDelegate::OnWidgetMove. Created 8 years, 8 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_delegate.h ('k') | ui/views/bubble/bubble_frame_view.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_delegate.h" 5 #include "ui/views/bubble/bubble_delegate.h"
6 6
7 #include "ui/base/animation/slide_animation.h" 7 #include "ui/base/animation/slide_animation.h"
8 #include "ui/gfx/color_utils.h" 8 #include "ui/gfx/color_utils.h"
9 #include "ui/views/bubble/bubble_frame_view.h" 9 #include "ui/views/bubble/bubble_frame_view.h"
10 #include "ui/views/widget/widget.h" 10 #include "ui/views/widget/widget.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 View* BubbleDelegateView::GetContentsView() { 165 View* BubbleDelegateView::GetContentsView() {
166 return this; 166 return this;
167 } 167 }
168 168
169 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView( 169 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView(
170 Widget* widget) { 170 Widget* widget) {
171 return new BubbleFrameView(arrow_location(), color(), margin()); 171 return new BubbleFrameView(arrow_location(), color(), margin());
172 } 172 }
173 173
174 void BubbleDelegateView::OnWidgetClosing(Widget* widget) {
175 if (anchor_view() && anchor_view()->GetWidget() == widget)
176 anchor_view_ = NULL;
177 }
178
174 void BubbleDelegateView::OnWidgetVisibilityChanged(Widget* widget, 179 void BubbleDelegateView::OnWidgetVisibilityChanged(Widget* widget,
175 bool visible) { 180 bool visible) {
176 if (widget == GetWidget()) { 181 if (widget != GetWidget())
177 if (visible) { 182 return;
178 if (border_widget_) 183
179 border_widget_->Show(); 184 Widget* anchor_widget = anchor_view() ? anchor_view()->GetWidget() : NULL;
180 GetFocusManager()->SetFocusedView(GetInitiallyFocusedView()); 185 if (visible) {
181 Widget* anchor_widget = anchor_view() ? anchor_view()->GetWidget() : NULL; 186 if (border_widget_)
182 if (anchor_widget && anchor_widget->GetTopLevelWidget()) 187 border_widget_->Show();
183 anchor_widget->GetTopLevelWidget()->DisableInactiveRendering(); 188 if (anchor_widget)
184 } else if (border_widget_) { 189 anchor_widget->AddObserver(this);
190 GetFocusManager()->SetFocusedView(GetInitiallyFocusedView());
191 if (anchor_widget && anchor_widget->GetTopLevelWidget())
192 anchor_widget->GetTopLevelWidget()->DisableInactiveRendering();
193 } else {
194 if (border_widget_)
185 border_widget_->Hide(); 195 border_widget_->Hide();
186 } 196 if (anchor_widget)
197 anchor_widget->RemoveObserver(this);
187 } 198 }
188 } 199 }
189 200
190 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, 201 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget,
191 bool active) { 202 bool active) {
192 if (close_on_deactivate() && widget == GetWidget() && !active) 203 if (close_on_deactivate() && widget == GetWidget() && !active)
193 GetWidget()->Close(); 204 GetWidget()->Close();
194 } 205 }
195 206
207 void BubbleDelegateView::OnWidgetMoved(Widget* widget) {
208 if (anchor_view() && anchor_view()->GetWidget() == widget)
209 SizeToContents();
210 }
211
196 gfx::Rect BubbleDelegateView::GetAnchorRect() { 212 gfx::Rect BubbleDelegateView::GetAnchorRect() {
197 return anchor_view() ? anchor_view()->GetScreenBounds() : gfx::Rect(); 213 return anchor_view() ? anchor_view()->GetScreenBounds() : gfx::Rect();
198 } 214 }
199 215
200 void BubbleDelegateView::Show() { 216 void BubbleDelegateView::Show() {
201 GetWidget()->Show(); 217 GetWidget()->Show();
202 } 218 }
203 219
204 void BubbleDelegateView::StartFade(bool fade_in) { 220 void BubbleDelegateView::StartFade(bool fade_in) {
205 fade_animation_.reset(new ui::SlideAnimation(this)); 221 fade_animation_.reset(new ui::SlideAnimation(this));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 319
304 #if defined(OS_WIN) && !defined(USE_AURA) 320 #if defined(OS_WIN) && !defined(USE_AURA)
305 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { 321 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const {
306 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); 322 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView());
307 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); 323 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin());
308 return client_bounds; 324 return client_bounds;
309 } 325 }
310 #endif 326 #endif
311 327
312 } // namespace views 328 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_delegate.h ('k') | ui/views/bubble/bubble_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698