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 "ash/launcher/overflow_bubble.h" | 5 #include "ash/launcher/overflow_bubble.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher_types.h" | 9 #include "ash/launcher/launcher_types.h" |
10 #include "ash/launcher/launcher_view.h" | 10 #include "ash/launcher/launcher_view.h" |
11 #include "ui/gfx/insets.h" | 11 #include "ui/gfx/insets.h" |
12 #include "ui/gfx/screen.h" | 12 #include "ui/gfx/screen.h" |
13 #include "ui/views/bubble/bubble_delegate.h" | 13 #include "ui/views/bubble/bubble_delegate.h" |
14 #include "ui/views/bubble/bubble_frame_view.h" | 14 #include "ui/views/bubble/bubble_frame_view.h" |
15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
16 | 16 |
17 namespace ash { | 17 namespace ash { |
18 namespace internal { | 18 namespace internal { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // This should be the same color as the darkest launcher bar. | |
23 const SkColor kLauncherColor = SkColorSetARGB(0x80, 0, 0, 0); | |
24 | |
25 // Max bubble size to screen size ratio. | 22 // Max bubble size to screen size ratio. |
26 const float kMaxBubbleSizeToScreenRatio = 0.5f; | 23 const float kMaxBubbleSizeToScreenRatio = 0.5f; |
27 | 24 |
28 // Inner padding in pixels for launcher view inside bubble. | 25 // Inner padding in pixels for launcher view inside bubble. |
29 const int kPadding = 2; | 26 const int kPadding = 2; |
30 | 27 |
31 // Padding space in pixels between LauncherView's left/top edge to its contents. | 28 // Padding space in pixels between LauncherView's left/top edge to its contents. |
32 const int kLauncherViewLeadingInset = 8; | 29 const int kLauncherViewLeadingInset = 8; |
33 | 30 |
34 // Gets arrow location based on shelf alignment. | 31 // Gets arrow location based on shelf alignment. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 launcher_view_ = new LauncherView(model, delegate, NULL); | 111 launcher_view_ = new LauncherView(model, delegate, NULL); |
115 launcher_view_->set_first_visible_index(overflow_start_index); | 112 launcher_view_->set_first_visible_index(overflow_start_index); |
116 launcher_view_->set_leading_inset(kLauncherViewLeadingInset); | 113 launcher_view_->set_leading_inset(kLauncherViewLeadingInset); |
117 launcher_view_->Init(); | 114 launcher_view_->Init(); |
118 launcher_view_->SetAlignment(shelf_alignment); | 115 launcher_view_->SetAlignment(shelf_alignment); |
119 AddChildView(launcher_view_); | 116 AddChildView(launcher_view_); |
120 | 117 |
121 set_anchor_view(anchor); | 118 set_anchor_view(anchor); |
122 set_arrow_location(GetBubbleArrowLocation(shelf_alignment)); | 119 set_arrow_location(GetBubbleArrowLocation(shelf_alignment)); |
123 set_background(NULL); | 120 set_background(NULL); |
124 set_color(kLauncherColor); | 121 set_color(SkColorSetARGB(kLauncherBackgroundAlpha, 0, 0, 0)); |
125 set_margins(gfx::Insets(kPadding, kPadding, kPadding, kPadding)); | 122 set_margins(gfx::Insets(kPadding, kPadding, kPadding, kPadding)); |
126 set_move_with_anchor(true); | 123 set_move_with_anchor(true); |
127 views::BubbleDelegateView::CreateBubble(this); | 124 views::BubbleDelegateView::CreateBubble(this); |
128 } | 125 } |
129 | 126 |
130 void OverflowBubbleView::ScrollByXOffset(int x_offset) { | 127 void OverflowBubbleView::ScrollByXOffset(int x_offset) { |
131 const gfx::Rect visible_bounds(GetContentsBounds()); | 128 const gfx::Rect visible_bounds(GetContentsBounds()); |
132 const gfx::Size contents_size(GetContentsSize()); | 129 const gfx::Size contents_size(GetContentsSize()); |
133 | 130 |
134 int x = std::min(contents_size.width() - visible_bounds.width(), | 131 int x = std::min(contents_size.width() - visible_bounds.width(), |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 bubble_ = NULL; | 281 bubble_ = NULL; |
285 } | 282 } |
286 | 283 |
287 void OverflowBubble::OnWidgetClosing(views::Widget* widget) { | 284 void OverflowBubble::OnWidgetClosing(views::Widget* widget) { |
288 DCHECK(widget == bubble_->GetWidget()); | 285 DCHECK(widget == bubble_->GetWidget()); |
289 bubble_ = NULL; | 286 bubble_ = NULL; |
290 } | 287 } |
291 | 288 |
292 } // namespace internal | 289 } // namespace internal |
293 } // namespace ash | 290 } // namespace ash |
OLD | NEW |