| 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 "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/views/bubble/bubble_frame_view.h" | 8 #include "ui/views/bubble/bubble_frame_view.h" |
| 9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 // TODO(msw): Use NativeTheme/color_helper (crbug.com/105023). | 74 // TODO(msw): Use NativeTheme/color_helper (crbug.com/105023). |
| 75 const SkColor BubbleDelegateView::kBackgroundColor = SK_ColorWHITE; | 75 const SkColor BubbleDelegateView::kBackgroundColor = SK_ColorWHITE; |
| 76 | 76 |
| 77 BubbleDelegateView::BubbleDelegateView() | 77 BubbleDelegateView::BubbleDelegateView() |
| 78 : close_on_esc_(true), | 78 : close_on_esc_(true), |
| 79 close_on_deactivate_(true), | 79 close_on_deactivate_(true), |
| 80 allow_bubble_offscreen_(false), | 80 allow_bubble_offscreen_(false), |
| 81 anchor_view_(NULL), | 81 anchor_view_(NULL), |
| 82 arrow_location_(BubbleBorder::TOP_LEFT), | 82 arrow_location_(BubbleBorder::TOP_LEFT), |
| 83 color_(SK_ColorWHITE), | 83 color_(kBackgroundColor), |
| 84 original_opacity_(255), |
| 84 border_widget_(NULL), | 85 border_widget_(NULL), |
| 85 use_focusless_(false) { | 86 use_focusless_(false) { |
| 86 set_background(views::Background::CreateSolidBackground(color_)); | 87 set_background(views::Background::CreateSolidBackground(color_)); |
| 87 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); | 88 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); |
| 88 } | 89 } |
| 89 | 90 |
| 90 BubbleDelegateView::BubbleDelegateView( | 91 BubbleDelegateView::BubbleDelegateView( |
| 91 View* anchor_view, | 92 View* anchor_view, |
| 92 BubbleBorder::ArrowLocation arrow_location, | 93 BubbleBorder::ArrowLocation arrow_location) |
| 93 const SkColor& color) | |
| 94 : close_on_esc_(true), | 94 : close_on_esc_(true), |
| 95 close_on_deactivate_(true), | 95 close_on_deactivate_(true), |
| 96 allow_bubble_offscreen_(false), | 96 allow_bubble_offscreen_(false), |
| 97 anchor_view_(anchor_view), | 97 anchor_view_(anchor_view), |
| 98 arrow_location_(arrow_location), | 98 arrow_location_(arrow_location), |
| 99 color_(color), | 99 color_(kBackgroundColor), |
| 100 original_opacity_(255), | 100 original_opacity_(255), |
| 101 border_widget_(NULL), | 101 border_widget_(NULL), |
| 102 use_focusless_(false) { | 102 use_focusless_(false) { |
| 103 set_background(views::Background::CreateSolidBackground(color_)); | 103 set_background(views::Background::CreateSolidBackground(color_)); |
| 104 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); | 104 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, 0)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 BubbleDelegateView::~BubbleDelegateView() { | 107 BubbleDelegateView::~BubbleDelegateView() { |
| 108 if (border_widget_) | 108 if (border_widget_) |
| 109 border_widget_->Close(); | 109 border_widget_->Close(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 135 return this; | 135 return this; |
| 136 } | 136 } |
| 137 | 137 |
| 138 View* BubbleDelegateView::GetContentsView() { | 138 View* BubbleDelegateView::GetContentsView() { |
| 139 return this; | 139 return this; |
| 140 } | 140 } |
| 141 | 141 |
| 142 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView() { | 142 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView() { |
| 143 return new BubbleFrameView(GetArrowLocation(), | 143 return new BubbleFrameView(GetArrowLocation(), |
| 144 GetPreferredSize(), | 144 GetPreferredSize(), |
| 145 GetColor(), | 145 color(), |
| 146 allow_bubble_offscreen_); | 146 allow_bubble_offscreen()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, | 149 void BubbleDelegateView::OnWidgetActivationChanged(Widget* widget, |
| 150 bool active) { | 150 bool active) { |
| 151 if (close_on_deactivate() && widget == GetWidget() && !active) { | 151 if (close_on_deactivate() && widget == GetWidget() && !active) { |
| 152 GetWidget()->RemoveObserver(this); | 152 GetWidget()->RemoveObserver(this); |
| 153 GetWidget()->Close(); | 153 GetWidget()->Close(); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 170 anchor_view_->height() / 2); | 170 anchor_view_->height() / 2); |
| 171 } | 171 } |
| 172 View::ConvertPointToScreen(anchor_view(), &anchor); | 172 View::ConvertPointToScreen(anchor_view(), &anchor); |
| 173 return anchor; | 173 return anchor; |
| 174 } | 174 } |
| 175 | 175 |
| 176 BubbleBorder::ArrowLocation BubbleDelegateView::GetArrowLocation() const { | 176 BubbleBorder::ArrowLocation BubbleDelegateView::GetArrowLocation() const { |
| 177 return arrow_location_; | 177 return arrow_location_; |
| 178 } | 178 } |
| 179 | 179 |
| 180 SkColor BubbleDelegateView::GetColor() const { | |
| 181 return color_; | |
| 182 } | |
| 183 | |
| 184 void BubbleDelegateView::Show() { | 180 void BubbleDelegateView::Show() { |
| 185 if (border_widget_) | 181 if (border_widget_) |
| 186 border_widget_->Show(); | 182 border_widget_->Show(); |
| 187 GetWidget()->Show(); | 183 GetWidget()->Show(); |
| 188 GetFocusManager()->SetFocusedView(GetInitiallyFocusedView()); | 184 GetFocusManager()->SetFocusedView(GetInitiallyFocusedView()); |
| 189 if (anchor_view() && anchor_view()->GetWidget() && | 185 if (anchor_view() && anchor_view()->GetWidget() && |
| 190 anchor_view()->GetWidget()->GetTopLevelWidget()) | 186 anchor_view()->GetWidget()->GetTopLevelWidget()) |
| 191 anchor_view()->GetWidget()->GetTopLevelWidget()->DisableInactiveRendering(); | 187 anchor_view()->GetWidget()->GetTopLevelWidget()->DisableInactiveRendering(); |
| 192 } | 188 } |
| 193 | 189 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 278 |
| 283 #if defined(OS_WIN) && !defined(USE_AURA) | 279 #if defined(OS_WIN) && !defined(USE_AURA) |
| 284 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { | 280 gfx::Rect BubbleDelegateView::GetBubbleClientBounds() const { |
| 285 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); | 281 gfx::Rect client_bounds(GetBubbleFrameView()->GetBoundsForClientView()); |
| 286 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); | 282 client_bounds.Offset(border_widget_->GetWindowScreenBounds().origin()); |
| 287 return client_bounds; | 283 return client_bounds; |
| 288 } | 284 } |
| 289 #endif | 285 #endif |
| 290 | 286 |
| 291 } // namespace views | 287 } // namespace views |
| OLD | NEW |