| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/shelf/overflow_bubble_view.h" | 5 #include "ash/shelf/overflow_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_constants.h" | 10 #include "ash/shelf/shelf_constants.h" |
| 11 #include "ash/shelf/shelf_layout_manager.h" | 11 #include "ash/shelf/shelf_layout_manager.h" |
| 12 #include "ash/shelf/shelf_view.h" | 12 #include "ash/shelf/shelf_view.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/shell_window_ids.h" | 14 #include "ash/shell_window_ids.h" |
| 15 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 16 #include "ui/gfx/insets.h" | 16 #include "ui/gfx/insets.h" |
| 17 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 18 #include "ui/views/bubble/bubble_frame_view.h" | 18 #include "ui/views/bubble/bubble_frame_view.h" |
| 19 #include "ui/views/widget/widget.h" | 19 #include "ui/views/widget/widget.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace internal { | |
| 23 | |
| 24 namespace { | 22 namespace { |
| 25 | 23 |
| 26 // Max bubble size to screen size ratio. | 24 // Max bubble size to screen size ratio. |
| 27 const float kMaxBubbleSizeToScreenRatio = 0.5f; | 25 const float kMaxBubbleSizeToScreenRatio = 0.5f; |
| 28 | 26 |
| 29 // Inner padding in pixels for shelf view inside bubble. | 27 // Inner padding in pixels for shelf view inside bubble. |
| 30 const int kPadding = 2; | 28 const int kPadding = 2; |
| 31 | 29 |
| 32 // Padding space in pixels between ShelfView's left/top edge to its contents. | 30 // Padding space in pixels between ShelfView's left/top edge to its contents. |
| 33 const int kShelfViewLeadingInset = 8; | 31 const int kShelfViewLeadingInset = 8; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 // Makes bubble view has a layer and clip its children layers. | 56 // Makes bubble view has a layer and clip its children layers. |
| 59 SetPaintToLayer(true); | 57 SetPaintToLayer(true); |
| 60 SetFillsBoundsOpaquely(false); | 58 SetFillsBoundsOpaquely(false); |
| 61 layer()->SetMasksToBounds(true); | 59 layer()->SetMasksToBounds(true); |
| 62 | 60 |
| 63 shelf_view_ = shelf_view; | 61 shelf_view_ = shelf_view; |
| 64 AddChildView(shelf_view_); | 62 AddChildView(shelf_view_); |
| 65 | 63 |
| 66 set_parent_window(Shell::GetContainer( | 64 set_parent_window(Shell::GetContainer( |
| 67 anchor->GetWidget()->GetNativeWindow()->GetRootWindow(), | 65 anchor->GetWidget()->GetNativeWindow()->GetRootWindow(), |
| 68 internal::kShellWindowId_ShelfBubbleContainer)); | 66 kShellWindowId_ShelfBubbleContainer)); |
| 69 views::BubbleDelegateView::CreateBubble(this); | 67 views::BubbleDelegateView::CreateBubble(this); |
| 70 } | 68 } |
| 71 | 69 |
| 72 bool OverflowBubbleView::IsHorizontalAlignment() const { | 70 bool OverflowBubbleView::IsHorizontalAlignment() const { |
| 73 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); | 71 ShelfLayoutManager* shelf_layout_manager = GetShelfLayoutManager(); |
| 74 return shelf_layout_manager ? shelf_layout_manager->IsHorizontalAlignment() | 72 return shelf_layout_manager ? shelf_layout_manager->IsHorizontalAlignment() |
| 75 : false; | 73 : false; |
| 76 } | 74 } |
| 77 | 75 |
| 78 const gfx::Size OverflowBubbleView::GetContentsSize() const { | 76 const gfx::Size OverflowBubbleView::GetContentsSize() const { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 offset = monitor_rect.bottom() - bubble_rect.bottom(); | 214 offset = monitor_rect.bottom() - bubble_rect.bottom(); |
| 217 | 215 |
| 218 bubble_rect.Offset(0, offset); | 216 bubble_rect.Offset(0, offset); |
| 219 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); | 217 border->set_arrow_offset(anchor_rect.CenterPoint().y() - bubble_rect.y()); |
| 220 } | 218 } |
| 221 | 219 |
| 222 GetBubbleFrameView()->SchedulePaint(); | 220 GetBubbleFrameView()->SchedulePaint(); |
| 223 return bubble_rect; | 221 return bubble_rect; |
| 224 } | 222 } |
| 225 | 223 |
| 226 } // namespace internal | |
| 227 } // namespace ash | 224 } // namespace ash |
| OLD | NEW |