Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: ash/popup_message.cc

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/popup_message.h ('k') | ash/popup_message_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 PopupMessage::MessageBubble::MessageBubble(const base::string16& caption, 71 PopupMessage::MessageBubble::MessageBubble(const base::string16& caption,
72 const base::string16& message, 72 const base::string16& message,
73 IconType message_type, 73 IconType message_type,
74 views::View* anchor, 74 views::View* anchor,
75 views::BubbleBorder::Arrow arrow, 75 views::BubbleBorder::Arrow arrow,
76 const gfx::Size& size_override, 76 const gfx::Size& size_override,
77 int arrow_offset) 77 int arrow_offset)
78 : views::BubbleDialogDelegateView(anchor, arrow), 78 : views::BubbleDialogDelegateView(anchor, arrow),
79 size_override_(size_override) { 79 size_override_(size_override) {
80 gfx::Insets insets = gfx::Insets(kArrowOffsetTopBottom, 80 gfx::Insets insets =
81 kArrowOffsetLeftRight, 81 gfx::Insets(kArrowOffsetTopBottom, kArrowOffsetLeftRight,
82 kArrowOffsetTopBottom, 82 kArrowOffsetTopBottom, kArrowOffsetLeftRight);
83 kArrowOffsetLeftRight);
84 // An anchor can have an asymmetrical border for spacing reasons. Adjust the 83 // An anchor can have an asymmetrical border for spacing reasons. Adjust the
85 // anchor location for this. 84 // anchor location for this.
86 if (anchor->border()) 85 if (anchor->border())
87 insets += anchor->border()->GetInsets(); 86 insets += anchor->border()->GetInsets();
88 87
89 set_anchor_view_insets(insets); 88 set_anchor_view_insets(insets);
90 set_close_on_deactivate(false); 89 set_close_on_deactivate(false);
91 set_can_activate(false); 90 set_can_activate(false);
92 set_accept_events(false); 91 set_accept_events(false);
93 92
(...skipping 16 matching lines...) Expand all
110 // | Message text which can be multi line | message_label 109 // | Message text which can be multi line | message_label
111 // | as well. | 110 // | as well. |
112 // | |- 111 // | |-
113 // +-------------------------------------------------+ 112 // +-------------------------------------------------+
114 // |------------details container--------------| 113 // |------------details container--------------|
115 // Note that the icon, caption and message are optional. 114 // Note that the icon, caption and message are optional.
116 115
117 // Add the icon to the first column (if there is one). 116 // Add the icon to the first column (if there is one).
118 if (message_type != ICON_NONE) { 117 if (message_type != ICON_NONE) {
119 views::ImageView* icon = new views::ImageView(); 118 views::ImageView* icon = new views::ImageView();
120 icon->SetImage( 119 icon->SetImage(bundle.GetImageNamed(IDR_AURA_WARNING_ICON).ToImageSkia());
121 bundle.GetImageNamed(IDR_AURA_WARNING_ICON).ToImageSkia());
122 icon->SetVerticalAlignment(views::ImageView::LEADING); 120 icon->SetVerticalAlignment(views::ImageView::LEADING);
123 AddChildView(icon); 121 AddChildView(icon);
124 } 122 }
125 123
126 // Create a container for the text items and use it as second column. 124 // Create a container for the text items and use it as second column.
127 views::View* details = new views::View(); 125 views::View* details = new views::View();
128 AddChildView(details); 126 AddChildView(details);
129 details->SetLayoutManager(new views::BoxLayout( 127 details->SetLayoutManager(new views::BoxLayout(
130 views::BoxLayout::kVertical, 0, 0, kVerticalPopupPaddingBetweenItems)); 128 views::BoxLayout::kVertical, 0, 0, kVerticalPopupPaddingBetweenItems));
131 129
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 189 }
192 190
193 PopupMessage::PopupMessage(const base::string16& caption, 191 PopupMessage::PopupMessage(const base::string16& caption,
194 const base::string16& message, 192 const base::string16& message,
195 IconType message_type, 193 IconType message_type,
196 views::View* anchor, 194 views::View* anchor,
197 views::BubbleBorder::Arrow arrow, 195 views::BubbleBorder::Arrow arrow,
198 const gfx::Size& size_override, 196 const gfx::Size& size_override,
199 int arrow_offset) 197 int arrow_offset)
200 : view_(NULL) { 198 : view_(NULL) {
201 view_ = new MessageBubble( 199 view_ = new MessageBubble(caption, message, message_type, anchor, arrow,
202 caption, message, message_type, anchor, arrow, size_override, 200 size_override, arrow_offset);
203 arrow_offset);
204 widget_ = view_->GetWidget(); 201 widget_ = view_->GetWidget();
205 202
206 gfx::NativeView native_view = widget_->GetNativeView(); 203 gfx::NativeView native_view = widget_->GetNativeView();
207 wm::SetWindowVisibilityAnimationType( 204 wm::SetWindowVisibilityAnimationType(
208 native_view, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL); 205 native_view, wm::WINDOW_VISIBILITY_ANIMATION_TYPE_VERTICAL);
209 wm::SetWindowVisibilityAnimationTransition( 206 wm::SetWindowVisibilityAnimationTransition(native_view, wm::ANIMATE_HIDE);
210 native_view, wm::ANIMATE_HIDE);
211 view_->GetWidget()->Show(); 207 view_->GetWidget()->Show();
212 } 208 }
213 209
214 PopupMessage::~PopupMessage() { 210 PopupMessage::~PopupMessage() {
215 CancelHidingAnimation(); 211 CancelHidingAnimation();
216 Close(); 212 Close();
217 } 213 }
218 214
219 void PopupMessage::Close() { 215 void PopupMessage::Close() {
220 if (view_) { 216 if (view_) {
221 view_->ClosePopup(); 217 view_->ClosePopup();
222 view_ = NULL; 218 view_ = NULL;
223 widget_ = NULL; 219 widget_ = NULL;
224 } 220 }
225 } 221 }
226 222
227 void PopupMessage::CancelHidingAnimation() { 223 void PopupMessage::CancelHidingAnimation() {
228 if (!widget_ || !widget_->GetNativeView()) 224 if (!widget_ || !widget_->GetNativeView())
229 return; 225 return;
230 226
231 gfx::NativeView native_view = widget_->GetNativeView(); 227 gfx::NativeView native_view = widget_->GetNativeView();
232 wm::SetWindowVisibilityAnimationTransition( 228 wm::SetWindowVisibilityAnimationTransition(native_view, wm::ANIMATE_NONE);
233 native_view, wm::ANIMATE_NONE);
234 } 229 }
235 230
236 } // namespace ash 231 } // namespace ash
OLDNEW
« no previous file with comments | « ash/popup_message.h ('k') | ash/popup_message_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698