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

Side by Side Diff: chrome/browser/ui/views/find_bar_view.cc

Issue 10908234: Add high DPI assets and update defaults for CrOS find in page bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use new find bar assets on cros only. Created 8 years, 3 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 | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/ui/views/find_bar_view.h" 5 #include "chrome/browser/ui/views/find_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 30 matching lines...) Expand all
41 static const int kMarginRightOfCloseButton = 7; 41 static const int kMarginRightOfCloseButton = 7;
42 static const int kMarginLeftOfFindTextfield = 12; 42 static const int kMarginLeftOfFindTextfield = 12;
43 43
44 // The margins around the match count label (We add extra space so that the 44 // The margins around the match count label (We add extra space so that the
45 // background highlight extends beyond just the text). 45 // background highlight extends beyond just the text).
46 static const int kMatchCountExtraWidth = 9; 46 static const int kMatchCountExtraWidth = 9;
47 47
48 // Minimum width for the match count label. 48 // Minimum width for the match count label.
49 static const int kMatchCountMinWidth = 30; 49 static const int kMatchCountMinWidth = 30;
50 50
51 // The background color of the find box.
52 static const SkColor kFindBoxBackgroundColor = SkColorSetARGB(0, 255, 255, 255);
53
51 // The text color for the match count label. 54 // The text color for the match count label.
52 static const SkColor kTextColorMatchCount = SkColorSetRGB(178, 178, 178); 55 static const SkColor kTextColorMatchCount = SkColorSetRGB(178, 178, 178);
53 56
54 // The text color for the match count label when no matches are found. 57 // The text color for the match count label when no matches are found.
55 static const SkColor kTextColorNoMatch = SK_ColorBLACK; 58 static const SkColor kTextColorNoMatch = SK_ColorBLACK;
56 59
57 // The background color of the match count label when results are found. 60 // The background color of the match count label when results are found.
58 static const SkColor kBackgroundColorMatch = SK_ColorWHITE; 61 static const SkColor kBackgroundColorMatch = SkColorSetARGB(0, 255, 255, 255);
59 62
60 // The background color of the match count label when no results are found. 63 // The background color of the match count label when no results are found.
61 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); 64 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102);
62 65
63 // The default number of average characters that the text box will be. This 66 // The default number of average characters that the text box will be. This
64 // number brings the width on a "regular fonts" system to about 300px. 67 // number brings the width on a "regular fonts" system to about 300px.
65 static const int kDefaultCharWidth = 43; 68 static const int kDefaultCharWidth = 43;
66 69
67 //////////////////////////////////////////////////////////////////////////////// 70 ////////////////////////////////////////////////////////////////////////////////
68 // FindBarView, public: 71 // FindBarView, public:
69 72
70 FindBarView::FindBarView(FindBarHost* host) 73 FindBarView::FindBarView(FindBarHost* host)
71 : DropdownBarView(host), 74 : DropdownBarView(host),
72 find_text_(NULL), 75 find_text_(NULL),
73 match_count_text_(NULL), 76 match_count_text_(NULL),
74 focus_forwarder_view_(NULL), 77 focus_forwarder_view_(NULL),
75 find_previous_button_(NULL), 78 find_previous_button_(NULL),
76 find_next_button_(NULL), 79 find_next_button_(NULL),
77 close_button_(NULL), 80 close_button_(NULL),
78 text_box_background_(NULL), 81 text_box_background_(NULL),
79 text_box_background_left_(NULL) { 82 text_box_background_left_(NULL) {
80 set_id(VIEW_ID_FIND_IN_PAGE); 83 set_id(VIEW_ID_FIND_IN_PAGE);
81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 84 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
82 85
83 find_text_ = new SearchTextfieldView(); 86 find_text_ = new SearchTextfieldView();
87 find_text_->SetBackgroundColor(kFindBoxBackgroundColor);
sky 2012/09/14 21:57:30 Don't you only want this for chromeos?
flackr 2012/09/15 01:46:34 It doesn't change the appearance on Windows since
84 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); 88 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
85 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); 89 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont));
86 find_text_->set_default_width_in_chars(kDefaultCharWidth); 90 find_text_->set_default_width_in_chars(kDefaultCharWidth);
87 find_text_->SetController(this); 91 find_text_->SetController(this);
88 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); 92 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND));
89 AddChildView(find_text_); 93 AddChildView(find_text_);
90 94
91 match_count_text_ = new views::Label(); 95 match_count_text_ = new views::Label();
92 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); 96 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont));
93 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); 97 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER);
94 AddChildView(match_count_text_); 98 AddChildView(match_count_text_);
95 99
96 // Create a focus forwarder view which sends focus to find_text_. 100 // Create a focus forwarder view which sends focus to find_text_.
97 focus_forwarder_view_ = new FocusForwarderView(find_text_); 101 focus_forwarder_view_ = new FocusForwarderView(find_text_);
98 AddChildView(focus_forwarder_view_); 102 AddChildView(focus_forwarder_view_);
99 103
100 find_previous_button_ = new views::ImageButton(this); 104 find_previous_button_ = new views::ImageButton(this);
101 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); 105 find_previous_button_->set_tag(FIND_PREVIOUS_TAG);
102 find_previous_button_->set_focusable(true); 106 find_previous_button_->set_focusable(true);
103 find_previous_button_->SetImage(views::CustomButton::BS_NORMAL, 107 find_previous_button_->SetImage(views::CustomButton::BS_NORMAL,
104 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV)); 108 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV));
105 find_previous_button_->SetImage(views::CustomButton::BS_HOT, 109 find_previous_button_->SetImage(views::CustomButton::BS_HOT,
106 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_H)); 110 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_H));
111 find_previous_button_->SetImage(views::CustomButton::BS_PUSHED,
112 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_P));
107 find_previous_button_->SetImage(views::CustomButton::BS_DISABLED, 113 find_previous_button_->SetImage(views::CustomButton::BS_DISABLED,
108 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_P)); 114 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_D));
109 find_previous_button_->SetTooltipText( 115 find_previous_button_->SetTooltipText(
110 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); 116 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP));
111 find_previous_button_->SetAccessibleName( 117 find_previous_button_->SetAccessibleName(
112 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); 118 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS));
113 AddChildView(find_previous_button_); 119 AddChildView(find_previous_button_);
114 120
115 find_next_button_ = new views::ImageButton(this); 121 find_next_button_ = new views::ImageButton(this);
116 find_next_button_->set_tag(FIND_NEXT_TAG); 122 find_next_button_->set_tag(FIND_NEXT_TAG);
117 find_next_button_->set_focusable(true); 123 find_next_button_->set_focusable(true);
118 find_next_button_->SetImage(views::CustomButton::BS_NORMAL, 124 find_next_button_->SetImage(views::CustomButton::BS_NORMAL,
119 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT)); 125 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT));
120 find_next_button_->SetImage(views::CustomButton::BS_HOT, 126 find_next_button_->SetImage(views::CustomButton::BS_HOT,
121 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_H)); 127 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_H));
128 find_next_button_->SetImage(views::CustomButton::BS_PUSHED,
129 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_P));
122 find_next_button_->SetImage(views::CustomButton::BS_DISABLED, 130 find_next_button_->SetImage(views::CustomButton::BS_DISABLED,
123 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_P)); 131 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_D));
124 find_next_button_->SetTooltipText( 132 find_next_button_->SetTooltipText(
125 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); 133 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP));
126 find_next_button_->SetAccessibleName( 134 find_next_button_->SetAccessibleName(
127 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); 135 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT));
128 AddChildView(find_next_button_); 136 AddChildView(find_next_button_);
129 137
130 close_button_ = new views::ImageButton(this); 138 close_button_ = new views::ImageButton(this);
131 close_button_->set_tag(CLOSE_TAG); 139 close_button_->set_tag(CLOSE_TAG);
132 close_button_->set_focusable(true); 140 close_button_->set_focusable(true);
133 close_button_->SetImage(views::CustomButton::BS_NORMAL, 141 close_button_->SetImage(views::CustomButton::BS_NORMAL,
134 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); 142 rb.GetImageSkiaNamed(IDR_TAB_CLOSE));
135 close_button_->SetImage(views::CustomButton::BS_HOT, 143 close_button_->SetImage(views::CustomButton::BS_HOT,
136 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); 144 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_H));
137 close_button_->SetImage(views::CustomButton::BS_PUSHED, 145 close_button_->SetImage(views::CustomButton::BS_PUSHED,
138 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); 146 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_P));
139 close_button_->SetTooltipText( 147 close_button_->SetTooltipText(
140 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); 148 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP));
141 close_button_->SetAccessibleName( 149 close_button_->SetAccessibleName(
142 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); 150 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE));
143 AddChildView(close_button_); 151 AddChildView(close_button_);
144 152
145 SetBackground(rb.GetImageSkiaNamed(IDR_FIND_DLG_LEFT_BACKGROUND), 153 SetBackground(rb.GetImageSkiaNamed(IDR_FIND_DLG_LEFT_BACKGROUND),
146 rb.GetImageSkiaNamed(IDR_FIND_DLG_RIGHT_BACKGROUND)); 154 rb.GetImageSkiaNamed(IDR_FIND_DLG_RIGHT_BACKGROUND));
147 155
148 SetBorder(IDR_FIND_DIALOG_LEFT, IDR_FIND_DIALOG_MIDDLE, 156 SetBorder(IDR_FIND_DIALOG_LEFT, IDR_FIND_DIALOG_MIDDLE,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 492
485 FindBarHost* FindBarView::find_bar_host() const { 493 FindBarHost* FindBarView::find_bar_host() const {
486 return static_cast<FindBarHost*>(host()); 494 return static_cast<FindBarHost*>(host());
487 } 495 }
488 496
489 void FindBarView::OnThemeChanged() { 497 void FindBarView::OnThemeChanged() {
490 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 498 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
491 if (GetThemeProvider()) { 499 if (GetThemeProvider()) {
492 close_button_->SetBackground( 500 close_button_->SetBackground(
493 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), 501 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT),
494 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), 502 rb.GetImageSkiaNamed(IDR_TAB_CLOSE),
495 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); 503 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK));
496 } 504 }
497 } 505 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/find_bar_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698