| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 if (ui::MaterialDesignController::IsModeMaterial()) { | 325 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 326 views::View::Layout(); | 326 views::View::Layout(); |
| 327 } else { | 327 } else { |
| 328 int panel_width = GetPreferredSize().width(); | 328 int panel_width = GetPreferredSize().width(); |
| 329 | 329 |
| 330 // Stay within view bounds. | 330 // Stay within view bounds. |
| 331 int view_width = width(); | 331 int view_width = width(); |
| 332 if (view_width && view_width < panel_width) | 332 if (view_width && view_width < panel_width) |
| 333 panel_width = view_width; | 333 panel_width = view_width; |
| 334 | 334 |
| 335 // First we draw the close button on the far right. | |
| 336 gfx::Size sz = close_button_->GetPreferredSize(); | |
| 337 close_button_->SetBounds(panel_width - sz.width() - | |
| 338 kMarginRightOfCloseButton, | |
| 339 (height() - sz.height()) / 2, | |
| 340 sz.width(), | |
| 341 sz.height()); | |
| 342 // Set the color. | 335 // Set the color. |
| 343 OnThemeChanged(); | 336 OnThemeChanged(); |
| 344 | 337 |
| 345 // Next, the FindNext button to the left the close button. | 338 // First we position the close button on the far right. |
| 346 sz = find_next_button_->GetPreferredSize(); | 339 close_button_->SizeToPreferredSize(); |
| 347 find_next_button_->SetBounds(close_button_->x() - | 340 close_button_->SetPosition(gfx::Point( |
| 348 find_next_button_->width() - | 341 panel_width - close_button_->width() - kMarginRightOfCloseButton, |
| 349 kMarginLeftOfCloseButton, | 342 (height() - close_button_->height()) / 2)); |
| 350 (height() - sz.height()) / 2, | |
| 351 sz.width(), | |
| 352 sz.height()); | |
| 353 | 343 |
| 354 // Then, the FindPrevious button to the left the FindNext button. | 344 // Then, the next button to the left of the close button. |
| 355 sz = find_previous_button_->GetPreferredSize(); | 345 find_next_button_->SizeToPreferredSize(); |
| 356 find_previous_button_->SetBounds(find_next_button_->x() - | 346 find_next_button_->SetPosition( |
| 357 find_previous_button_->width(), | 347 gfx::Point(close_button_->x() - find_next_button_->width() - |
| 358 (height() - sz.height()) / 2, | 348 kMarginLeftOfCloseButton, |
| 359 sz.width(), | 349 (height() - find_next_button_->height()) / 2)); |
| 360 sz.height()); | 350 |
| 351 // Then, the previous button to the left of the next button. |
| 352 find_previous_button_->SizeToPreferredSize(); |
| 353 find_previous_button_->SetPosition(gfx::Point( |
| 354 find_next_button_->x() - find_previous_button_->width(), |
| 355 (height() - find_previous_button_->height()) / 2)); |
| 361 | 356 |
| 362 // Then the label showing the match count number. | 357 // Then the label showing the match count number. |
| 363 sz = match_count_text_->GetPreferredSize(); | 358 gfx::Size sz = match_count_text_->GetPreferredSize(); |
| 364 // We extend the label bounds a bit to give the background highlighting a | 359 // We extend the label bounds a bit to give the background highlighting a |
| 365 // bit of breathing room (margins around the text). | 360 // bit of breathing room (margins around the text). |
| 366 sz.Enlarge(kMatchCountExtraWidth, 0); | 361 sz.Enlarge(kMatchCountExtraWidth, 0); |
| 367 sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0)); | 362 sz.SetToMax(gfx::Size(kMatchCountMinWidth, 0)); |
| 368 const int match_count_x = | 363 const int match_count_x = |
| 369 find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width(); | 364 find_previous_button_->x() - kMarginRightOfMatchCountLabel - sz.width(); |
| 370 const int find_text_y = kMarginVerticalFindTextfield; | 365 const int find_text_y = kMarginVerticalFindTextfield; |
| 371 const gfx::Insets find_text_insets(find_text_->GetInsets()); | 366 const gfx::Insets find_text_insets(find_text_->GetInsets()); |
| 372 match_count_text_->SetBounds(match_count_x, | 367 match_count_text_->SetBounds(match_count_x, |
| 373 find_text_y - find_text_insets.top() + | 368 find_text_y - find_text_insets.top() + |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 SkColor text_color = | 656 SkColor text_color = |
| 662 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); | 657 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 663 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); | 658 match_count_text_->SetEnabledColor(SkColorSetA(text_color, 0x69)); |
| 664 separator_->SetColor(SkColorSetA(text_color, 0x26)); | 659 separator_->SetColor(SkColorSetA(text_color, 0x26)); |
| 665 } | 660 } |
| 666 | 661 |
| 667 SkColor FindBarView::GetTextColorForIcon() { | 662 SkColor FindBarView::GetTextColorForIcon() { |
| 668 return GetNativeTheme()->GetSystemColor( | 663 return GetNativeTheme()->GetSystemColor( |
| 669 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 664 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 670 } | 665 } |
| OLD | NEW |