Chromium Code Reviews| Index: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| index 3c2a17070d61bc074d6043d215b21dedc8c16e3c..4f286756b32ca4e9e0e40b7d0b45dc9e0649583b 100644 |
| --- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| +++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc |
| @@ -22,6 +22,7 @@ |
| #include "ui/base/keycodes/keyboard_codes.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/views/bubble/bubble_frame_view.h" |
| #include "ui/views/controls/button/label_button.h" |
| #include "ui/views/controls/combobox/combobox.h" |
| #include "ui/views/controls/label.h" |
| @@ -37,14 +38,8 @@ using views::GridLayout; |
| namespace { |
| -// Padding between "Title:" and the actual title. |
| -const int kTitlePadding = 4; |
| - |
| -// Minimum width for the fields - they will push out the size of the bubble if |
| -// necessary. This should be big enough so that the field pushes the right side |
| -// of the bubble far enough so that the edit button's left edge is to the right |
| -// of the field's left edge. |
| -const int kMinimumFieldSize = 180; |
| +// Minimum width of the the bubble. |
| +const int kMinBubbleWidth = 340; |
|
msw
2013/06/15 20:51:44
Sorry, I measured with old insets, increase this t
tfarina
2013/06/16 13:47:17
Done.
|
| } // namespace |
| @@ -146,12 +141,12 @@ bool BookmarkBubbleView::AcceleratorPressed( |
| } |
| void BookmarkBubbleView::Init() { |
|
msw
2013/06/15 20:51:44
set_color(GetNativeTheme()->GetSystemColor(
tfarina
2013/06/16 13:47:17
Done.
|
| - remove_link_ = new views::Link(l10n_util::GetStringUTF16( |
| - IDS_BOOKMARK_BUBBLE_REMOVE_BOOKMARK)); |
| - remove_link_->set_listener(this); |
| + remove_button_ = new views::LabelButton(this, l10n_util::GetStringUTF16( |
| + IDS_BOOKMARK_BUBBLE_REMOVE_BUTTON)); |
| + remove_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| edit_button_ = new views::LabelButton( |
| - this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_OPTIONS)); |
| + this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_EDIT_BUTTON)); |
| edit_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
| close_button_ = new views::LabelButton( |
| @@ -160,42 +155,26 @@ void BookmarkBubbleView::Init() { |
| close_button_->SetIsDefault(true); |
| views::Label* combobox_label = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_FOLDER_TEXT)); |
| + l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_FOLDER_LABEL)); |
| parent_combobox_ = new views::Combobox(&parent_model_); |
| parent_combobox_->set_listener(this); |
| parent_combobox_->SetAccessibleName(combobox_label->text()); |
| - views::Label* title_label = new views::Label( |
| - l10n_util::GetStringUTF16( |
| - newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED : |
| - IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK)); |
| - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| - title_label->SetFont(rb.GetFont(ui::ResourceBundle::MediumFont)); |
| - |
| GridLayout* layout = new GridLayout(this); |
| SetLayoutManager(layout); |
| - ColumnSet* cs = layout->AddColumnSet(0); |
| - |
| - // Top (title) row. |
| - cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::USE_PREF, |
| - 0, 0); |
| - cs->AddPaddingColumn(1, views::kUnrelatedControlHorizontalSpacing); |
| - cs->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::USE_PREF, |
| - 0, 0); |
| - |
| - // Middle (input field) rows. |
| - cs = layout->AddColumnSet(2); |
| + // The column layout used for middle and bottom rows. |
| + const int kFirstColumnSetID = 0; |
| + ColumnSet* cs = layout->AddColumnSet(kFirstColumnSetID); |
| cs->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
| GridLayout::USE_PREF, 0, 0); |
| - cs->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); |
| - cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, |
| - GridLayout::USE_PREF, 0, kMinimumFieldSize); |
| + cs->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); |
| + |
| + cs->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, |
| + GridLayout::USE_PREF, 0, 0); |
| + cs->AddPaddingColumn(1, views::kUnrelatedControlLargeHorizontalSpacing); |
| - // Bottom (buttons) row. |
| - cs = layout->AddColumnSet(3); |
| - cs->AddPaddingColumn(1, views::kRelatedControlHorizontalSpacing); |
| cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0, |
| GridLayout::USE_PREF, 0, 0); |
| // We subtract 2 to account for the natural button padding, and |
|
msw
2013/06/15 20:51:44
Remove this comment and the '- 2' in the padding c
tfarina
2013/06/16 13:47:17
Done.
|
| @@ -205,27 +184,25 @@ void BookmarkBubbleView::Init() { |
| cs->AddColumn(GridLayout::LEADING, GridLayout::TRAILING, 0, |
| GridLayout::USE_PREF, 0, 0); |
| - layout->StartRow(0, 0); |
| - layout->AddView(title_label); |
| - layout->AddView(remove_link_); |
| - |
| - layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| - layout->StartRow(0, 2); |
| + layout->StartRow(0, kFirstColumnSetID); |
| views::Label* label = new views::Label( |
| - l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_TITLE_TEXT)); |
| + l10n_util::GetStringUTF16(IDS_BOOKMARK_BUBBLE_NAME_LABEL)); |
| layout->AddView(label); |
| title_tf_ = new views::Textfield(); |
| title_tf_->SetText(GetTitle()); |
| - layout->AddView(title_tf_); |
| + layout->AddView(title_tf_, 5, 1); |
| - layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| + layout->AddPaddingRow(0, views::kUnrelatedControlHorizontalSpacing); |
| - layout->StartRow(0, 2); |
| + layout->StartRow(0, kFirstColumnSetID); |
| layout->AddView(combobox_label); |
| - layout->AddView(parent_combobox_); |
| - layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); |
| + layout->AddView(parent_combobox_, 5, 1); |
| + |
| + layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| - layout->StartRow(0, 3); |
| + layout->StartRow(0, kFirstColumnSetID); |
| + layout->SkipColumns(2); |
| + layout->AddView(remove_button_); |
| layout->AddView(edit_button_); |
| layout->AddView(close_button_); |
| @@ -246,13 +223,15 @@ BookmarkBubbleView::BookmarkBubbleView(views::View* anchor_view, |
| BookmarkModelFactory::GetForProfile(profile_), |
| BookmarkModelFactory::GetForProfile(profile_)-> |
| GetMostRecentlyAddedNodeForURL(url)), |
| - remove_link_(NULL), |
| + remove_button_(NULL), |
| edit_button_(NULL), |
| close_button_(NULL), |
| title_tf_(NULL), |
| parent_combobox_(NULL), |
| remove_bookmark_(false), |
| apply_edits_(true) { |
| + set_margins(gfx::Insets(0, 19, 18, |
| + views::kUnrelatedControlLargeHorizontalSpacing)); |
|
msw
2013/06/15 20:51:44
This should be still be 18, result: set_margins(gf
tfarina
2013/06/16 13:47:17
Done.
|
| // Compensate for built-in vertical padding in the anchor view's image. |
| set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| } |
| @@ -269,21 +248,17 @@ string16 BookmarkBubbleView::GetTitle() { |
| return string16(); |
| } |
| +gfx::Size BookmarkBubbleView::GetMinimumSize() { |
| + gfx::Size size(views::BubbleDelegateView::GetPreferredSize()); |
| + size.SetToMax(gfx::Size(kMinBubbleWidth, 0)); |
| + return size; |
| +} |
| + |
| void BookmarkBubbleView::ButtonPressed(views::Button* sender, |
| const ui::Event& event) { |
| HandleButtonPressed(sender); |
| } |
| -void BookmarkBubbleView::LinkClicked(views::Link* source, int event_flags) { |
| - DCHECK_EQ(remove_link_, source); |
| - content::RecordAction(UserMetricsAction("BookmarkBubble_Unstar")); |
| - |
| - // Set this so we remove the bookmark after the window closes. |
| - remove_bookmark_ = true; |
| - apply_edits_ = false; |
| - StartFade(false); |
| -} |
| - |
| void BookmarkBubbleView::OnSelectedIndexChanged(views::Combobox* combobox) { |
| if (combobox->selected_index() + 1 == parent_model_.GetItemCount()) { |
| content::RecordAction(UserMetricsAction("BookmarkBubble_EditFromCombobox")); |
| @@ -292,7 +267,13 @@ void BookmarkBubbleView::OnSelectedIndexChanged(views::Combobox* combobox) { |
| } |
| void BookmarkBubbleView::HandleButtonPressed(views::Button* sender) { |
| - if (sender == edit_button_) { |
| + if (sender == remove_button_) { |
| + content::RecordAction(UserMetricsAction("BookmarkBubble_Unstar")); |
| + // Set this so we remove the bookmark after the window closes. |
| + remove_bookmark_ = true; |
| + apply_edits_ = false; |
| + StartFade(false); |
| + } else if (sender == edit_button_) { |
| content::RecordAction(UserMetricsAction("BookmarkBubble_Edit")); |
| ShowEditor(); |
| } else { |
| @@ -333,3 +314,14 @@ void BookmarkBubbleView::ApplyEdits() { |
| parent_model_.MaybeChangeParent(node, parent_combobox_->selected_index()); |
| } |
| } |
| + |
| +void BookmarkBubbleView::ViewHierarchyChanged( |
| + const ViewHierarchyChangedDetails& details) { |
| + if (details.is_add && details.child == this) { |
| + GetBubbleFrameView()->SetTitle(l10n_util::GetStringUTF16( |
| + newly_bookmarked_ ? IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARKED |
| + : IDS_BOOKMARK_BUBBLE_PAGE_BOOKMARK)); |
| + GetBubbleFrameView()->bubble_border()->set_paint_arrow( |
|
msw
2013/06/15 20:51:44
Stefan is adding BubbleDelegateView::SetArrowPaint
|
| + views::BubbleBorder::PAINT_NONE); |
| + } |
| +} |