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

Side by Side Diff: chrome/browser/ui/views/location_bar/search_token_view.cc

Issue 11418229: alternate ntp: implement right-aligned search token (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: impl new design to handle separator in layout system Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/location_bar/search_token_view.h"
6
7 #include "base/logging.h"
8 #include "grit/generated_resources.h"
9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/gfx/canvas.h"
11 #include "ui/views/controls/label.h"
12
13 SearchTokenView::SearchTokenView()
14 : label_(new views::Label()) {
15 label_->SetAutoColorReadabilityEnabled(false);
16 AddChildView(label_);
17 }
18
19 SearchTokenView::~SearchTokenView() {
20 }
21
22 void SearchTokenView::SetFont(const gfx::Font& font) {
23 label_->SetFont(font);
24 }
25
26 void SearchTokenView::SetBackgroundColor(SkColor color) {
27 label_->SetBackgroundColor(color);
28 }
29
30 void SearchTokenView::SetForegroundColor(SkColor color) {
31 label_->SetEnabledColor(color);
32 }
33
34 void SearchTokenView::SetSearchProvider(const string16& search_provider) {
35 if (search_provider_ == search_provider)
36 return;
37 search_provider_ = search_provider;
38 if (!search_provider_.empty()) {
39 label_->SetText(l10n_util::GetStringFUTF16(IDS_OMNIBOX_SEARCH_TOKEN_TEXT,
40 search_provider_));
41 }
42 }
43
44 gfx::Size SearchTokenView::GetPreferredSize() {
45 return label_->GetPreferredSize();
46 }
47
48 void SearchTokenView::Layout() {
49 label_->SetBounds(0, 0, label_->GetPreferredSize().width(), height());
50 }
51
52 void SearchTokenView::OnPaint(gfx::Canvas* canvas) {
53 // Paint the background color.
54 canvas->DrawColor(label_->background_color());
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698