| OLD | NEW |
| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 anchor_widget_(NULL), | 109 anchor_widget_(NULL), |
| 110 move_with_anchor_(false), | 110 move_with_anchor_(false), |
| 111 arrow_location_(BubbleBorder::TOP_LEFT), | 111 arrow_location_(BubbleBorder::TOP_LEFT), |
| 112 color_(kBackgroundColor), | 112 color_(kBackgroundColor), |
| 113 margin_(kDefaultMargin), | 113 margin_(kDefaultMargin), |
| 114 original_opacity_(255), | 114 original_opacity_(255), |
| 115 border_widget_(NULL), | 115 border_widget_(NULL), |
| 116 use_focusless_(false), | 116 use_focusless_(false), |
| 117 parent_window_(NULL) { | 117 parent_window_(NULL) { |
| 118 set_background(views::Background::CreateSolidBackground(color_)); | 118 set_background(views::Background::CreateSolidBackground(color_)); |
| 119 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 119 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, |
| 120 ui::EF_NONE, |
| 121 ui::ET_KEY_PRESSED)); |
| 120 } | 122 } |
| 121 | 123 |
| 122 BubbleDelegateView::BubbleDelegateView( | 124 BubbleDelegateView::BubbleDelegateView( |
| 123 View* anchor_view, | 125 View* anchor_view, |
| 124 BubbleBorder::ArrowLocation arrow_location) | 126 BubbleBorder::ArrowLocation arrow_location) |
| 125 : close_on_esc_(true), | 127 : close_on_esc_(true), |
| 126 close_on_deactivate_(true), | 128 close_on_deactivate_(true), |
| 127 anchor_view_(anchor_view), | 129 anchor_view_(anchor_view), |
| 128 anchor_widget_(NULL), | 130 anchor_widget_(NULL), |
| 129 move_with_anchor_(false), | 131 move_with_anchor_(false), |
| 130 arrow_location_(arrow_location), | 132 arrow_location_(arrow_location), |
| 131 color_(kBackgroundColor), | 133 color_(kBackgroundColor), |
| 132 margin_(kDefaultMargin), | 134 margin_(kDefaultMargin), |
| 133 original_opacity_(255), | 135 original_opacity_(255), |
| 134 border_widget_(NULL), | 136 border_widget_(NULL), |
| 135 use_focusless_(false), | 137 use_focusless_(false), |
| 136 parent_window_(NULL) { | 138 parent_window_(NULL) { |
| 137 set_background(views::Background::CreateSolidBackground(color_)); | 139 set_background(views::Background::CreateSolidBackground(color_)); |
| 138 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE)); | 140 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, |
| 141 ui::EF_NONE, |
| 142 ui::ET_KEY_PRESSED)); |
| 139 } | 143 } |
| 140 | 144 |
| 141 BubbleDelegateView::~BubbleDelegateView() {} | 145 BubbleDelegateView::~BubbleDelegateView() {} |
| 142 | 146 |
| 143 // static | 147 // static |
| 144 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate) { | 148 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate) { |
| 145 bubble_delegate->Init(); | 149 bubble_delegate->Init(); |
| 146 // Determine the anchor widget from the anchor view at bubble creation time. | 150 // Determine the anchor widget from the anchor view at bubble creation time. |
| 147 bubble_delegate->anchor_widget_ = bubble_delegate->anchor_view() ? | 151 bubble_delegate->anchor_widget_ = bubble_delegate->anchor_view() ? |
| 148 bubble_delegate->anchor_view()->GetWidget() : NULL; | 152 bubble_delegate->anchor_view()->GetWidget() : NULL; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 | 335 |
| 332 #if defined(OS_WIN) && !defined(USE_AURA) | 336 #if defined(OS_WIN) && !defined(USE_AURA) |
| 333 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { | 337 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { |
| 334 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); | 338 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); |
| 335 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); | 339 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); |
| 336 return client_bounds; | 340 return client_bounds; |
| 337 } | 341 } |
| 338 #endif | 342 #endif |
| 339 | 343 |
| 340 } // namespace views | 344 } // namespace views |
| OLD | NEW |