Index: ui/app_list/views/search_box_view.cc |
diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc |
index b77ee6665323aa8097c6e60541d0bc7fc234c6cc..7bb48a68e68a1b6bd6f2dec6bc616537c9eda2bf 100644 |
--- a/ui/app_list/views/search_box_view.cc |
+++ b/ui/app_list/views/search_box_view.cc |
@@ -22,18 +22,15 @@ |
#include "ui/views/controls/button/menu_button.h" |
#include "ui/views/controls/image_view.h" |
#include "ui/views/controls/textfield/textfield.h" |
+#include "ui/views/layout/box_layout.h" |
namespace app_list { |
namespace { |
const int kPadding = 14; |
-const int kIconDimension = 32; |
const int kPreferredWidth = 360; |
const int kPreferredHeight = 48; |
-#if !defined(OS_CHROMEOS) |
-const int kMenuButtonDimension = 29; |
-#endif |
const SkColor kHintTextColor = SkColorSetRGB(0xA0, 0xA0, 0xA0); |
@@ -94,8 +91,24 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, |
if (switches::IsExperimentalAppListEnabled()) |
set_background(new SearchBoxBackground()); |
+ views::BoxLayout* layout = new views::BoxLayout( |
+ views::BoxLayout::kHorizontal, kPadding, 0, kPadding); |
+ SetLayoutManager(layout); |
+ layout->set_cross_axis_alignment( |
+ views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
+ layout->set_minimum_cross_axis_size(switches::IsExperimentalAppListEnabled() |
+ ? kExperimentalSearchBoxHeight |
+ : kPreferredHeight); |
+ |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
+ search_box_->SetBorder(views::Border::NullBorder()); |
+ search_box_->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
+ search_box_->set_placeholder_text_color(kHintTextColor); |
+ search_box_->set_controller(this); |
+ AddChildView(search_box_); |
+ layout->SetFlexForView(search_box_, 1); |
+ |
#if !defined(OS_CHROMEOS) |
menu_button_ = new views::MenuButton(NULL, base::string16(), this, false); |
menu_button_->SetBorder(views::Border::NullBorder()); |
@@ -108,12 +121,6 @@ SearchBoxView::SearchBoxView(SearchBoxViewDelegate* delegate, |
AddChildView(menu_button_); |
#endif |
- search_box_->SetBorder(views::Border::NullBorder()); |
- search_box_->SetFontList(rb.GetFontList(ui::ResourceBundle::MediumFont)); |
- search_box_->set_placeholder_text_color(kHintTextColor); |
- search_box_->set_controller(this); |
- AddChildView(search_box_); |
- |
view_delegate_->GetSpeechUI()->AddObserver(this); |
ModelChanged(); |
} |
@@ -159,50 +166,6 @@ gfx::Size SearchBoxView::GetPreferredSize() const { |
: kPreferredHeight); |
} |
-void SearchBoxView::Layout() { |
- gfx::Rect rect(GetContentsBounds()); |
- if (rect.IsEmpty()) |
- return; |
- |
- gfx::Rect icon_frame(rect); |
- icon_frame.set_width(kIconDimension + 2 * kPadding); |
- icon_view_->SetBoundsRect(icon_frame); |
- |
- // Places |speech_button_| if exists. |speech_button_frame| holds its bounds |
- // to calculate the search box bounds. |
- gfx::Rect speech_button_frame; |
- if (speech_button_) { |
- speech_button_frame = icon_frame; |
- speech_button_frame.set_x(rect.right() - icon_frame.width()); |
- gfx::Size button_size = speech_button_->GetPreferredSize(); |
- gfx::Point button_origin = speech_button_frame.CenterPoint(); |
- button_origin.Offset(-button_size.width() / 2, -button_size.height() / 2); |
- speech_button_->SetBoundsRect(gfx::Rect(button_origin, button_size)); |
- } |
- |
- gfx::Rect menu_button_frame(rect); |
-#if !defined(OS_CHROMEOS) |
- menu_button_frame.set_width(kMenuButtonDimension); |
- menu_button_frame.set_x(rect.right() - menu_button_frame.width() - kPadding); |
- menu_button_frame.ClampToCenteredSize(gfx::Size(menu_button_frame.width(), |
- kMenuButtonDimension)); |
- menu_button_->SetBoundsRect(menu_button_frame); |
-#else |
- menu_button_frame.set_width(0); |
-#endif |
- |
- gfx::Rect edit_frame(rect); |
- edit_frame.set_x(icon_frame.right()); |
- int edit_frame_width = |
- rect.width() - icon_frame.width() - kPadding - menu_button_frame.width(); |
- if (!speech_button_frame.IsEmpty()) |
- edit_frame_width -= speech_button_frame.width() + kPadding; |
- edit_frame.set_width(edit_frame_width); |
- edit_frame.ClampToCenteredSize( |
- gfx::Size(edit_frame.width(), search_box_->GetPreferredSize().height())); |
- search_box_->SetBoundsRect(edit_frame); |
-} |
- |
bool SearchBoxView::OnMouseWheel(const ui::MouseWheelEvent& event) { |
if (contents_view_) |
return contents_view_->OnMouseWheel(event); |