| Index: ui/views/bubble/bubble_frame_view.cc
|
| diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc
|
| index 88628fbb75137774127b2bb6f31e4bc0cac9f532..b46a4b1863f0ae2ac8fc68f861ac8b825b90ae77 100644
|
| --- a/ui/views/bubble/bubble_frame_view.cc
|
| +++ b/ui/views/bubble/bubble_frame_view.cc
|
| @@ -15,6 +15,7 @@
|
| #include "ui/resources/grit/ui_resources.h"
|
| #include "ui/views/bubble/bubble_border.h"
|
| #include "ui/views/controls/button/label_button.h"
|
| +#include "ui/views/controls/image_view.h"
|
| #include "ui/views/widget/widget.h"
|
| #include "ui/views/widget/widget_delegate.h"
|
| #include "ui/views/window/client_view.h"
|
| @@ -60,10 +61,14 @@ const char BubbleFrameView::kViewClassName[] = "BubbleFrameView";
|
| BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins)
|
| : bubble_border_(NULL),
|
| content_margins_(content_margins),
|
| + title_icon_(NULL),
|
| title_(NULL),
|
| close_(NULL),
|
| titlebar_extra_view_(NULL) {
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
| + title_icon_ = new views::ImageView();
|
| + AddChildView(title_icon_);
|
| +
|
| title_ = new Label(base::string16(),
|
| rb.GetFontList(ui::ResourceBundle::MediumFont));
|
| title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
|
| @@ -164,6 +169,11 @@ void BubbleFrameView::ResetWindowControls() {
|
| void BubbleFrameView::UpdateWindowIcon() {}
|
|
|
| void BubbleFrameView::UpdateWindowTitle() {
|
| + gfx::ImageSkia image;
|
| + if (GetWidget()->widget_delegate()->ShouldShowWindowTitleIcon())
|
| + image = GetWidget()->widget_delegate()->GetWindowTitleIcon();
|
| + title_icon_->SetImage(&image);
|
| +
|
| title_->SetText(GetWidget()->widget_delegate()->ShouldShowWindowTitle() ?
|
| GetWidget()->widget_delegate()->GetWindowTitle() : base::string16());
|
| // Update the close button visibility too, otherwise it's not intialized.
|
| @@ -203,11 +213,29 @@ void BubbleFrameView::Layout() {
|
| close_->SetPosition(gfx::Point(bounds.right() - close_->width(),
|
| bounds.y() - 5));
|
|
|
| - gfx::Size title_size(title_->GetPreferredSize());
|
| - const int title_width = std::max(0, close_->x() - bounds.x());
|
| - title_size.SetToMin(gfx::Size(title_width, title_size.height()));
|
| - bounds.set_size(title_size);
|
| - title_->SetBoundsRect(bounds);
|
| + gfx::Size title_icon_size(title_icon_->GetPreferredSize());
|
| + gfx::Size title_label_size(title_->GetPreferredSize());
|
| + const int title_height = std::max(title_icon_size.height(),
|
| + title_label_size.height());
|
| +
|
| + const int title_icon_width = std::max(0, close_->x() - bounds.x());
|
| + title_icon_size.SetToMin(gfx::Size(title_icon_width, title_height));
|
| + gfx::Rect title_icon_bounds(
|
| + bounds.x(),
|
| + bounds.y() + (title_height - title_icon_size.height()) / 2,
|
| + title_icon_size.width(),
|
| + title_icon_size.height());
|
| + title_icon_->SetBoundsRect(title_icon_bounds);
|
| +
|
| + const int title_label_x = title_icon_->bounds().right() + 5;
|
| + const int title_width = std::max(0, close_->x() - title_label_x);
|
| + title_label_size.SetToMin(gfx::Size(title_width, title_label_size.height()));
|
| + gfx::Rect title_label_bounds(
|
| + title_label_x,
|
| + bounds.y() + (title_height - title_label_size.height()) / 2,
|
| + title_label_size.width(),
|
| + title_label_size.height());
|
| + title_->SetBoundsRect(title_label_bounds);
|
|
|
| if (titlebar_extra_view_) {
|
| const int extra_width = close_->x() - title_->bounds().right();
|
| @@ -371,8 +399,15 @@ gfx::Size BubbleFrameView::GetSizeForClientSize(
|
| const gfx::Size& client_size) const {
|
| // Accommodate the width of the title bar elements.
|
| int title_bar_width = GetInsets().width() + border()->GetInsets().width();
|
| + gfx::Size title_icon_size = title_icon_->GetPreferredSize();
|
| + if (title_icon_size.width() > 0 || !title_->text().empty()) {
|
| + title_bar_width += kTitleLeftInset;
|
| + }
|
| + if (title_icon_size.width() > 0) {
|
| + title_bar_width += title_icon_size.width() + 5;
|
| + }
|
| if (!title_->text().empty())
|
| - title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width();
|
| + title_bar_width += title_->GetPreferredSize().width();
|
| if (close_->visible())
|
| title_bar_width += close_->width() + 1;
|
| if (titlebar_extra_view_ != NULL)
|
|
|