| 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 "ui/app_list/app_list_view.h" | 5 #include "ui/app_list/app_list_view.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "ui/app_list/app_list_bubble_border.h" | 8 #include "ui/app_list/app_list_bubble_border.h" |
| 9 #include "ui/app_list/app_list_constants.h" |
| 9 #include "ui/app_list/app_list_item_view.h" | 10 #include "ui/app_list/app_list_item_view.h" |
| 10 #include "ui/app_list/app_list_model.h" | 11 #include "ui/app_list/app_list_model.h" |
| 11 #include "ui/app_list/app_list_view_delegate.h" | 12 #include "ui/app_list/app_list_view_delegate.h" |
| 12 #include "ui/app_list/contents_view.h" | 13 #include "ui/app_list/contents_view.h" |
| 13 #include "ui/app_list/pagination_model.h" | 14 #include "ui/app_list/pagination_model.h" |
| 14 #include "ui/app_list/search_box_model.h" | 15 #include "ui/app_list/search_box_model.h" |
| 15 #include "ui/app_list/search_box_view.h" | 16 #include "ui/app_list/search_box_view.h" |
| 16 #include "ui/base/events/event.h" | 17 #include "ui/base/events/event.h" |
| 17 #include "ui/gfx/insets.h" | 18 #include "ui/gfx/insets.h" |
| 18 #include "ui/views/bubble/bubble_frame_view.h" | 19 #include "ui/views/bubble/bubble_frame_view.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 44 | 45 |
| 45 AppListView::~AppListView() { | 46 AppListView::~AppListView() { |
| 46 // Deletes all child views while the models are still valid. | 47 // Deletes all child views while the models are still valid. |
| 47 RemoveAllChildViews(true); | 48 RemoveAllChildViews(true); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void AppListView::InitAsBubble( | 51 void AppListView::InitAsBubble( |
| 51 gfx::NativeView parent, | 52 gfx::NativeView parent, |
| 52 PaginationModel* pagination_model, | 53 PaginationModel* pagination_model, |
| 53 views::View* anchor, | 54 views::View* anchor, |
| 55 const gfx::Point& anchor_point, |
| 54 views::BubbleBorder::ArrowLocation arrow_location) { | 56 views::BubbleBorder::ArrowLocation arrow_location) { |
| 57 #if defined(OS_WIN) |
| 58 set_background(views::Background::CreateSolidBackground( |
| 59 kContentsBackgroundColor)); |
| 60 #else |
| 55 set_background(NULL); | 61 set_background(NULL); |
| 62 #endif |
| 56 | 63 |
| 57 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 64 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, |
| 58 kInnerPadding, | 65 kInnerPadding, |
| 59 kInnerPadding, | 66 kInnerPadding, |
| 60 kInnerPadding)); | 67 kInnerPadding)); |
| 61 | 68 |
| 62 search_box_view_ = new SearchBoxView(this); | 69 search_box_view_ = new SearchBoxView(this); |
| 63 AddChildView(search_box_view_); | 70 AddChildView(search_box_view_); |
| 64 | 71 |
| 65 contents_view_ = new ContentsView(this, pagination_model); | 72 contents_view_ = new ContentsView(this, pagination_model); |
| 66 AddChildView(contents_view_); | 73 AddChildView(contents_view_); |
| 67 | 74 |
| 68 search_box_view_->set_contents_view(contents_view_); | 75 search_box_view_->set_contents_view(contents_view_); |
| 69 | 76 |
| 70 set_anchor_view(anchor); | 77 set_anchor_view(anchor); |
| 78 set_anchor_point(anchor_point); |
| 71 set_margins(gfx::Insets()); | 79 set_margins(gfx::Insets()); |
| 72 set_move_with_anchor(true); | 80 set_move_with_anchor(true); |
| 73 set_parent_window(parent); | 81 set_parent_window(parent); |
| 74 set_close_on_deactivate(false); | 82 set_close_on_deactivate(false); |
| 75 set_anchor_insets(gfx::Insets(kArrowOffset, kArrowOffset, kArrowOffset, | 83 set_anchor_insets(gfx::Insets(kArrowOffset, kArrowOffset, kArrowOffset, |
| 76 kArrowOffset)); | 84 kArrowOffset)); |
| 77 views::BubbleDelegateView::CreateBubble(this); | 85 views::BubbleDelegateView::CreateBubble(this); |
| 78 | 86 |
| 79 // Overrides border with AppListBubbleBorder. | 87 // Overrides border with AppListBubbleBorder. |
| 80 bubble_border_ = new AppListBubbleBorder(this, search_box_view_); | 88 bubble_border_ = new AppListBubbleBorder(this, search_box_view_); |
| 81 GetBubbleFrameView()->SetBubbleBorder(bubble_border_); | 89 GetBubbleFrameView()->SetBubbleBorder(bubble_border_); |
| 82 SetBubbleArrowLocation(arrow_location); | 90 SetBubbleArrowLocation(arrow_location); |
| 83 | 91 |
| 92 #if !defined(OS_WIN) |
| 84 // Resets default background since AppListBubbleBorder paints background. | 93 // Resets default background since AppListBubbleBorder paints background. |
| 85 GetBubbleFrameView()->set_background(NULL); | 94 GetBubbleFrameView()->set_background(NULL); |
| 86 | 95 |
| 87 contents_view_->SetPaintToLayer(true); | 96 contents_view_->SetPaintToLayer(true); |
| 88 contents_view_->SetFillsBoundsOpaquely(false); | 97 contents_view_->SetFillsBoundsOpaquely(false); |
| 89 contents_view_->layer()->SetMasksToBounds(true); | 98 contents_view_->layer()->SetMasksToBounds(true); |
| 99 #endif |
| 90 | 100 |
| 91 CreateModel(); | 101 CreateModel(); |
| 92 } | 102 } |
| 93 | 103 |
| 94 void AppListView::SetBubbleArrowLocation( | 104 void AppListView::SetBubbleArrowLocation( |
| 95 views::BubbleBorder::ArrowLocation arrow_location) { | 105 views::BubbleBorder::ArrowLocation arrow_location) { |
| 96 DCHECK(bubble_border_); | 106 DCHECK(bubble_border_); |
| 97 bubble_border_->set_arrow_location(arrow_location); | 107 bubble_border_->set_arrow_location(arrow_location); |
| 98 SizeToContents(); // Recalcuates with new border. | 108 SizeToContents(); // Recalcuates with new border. |
| 99 } | 109 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 119 contents_view_->SetModel(new_model.get()); | 129 contents_view_->SetModel(new_model.get()); |
| 120 | 130 |
| 121 model_.reset(new_model.release()); | 131 model_.reset(new_model.release()); |
| 122 } | 132 } |
| 123 } | 133 } |
| 124 | 134 |
| 125 views::View* AppListView::GetInitiallyFocusedView() { | 135 views::View* AppListView::GetInitiallyFocusedView() { |
| 126 return search_box_view_->search_box(); | 136 return search_box_view_->search_box(); |
| 127 } | 137 } |
| 128 | 138 |
| 139 gfx::ImageSkia AppListView::GetWindowAppIcon() { |
| 140 if (delegate_.get()) |
| 141 return delegate_->GetWindowAppIcon(); |
| 142 |
| 143 return gfx::ImageSkia(); |
| 144 } |
| 145 |
| 129 bool AppListView::HasHitTestMask() const { | 146 bool AppListView::HasHitTestMask() const { |
| 130 return true; | 147 return true; |
| 131 } | 148 } |
| 132 | 149 |
| 133 void AppListView::GetHitTestMask(gfx::Path* mask) const { | 150 void AppListView::GetHitTestMask(gfx::Path* mask) const { |
| 134 DCHECK(mask); | 151 DCHECK(mask); |
| 135 bubble_border_->GetMask(GetBubbleFrameView()->bounds(), mask); | 152 bubble_border_->GetMask(GetBubbleFrameView()->bounds(), mask); |
| 136 } | 153 } |
| 137 | 154 |
| 138 bool AppListView::OnKeyPressed(const ui::KeyEvent& event) { | 155 bool AppListView::OnKeyPressed(const ui::KeyEvent& event) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 215 } |
| 199 | 216 |
| 200 void AppListView::InvokeResultAction(const SearchResult& result, | 217 void AppListView::InvokeResultAction(const SearchResult& result, |
| 201 int action_index, | 218 int action_index, |
| 202 int event_flags) { | 219 int event_flags) { |
| 203 if (delegate_.get()) | 220 if (delegate_.get()) |
| 204 delegate_->InvokeSearchResultAction(result, action_index, event_flags); | 221 delegate_->InvokeSearchResultAction(result, action_index, event_flags); |
| 205 } | 222 } |
| 206 | 223 |
| 207 } // namespace app_list | 224 } // namespace app_list |
| OLD | NEW |