| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 canvas->TileImageInt(*background_, find_text_x, back_button_origin.y(), | 251 canvas->TileImageInt(*background_, find_text_x, back_button_origin.y(), |
| 252 back_button_origin.x() - find_text_x, | 252 back_button_origin.x() - find_text_x, |
| 253 background_->height()); | 253 background_->height()); |
| 254 | 254 |
| 255 PaintAnimatingEdges(canvas, bounds); | 255 PaintAnimatingEdges(canvas, bounds); |
| 256 | 256 |
| 257 canvas->Restore(); | 257 canvas->Restore(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void FindBarView::Layout() { | 260 void FindBarView::Layout() { |
| 261 gfx::Size panel_size = GetPreferredSize(); | 261 int panel_width = GetPreferredSize().width(); |
| 262 |
| 263 // Stay within view bounds. |
| 264 int view_width = width(); |
| 265 if (view_width && view_width < panel_width) |
| 266 panel_width = view_width; |
| 262 | 267 |
| 263 // First we draw the close button on the far right. | 268 // First we draw the close button on the far right. |
| 264 gfx::Size sz = close_button_->GetPreferredSize(); | 269 gfx::Size sz = close_button_->GetPreferredSize(); |
| 265 close_button_->SetBounds(panel_size.width() - sz.width() - | 270 close_button_->SetBounds(panel_width - sz.width() - |
| 266 kMarginRightOfCloseButton, | 271 kMarginRightOfCloseButton, |
| 267 (height() - sz.height()) / 2, | 272 (height() - sz.height()) / 2, |
| 268 sz.width(), | 273 sz.width(), |
| 269 sz.height()); | 274 sz.height()); |
| 270 // Set the color. | 275 // Set the color. |
| 271 OnThemeChanged(); | 276 OnThemeChanged(); |
| 272 | 277 |
| 273 // Next, the FindNext button to the left the close button. | 278 // Next, the FindNext button to the left the close button. |
| 274 sz = find_next_button_->GetPreferredSize(); | 279 sz = find_next_button_->GetPreferredSize(); |
| 275 find_next_button_->SetBounds(close_button_->x() - | 280 find_next_button_->SetBounds(close_button_->x() - |
| (...skipping 27 matching lines...) Expand all Loading... |
| 303 int match_count_x = find_previous_button_->x() - | 308 int match_count_x = find_previous_button_->x() - |
| 304 kWhiteSpaceAfterMatchCountLabel - | 309 kWhiteSpaceAfterMatchCountLabel - |
| 305 sz.width(); | 310 sz.width(); |
| 306 match_count_text_->SetBounds(match_count_x, | 311 match_count_text_->SetBounds(match_count_x, |
| 307 (height() - sz.height()) / 2, | 312 (height() - sz.height()) / 2, |
| 308 sz.width(), | 313 sz.width(), |
| 309 sz.height()); | 314 sz.height()); |
| 310 | 315 |
| 311 // And whatever space is left in between, gets filled up by the find edit box. | 316 // And whatever space is left in between, gets filled up by the find edit box. |
| 312 sz = find_text_->GetPreferredSize(); | 317 sz = find_text_->GetPreferredSize(); |
| 313 sz.set_width(match_count_x - kMarginLeftOfFindTextfield); | 318 sz.set_width(std::max(0, match_count_x - kMarginLeftOfFindTextfield)); |
| 314 find_text_->SetBounds(match_count_x - sz.width(), | 319 int find_text_x = std::max(0, match_count_x - sz.width()); |
| 320 find_text_->SetBounds(find_text_x, |
| 315 (height() - sz.height()) / 2 + 1, | 321 (height() - sz.height()) / 2 + 1, |
| 316 sz.width(), | 322 sz.width(), |
| 317 sz.height()); | 323 sz.height()); |
| 318 | 324 |
| 319 // The focus forwarder view is a hidden view that should cover the area | 325 // The focus forwarder view is a hidden view that should cover the area |
| 320 // between the find text box and the find button so that when the user clicks | 326 // between the find text box and the find button so that when the user clicks |
| 321 // in that area we focus on the find text box. | 327 // in that area we focus on the find text box. |
| 322 int find_text_edge = find_text_->x() + find_text_->width(); | 328 int find_text_edge = find_text_->x() + find_text_->width(); |
| 323 focus_forwarder_view_->SetBounds(find_text_edge, | 329 focus_forwarder_view_->SetBounds(find_text_edge, |
| 324 find_previous_button_->y(), | 330 find_previous_button_->y(), |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 490 |
| 485 void FindBarView::OnThemeChanged() { | 491 void FindBarView::OnThemeChanged() { |
| 486 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 492 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 487 if (GetThemeProvider()) { | 493 if (GetThemeProvider()) { |
| 488 close_button_->SetBackground( | 494 close_button_->SetBackground( |
| 489 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), | 495 GetThemeProvider()->GetColor(ThemeService::COLOR_TAB_TEXT), |
| 490 rb.GetBitmapNamed(IDR_CLOSE_BAR), | 496 rb.GetBitmapNamed(IDR_CLOSE_BAR), |
| 491 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); | 497 rb.GetBitmapNamed(IDR_CLOSE_BAR_MASK)); |
| 492 } | 498 } |
| 493 } | 499 } |
| OLD | NEW |