Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 text color for the match count label. | 51 // The text color for the match count label. |
| 52 static const SkColor kTextColorMatchCount = SkColorSetRGB(178, 178, 178); | 52 static const SkColor kTextColorMatchCount = SkColorSetRGB(178, 178, 178); |
| 53 | 53 |
| 54 // The text color for the match count label when no matches are found. | 54 // The text color for the match count label when no matches are found. |
| 55 static const SkColor kTextColorNoMatch = SK_ColorBLACK; | 55 static const SkColor kTextColorNoMatch = SK_ColorBLACK; |
| 56 | 56 |
| 57 // The background color of the match count label when results are found. | 57 // The background color of the match count label when results are found. |
| 58 static const SkColor kBackgroundColorMatch = SK_ColorWHITE; | 58 static const SkColor kBackgroundColorMatch = SkColorSetARGB(0, 255, 255, 255); |
| 59 | 59 |
| 60 // The background color of the match count label when no results are found. | 60 // The background color of the match count label when no results are found. |
| 61 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); | 61 static const SkColor kBackgroundColorNoMatch = SkColorSetRGB(255, 102, 102); |
| 62 | 62 |
| 63 // The default number of average characters that the text box will be. This | 63 // 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. | 64 // number brings the width on a "regular fonts" system to about 300px. |
| 65 static const int kDefaultCharWidth = 43; | 65 static const int kDefaultCharWidth = 43; |
| 66 | 66 |
| 67 #if defined(OS_CHROMEOS) | |
| 68 // The background color of the find box. | |
| 69 static const SkColor kFindBoxBackgroundColor = SkColorSetARGB(0, 255, 255, 255); | |
| 70 #endif | |
| 71 | |
| 67 //////////////////////////////////////////////////////////////////////////////// | 72 //////////////////////////////////////////////////////////////////////////////// |
| 68 // FindBarView, public: | 73 // FindBarView, public: |
| 69 | 74 |
| 70 FindBarView::FindBarView(FindBarHost* host) | 75 FindBarView::FindBarView(FindBarHost* host) |
| 71 : DropdownBarView(host), | 76 : DropdownBarView(host), |
| 72 find_text_(NULL), | 77 find_text_(NULL), |
| 73 match_count_text_(NULL), | 78 match_count_text_(NULL), |
| 74 focus_forwarder_view_(NULL), | 79 focus_forwarder_view_(NULL), |
| 75 find_previous_button_(NULL), | 80 find_previous_button_(NULL), |
| 76 find_next_button_(NULL), | 81 find_next_button_(NULL), |
| 77 close_button_(NULL), | 82 close_button_(NULL), |
| 78 text_box_background_(NULL), | 83 text_box_background_(NULL), |
| 79 text_box_background_left_(NULL) { | 84 text_box_background_left_(NULL) { |
| 80 set_id(VIEW_ID_FIND_IN_PAGE); | 85 set_id(VIEW_ID_FIND_IN_PAGE); |
| 81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 86 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 82 | 87 |
| 83 find_text_ = new SearchTextfieldView(); | 88 find_text_ = new SearchTextfieldView(); |
| 84 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); | 89 find_text_->set_id(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD); |
| 85 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 90 find_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 86 find_text_->set_default_width_in_chars(kDefaultCharWidth); | 91 find_text_->set_default_width_in_chars(kDefaultCharWidth); |
| 87 find_text_->SetController(this); | 92 find_text_->SetController(this); |
| 88 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); | 93 find_text_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FIND)); |
| 94 | |
| 95 #if defined(OS_CHROMEOS) | |
| 96 // Use a transparent background on ChromeOS as the theme image for the find | |
| 97 // box uses a partially transparent background. | |
| 98 find_text_->SetBackgroundColor(kFindBoxBackgroundColor); | |
| 99 #endif | |
| 100 | |
| 89 AddChildView(find_text_); | 101 AddChildView(find_text_); |
| 90 | 102 |
| 91 match_count_text_ = new views::Label(); | 103 match_count_text_ = new views::Label(); |
| 92 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); | 104 match_count_text_->SetFont(rb.GetFont(ui::ResourceBundle::BaseFont)); |
| 93 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); | 105 match_count_text_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); |
| 94 AddChildView(match_count_text_); | 106 AddChildView(match_count_text_); |
| 95 | 107 |
| 96 // Create a focus forwarder view which sends focus to find_text_. | 108 // Create a focus forwarder view which sends focus to find_text_. |
| 97 focus_forwarder_view_ = new FocusForwarderView(find_text_); | 109 focus_forwarder_view_ = new FocusForwarderView(find_text_); |
| 98 AddChildView(focus_forwarder_view_); | 110 AddChildView(focus_forwarder_view_); |
| 99 | 111 |
| 100 find_previous_button_ = new views::ImageButton(this); | 112 find_previous_button_ = new views::ImageButton(this); |
| 101 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); | 113 find_previous_button_->set_tag(FIND_PREVIOUS_TAG); |
| 102 find_previous_button_->set_focusable(true); | 114 find_previous_button_->set_focusable(true); |
| 103 find_previous_button_->SetImage(views::CustomButton::BS_NORMAL, | 115 find_previous_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 104 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV)); | 116 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV)); |
| 105 find_previous_button_->SetImage(views::CustomButton::BS_HOT, | 117 find_previous_button_->SetImage(views::CustomButton::BS_HOT, |
| 106 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_H)); | 118 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_H)); |
| 119 find_previous_button_->SetImage(views::CustomButton::BS_PUSHED, | |
| 120 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_P)); | |
| 107 find_previous_button_->SetImage(views::CustomButton::BS_DISABLED, | 121 find_previous_button_->SetImage(views::CustomButton::BS_DISABLED, |
| 108 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_P)); | 122 rb.GetImageSkiaNamed(IDR_FINDINPAGE_PREV_D)); |
| 109 find_previous_button_->SetTooltipText( | 123 find_previous_button_->SetTooltipText( |
| 110 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); | 124 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_PREVIOUS_TOOLTIP)); |
| 111 find_previous_button_->SetAccessibleName( | 125 find_previous_button_->SetAccessibleName( |
| 112 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); | 126 l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS)); |
| 113 AddChildView(find_previous_button_); | 127 AddChildView(find_previous_button_); |
| 114 | 128 |
| 115 find_next_button_ = new views::ImageButton(this); | 129 find_next_button_ = new views::ImageButton(this); |
| 116 find_next_button_->set_tag(FIND_NEXT_TAG); | 130 find_next_button_->set_tag(FIND_NEXT_TAG); |
| 117 find_next_button_->set_focusable(true); | 131 find_next_button_->set_focusable(true); |
| 118 find_next_button_->SetImage(views::CustomButton::BS_NORMAL, | 132 find_next_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 119 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT)); | 133 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT)); |
| 120 find_next_button_->SetImage(views::CustomButton::BS_HOT, | 134 find_next_button_->SetImage(views::CustomButton::BS_HOT, |
| 121 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_H)); | 135 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_H)); |
| 136 find_next_button_->SetImage(views::CustomButton::BS_PUSHED, | |
| 137 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_P)); | |
| 122 find_next_button_->SetImage(views::CustomButton::BS_DISABLED, | 138 find_next_button_->SetImage(views::CustomButton::BS_DISABLED, |
| 123 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_P)); | 139 rb.GetImageSkiaNamed(IDR_FINDINPAGE_NEXT_D)); |
| 124 find_next_button_->SetTooltipText( | 140 find_next_button_->SetTooltipText( |
| 125 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); | 141 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_NEXT_TOOLTIP)); |
| 126 find_next_button_->SetAccessibleName( | 142 find_next_button_->SetAccessibleName( |
| 127 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); | 143 l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT)); |
| 128 AddChildView(find_next_button_); | 144 AddChildView(find_next_button_); |
| 129 | 145 |
| 130 close_button_ = new views::ImageButton(this); | 146 close_button_ = new views::ImageButton(this); |
| 131 close_button_->set_tag(CLOSE_TAG); | 147 close_button_->set_tag(CLOSE_TAG); |
| 132 close_button_->set_focusable(true); | 148 close_button_->set_focusable(true); |
| 133 close_button_->SetImage(views::CustomButton::BS_NORMAL, | 149 close_button_->SetImage(views::CustomButton::BS_NORMAL, |
| 134 rb.GetImageSkiaNamed(IDR_CLOSE_BAR)); | 150 rb.GetImageSkiaNamed(IDR_TAB_CLOSE)); |
|
sky
2012/09/17 13:47:06
Sorry, one last question. Are you sure about this?
flackr
2012/09/17 14:02:28
I believe Sebastien wanted the tab close button to
flackr
2012/09/17 18:34:35
Okay, talked to Sebastien and he wants to only use
| |
| 135 close_button_->SetImage(views::CustomButton::BS_HOT, | 151 close_button_->SetImage(views::CustomButton::BS_HOT, |
| 136 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_H)); | 152 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_H)); |
| 137 close_button_->SetImage(views::CustomButton::BS_PUSHED, | 153 close_button_->SetImage(views::CustomButton::BS_PUSHED, |
| 138 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_P)); | 154 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_P)); |
| 139 close_button_->SetTooltipText( | 155 close_button_->SetTooltipText( |
| 140 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); | 156 l10n_util::GetStringUTF16(IDS_FIND_IN_PAGE_CLOSE_TOOLTIP)); |
| 141 close_button_->SetAccessibleName( | 157 close_button_->SetAccessibleName( |
| 142 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); | 158 l10n_util::GetStringUTF16(IDS_ACCNAME_CLOSE)); |
| 143 AddChildView(close_button_); | 159 AddChildView(close_button_); |
| 144 | 160 |
| 145 SetBackground(rb.GetImageSkiaNamed(IDR_FIND_DLG_LEFT_BACKGROUND), | 161 SetBackground(rb.GetImageSkiaNamed(IDR_FIND_DLG_LEFT_BACKGROUND), |
| 146 rb.GetImageSkiaNamed(IDR_FIND_DLG_RIGHT_BACKGROUND)); | 162 rb.GetImageSkiaNamed(IDR_FIND_DLG_RIGHT_BACKGROUND)); |
| 147 | 163 |
| 148 SetBorder(IDR_FIND_DIALOG_LEFT, IDR_FIND_DIALOG_MIDDLE, | 164 SetBorder(IDR_FIND_DIALOG_LEFT, IDR_FIND_DIALOG_MIDDLE, |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 | 500 |
| 485 FindBarHost* FindBarView::find_bar_host() const { | 501 FindBarHost* FindBarView::find_bar_host() const { |
| 486 return static_cast<FindBarHost*>(host()); | 502 return static_cast<FindBarHost*>(host()); |
| 487 } | 503 } |
| 488 | 504 |
| 489 void FindBarView::OnThemeChanged() { | 505 void FindBarView::OnThemeChanged() { |
| 490 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 506 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 491 if (GetThemeProvider()) { | 507 if (GetThemeProvider()) { |
| 492 close_button_->SetBackground( | 508 close_button_->SetBackground( |
| 493 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), | 509 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), |
| 494 rb.GetImageSkiaNamed(IDR_CLOSE_BAR), | 510 rb.GetImageSkiaNamed(IDR_TAB_CLOSE), |
| 495 rb.GetImageSkiaNamed(IDR_CLOSE_BAR_MASK)); | 511 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK)); |
| 496 } | 512 } |
| 497 } | 513 } |
| OLD | NEW |