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

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 25039002: Always aligns text at vertically center (Textfield, Label). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 font_list_(GetDefaultFontList()), 84 font_list_(GetDefaultFontList()),
85 read_only_(false), 85 read_only_(false),
86 default_width_in_chars_(0), 86 default_width_in_chars_(0),
87 draw_border_(true), 87 draw_border_(true),
88 text_color_(SK_ColorBLACK), 88 text_color_(SK_ColorBLACK),
89 use_default_text_color_(true), 89 use_default_text_color_(true),
90 background_color_(SK_ColorWHITE), 90 background_color_(SK_ColorWHITE),
91 use_default_background_color_(true), 91 use_default_background_color_(true),
92 horizontal_margins_were_set_(false), 92 horizontal_margins_were_set_(false),
93 vertical_margins_were_set_(false), 93 vertical_margins_were_set_(false),
94 vertical_alignment_(gfx::ALIGN_VCENTER),
95 placeholder_text_color_(kDefaultPlaceholderTextColor), 94 placeholder_text_color_(kDefaultPlaceholderTextColor),
96 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), 95 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
97 weak_ptr_factory_(this) { 96 weak_ptr_factory_(this) {
98 set_focusable(true); 97 set_focusable(true);
99 98
100 if (ViewsDelegate::views_delegate) { 99 if (ViewsDelegate::views_delegate) {
101 obscured_reveal_duration_ = ViewsDelegate::views_delegate-> 100 obscured_reveal_duration_ = ViewsDelegate::views_delegate->
102 GetDefaultTextfieldObscuredRevealDuration(); 101 GetDefaultTextfieldObscuredRevealDuration();
103 } 102 }
104 } 103 }
105 104
106 Textfield::Textfield(StyleFlags style) 105 Textfield::Textfield(StyleFlags style)
107 : native_wrapper_(NULL), 106 : native_wrapper_(NULL),
108 controller_(NULL), 107 controller_(NULL),
109 style_(style), 108 style_(style),
110 font_list_(GetDefaultFontList()), 109 font_list_(GetDefaultFontList()),
111 read_only_(false), 110 read_only_(false),
112 default_width_in_chars_(0), 111 default_width_in_chars_(0),
113 draw_border_(true), 112 draw_border_(true),
114 text_color_(SK_ColorBLACK), 113 text_color_(SK_ColorBLACK),
115 use_default_text_color_(true), 114 use_default_text_color_(true),
116 background_color_(SK_ColorWHITE), 115 background_color_(SK_ColorWHITE),
117 use_default_background_color_(true), 116 use_default_background_color_(true),
118 horizontal_margins_were_set_(false), 117 horizontal_margins_were_set_(false),
119 vertical_margins_were_set_(false), 118 vertical_margins_were_set_(false),
120 vertical_alignment_(gfx::ALIGN_VCENTER),
121 placeholder_text_color_(kDefaultPlaceholderTextColor), 119 placeholder_text_color_(kDefaultPlaceholderTextColor),
122 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), 120 text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
123 weak_ptr_factory_(this) { 121 weak_ptr_factory_(this) {
124 set_focusable(true); 122 set_focusable(true);
125 if (IsObscured()) 123 if (IsObscured())
126 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 124 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
127 125
128 if (ViewsDelegate::views_delegate) { 126 if (ViewsDelegate::views_delegate) {
129 obscured_reveal_duration_ = ViewsDelegate::views_delegate-> 127 obscured_reveal_duration_ = ViewsDelegate::views_delegate->
130 GetDefaultTextfieldObscuredRevealDuration(); 128 GetDefaultTextfieldObscuredRevealDuration();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 298 }
301 299
302 void Textfield::SetVerticalMargins(int top, int bottom) { 300 void Textfield::SetVerticalMargins(int top, int bottom) {
303 margins_.Set(top, margins_.left(), bottom, margins_.right()); 301 margins_.Set(top, margins_.left(), bottom, margins_.right());
304 vertical_margins_were_set_ = true; 302 vertical_margins_were_set_ = true;
305 if (native_wrapper_) 303 if (native_wrapper_)
306 native_wrapper_->UpdateVerticalMargins(); 304 native_wrapper_->UpdateVerticalMargins();
307 PreferredSizeChanged(); 305 PreferredSizeChanged();
308 } 306 }
309 307
310 void Textfield::SetVerticalAlignment(gfx::VerticalAlignment alignment) {
311 vertical_alignment_ = alignment;
312 if (native_wrapper_)
313 native_wrapper_->UpdateVerticalAlignment();
314 }
315
316 void Textfield::RemoveBorder() { 308 void Textfield::RemoveBorder() {
317 if (!draw_border_) 309 if (!draw_border_)
318 return; 310 return;
319 311
320 draw_border_ = false; 312 draw_border_ = false;
321 if (native_wrapper_) 313 if (native_wrapper_)
322 native_wrapper_->UpdateBorder(); 314 native_wrapper_->UpdateBorder();
323 } 315 }
324 316
325 base::string16 Textfield::GetPlaceholderText() const { 317 base::string16 Textfield::GetPlaceholderText() const {
(...skipping 23 matching lines...) Expand all
349 native_wrapper_->UpdateText(); 341 native_wrapper_->UpdateText();
350 native_wrapper_->UpdateTextColor(); 342 native_wrapper_->UpdateTextColor();
351 native_wrapper_->UpdateBackgroundColor(); 343 native_wrapper_->UpdateBackgroundColor();
352 native_wrapper_->UpdateReadOnly(); 344 native_wrapper_->UpdateReadOnly();
353 native_wrapper_->UpdateFont(); 345 native_wrapper_->UpdateFont();
354 native_wrapper_->UpdateEnabled(); 346 native_wrapper_->UpdateEnabled();
355 native_wrapper_->UpdateBorder(); 347 native_wrapper_->UpdateBorder();
356 native_wrapper_->UpdateIsObscured(); 348 native_wrapper_->UpdateIsObscured();
357 native_wrapper_->UpdateHorizontalMargins(); 349 native_wrapper_->UpdateHorizontalMargins();
358 native_wrapper_->UpdateVerticalMargins(); 350 native_wrapper_->UpdateVerticalMargins();
359 native_wrapper_->UpdateVerticalAlignment();
360 } 351 }
361 } 352 }
362 353
363 void Textfield::SyncText() { 354 void Textfield::SyncText() {
364 if (native_wrapper_) { 355 if (native_wrapper_) {
365 string16 new_text = native_wrapper_->GetText(); 356 string16 new_text = native_wrapper_->GetText();
366 if (new_text != text_) { 357 if (new_text != text_) {
367 text_ = new_text; 358 text_ = new_text;
368 if (controller_) 359 if (controller_)
369 controller_->ContentsChanged(this, text_); 360 controller_->ContentsChanged(this, text_);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( 583 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
593 Textfield* field) { 584 Textfield* field) {
594 #if defined(OS_WIN) && !defined(USE_AURA) 585 #if defined(OS_WIN) && !defined(USE_AURA)
595 if (!Textfield::IsViewsTextfieldEnabled()) 586 if (!Textfield::IsViewsTextfieldEnabled())
596 return new NativeTextfieldWin(field); 587 return new NativeTextfieldWin(field);
597 #endif 588 #endif
598 return new NativeTextfieldViews(field); 589 return new NativeTextfieldViews(field);
599 } 590 }
600 591
601 } // namespace views 592 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698