Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: ui/app_list/views/folder_header_view.cc

Issue 516943003: Add textfield internal padding from FocusableBorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update AppList's SearchBoxView and FolderHeaderView; git cl format. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 2 * views::Textfield::kTextPadding;
Peter Kasting 2014/09/05 22:56:49 Can this be calculated by setting |folder_name_vie
msw 2014/09/05 23:46:55 The preferred size of a textfield does not depend
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698