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

Unified Diff: ui/views/controls/textfield/textfield.cc

Issue 2406363003: Update appearance of invalid textfields in Harmony. (Closed)
Patch Set: combine install with setcolorid Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/examples/textfield_example.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index 107bea8e0249824f2ad2639d1bceadab55bd6502..4163c40a3742095f01fec3da7cf14d44db94aae4 100644
--- a/ui/views/controls/textfield/textfield.cc
+++ b/ui/views/controls/textfield/textfield.cc
@@ -252,6 +252,7 @@ Textfield::Textfield()
selection_text_color_(SK_ColorWHITE),
selection_background_color_(SK_ColorBLUE),
placeholder_text_color_(kDefaultPlaceholderTextColor),
+ invalid_(false),
text_input_type_(ui::TEXT_INPUT_TYPE_TEXT),
text_input_flags_(0),
performing_user_action_(false),
@@ -523,6 +524,19 @@ void Textfield::ApplyStyle(gfx::TextStyle style,
SchedulePaint();
}
+void Textfield::SetInvalid(bool invalid) {
+ if (invalid == invalid_)
+ return;
+ invalid_ = invalid;
+ UpdateBorder();
+
+ if (HasFocus() && use_focus_ring_) {
+ FocusRing::Install(this, invalid_
+ ? ui::NativeTheme::kColorId_AlertSeverityHigh
+ : ui::NativeTheme::kColorId_NumColors);
+ }
+}
+
void Textfield::ClearEditHistory() {
model_->ClearEditHistory();
}
@@ -996,8 +1010,11 @@ void Textfield::OnFocus() {
OnCaretBoundsChanged();
if (ShouldBlinkCursor())
StartBlinkingCursor();
- if (use_focus_ring_)
- FocusRing::Install(this);
+ if (use_focus_ring_) {
+ FocusRing::Install(this, invalid_
+ ? ui::NativeTheme::kColorId_AlertSeverityHigh
+ : ui::NativeTheme::kColorId_NumColors);
+ }
SchedulePaint();
View::OnFocus();
}
@@ -1815,6 +1832,13 @@ void Textfield::UpdateBackgroundColor() {
SchedulePaint();
}
+void Textfield::UpdateBorder() {
+ auto border = base::MakeUnique<views::FocusableBorder>();
+ if (invalid_)
+ border->SetColorId(ui::NativeTheme::kColorId_AlertSeverityHigh);
+ View::SetBorder(std::move(border));
+}
+
void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
if (text_changed) {
if (controller_)
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | ui/views/examples/textfield_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698