| 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/popup_message.h" |
| 6 | 6 |
| 7 #include "ash/wm/window_animations.h" | 7 #include "ash/wm/window_animations.h" |
| 8 #include "grit/ash_resources.h" | 8 #include "grit/ash_resources.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/geometry/insets.h" | 10 #include "ui/gfx/geometry/insets.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // views::View overrides: | 56 // views::View overrides: |
| 57 gfx::Size GetPreferredSize() const override; | 57 gfx::Size GetPreferredSize() const override; |
| 58 | 58 |
| 59 // Each component (width/height) can force a size override for that component | 59 // Each component (width/height) can force a size override for that component |
| 60 // if not 0. | 60 // if not 0. |
| 61 gfx::Size size_override_; | 61 gfx::Size size_override_; |
| 62 | 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(MessageBubble); | 63 DISALLOW_COPY_AND_ASSIGN(MessageBubble); |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 // static |
| 67 const int PopupMessage::kCaptionLabelID = 1000; |
| 68 const int PopupMessage::kMessageLabelID = 1001; |
| 69 |
| 66 PopupMessage::MessageBubble::MessageBubble(const base::string16& caption, | 70 PopupMessage::MessageBubble::MessageBubble(const base::string16& caption, |
| 67 const base::string16& message, | 71 const base::string16& message, |
| 68 IconType message_type, | 72 IconType message_type, |
| 69 views::View* anchor, | 73 views::View* anchor, |
| 70 views::BubbleBorder::Arrow arrow, | 74 views::BubbleBorder::Arrow arrow, |
| 71 const gfx::Size& size_override, | 75 const gfx::Size& size_override, |
| 72 int arrow_offset) | 76 int arrow_offset) |
| 73 : views::BubbleDelegateView(anchor, arrow), | 77 : views::BubbleDelegateView(anchor, arrow), |
| 74 size_override_(size_override) { | 78 size_override_(size_override) { |
| 75 gfx::Insets insets = gfx::Insets(kArrowOffsetTopBottom, | 79 gfx::Insets insets = gfx::Insets(kArrowOffsetTopBottom, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 125 |
| 122 // Create a container for the text items and use it as second column. | 126 // Create a container for the text items and use it as second column. |
| 123 views::View* details = new views::View(); | 127 views::View* details = new views::View(); |
| 124 AddChildView(details); | 128 AddChildView(details); |
| 125 details->SetLayoutManager(new views::BoxLayout( | 129 details->SetLayoutManager(new views::BoxLayout( |
| 126 views::BoxLayout::kVertical, 0, 0, kVerticalPopupPaddingBetweenItems)); | 130 views::BoxLayout::kVertical, 0, 0, kVerticalPopupPaddingBetweenItems)); |
| 127 | 131 |
| 128 // The caption label. | 132 // The caption label. |
| 129 if (!caption.empty()) { | 133 if (!caption.empty()) { |
| 130 views::Label* caption_label = new views::Label(caption); | 134 views::Label* caption_label = new views::Label(caption); |
| 135 caption_label->set_id(kCaptionLabelID); |
| 131 caption_label->SetMultiLine(true); | 136 caption_label->SetMultiLine(true); |
| 132 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 137 caption_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 133 caption_label->SetFontList( | 138 caption_label->SetFontList( |
| 134 bundle.GetFontList(ui::ResourceBundle::BoldFont)); | 139 bundle.GetFontList(ui::ResourceBundle::BoldFont)); |
| 135 caption_label->SetEnabledColor(kMessageTextColor); | 140 caption_label->SetEnabledColor(kMessageTextColor); |
| 136 details->AddChildView(caption_label); | 141 details->AddChildView(caption_label); |
| 137 } | 142 } |
| 138 | 143 |
| 139 // The message label. | 144 // The message label. |
| 140 if (!message.empty()) { | 145 if (!message.empty()) { |
| 141 views::Label* message_label = new views::Label(message); | 146 views::Label* message_label = new views::Label(message); |
| 147 message_label->set_id(kMessageLabelID); |
| 142 message_label->SetMultiLine(true); | 148 message_label->SetMultiLine(true); |
| 143 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 149 message_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 144 message_label->SetEnabledColor(kMessageTextColor); | 150 message_label->SetEnabledColor(kMessageTextColor); |
| 145 details->AddChildView(message_label); | 151 details->AddChildView(message_label); |
| 146 } | 152 } |
| 147 views::BubbleDelegateView::CreateBubble(this); | 153 views::BubbleDelegateView::CreateBubble(this); |
| 148 | 154 |
| 149 // Change the arrow offset if needed. | 155 // Change the arrow offset if needed. |
| 150 if (arrow_offset) { | 156 if (arrow_offset) { |
| 151 // With the creation of the bubble, the bubble got already placed (and | 157 // With the creation of the bubble, the bubble got already placed (and |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 void PopupMessage::CancelHidingAnimation() { | 223 void PopupMessage::CancelHidingAnimation() { |
| 218 if (!widget_ || !widget_->GetNativeView()) | 224 if (!widget_ || !widget_->GetNativeView()) |
| 219 return; | 225 return; |
| 220 | 226 |
| 221 gfx::NativeView native_view = widget_->GetNativeView(); | 227 gfx::NativeView native_view = widget_->GetNativeView(); |
| 222 wm::SetWindowVisibilityAnimationTransition( | 228 wm::SetWindowVisibilityAnimationTransition( |
| 223 native_view, wm::ANIMATE_NONE); | 229 native_view, wm::ANIMATE_NONE); |
| 224 } | 230 } |
| 225 | 231 |
| 226 } // namespace ash | 232 } // namespace ash |
| OLD | NEW |