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

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

Issue 10383236: Revert 137059 - Better fix for closing uber tray when clicking on Desktop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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_delegate.h ('k') | ui/views/widget/widget.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_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"
11 11
12 // The duration of the fade animation in milliseconds. 12 // The duration of the fade animation in milliseconds.
13 static const int kHideFadeDurationMS = 200; 13 static const int kHideFadeDurationMS = 200;
14 14
15 // The defaut margin between the content and the inside border, in pixels. 15 // The defaut margin between the content and the inside border, in pixels.
16 static const int kDefaultMargin = 6; 16 static const int kDefaultMargin = 6;
17 17
18 namespace views { 18 namespace views {
19 19
20 namespace { 20 namespace {
21 21
22 // Create a widget to host the bubble. 22 // Create a widget to host the bubble.
23 Widget* CreateBubbleWidget(BubbleDelegateView* bubble) { 23 Widget* CreateBubbleWidget(BubbleDelegateView* bubble) {
24 Widget* bubble_widget = new Widget(); 24 Widget* bubble_widget = new Widget();
25 Widget::InitParams bubble_params(Widget::InitParams::TYPE_BUBBLE); 25 Widget::InitParams bubble_params(Widget::InitParams::TYPE_BUBBLE);
26 bubble_params.delegate = bubble; 26 bubble_params.delegate = bubble;
27 bubble_params.transparent = true; 27 bubble_params.transparent = true;
28 bubble_params.close_on_deactivate = bubble->close_on_deactivate();
29 if (bubble->parent_window()) 28 if (bubble->parent_window())
30 bubble_params.parent = bubble->parent_window(); 29 bubble_params.parent = bubble->parent_window();
31 else 30 else
32 bubble_params.parent_widget = bubble->anchor_widget(); 31 bubble_params.parent_widget = bubble->anchor_widget();
33 if (bubble->use_focusless()) 32 if (bubble->use_focusless())
34 bubble_params.can_activate = false; 33 bubble_params.can_activate = false;
35 #if defined(OS_WIN) && !defined(USE_AURA) 34 #if defined(OS_WIN) && !defined(USE_AURA)
36 bubble_params.type = Widget::InitParams::TYPE_WINDOW_FRAMELESS; 35 bubble_params.type = Widget::InitParams::TYPE_WINDOW_FRAMELESS;
37 bubble_params.transparent = false; 36 bubble_params.transparent = false;
38 #endif 37 #endif
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 if (anchor_widget() && anchor_widget()->GetTopLevelWidget()) 205 if (anchor_widget() && anchor_widget()->GetTopLevelWidget())
207 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); 206 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering();
208 } else { 207 } else {
209 if (border_widget_) 208 if (border_widget_)
210 border_widget_->Hide(); 209 border_widget_->Hide();
211 if (anchor_widget()) 210 if (anchor_widget())
212 anchor_widget()->RemoveObserver(this); 211 anchor_widget()->RemoveObserver(this);
213 } 212 }
214 } 213 }
215 214
215 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget,
216 bool active) {
217 if (close_on_deactivate() && widget == GetWidget() && !active)
218 GetWidget()->Close();
219 }
220
216 void BubbleDelegateView::OnWidgetMoved(Widget* widget) { 221 void BubbleDelegateView::OnWidgetMoved(Widget* widget) {
217 if (move_with_anchor() && anchor_widget() == widget) 222 if (move_with_anchor() && anchor_widget() == widget)
218 SizeToContents(); 223 SizeToContents();
219 } 224 }
220 225
221 gfx::Rect BubbleDelegateView::GetAnchorRect() { 226 gfx::Rect BubbleDelegateView::GetAnchorRect() {
222 return anchor_view() ? anchor_view()->GetScreenBounds() : gfx::Rect(); 227 return anchor_view() ? anchor_view()->GetScreenBounds() : gfx::Rect();
223 } 228 }
224 229
225 void BubbleDelegateView::Show() { 230 void BubbleDelegateView::Show() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 331
327 #if defined(OS_WIN) && !defined(USE_AURA) 332 #if defined(OS_WIN) && !defined(USE_AURA)
328 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { 333 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const {
329 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); 334 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView());
330 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); 335 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin());
331 return client_bounds; 336 return client_bounds;
332 } 337 }
333 #endif 338 #endif
334 339
335 } // namespace views 340 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_delegate.h ('k') | ui/views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698