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/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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0)); | 318 sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0)); |
319 int match_count_x = | 319 int match_count_x = |
320 find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width(); | 320 find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width(); |
321 int find_text_y = (height() - find_text_->GetPreferredSize().height()) / 2; | 321 int find_text_y = (height() - find_text_->GetPreferredSize().height()) / 2; |
322 match_count_text_->SetBounds(match_count_x, | 322 match_count_text_->SetBounds(match_count_x, |
323 find_text_y + find_text_->GetBaseline() - | 323 find_text_y + find_text_->GetBaseline() - |
324 match_count_text_->GetBaseline(), | 324 match_count_text_->GetBaseline(), |
325 sz.width(), sz.height()); | 325 sz.width(), sz.height()); |
326 | 326 |
327 // And whatever space is left in between, gets filled up by the find edit box. | 327 // And whatever space is left in between, gets filled up by the find edit box. |
328 int find_text_width = std::max(0, match_count_x - | 328 int left_margin = kMarginLeftOfFindTextfield - views::Textfield::kTextPadding; |
Peter Kasting
2014/08/30 00:46:42
The changes here and below look like they only acc
msw
2014/09/04 01:25:51
Done, but that necessitates increasing kMarginLeft
| |
329 kMarginLeftOfMatchCountLabel - kMarginLeftOfFindTextfield); | 329 int find_text_width = |
330 find_text_->SetBounds(kMarginLeftOfFindTextfield, find_text_y, | 330 std::max(0, match_count_x - left_margin - kMarginLeftOfMatchCountLabel); |
331 find_text_width, find_text_->GetPreferredSize().height()); | 331 find_text_->SetBounds(left_margin, find_text_y, find_text_width, |
332 find_text_->GetPreferredSize().height()); | |
332 | 333 |
333 // The focus forwarder view is a hidden view that should cover the area | 334 // The focus forwarder view is a hidden view that should cover the area |
334 // between the find text box and the find button so that when the user clicks | 335 // between the find text box and the find button so that when the user clicks |
335 // in that area we focus on the find text box. | 336 // in that area we focus on the find text box. |
336 int find_text_edge = find_text_->x() + find_text_->width(); | 337 int find_text_edge = find_text_->x() + find_text_->width(); |
337 focus_forwarder_view_->SetBounds( | 338 focus_forwarder_view_->SetBounds( |
338 find_text_edge, find_previous_button_->y(), | 339 find_text_edge, find_previous_button_->y(), |
339 find_previous_button_->x() - find_text_edge, | 340 find_previous_button_->x() - find_text_edge, |
340 find_previous_button_->height()); | 341 find_previous_button_->height()); |
341 } | 342 } |
342 | 343 |
343 gfx::Size FindBarView::GetPreferredSize() const { | 344 gfx::Size FindBarView::GetPreferredSize() const { |
Peter Kasting
2014/08/30 00:46:42
It surprises me that this function doesn't seem to
msw
2014/09/04 01:25:51
The match count label is initially not shown and i
| |
344 gfx::Size prefsize = find_text_->GetPreferredSize(); | 345 gfx::Size prefsize = find_text_->GetPreferredSize(); |
345 prefsize.set_height(preferred_height_); | 346 prefsize.set_height(preferred_height_); |
346 | 347 |
347 // Add up all the preferred sizes and margins of the rest of the controls. | 348 // Add up all the preferred sizes and margins of the rest of the controls. |
348 prefsize.Enlarge(kMarginLeftOfCloseButton + kMarginRightOfCloseButton + | 349 prefsize.Enlarge( |
349 kMarginLeftOfFindTextfield, | 350 kMarginLeftOfCloseButton + kMarginRightOfCloseButton + |
350 0); | 351 kMarginLeftOfFindTextfield - views::Textfield::kTextPadding, |
352 0); | |
351 prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0); | 353 prefsize.Enlarge(find_previous_button_->GetPreferredSize().width(), 0); |
352 prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0); | 354 prefsize.Enlarge(find_next_button_->GetPreferredSize().width(), 0); |
353 prefsize.Enlarge(close_button_->GetPreferredSize().width(), 0); | 355 prefsize.Enlarge(close_button_->GetPreferredSize().width(), 0); |
354 return prefsize; | 356 return prefsize; |
355 } | 357 } |
356 | 358 |
357 //////////////////////////////////////////////////////////////////////////////// | 359 //////////////////////////////////////////////////////////////////////////////// |
358 // FindBarView, views::ButtonListener implementation: | 360 // FindBarView, views::ButtonListener implementation: |
359 | 361 |
360 void FindBarView::ButtonPressed( | 362 void FindBarView::ButtonPressed( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 | 494 |
493 void FindBarView::OnThemeChanged() { | 495 void FindBarView::OnThemeChanged() { |
494 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 496 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
495 if (GetThemeProvider()) { | 497 if (GetThemeProvider()) { |
496 close_button_->SetBackground( | 498 close_button_->SetBackground( |
497 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), | 499 GetThemeProvider()->GetColor(ThemeProperties::COLOR_TAB_TEXT), |
498 rb.GetImageSkiaNamed(IDR_CLOSE_1), | 500 rb.GetImageSkiaNamed(IDR_CLOSE_1), |
499 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); | 501 rb.GetImageSkiaNamed(IDR_CLOSE_1_MASK)); |
500 } | 502 } |
501 } | 503 } |
OLD | NEW |