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

Side by Side Diff: ash/app_list/search_box_view.cc

Issue 9479031: aura: Implement new app list mock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 8 years, 10 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
« no previous file with comments | « ash/app_list/search_box_view.h ('k') | ash/ash.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "ash/app_list/search_box_view.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "grit/ui_resources.h"
9 #include "ui/base/resource/resource_bundle.h"
10 #include "ui/gfx/image/image.h"
11 #include "ui/views/background.h"
12 #include "ui/views/border.h"
13 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/textfield/textfield.h"
15
16 namespace ash {
17
18 namespace {
19
20 const int kPadding = 9;
21
22 // 0.5 white
23 const SkColor kBorderColor = SkColorSetARGB(0x7F, 0xFF, 0xFF, 0xFF);
24
25 // 0.2 white
26 const SkColor kBackgroundColor = SkColorSetARGB(0x33, 0xFF, 0xFF, 0xFF);
27
28 // 0.9 white
29 const SkColor kTextColor = SkColorSetARGB(0xE5, 0xFF, 0xFF, 0xFF);
30
31 } // namespace
32
33 SearchBoxView::SearchBoxView() {
34 set_border(views::Border::CreateSolidBorder(1, kBorderColor));
35 set_background(views::Background::CreateSolidBackground(kBackgroundColor));
36
37 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
38
39 white_search_ = new views::ImageView;
40 white_search_->SetImage(
41 *rb.GetImageNamed(IDR_AURA_WHITE_SEARCH).ToSkBitmap());
42 AddChildView(white_search_);
43
44 search_box_ = new views::Textfield;
45 search_box_->RemoveBorder();
46 search_box_->SetBackgroundColor(0); // Clear color.
47 search_box_->SetTextColor(kTextColor);
48 search_box_->SetFont(rb.GetFont(ResourceBundle::BaseFont).DeriveFont(
49 2, gfx::Font::BOLD));
50 AddChildView(search_box_);
51 }
52
53 std::string SearchBoxView::search_text() const {
54 return UTF16ToUTF8(search_box_->text());
55 }
56
57 void SearchBoxView::Layout() {
58 gfx::Rect rect(GetContentsBounds());
59
60 gfx::Size icon_size = white_search_->GetPreferredSize();
61 gfx::Rect icon_frame(rect);
62 icon_frame.set_width(icon_size.width() + 2 * kPadding);
63 white_search_->SetBoundsRect(icon_frame);
64
65 gfx::Rect edit_frame(rect);
66 edit_frame.set_x(icon_frame.right());
67 edit_frame.set_width(rect.width() - icon_frame.width() - kPadding);
68 search_box_->SetBoundsRect(edit_frame);
69 }
70
71 void SearchBoxView::ContentsChanged(views::Textfield* sender,
72 const string16& new_contents) {
73 }
74
75 bool SearchBoxView::HandleKeyEvent(views::Textfield* sender,
76 const views::KeyEvent& key_event) {
77 return false;
78 }
79
80 } // namespace ash
OLDNEW
« no previous file with comments | « ash/app_list/search_box_view.h ('k') | ash/ash.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698