| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/popup_message.h" | 5 #include "ash/common/popup_message.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_animations.h" | 7 #include "ash/common/wm_lookup.h" |
| 8 #include "ash/common/wm_window.h" |
| 8 #include "grit/ash_resources.h" | 9 #include "grit/ash_resources.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/geometry/insets.h" | 11 #include "ui/gfx/geometry/insets.h" |
| 11 #include "ui/views/bubble/bubble_dialog_delegate.h" | 12 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 12 #include "ui/views/bubble/bubble_frame_view.h" | 13 #include "ui/views/bubble/bubble_frame_view.h" |
| 13 #include "ui/views/controls/image_view.h" | 14 #include "ui/views/controls/image_view.h" |
| 14 #include "ui/views/controls/label.h" | 15 #include "ui/views/controls/label.h" |
| 15 #include "ui/views/layout/box_layout.h" | 16 #include "ui/views/layout/box_layout.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 #include "ui/wm/core/window_animations.h" |
| 17 | 19 |
| 18 namespace ash { | 20 namespace ash { |
| 19 namespace { | 21 namespace { |
| 20 const int kMessageTopBottomMargin = 10; | 22 const int kMessageTopBottomMargin = 10; |
| 21 const int kMessageLeftRightMargin = 10; | 23 const int kMessageLeftRightMargin = 10; |
| 22 const int kMessageMinHeight = 29 - 2 * kMessageTopBottomMargin; | 24 const int kMessageMinHeight = 29 - 2 * kMessageTopBottomMargin; |
| 23 const SkColor kMessageTextColor = SkColorSetRGB(0x22, 0x22, 0x22); | 25 const SkColor kMessageTextColor = SkColorSetRGB(0x22, 0x22, 0x22); |
| 24 | 26 |
| 25 // The maximum width of the Message bubble. Borrowed the value from | 27 // The maximum width of the Message bubble. Borrowed the value from |
| 26 // ash/message/message_controller.cc | 28 // ash/message/message_controller.cc |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 const base::string16& message, | 194 const base::string16& message, |
| 193 IconType message_type, | 195 IconType message_type, |
| 194 views::View* anchor, | 196 views::View* anchor, |
| 195 views::BubbleBorder::Arrow arrow, | 197 views::BubbleBorder::Arrow arrow, |
| 196 const gfx::Size& size_override, | 198 const gfx::Size& size_override, |
| 197 int arrow_offset) | 199 int arrow_offset) |
| 198 : view_(NULL) { | 200 : view_(NULL) { |
| 199 view_ = new MessageBubble(caption, message, message_type, anchor, arrow, | 201 view_ = new MessageBubble(caption, message, message_type, anchor, arrow, |
| 200 size_override, arrow_offset); | 202 size_override, arrow_offset); |
| 201 widget_ = view_->GetWidget(); | 203 widget_ = view_->GetWidget(); |
| 202 | 204 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget_); |
| 203 gfx::NativeView native_view = widget_->GetNativeView(); | 205 window->SetVisibilityAnimationType( |
| 204 wm::SetWindowVisibilityAnimationType( | 206 ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); |
| 205 native_view, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); | 207 window->SetVisibilityAnimationTransition(::wm::ANIMATE_HIDE); |
| 206 wm::SetWindowVisibilityAnimationTransition(native_view, wm::ANIMATE_HIDE); | |
| 207 view_->GetWidget()->Show(); | 208 view_->GetWidget()->Show(); |
| 208 } | 209 } |
| 209 | 210 |
| 210 PopupMessage::~PopupMessage() { | 211 PopupMessage::~PopupMessage() { |
| 211 CancelHidingAnimation(); | 212 CancelHidingAnimation(); |
| 212 Close(); | 213 Close(); |
| 213 } | 214 } |
| 214 | 215 |
| 215 void PopupMessage::Close() { | 216 void PopupMessage::Close() { |
| 216 if (view_) { | 217 if (view_) { |
| 217 view_->ClosePopup(); | 218 view_->ClosePopup(); |
| 218 view_ = NULL; | 219 view_ = NULL; |
| 219 widget_ = NULL; | 220 widget_ = NULL; |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 void PopupMessage::CancelHidingAnimation() { | 224 void PopupMessage::CancelHidingAnimation() { |
| 224 if (!widget_ || !widget_->GetNativeView()) | 225 if (!widget_) |
| 225 return; | 226 return; |
| 226 | 227 |
| 227 gfx::NativeView native_view = widget_->GetNativeView(); | 228 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget_); |
| 228 wm::SetWindowVisibilityAnimationTransition(native_view, wm::ANIMATE_NONE); | 229 if (window) |
| 230 window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
| 229 } | 231 } |
| 230 | 232 |
| 231 } // namespace ash | 233 } // namespace ash |
| OLD | NEW |