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

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

Issue 1028023002: Make the app list speech view query able to span multiple lines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@content_view_base_class
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/speech_view.h" 5 #include "ui/app_list/views/speech_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "ui/app_list/app_list_constants.h" 9 #include "ui/app_list/app_list_constants.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 container->AddChildView(indicator_); 131 container->AddChildView(indicator_);
132 132
133 MicButton* mic_button = new MicButton(this); 133 MicButton* mic_button = new MicButton(this);
134 mic_button_ = mic_button; 134 mic_button_ = mic_button;
135 container->AddChildView(mic_button_); 135 container->AddChildView(mic_button_);
136 mic_button_->SetEventTargeter( 136 mic_button_->SetEventTargeter(
137 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(mic_button))); 137 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(mic_button)));
138 138
139 // TODO(mukai): use BoundedLabel to cap 2 lines. 139 // TODO(mukai): use BoundedLabel to cap 2 lines.
140 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 140 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
141 // TODO(calamity): make this label multiline once Label caches its RenderText.
142 // See http://crbug.com/450791.
143 speech_result_ = new views::Label( 141 speech_result_ = new views::Label(
144 base::string16(), bundle.GetFontList(ui::ResourceBundle::LargeFont)); 142 base::string16(), bundle.GetFontList(ui::ResourceBundle::LargeFont));
143 speech_result_->SetMultiLine(true);
145 speech_result_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 144 speech_result_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
146 145
147 container->AddChildView(speech_result_); 146 container->AddChildView(speech_result_);
148 147
149 AddChildView(container); 148 AddChildView(container);
150 149
151 delegate_->GetSpeechUI()->AddObserver(this); 150 delegate_->GetSpeechUI()->AddObserver(this);
152 indicator_animator_.reset(new views::BoundsAnimator(container)); 151 indicator_animator_.reset(new views::BoundsAnimator(container));
153 indicator_animator_->SetAnimationDuration(kIndicatorAnimationDuration); 152 indicator_animator_->SetAnimationDuration(kIndicatorAnimationDuration);
154 indicator_animator_->set_tween_type(gfx::Tween::LINEAR); 153 indicator_animator_->set_tween_type(gfx::Tween::LINEAR);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } else { 215 } else {
217 indicator_->SetVisible(true); 216 indicator_->SetVisible(true);
218 indicator_->SetBoundsRect(indicator_bounds); 217 indicator_->SetBoundsRect(indicator_bounds);
219 } 218 }
220 } 219 }
221 220
222 void SpeechView::OnSpeechResult(const base::string16& result, 221 void SpeechView::OnSpeechResult(const base::string16& result,
223 bool is_final) { 222 bool is_final) {
224 speech_result_->SetText(result); 223 speech_result_->SetText(result);
225 speech_result_->SetEnabledColor(kResultTextColor); 224 speech_result_->SetEnabledColor(kResultTextColor);
225 Layout();
226 } 226 }
227 227
228 void SpeechView::OnSpeechRecognitionStateChanged( 228 void SpeechView::OnSpeechRecognitionStateChanged(
229 SpeechRecognitionState new_state) { 229 SpeechRecognitionState new_state) {
230 int resource_id = IDR_APP_LIST_SPEECH_MIC_OFF; 230 int resource_id = IDR_APP_LIST_SPEECH_MIC_OFF;
231 if (new_state == SPEECH_RECOGNITION_RECOGNIZING) 231 if (new_state == SPEECH_RECOGNITION_RECOGNIZING)
232 resource_id = IDR_APP_LIST_SPEECH_MIC_ON; 232 resource_id = IDR_APP_LIST_SPEECH_MIC_ON;
233 else if (new_state == SPEECH_RECOGNITION_IN_SPEECH) 233 else if (new_state == SPEECH_RECOGNITION_IN_SPEECH)
234 resource_id = IDR_APP_LIST_SPEECH_MIC_RECORDING; 234 resource_id = IDR_APP_LIST_SPEECH_MIC_RECORDING;
235 235
236 int text_resource_id = IDS_APP_LIST_SPEECH_HINT_TEXT; 236 int text_resource_id = IDS_APP_LIST_SPEECH_HINT_TEXT;
237 237
238 if (new_state == SPEECH_RECOGNITION_NETWORK_ERROR) { 238 if (new_state == SPEECH_RECOGNITION_NETWORK_ERROR) {
239 text_resource_id = IDS_APP_LIST_SPEECH_NETWORK_ERROR_HINT_TEXT; 239 text_resource_id = IDS_APP_LIST_SPEECH_NETWORK_ERROR_HINT_TEXT;
240 indicator_->SetVisible(false); 240 indicator_->SetVisible(false);
241 } 241 }
242 speech_result_->SetText(l10n_util::GetStringUTF16(text_resource_id)); 242 speech_result_->SetText(l10n_util::GetStringUTF16(text_resource_id));
243 speech_result_->SetEnabledColor(kHintTextColor); 243 speech_result_->SetEnabledColor(kHintTextColor);
244 244
245 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 245 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
246 mic_button_->SetImage(views::Button::STATE_NORMAL, 246 mic_button_->SetImage(views::Button::STATE_NORMAL,
247 bundle.GetImageSkiaNamed(resource_id)); 247 bundle.GetImageSkiaNamed(resource_id));
248 } 248 }
249 249
250 } // namespace app_list 250 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698