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/views/search_box_view.h" | 5 #include "ui/app_list/views/search_box_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/app_list/app_list_model.h" | 10 #include "ui/app_list/app_list_model.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace { | 22 namespace { |
23 | 23 |
24 const int kPadding = 14; | 24 const int kPadding = 14; |
25 const int kIconDimension = 32; | 25 const int kIconDimension = 32; |
26 const int kPreferredWidth = 360; | 26 const int kPreferredWidth = 360; |
27 const int kPreferredHeight = 48; | 27 const int kPreferredHeight = 48; |
28 const int kMenuButtonDimension = 29; | 28 const int kMenuButtonDimension = 29; |
29 | 29 |
30 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); | 30 const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); |
31 | 31 |
| 32 // Menu offset relative to the bottom-right corner of the menu button. |
| 33 const int kMenuYOffsetFromButton = -4; |
| 34 const int kMenuXOffsetFromButton = -7; |
| 35 |
32 } // namespace | 36 } // namespace |
33 | 37 |
34 SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, | 38 SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, |
35 AppListViewDelegate* view_delegate, | 39 AppListViewDelegate* view_delegate, |
36 AppListModel* model) | 40 AppListModel* model) |
37 : delegate_(delegate), | 41 : delegate_(delegate), |
38 view_delegate_(view_delegate), | 42 view_delegate_(view_delegate), |
39 model_(model->search_box()), | 43 model_(model->search_box()), |
40 icon_view_(new views::ImageView), | 44 icon_view_(new views::ImageView), |
41 search_box_(new views::Textfield), | 45 search_box_(new views::Textfield), |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (contents_view_ && contents_view_->visible()) | 155 if (contents_view_ && contents_view_->visible()) |
152 handled = contents_view_->OnKeyPressed(key_event); | 156 handled = contents_view_->OnKeyPressed(key_event); |
153 | 157 |
154 return handled; | 158 return handled; |
155 } | 159 } |
156 | 160 |
157 void SearchBoxView::OnMenuButtonClicked(View* source, const gfx::Point& point) { | 161 void SearchBoxView::OnMenuButtonClicked(View* source, const gfx::Point& point) { |
158 if (!menu_) | 162 if (!menu_) |
159 menu_.reset(new AppListMenuViews(view_delegate_)); | 163 menu_.reset(new AppListMenuViews(view_delegate_)); |
160 | 164 |
161 menu_->RunMenuAt(menu_button_, | 165 const gfx::Point menu_location = |
162 menu_button_->GetBoundsInScreen().bottom_right()); | 166 menu_button_->GetBoundsInScreen().bottom_right() + |
| 167 gfx::Vector2d(kMenuXOffsetFromButton, kMenuYOffsetFromButton); |
| 168 menu_->RunMenuAt(menu_button_, menu_location); |
163 } | 169 } |
164 | 170 |
165 void SearchBoxView::IconChanged() { | 171 void SearchBoxView::IconChanged() { |
166 icon_view_->SetImage(model_->icon()); | 172 icon_view_->SetImage(model_->icon()); |
167 } | 173 } |
168 | 174 |
169 void SearchBoxView::HintTextChanged() { | 175 void SearchBoxView::HintTextChanged() { |
170 search_box_->set_placeholder_text(model_->hint_text()); | 176 search_box_->set_placeholder_text(model_->hint_text()); |
171 } | 177 } |
172 | 178 |
173 void SearchBoxView::SelectionModelChanged() { | 179 void SearchBoxView::SelectionModelChanged() { |
174 search_box_->SelectSelectionModel(model_->selection_model()); | 180 search_box_->SelectSelectionModel(model_->selection_model()); |
175 } | 181 } |
176 | 182 |
177 void SearchBoxView::TextChanged() { | 183 void SearchBoxView::TextChanged() { |
178 search_box_->SetText(model_->text()); | 184 search_box_->SetText(model_->text()); |
179 } | 185 } |
180 | 186 |
181 } // namespace app_list | 187 } // namespace app_list |
OLD | NEW |