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

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

Issue 135813002: Revert of Merge NativeTextfieldViews into views::Textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
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/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/ui/views/frame/browser_view.h" 21 #include "chrome/browser/ui/views/frame/browser_view.h"
22 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
23 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "grit/ui_resources.h" 24 #include "grit/ui_resources.h"
25 #include "third_party/skia/include/effects/SkGradientShader.h" 25 #include "third_party/skia/include/effects/SkGradientShader.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/base/theme_provider.h" 28 #include "ui/base/theme_provider.h"
29 #include "ui/events/event.h" 29 #include "ui/events/event.h"
30 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
31 #include "ui/views/border.h"
32 #include "ui/views/controls/button/image_button.h" 31 #include "ui/views/controls/button/image_button.h"
33 #include "ui/views/controls/label.h" 32 #include "ui/views/controls/label.h"
34 #include "ui/views/controls/textfield/textfield.h" 33 #include "ui/views/controls/textfield/textfield.h"
35 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
36 35
37 // The amount of whitespace to have before the find button. 36 // The amount of whitespace to have before the find button.
38 static const int kWhiteSpaceAfterMatchCountLabel = 1; 37 static const int kWhiteSpaceAfterMatchCountLabel = 1;
39 38
40 // The margins around the search field and the close button. 39 // The margins around the search field and the close button.
41 static const int kMarginLeftOfCloseButton = 3; 40 static const int kMarginLeftOfCloseButton = 3;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 text_box_background_(NULL), 78 text_box_background_(NULL),
80 text_box_background_left_(NULL) { 79 text_box_background_left_(NULL) {
81 set_id(VIEW_ID_FIND_IN_PAGE); 80 set_id(VIEW_ID_FIND_IN_PAGE);
82 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
83 82
84 find_text_ = new views::Textfield; 83 find_text_ = new views::Textfield;
85 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); 84 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD);
86 find_text_->set_default_width_in_chars(kDefaultCharWidth); 85 find_text_->set_default_width_in_chars(kDefaultCharWidth);
87 find_text_->SetController(this); 86 find_text_->SetController(this);
88 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); 87 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND));
89 // The find bar textfield has a background image instead of a border.
90 const gfx::Insets insets = find_text_->GetInsets();
91 find_text_->set_border(
92 views::Border::CreateEmptyBorder(insets.top(), 0, insets.bottom(), 2));
93 88
94 AddChildView(find_text_); 89 AddChildView(find_text_);
95 90
96 match_count_text_ = new views::Label(); 91 match_count_text_ = new views::Label();
97 AddChildView(match_count_text_); 92 AddChildView(match_count_text_);
98 93
99 // Create a focus forwarder view which sends focus to find_text_. 94 // Create a focus forwarder view which sends focus to find_text_.
100 focus_forwarder_view_ = new FocusForwarderView(find_text_); 95 focus_forwarder_view_ = new FocusForwarderView(find_text_);
101 AddChildView(focus_forwarder_view_); 96 AddChildView(focus_forwarder_view_);
102 97
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // The focus forwarder view is a hidden view that should cover the area 332 // The focus forwarder view is a hidden view that should cover the area
338 // between the find text box and the find button so that when the user clicks 333 // between the find text box and the find button so that when the user clicks
339 // in that area we focus on the find text box. 334 // in that area we focus on the find text box.
340 int find_text_edge = find_text_->x() + find_text_->width(); 335 int find_text_edge = find_text_->x() + find_text_->width();
341 focus_forwarder_view_->SetBounds( 336 focus_forwarder_view_->SetBounds(
342 find_text_edge, find_previous_button_->y(), 337 find_text_edge, find_previous_button_->y(),
343 find_previous_button_->x() - find_text_edge, 338 find_previous_button_->x() - find_text_edge,
344 find_previous_button_->height()); 339 find_previous_button_->height());
345 } 340 }
346 341
342 void FindBarView::ViewHierarchyChanged(
343 const ViewHierarchyChangedDetails& details) {
344 if (details.is_add && details.child == this) {
345 find_text_->SetHorizontalMargins(0, 2); // Left and Right margins.
346 find_text_->RemoveBorder(); // We draw our own border (a background image).
347 }
348 }
349
347 gfx::Size FindBarView::GetPreferredSize() { 350 gfx::Size FindBarView::GetPreferredSize() {
348 gfx::Size prefsize = find_text_->GetPreferredSize(); 351 gfx::Size prefsize = find_text_->GetPreferredSize();
349 prefsize.set_height(preferred_height_); 352 prefsize.set_height(preferred_height_);
350 353
351 // Add up all the preferred sizes and margins of the rest of the controls. 354 // Add up all the preferred sizes and margins of the rest of the controls.
352 prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton + 355 prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton +
353 kMarginLeftOfFindTextfield, 356 kMarginLeftOfFindTextfield,
354 0); 357 0);
355 prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0); 358 prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0);
356 prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0); 359 prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 499
497 void FindBarView::OnThemeChanged() { 500 void FindBarView::OnThemeChanged() {
498 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 501 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
499 if (GetThemeProvider()) { 502 if (GetThemeProvider()) {
500 close_button_->SetBackground( 503 close_button_->SetBackground(
501 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), 504 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT),
502 rb.GetImageSkiaNamed(IDR_CLOSE_1), 505 rb.GetImageSkiaNamed(IDR_CLOSE_1),
503 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); 506 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK));
504 } 507 }
505 } 508 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698