| 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/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 gfx::Rect back_bounds(rect); | 160 gfx::Rect back_bounds(rect); |
| 161 back_bounds.set_width(kIconDimension + 2 * kPadding); | 161 back_bounds.set_width(kIconDimension + 2 * kPadding); |
| 162 back_button_->SetBoundsRect(back_bounds); | 162 back_button_->SetBoundsRect(back_bounds); |
| 163 | 163 |
| 164 gfx::Rect text_bounds(rect); | 164 gfx::Rect text_bounds(rect); |
| 165 base::string16 text = folder_item_ && !folder_item_->name().empty() | 165 base::string16 text = folder_item_ && !folder_item_->name().empty() |
| 166 ? base::UTF8ToUTF16(folder_item_->name()) | 166 ? base::UTF8ToUTF16(folder_item_->name()) |
| 167 : folder_name_placeholder_text_; | 167 : folder_name_placeholder_text_; |
| 168 int text_width = | 168 int text_width = |
| 169 gfx::Canvas::GetStringWidth(text, folder_name_view_->GetFontList()) + | 169 gfx::Canvas::GetStringWidth(text, folder_name_view_->GetFontList()) + |
| 170 folder_name_view_->GetCaretBounds().width(); | 170 folder_name_view_->GetCaretBounds().width() + |
| 171 folder_name_view_->GetInsets().width(); |
| 171 text_width = std::min(text_width, kMaxFolderNameWidth); | 172 text_width = std::min(text_width, kMaxFolderNameWidth); |
| 172 text_bounds.set_x(back_bounds.x() + (rect.width() - text_width) / 2); | 173 text_bounds.set_x(back_bounds.x() + (rect.width() - text_width) / 2); |
| 173 text_bounds.set_width(text_width); | 174 text_bounds.set_width(text_width); |
| 174 text_bounds.ClampToCenteredSize(gfx::Size(text_bounds.width(), | 175 text_bounds.ClampToCenteredSize(gfx::Size(text_bounds.width(), |
| 175 folder_name_view_->GetPreferredSize().height())); | 176 folder_name_view_->GetPreferredSize().height())); |
| 176 folder_name_view_->SetBoundsRect(text_bounds); | 177 folder_name_view_->SetBoundsRect(text_bounds); |
| 177 } | 178 } |
| 178 | 179 |
| 179 bool FolderHeaderView::OnKeyPressed(const ui::KeyEvent& event) { | 180 bool FolderHeaderView::OnKeyPressed(const ui::KeyEvent& event) { |
| 180 if (event.key_code() == ui::VKEY_RETURN) | 181 if (event.key_code() == ui::VKEY_RETURN) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void FolderHeaderView::ButtonPressed(views::Button* sender, | 221 void FolderHeaderView::ButtonPressed(views::Button* sender, |
| 221 const ui::Event& event) { | 222 const ui::Event& event) { |
| 222 delegate_->NavigateBack(folder_item_, event); | 223 delegate_->NavigateBack(folder_item_, event); |
| 223 } | 224 } |
| 224 | 225 |
| 225 void FolderHeaderView::ItemNameChanged() { | 226 void FolderHeaderView::ItemNameChanged() { |
| 226 Update(); | 227 Update(); |
| 227 } | 228 } |
| 228 | 229 |
| 229 } // namespace app_list | 230 } // namespace app_list |
| OLD | NEW |