OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/bubble/bubble_delegate.h" | 5 #include "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 "views/bubble/bubble_frame_view.h" | 8 #include "views/bubble/bubble_frame_view.h" |
9 #include "views/widget/widget.h" | 9 #include "views/widget/widget.h" |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 BubbleDelegateView::BubbleDelegateView() | 76 BubbleDelegateView::BubbleDelegateView() |
77 : close_on_esc_(true), | 77 : close_on_esc_(true), |
78 close_on_deactivate_(true), | 78 close_on_deactivate_(true), |
79 allow_bubble_offscreen_(false), | 79 allow_bubble_offscreen_(false), |
80 anchor_view_(NULL), | 80 anchor_view_(NULL), |
81 arrow_location_(BubbleBorder::TOP_LEFT), | 81 arrow_location_(BubbleBorder::TOP_LEFT), |
82 color_(SK_ColorWHITE), | 82 color_(SK_ColorWHITE), |
83 border_widget_(NULL), | 83 border_widget_(NULL), |
84 use_focusless_(false) { | 84 use_focusless_(false) { |
85 set_background(views::Background::CreateSolidBackground(color_)); | 85 set_background(views::Background::CreateSolidBackground(color_)); |
86 AddAccelerator(Accelerator(ui::VKEY_ESCAPE, 0)); | 86 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); |
87 } | 87 } |
88 | 88 |
89 BubbleDelegateView::BubbleDelegateView( | 89 BubbleDelegateView::BubbleDelegateView( |
90 View* anchor_view, | 90 View* anchor_view, |
91 BubbleBorder::ArrowLocation arrow_location, | 91 BubbleBorder::ArrowLocation arrow_location, |
92 const SkColor& color) | 92 const SkColor& color) |
93 : close_on_esc_(true), | 93 : close_on_esc_(true), |
94 close_on_deactivate_(true), | 94 close_on_deactivate_(true), |
95 allow_bubble_offscreen_(false), | 95 allow_bubble_offscreen_(false), |
96 anchor_view_(anchor_view), | 96 anchor_view_(anchor_view), |
97 arrow_location_(arrow_location), | 97 arrow_location_(arrow_location), |
98 color_(color), | 98 color_(color), |
99 original_opacity_(255), | 99 original_opacity_(255), |
100 border_widget_(NULL), | 100 border_widget_(NULL), |
101 use_focusless_(false) { | 101 use_focusless_(false) { |
102 set_background(views::Background::CreateSolidBackground(color_)); | 102 set_background(views::Background::CreateSolidBackground(color_)); |
103 AddAccelerator(Accelerator(ui::VKEY_ESCAPE, 0)); | 103 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); |
104 } | 104 } |
105 | 105 |
106 BubbleDelegateView::~BubbleDelegateView() { | 106 BubbleDelegateView::~BubbleDelegateView() { |
107 if (border_widget_) | 107 if (border_widget_) |
108 border_widget_->Close(); | 108 border_widget_->Close(); |
109 } | 109 } |
110 | 110 |
111 // static | 111 // static |
112 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate) { | 112 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate) { |
113 bubble_delegate->Init(); | 113 bubble_delegate->Init(); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 void BubbleDelegateView::ResetFade() { | 211 void BubbleDelegateView::ResetFade() { |
212 fade_animation_.reset(); | 212 fade_animation_.reset(); |
213 if (border_widget_) | 213 if (border_widget_) |
214 border_widget_->SetOpacity(original_opacity_); | 214 border_widget_->SetOpacity(original_opacity_); |
215 GetWidget()->SetOpacity(original_opacity_); | 215 GetWidget()->SetOpacity(original_opacity_); |
216 } | 216 } |
217 | 217 |
218 bool BubbleDelegateView::AcceleratorPressed(const Accelerator& accelerator) { | 218 bool BubbleDelegateView::AcceleratorPressed( |
| 219 const ui::Accelerator& accelerator) { |
219 if (!close_on_esc() || accelerator.key_code() != ui::VKEY_ESCAPE) | 220 if (!close_on_esc() || accelerator.key_code() != ui::VKEY_ESCAPE) |
220 return false; | 221 return false; |
221 if (fade_animation_.get()) | 222 if (fade_animation_.get()) |
222 fade_animation_->Reset(); | 223 fade_animation_->Reset(); |
223 GetWidget()->Close(); | 224 GetWidget()->Close(); |
224 return true; | 225 return true; |
225 } | 226 } |
226 | 227 |
227 void BubbleDelegateView::Init() {} | 228 void BubbleDelegateView::Init() {} |
228 | 229 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 276 } |
276 | 277 |
277 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { | 278 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { |
278 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); | 279 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); |
279 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); | 280 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); |
280 return client_bounds; | 281 return client_bounds; |
281 } | 282 } |
282 #endif | 283 #endif |
283 | 284 |
284 } // namespace views | 285 } // namespace views |
OLD | NEW |