Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 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 "chrome/browser/ui/views/location_bar/location_bar_view.h" | |
| 9 #include "grit/generated_resources.h" | |
| 10 #include "ui/base/l10n/l10n_util.h" | |
| 11 #include "ui/gfx/canvas.h" | |
| 12 #include "ui/views/controls/label.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // Paddings on the left and right of the label. | |
| 17 const int kLeftPadding = 25; | |
| 18 const int kRightPadding = 8; | |
|
Peter Kasting
2012/12/17 21:01:00
Don't do this for two reasons.
One is that these
kuan
2012/12/20 00:26:14
i've moved the paddings to location_bar_view.cc, b
Peter Kasting
2012/12/20 01:45:39
We shouldn't use different paddings than are avail
kuan
2012/12/20 16:51:22
i dug thru the iteration emails w/ cole and rememb
Peter Kasting
2012/12/20 19:15:07
Don't do this. The location height should have no
| |
| 19 | |
| 20 } // namespace | |
| 21 | |
| 22 SearchTokenView::SearchTokenView(const LocationBarView* location_bar_view) | |
| 23 : label_(new views::Label()) { | |
| 24 label_->SetAutoColorReadabilityEnabled(false); | |
| 25 label_->SetBackgroundColor(location_bar_view->GetColor( | |
| 26 ToolbarModel::NONE, LocationBarView::BACKGROUND)); | |
|
Peter Kasting
2012/12/17 21:01:00
NONE isn't right here (or below). We need to use
kuan
2012/12/20 00:26:14
Done.
| |
| 27 label_->SetEnabledColor(location_bar_view->GetColor( | |
| 28 ToolbarModel::NONE, LocationBarView::DEEMPHASIZED_TEXT)); | |
| 29 border_color_ = SkColorSetA(location_bar_view->GetColor( | |
| 30 ToolbarModel::NONE, LocationBarView::TEXT), 64); // 25% alpha. | |
|
Peter Kasting
2012/12/17 21:01:00
Turning off auto-color and manually alpha-blending
kuan
2012/12/20 00:26:14
i removed the disabling of auto-color. the reason
Peter Kasting
2012/12/20 01:45:39
Well, it shouldn't be as dark as the text, it shou
kuan
2012/12/20 16:51:22
i've disabled back auto-coloring. i meant the bor
| |
| 31 AddChildView(label_); | |
| 32 } | |
| 33 | |
| 34 SearchTokenView::~SearchTokenView() { | |
| 35 } | |
| 36 | |
| 37 void SearchTokenView::SetFont(const gfx::Font& font) { | |
| 38 label_->SetFont(font); | |
| 39 } | |
| 40 | |
| 41 void SearchTokenView::SetSearchProvider(const string16& search_provider) { | |
| 42 if (search_provider_ == search_provider) | |
| 43 return; | |
| 44 search_provider_ = search_provider; | |
| 45 if (!search_provider_.empty()) { | |
| 46 label_->SetText(l10n_util::GetStringFUTF16(IDS_OMNIBOX_SEARCH_TOKEN_TEXT, | |
| 47 search_provider_)); | |
| 48 } else { | |
| 49 SetVisible(false); | |
|
Peter Kasting
2012/12/17 21:01:00
It's not right for this class to set itself as inv
kuan
2012/12/20 00:26:14
Done.
| |
| 50 } | |
| 51 } | |
| 52 | |
| 53 gfx::Size SearchTokenView::GetPreferredSize() { | |
| 54 gfx::Size size = label_->GetPreferredSize(); | |
| 55 size.Enlarge(kLeftPadding + kRightPadding, 0); | |
| 56 return size; | |
| 57 } | |
| 58 | |
| 59 void SearchTokenView::Layout() { | |
| 60 label_->SetBounds(kLeftPadding, 0, label_->GetPreferredSize().width(), | |
| 61 height()); | |
| 62 } | |
| 63 | |
| 64 void SearchTokenView::OnPaintBorder(gfx::Canvas* canvas) { | |
|
Peter Kasting
2012/12/17 21:01:00
Instead of this, why don't you simply use a real b
kuan
2012/12/20 00:26:14
i tried that, but it paints a 2-px thick right bor
Peter Kasting
2012/12/20 01:45:39
You should add comments to this effect, since futu
kuan
2012/12/20 16:51:22
Done.
| |
| 65 SkPaint paint; | |
| 66 paint.setAntiAlias(false); | |
| 67 paint.setStrokeWidth(0); | |
| 68 paint.setColor(border_color_); | |
| 69 int right = width() - 1; | |
| 70 canvas->DrawLine(gfx::Point(right, 0), gfx::Point(right, height()), paint); | |
| 71 } | |
| OLD | NEW |