| 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/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
| 9 #include "ui/gfx/color_utils.h" | 9 #include "ui/gfx/color_utils.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 bubble_params.parent = bubble->anchor_widget()->GetNativeView(); | 38 bubble_params.parent = bubble->anchor_widget()->GetNativeView(); |
| 39 bubble_params.activatable = bubble->CanActivate() ? | 39 bubble_params.activatable = bubble->CanActivate() ? |
| 40 Widget::InitParams::ACTIVATABLE_YES : Widget::InitParams::ACTIVATABLE_NO; | 40 Widget::InitParams::ACTIVATABLE_YES : Widget::InitParams::ACTIVATABLE_NO; |
| 41 bubble->OnBeforeBubbleWidgetInit(&bubble_params, bubble_widget); | 41 bubble->OnBeforeBubbleWidgetInit(&bubble_params, bubble_widget); |
| 42 bubble_widget->Init(bubble_params); | 42 bubble_widget->Init(bubble_params); |
| 43 return bubble_widget; | 43 return bubble_widget; |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 // static |
| 49 const char BubbleDelegateView::kViewClassName[] = "BubbleDelegateView"; |
| 50 |
| 48 BubbleDelegateView::BubbleDelegateView() | 51 BubbleDelegateView::BubbleDelegateView() |
| 49 : close_on_esc_(true), | 52 : close_on_esc_(true), |
| 50 close_on_deactivate_(true), | 53 close_on_deactivate_(true), |
| 51 anchor_view_storage_id_(ViewStorage::GetInstance()->CreateStorageID()), | 54 anchor_view_storage_id_(ViewStorage::GetInstance()->CreateStorageID()), |
| 52 anchor_widget_(NULL), | 55 anchor_widget_(NULL), |
| 53 arrow_(BubbleBorder::TOP_LEFT), | 56 arrow_(BubbleBorder::TOP_LEFT), |
| 54 shadow_(BubbleBorder::SMALL_SHADOW), | 57 shadow_(BubbleBorder::SMALL_SHADOW), |
| 55 color_explicitly_set_(false), | 58 color_explicitly_set_(false), |
| 56 margins_(kDefaultMargin, kDefaultMargin, kDefaultMargin, kDefaultMargin), | 59 margins_(kDefaultMargin, kDefaultMargin, kDefaultMargin, kDefaultMargin), |
| 57 accept_events_(true), | 60 accept_events_(true), |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); | 137 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); |
| 135 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>( | 138 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>( |
| 136 new BubbleBorder(adjusted_arrow, shadow(), color()))); | 139 new BubbleBorder(adjusted_arrow, shadow(), color()))); |
| 137 return frame; | 140 return frame; |
| 138 } | 141 } |
| 139 | 142 |
| 140 void BubbleDelegateView::GetAccessibleState(ui::AXViewState* state) { | 143 void BubbleDelegateView::GetAccessibleState(ui::AXViewState* state) { |
| 141 state->role = ui::AX_ROLE_DIALOG; | 144 state->role = ui::AX_ROLE_DIALOG; |
| 142 } | 145 } |
| 143 | 146 |
| 147 const char* BubbleDelegateView::GetClassName() const { |
| 148 return kViewClassName; |
| 149 } |
| 150 |
| 144 void BubbleDelegateView::OnWidgetDestroying(Widget* widget) { | 151 void BubbleDelegateView::OnWidgetDestroying(Widget* widget) { |
| 145 if (anchor_widget() == widget) | 152 if (anchor_widget() == widget) |
| 146 SetAnchorView(NULL); | 153 SetAnchorView(NULL); |
| 147 } | 154 } |
| 148 | 155 |
| 149 void BubbleDelegateView::OnWidgetVisibilityChanging(Widget* widget, | 156 void BubbleDelegateView::OnWidgetVisibilityChanging(Widget* widget, |
| 150 bool visible) { | 157 bool visible) { |
| 151 #if defined(OS_WIN) | 158 #if defined(OS_WIN) |
| 152 // On Windows we need to handle this before the bubble is visible or hidden. | 159 // On Windows we need to handle this before the bubble is visible or hidden. |
| 153 // Please see the comment on the OnWidgetVisibilityChanging function. On | 160 // Please see the comment on the OnWidgetVisibilityChanging function. On |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 if (widget == GetWidget() && anchor_widget() && | 301 if (widget == GetWidget() && anchor_widget() && |
| 295 anchor_widget()->GetTopLevelWidget()) { | 302 anchor_widget()->GetTopLevelWidget()) { |
| 296 if (visible) | 303 if (visible) |
| 297 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); | 304 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); |
| 298 else | 305 else |
| 299 anchor_widget()->GetTopLevelWidget()->EnableInactiveRendering(); | 306 anchor_widget()->GetTopLevelWidget()->EnableInactiveRendering(); |
| 300 } | 307 } |
| 301 } | 308 } |
| 302 | 309 |
| 303 } // namespace views | 310 } // namespace views |
| OLD | NEW |