Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/app_list/views/folder_header_view.h" | 5 #include "ui/app_list/views/folder_header_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "ui/app_list/app_list_constants.h" | 11 #include "ui/app_list/app_list_constants.h" |
| 12 #include "ui/app_list/app_list_folder_item.h" | 12 #include "ui/app_list/app_list_folder_item.h" |
| 13 #include "ui/app_list/app_list_switches.h" | 13 #include "ui/app_list/app_list_switches.h" |
| 14 #include "ui/app_list/resources/grit/app_list_resources.h" | 14 #include "ui/app_list/resources/grit/app_list_resources.h" |
| 15 #include "ui/app_list/views/app_list_folder_view.h" | 15 #include "ui/app_list/views/app_list_folder_view.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 18 #include "ui/strings/grit/ui_strings.h" | 18 #include "ui/strings/grit/ui_strings.h" |
| 19 #include "ui/views/border.h" | 19 #include "ui/views/border.h" |
| 20 #include "ui/views/controls/button/image_button.h" | 20 #include "ui/views/controls/button/image_button.h" |
| 21 #include "ui/views/controls/textfield/textfield.h" | 21 #include "ui/views/controls/textfield/textfield.h" |
| 22 #include "ui/views/focus/focus_manager.h" | |
| 23 #include "ui/views/painter.h" | 22 #include "ui/views/painter.h" |
| 24 | 23 |
| 25 namespace app_list { | 24 namespace app_list { |
| 26 | 25 |
| 27 namespace { | 26 namespace { |
| 28 | 27 |
| 29 const int kPreferredWidth = 360; | 28 const int kPreferredWidth = 360; |
| 30 const int kPreferredHeight = 48; | 29 const int kPreferredHeight = 48; |
| 31 const int kBottomSeparatorHeight = 1; | 30 const int kBottomSeparatorHeight = 1; |
| 32 const int kMaxFolderNameWidth = 300; | 31 const int kMaxFolderNameWidth = 300; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 folder_name_visible_ = visible; | 88 folder_name_visible_ = visible; |
| 90 Update(); | 89 Update(); |
| 91 SchedulePaint(); | 90 SchedulePaint(); |
| 92 } | 91 } |
| 93 | 92 |
| 94 void FolderHeaderView::OnFolderItemRemoved() { | 93 void FolderHeaderView::OnFolderItemRemoved() { |
| 95 folder_item_ = NULL; | 94 folder_item_ = NULL; |
| 96 } | 95 } |
| 97 | 96 |
| 98 void FolderHeaderView::SetTextFocus() { | 97 void FolderHeaderView::SetTextFocus() { |
| 99 if (!folder_name_view_->HasFocus()) { | 98 folder_name_view_->RequestFocus(); |
|
sky
2017/03/10 15:45:03
There's no need to check if the view has focus. Fo
msw
2017/03/10 17:47:08
Acknowledged.
| |
| 100 views::FocusManager* focus_manager = GetFocusManager(); | |
| 101 if (focus_manager) | |
| 102 focus_manager->SetFocusedView(folder_name_view_); | |
| 103 } | |
| 104 } | 99 } |
| 105 | 100 |
| 106 bool FolderHeaderView::HasTextFocus() const { | 101 bool FolderHeaderView::HasTextFocus() const { |
| 107 return folder_name_view_->HasFocus(); | 102 return folder_name_view_->HasFocus(); |
| 108 } | 103 } |
| 109 | 104 |
| 110 void FolderHeaderView::Update() { | 105 void FolderHeaderView::Update() { |
| 111 if (!folder_item_) | 106 if (!folder_item_) |
| 112 return; | 107 return; |
| 113 | 108 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 void FolderHeaderView::ButtonPressed(views::Button* sender, | 206 void FolderHeaderView::ButtonPressed(views::Button* sender, |
| 212 const ui::Event& event) { | 207 const ui::Event& event) { |
| 213 delegate_->NavigateBack(folder_item_, event); | 208 delegate_->NavigateBack(folder_item_, event); |
| 214 } | 209 } |
| 215 | 210 |
| 216 void FolderHeaderView::ItemNameChanged() { | 211 void FolderHeaderView::ItemNameChanged() { |
| 217 Update(); | 212 Update(); |
| 218 } | 213 } |
| 219 | 214 |
| 220 } // namespace app_list | 215 } // namespace app_list |
| OLD | NEW |