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

Side by Side Diff: ash/system/tray/system_tray_bubble.cc

Issue 10384217: Add left/right layout support for uber tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: UpdateWidgetSize when layout manager is changed for systemtray and add test. Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/system_tray_bubble.h ('k') | ash/system/tray/tray_constants.h » ('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) 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 "ash/system/tray/system_tray_bubble.h" 5 #include "ash/system/tray/system_tray_bubble.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/system/tray/system_tray.h" 9 #include "ash/system/tray/system_tray.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
(...skipping 17 matching lines...) Expand all
28 #include "ui/views/layout/box_layout.h" 28 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/layout/fill_layout.h" 29 #include "ui/views/layout/fill_layout.h"
30 #include "ui/views/view.h" 30 #include "ui/views/view.h"
31 31
32 namespace ash { 32 namespace ash {
33 33
34 namespace { 34 namespace {
35 35
36 const int kShadowThickness = 4; 36 const int kShadowThickness = 4;
37 37
38 const int kLeftPadding = 4;
39 const int kBottomLineHeight = 1; 38 const int kBottomLineHeight = 1;
40 39
40 const int kSystemTrayBubbleHorizontalInset = 1;
41 const int kSystemTrayBubbleVerticalInset = 1;
42
41 const int kArrowHeight = 10; 43 const int kArrowHeight = 10;
42 const int kArrowWidth = 20; 44 const int kArrowWidth = 20;
43 const int kArrowPaddingFromRight = 20; 45 const int kArrowPaddingFromRight = 20;
46 const int kMinArrowOffset = 12;
44 47
45 const int kAnimationDurationForPopupMS = 200; 48 const int kAnimationDurationForPopupMS = 200;
46 49
47 const SkColor kShadowColor = SkColorSetARGB(0xff, 0, 0, 0); 50 const SkColor kShadowColor = SkColorSetARGB(0xff, 0, 0, 0);
48 51
49 void DrawBlurredShadowAroundView(gfx::Canvas* canvas, 52 void DrawBlurredShadowAroundView(gfx::Canvas* canvas,
50 int top, 53 int top,
51 int bottom, 54 int bottom,
52 int width, 55 int width,
53 const gfx::Insets& inset) { 56 const gfx::Insets& inset) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 canvas->FillRect(gfx::Rect(size()), 125 canvas->FillRect(gfx::Rect(size()),
123 hover_ ? kHoverBackgroundColor : kBackgroundColor); 126 hover_ ? kHoverBackgroundColor : kBackgroundColor);
124 } 127 }
125 } 128 }
126 129
127 bool hover_; 130 bool hover_;
128 131
129 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemContainer); 132 DISALLOW_COPY_AND_ASSIGN(TrayPopupItemContainer);
130 }; 133 };
131 134
132 class SystemTrayBubbleBackground : public views::Background { 135 class SystemTrayBubbleBorder : public views::BubbleBorder {
133 public: 136 public:
134 explicit SystemTrayBubbleBackground(views::View* owner) 137 SystemTrayBubbleBorder(views::View* owner,
135 : owner_(owner) { 138 views::BubbleBorder::ArrowLocation arrow_location,
139 int arrow_offset)
140 : views::BubbleBorder(arrow_location,
141 views::BubbleBorder::NO_SHADOW),
142 owner_(owner),
143 arrow_offset_(std::max(arrow_offset, kMinArrowOffset)) {
144 set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
136 } 145 }
137 146
138 virtual ~SystemTrayBubbleBackground() {} 147 virtual ~SystemTrayBubbleBorder() {}
139 148
140 private: 149 private:
141 // Overridden from views::Background. 150 void PaintChildBorder(gfx::Canvas* canvas) const {
142 virtual void Paint(gfx::Canvas* canvas, views::View* view) const OVERRIDE { 151 gfx::Insets insets;
152 GetInsets(&insets);
153 canvas->Save();
154 canvas->Translate(gfx::Point(insets.left(), insets.top()));
143 views::View* last_view = NULL; 155 views::View* last_view = NULL;
144 for (int i = 0; i < owner_->child_count(); i++) { 156 for (int i = 0; i < owner_->child_count(); i++) {
145 views::View* v = owner_->child_at(i); 157 views::View* v = owner_->child_at(i);
158 if (!v->visible())
159 continue;
146 160
147 if (!v->border()) { 161 if (!v->border()) {
148 canvas->DrawLine(gfx::Point(v->x(), v->y() - 1), 162 canvas->DrawLine(gfx::Point(v->x(), v->y() - 1),
149 gfx::Point(v->x() + v->width(), v->y() - 1), 163 gfx::Point(v->x() + v->width(), v->y() - 1),
150 !last_view || last_view->border() ? kBorderDarkColor : 164 !last_view || last_view->border() ? kBorderDarkColor :
151 kBorderLightColor); 165 kBorderLightColor);
152 } else if (last_view && !last_view->border()) { 166 } else if (last_view && !last_view->border()) {
153 canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1), 167 canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
154 gfx::Point(v->x() + v->width() + 1, v->y() - 1), 168 gfx::Point(v->x() + v->width() + 1, v->y() - 1),
155 kBorderDarkColor); 169 kBorderDarkColor);
156 } 170 }
157 171
158 canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1), 172 canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
159 gfx::Point(v->x() - 1, v->y() + v->height() + 1), 173 gfx::Point(v->x() - 1, v->y() + v->height() + 1),
160 kBorderDarkColor); 174 kBorderDarkColor);
161 canvas->DrawLine(gfx::Point(v->x() + v->width(), v->y() - 1), 175 canvas->DrawLine(gfx::Point(v->x() + v->width(), v->y() - 1),
162 gfx::Point(v->x() + v->width(), v->y() + v->height() + 1), 176 gfx::Point(v->x() + v->width(), v->y() + v->height() + 1),
163 kBorderDarkColor); 177 kBorderDarkColor);
164 last_view = v; 178 last_view = v;
165 } 179 }
180 canvas->Restore();
166 } 181 }
167 182
168 views::View* owner_;
169
170 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBackground);
171 };
172
173 class SystemTrayBubbleBorder : public views::BubbleBorder {
174 public:
175 enum ArrowType {
176 ARROW_TYPE_NONE,
177 ARROW_TYPE_BOTTOM,
178 };
179
180 SystemTrayBubbleBorder(views::View* owner,
181 ArrowType arrow_type,
182 int arrow_offset)
183 : views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT,
184 views::BubbleBorder::NO_SHADOW),
185 owner_(owner),
186 arrow_type_(arrow_type),
187 arrow_offset_(arrow_offset) {
188 set_alignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
189 }
190
191 virtual ~SystemTrayBubbleBorder() {}
192
193 private:
194 // Overridden from views::Border. 183 // Overridden from views::Border.
195 virtual void Paint(const views::View& view, 184 virtual void Paint(const views::View& view,
196 gfx::Canvas* canvas) const OVERRIDE { 185 gfx::Canvas* canvas) const OVERRIDE {
197 gfx::Insets inset; 186 gfx::Insets inset;
198 GetInsets(&inset); 187 GetInsets(&inset);
199 DrawBlurredShadowAroundView(canvas, 0, owner_->height(), owner_->width(), 188 DrawBlurredShadowAroundView(canvas, 0, owner_->height(), owner_->width(),
200 inset); 189 inset);
201 190
191 PaintChildBorder(canvas);
192
202 // Draw the bottom line. 193 // Draw the bottom line.
203 int y = owner_->height() + 1; 194 int y = owner_->height() + 1;
204 canvas->FillRect(gfx::Rect(kLeftPadding, y, owner_->width(), 195 canvas->FillRect(gfx::Rect(inset.left(), y, owner_->width(),
205 kBottomLineHeight), kBorderDarkColor); 196 kBottomLineHeight), kBorderDarkColor);
206 197
207 if (!Shell::GetInstance()->shelf()->IsVisible()) 198 if (!Shell::GetInstance()->shelf()->IsVisible() ||
199 arrow_location() == views::BubbleBorder::NONE)
208 return; 200 return;
209 201
210 // Draw the arrow. 202 // Draw the arrow after drawing child borders, so that the arrow can cover
211 if (arrow_type_ == ARROW_TYPE_BOTTOM) { 203 // the its overlap section with child border.
204 SkPath path;
205 path.incReserve(4);
206 if (arrow_location() == views::BubbleBorder::BOTTOM_RIGHT) {
212 int tip_x = base::i18n::IsRTL() ? arrow_offset_ : 207 int tip_x = base::i18n::IsRTL() ? arrow_offset_ :
213 owner_->width() - arrow_offset_; 208 owner_->width() - arrow_offset_;
214 if (tip_x < kArrowPaddingFromRight + kArrowWidth / 2) 209 if (tip_x < kArrowPaddingFromRight + kArrowWidth / 2)
215 tip_x = kArrowPaddingFromRight + kArrowWidth / 2; 210 tip_x = kArrowPaddingFromRight + kArrowWidth / 2;
216 if (tip_x > owner_->width() - kArrowPaddingFromRight - kArrowWidth / 2) 211 if (tip_x > owner_->width() - kArrowPaddingFromRight - kArrowWidth / 2)
217 tip_x = owner_->width() - kArrowPaddingFromRight - kArrowWidth / 2; 212 tip_x = owner_->width() - kArrowPaddingFromRight - kArrowWidth / 2;
218 int left_base_x = tip_x - kArrowWidth / 2; 213 int left_base_x = tip_x - kArrowWidth / 2;
219 int left_base_y = y; 214 int left_base_y = y;
220 int tip_y = left_base_y + kArrowHeight; 215 int tip_y = left_base_y + kArrowHeight;
221
222 SkPath path;
223 path.incReserve(4);
224 path.moveTo(SkIntToScalar(left_base_x), SkIntToScalar(left_base_y)); 216 path.moveTo(SkIntToScalar(left_base_x), SkIntToScalar(left_base_y));
225 path.lineTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y)); 217 path.lineTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y));
226 path.lineTo(SkIntToScalar(left_base_x + kArrowWidth), 218 path.lineTo(SkIntToScalar(left_base_x + kArrowWidth),
227 SkIntToScalar(left_base_y)); 219 SkIntToScalar(left_base_y));
220 } else if (arrow_location() == views::BubbleBorder::LEFT_BOTTOM) {
221 int tip_y = y - arrow_offset_;
222 int top_base_y = tip_y - kArrowWidth / 2;
223 int top_base_x = inset.left() + kSystemTrayBubbleHorizontalInset;
224 int tip_x = top_base_x - kArrowHeight;
225 path.moveTo(SkIntToScalar(top_base_x), SkIntToScalar(top_base_y));
226 path.lineTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y));
227 path.lineTo(SkIntToScalar(top_base_x),
228 SkIntToScalar(top_base_y + kArrowWidth));
229 } else if (arrow_location() == views::BubbleBorder::RIGHT_BOTTOM){
230 int tip_y = y - arrow_offset_;
231 int top_base_y = tip_y - kArrowWidth / 2;
232 int top_base_x = inset.left() + owner_->width() -
233 kSystemTrayBubbleHorizontalInset;
234 int tip_x = top_base_x + kArrowHeight;
235 path.moveTo(SkIntToScalar(top_base_x), SkIntToScalar(top_base_y));
236 path.lineTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y));
237 path.lineTo(SkIntToScalar(top_base_x),
238 SkIntToScalar(top_base_y + kArrowWidth));
239 }
228 240
229 SkPaint paint; 241 SkPaint paint;
230 paint.setStyle(SkPaint::kFill_Style); 242 paint.setStyle(SkPaint::kFill_Style);
231 paint.setColor(kHeaderBackgroundColorDark); 243 paint.setColor(kHeaderBackgroundColorDark);
232 canvas->DrawPath(path, paint); 244 canvas->DrawPath(path, paint);
233 245
234 // Now draw the arrow border. 246 // Now draw the arrow border.
235 paint.setStyle(SkPaint::kStroke_Style); 247 paint.setStyle(SkPaint::kStroke_Style);
236 paint.setColor(kBorderDarkColor); 248 paint.setColor(kBorderDarkColor);
237 canvas->DrawPath(path, paint); 249 canvas->DrawPath(path, paint);
238 } 250
239 } 251 }
240 252
241 views::View* owner_; 253 views::View* owner_;
242 ArrowType arrow_type_;
243 const int arrow_offset_; 254 const int arrow_offset_;
244 255
245 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBorder); 256 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleBorder);
246 }; 257 };
247 258
248 } // namespace 259 } // namespace
249 260
250 namespace internal { 261 namespace internal {
251 262
252 // SystemTrayBubbleView 263 // SystemTrayBubbleView
253 264
254 SystemTrayBubbleView::SystemTrayBubbleView(views::View* anchor, 265 SystemTrayBubbleView::SystemTrayBubbleView(views::View* anchor,
255 SystemTrayBubble* host, 266 views::BubbleBorder::ArrowLocation arrow_location,
256 bool can_activate) 267 SystemTrayBubble* host,
257 : views::BubbleDelegateView(anchor, views::BubbleBorder::BOTTOM_RIGHT), 268 bool can_activate)
269 : views::BubbleDelegateView(anchor, arrow_location),
258 host_(host), 270 host_(host),
259 can_activate_(can_activate) { 271 can_activate_(can_activate) {
260 set_margin(0); 272 set_margin(0);
261 set_parent_window(ash::Shell::GetInstance()->GetContainer( 273 set_parent_window(ash::Shell::GetInstance()->GetContainer(
262 ash::internal::kShellWindowId_SettingBubbleContainer)); 274 ash::internal::kShellWindowId_SettingBubbleContainer));
263 set_notify_enter_exit_on_child(true); 275 set_notify_enter_exit_on_child(true);
264 } 276 }
265 277
266 SystemTrayBubbleView::~SystemTrayBubbleView() { 278 SystemTrayBubbleView::~SystemTrayBubbleView() {
267 // Inform host items (models) that their views are being destroyed. 279 // Inform host items (models) that their views are being destroyed.
268 if (host_) 280 if (host_)
269 host_->DestroyItemViews(); 281 host_->DestroyItemViews();
270 } 282 }
271 283
272 void SystemTrayBubbleView::SetBubbleBorder(views::BubbleBorder* border) { 284 void SystemTrayBubbleView::SetBubbleBorder(views::BubbleBorder* border) {
273 GetBubbleFrameView()->SetBubbleBorder(border); 285 GetBubbleFrameView()->SetBubbleBorder(border);
274 } 286 }
275 287
276 void SystemTrayBubbleView::UpdateAnchor() { 288 void SystemTrayBubbleView::UpdateAnchor() {
277 SizeToContents(); 289 SizeToContents();
278 GetWidget()->GetRootView()->SchedulePaint(); 290 GetWidget()->GetRootView()->SchedulePaint();
279 } 291 }
280 292
281 void SystemTrayBubbleView::Init() { 293 void SystemTrayBubbleView::Init() {
282 views::BoxLayout* layout = 294 views::BoxLayout* layout =
283 new views::BoxLayout(views::BoxLayout::kVertical, 1, 1, 1); 295 new views::BoxLayout(views::BoxLayout::kVertical,
296 kSystemTrayBubbleHorizontalInset,
297 kSystemTrayBubbleVerticalInset,
298 1);
284 layout->set_spread_blank_space(true); 299 layout->set_spread_blank_space(true);
285 SetLayoutManager(layout); 300 SetLayoutManager(layout);
286 set_background(new SystemTrayBubbleBackground(this)); 301 set_background(NULL);
287 } 302 }
288 303
289 gfx::Rect SystemTrayBubbleView::GetAnchorRect() { 304 gfx::Rect SystemTrayBubbleView::GetAnchorRect() {
290 gfx::Rect rect; 305 gfx::Rect rect;
291 if (host_) 306 if (host_)
292 rect = host_->GetAnchorRect(); 307 rect = host_->GetAnchorRect();
308 // TODO(jennyz): May need to add left/right alignment in the following code.
293 if (rect.IsEmpty()) { 309 if (rect.IsEmpty()) {
294 rect = gfx::Screen::GetPrimaryMonitor().bounds(); 310 rect = gfx::Screen::GetPrimaryMonitor().bounds();
295 rect = gfx::Rect(base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreen : 311 rect = gfx::Rect(
296 rect.width() - kPaddingFromRightEdgeOfScreen, 312 base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreenBottomAlignment :
297 rect.height() - kPaddingFromBottomOfScreen, 313 rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
298 0, 0); 314 rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
315 0, 0);
299 } 316 }
300 return rect; 317 return rect;
301 } 318 }
302 319
303 void SystemTrayBubbleView::ChildPreferredSizeChanged(View* child) { 320 void SystemTrayBubbleView::ChildPreferredSizeChanged(View* child) {
304 SizeToContents(); 321 SizeToContents();
305 } 322 }
306 323
307 void SystemTrayBubbleView::GetAccessibleState(ui::AccessibleViewState* state) { 324 void SystemTrayBubbleView::GetAccessibleState(ui::AccessibleViewState* state) {
308 if (can_activate_) { 325 if (can_activate_) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 CreateItemViews(Shell::GetInstance()->tray_delegate()->GetUserLoginStatus()); 400 CreateItemViews(Shell::GetInstance()->tray_delegate()->GetUserLoginStatus());
384 bubble_widget_->GetContentsView()->Layout(); 401 bubble_widget_->GetContentsView()->Layout();
385 // Make sure that the bubble is large enough for the default view. 402 // Make sure that the bubble is large enough for the default view.
386 if (bubble_type_ == BUBBLE_TYPE_DEFAULT) 403 if (bubble_type_ == BUBBLE_TYPE_DEFAULT)
387 bubble_view_->SizeToContents(); 404 bubble_view_->SizeToContents();
388 } 405 }
389 406
390 void SystemTrayBubble::InitView(const InitParams& init_params) { 407 void SystemTrayBubble::InitView(const InitParams& init_params) {
391 DCHECK(bubble_view_ == NULL); 408 DCHECK(bubble_view_ == NULL);
392 anchor_type_ = init_params.anchor_type; 409 anchor_type_ = init_params.anchor_type;
410 views::BubbleBorder::ArrowLocation arrow_location;
411 if (anchor_type_ == ANCHOR_TYPE_TRAY) {
412 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
413 arrow_location = views::BubbleBorder::BOTTOM_RIGHT;
414 } else if (tray_->shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
415 arrow_location = views::BubbleBorder::LEFT_BOTTOM;
416 } else {
417 arrow_location = views::BubbleBorder::RIGHT_BOTTOM;
418 }
419 } else {
420 arrow_location = views::BubbleBorder::NONE;
421 }
393 bubble_view_ = new SystemTrayBubbleView( 422 bubble_view_ = new SystemTrayBubbleView(
394 init_params.anchor, this, init_params.can_activate); 423 init_params.anchor, arrow_location, this, init_params.can_activate);
395 if (bubble_type_ == BUBBLE_TYPE_NOTIFICATION) 424 if (bubble_type_ == BUBBLE_TYPE_NOTIFICATION)
396 bubble_view_->set_close_on_deactivate(false); 425 bubble_view_->set_close_on_deactivate(false);
397 426
398 CreateItemViews(init_params.login_status); 427 CreateItemViews(init_params.login_status);
399 428
400 DCHECK(bubble_widget_ == NULL); 429 DCHECK(bubble_widget_ == NULL);
401 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_); 430 bubble_widget_ = views::BubbleDelegateView::CreateBubble(bubble_view_);
402 431
403 // Must occur after call to CreateBubble() 432 // Must occur after call to CreateBubble()
404 bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 433 bubble_view_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
405 bubble_widget_->non_client_view()->frame_view()->set_background(NULL); 434 bubble_widget_->non_client_view()->frame_view()->set_background(NULL);
406 SystemTrayBubbleBorder::ArrowType arrow_type;
407 if (anchor_type_ == ANCHOR_TYPE_TRAY)
408 arrow_type = SystemTrayBubbleBorder::ARROW_TYPE_BOTTOM;
409 else
410 arrow_type = SystemTrayBubbleBorder::ARROW_TYPE_NONE;
411
412 SystemTrayBubbleBorder* bubble_border = new SystemTrayBubbleBorder( 435 SystemTrayBubbleBorder* bubble_border = new SystemTrayBubbleBorder(
413 bubble_view_, arrow_type, init_params.arrow_offset); 436 bubble_view_, arrow_location, init_params.arrow_offset);
414 bubble_view_->SetBubbleBorder(bubble_border); 437 bubble_view_->SetBubbleBorder(bubble_border);
415 438
416 bubble_widget_->AddObserver(this); 439 bubble_widget_->AddObserver(this);
417 440
418 // Setup animation. 441 // Setup animation.
419 ash::SetWindowVisibilityAnimationType( 442 ash::SetWindowVisibilityAnimationType(
420 bubble_widget_->GetNativeWindow(), 443 bubble_widget_->GetNativeWindow(),
421 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); 444 ash::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE);
422 ash::SetWindowVisibilityAnimationTransition( 445 ash::SetWindowVisibilityAnimationTransition(
423 bubble_widget_->GetNativeWindow(), 446 bubble_widget_->GetNativeWindow(),
424 ash::ANIMATE_BOTH); 447 ash::ANIMATE_BOTH);
425 ash::SetWindowVisibilityAnimationDuration( 448 ash::SetWindowVisibilityAnimationDuration(
426 bubble_widget_->GetNativeWindow(), 449 bubble_widget_->GetNativeWindow(),
427 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS)); 450 base::TimeDelta::FromMilliseconds(kAnimationDurationForPopupMS));
428 451
429 bubble_view_->Show(); 452 bubble_view_->Show();
430 } 453 }
431 454
432 gfx::Rect SystemTrayBubble::GetAnchorRect() const { 455 gfx::Rect SystemTrayBubble::GetAnchorRect() const {
433 gfx::Rect rect; 456 gfx::Rect rect;
434 views::Widget* widget = bubble_view()->anchor_widget(); 457 views::Widget* widget = bubble_view()->anchor_widget();
435 if (widget->IsVisible()) { 458 if (widget->IsVisible()) {
436 rect = widget->GetWindowScreenBounds(); 459 rect = widget->GetWindowScreenBounds();
437 if (anchor_type_ == ANCHOR_TYPE_TRAY) { 460 if (anchor_type_ == ANCHOR_TYPE_TRAY) {
438 rect.Inset( 461 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
439 base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreen : 0, 462 rect.Inset(
440 0, 463 base::i18n::IsRTL() ?
441 base::i18n::IsRTL() ? 0 : kPaddingFromRightEdgeOfScreen, 464 kPaddingFromRightEdgeOfScreenBottomAlignment : 0,
442 kPaddingFromBottomOfScreen); 465 0,
466 base::i18n::IsRTL() ?
467 0 : kPaddingFromRightEdgeOfScreenBottomAlignment,
468 kPaddingFromBottomOfScreenBottomAlignment);
469 } else if (tray_->shelf_alignment() == SHELF_ALIGNMENT_LEFT) {
470 rect.Inset(0, 0, kPaddingFromLeftEdgeOfScreenLeftAlignment,
471 kPaddingFromBottomOfScreenVerticalAlignment);
472 } else {
473 rect.Inset(-kPaddingFromRightEdgeOfScreenRightAlignment,
474 0, 0, kPaddingFromBottomOfScreenVerticalAlignment);
475 }
443 } else if (anchor_type_ == ANCHOR_TYPE_BUBBLE) { 476 } else if (anchor_type_ == ANCHOR_TYPE_BUBBLE) {
477 // TODO(jennyz): add left/right launcher support for notification bubble.
444 rect.Inset( 478 rect.Inset(
445 base::i18n::IsRTL() ? kShadowThickness - 1 : 0, 479 base::i18n::IsRTL() ? kShadowThickness - 1 : 0,
446 0, 480 0,
447 base::i18n::IsRTL() ? 0 : kShadowThickness - 1, 481 base::i18n::IsRTL() ? 0 : kShadowThickness - 1,
448 0); 482 0);
449 } 483 }
450 } 484 }
451 return rect; 485 return rect;
452 } 486 }
453 487
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 void SystemTrayBubble::OnWidgetVisibilityChanged(views::Widget* widget, 575 void SystemTrayBubble::OnWidgetVisibilityChanged(views::Widget* widget,
542 bool visible) { 576 bool visible) {
543 if (!visible) 577 if (!visible)
544 MessageLoopForUI::current()->RemoveObserver(this); 578 MessageLoopForUI::current()->RemoveObserver(this);
545 else 579 else
546 MessageLoopForUI::current()->AddObserver(this); 580 MessageLoopForUI::current()->AddObserver(this);
547 } 581 }
548 582
549 } // namespace internal 583 } // namespace internal
550 } // namespace ash 584 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_bubble.h ('k') | ash/system/tray/tray_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698