| 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 "ui/views/bubble/bubble_frame_view.h" | 5 #include "ui/views/bubble/bubble_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/base/hit_test.h" | 9 #include "ui/base/hit_test.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 const char BubbleFrameView::kViewClassName[] = "BubbleFrameView"; | 65 const char BubbleFrameView::kViewClassName[] = "BubbleFrameView"; |
| 66 | 66 |
| 67 BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins) | 67 BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins) |
| 68 : bubble_border_(nullptr), | 68 : bubble_border_(nullptr), |
| 69 content_margins_(content_margins), | 69 content_margins_(content_margins), |
| 70 title_icon_(new views::ImageView()), | 70 title_icon_(new views::ImageView()), |
| 71 title_(nullptr), | 71 title_(nullptr), |
| 72 close_(nullptr), | 72 close_(nullptr), |
| 73 titlebar_extra_view_(nullptr) { | 73 titlebar_extra_view_(nullptr), |
| 74 close_button_clicked_(false) { |
| 74 AddChildView(title_icon_); | 75 AddChildView(title_icon_); |
| 75 | 76 |
| 76 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 77 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 77 title_ = new Label(base::string16(), | 78 title_ = new Label(base::string16(), |
| 78 rb.GetFontList(ui::ResourceBundle::MediumFont)); | 79 rb.GetFontList(ui::ResourceBundle::MediumFont)); |
| 79 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 80 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 80 title_->set_collapse_when_hidden(true); | 81 title_->set_collapse_when_hidden(true); |
| 81 title_->SetVisible(false); | 82 title_->SetVisible(false); |
| 82 AddChildView(title_); | 83 AddChildView(title_); |
| 83 | 84 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 | 315 |
| 315 void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 316 void BubbleFrameView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 316 if (bubble_border_ && bubble_border_->use_theme_background_color()) { | 317 if (bubble_border_ && bubble_border_->use_theme_background_color()) { |
| 317 bubble_border_->set_background_color(GetNativeTheme()-> | 318 bubble_border_->set_background_color(GetNativeTheme()-> |
| 318 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)); | 319 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)); |
| 319 SchedulePaint(); | 320 SchedulePaint(); |
| 320 } | 321 } |
| 321 } | 322 } |
| 322 | 323 |
| 323 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) { | 324 void BubbleFrameView::ButtonPressed(Button* sender, const ui::Event& event) { |
| 324 if (sender == close_) | 325 if (sender == close_) { |
| 326 close_button_clicked_ = true; |
| 325 GetWidget()->Close(); | 327 GetWidget()->Close(); |
| 328 } |
| 326 } | 329 } |
| 327 | 330 |
| 328 void BubbleFrameView::SetBubbleBorder(scoped_ptr<BubbleBorder> border) { | 331 void BubbleFrameView::SetBubbleBorder(scoped_ptr<BubbleBorder> border) { |
| 329 bubble_border_ = border.get(); | 332 bubble_border_ = border.get(); |
| 330 SetBorder(border.Pass()); | 333 SetBorder(border.Pass()); |
| 331 | 334 |
| 332 // Update the background, which relies on the border. | 335 // Update the background, which relies on the border. |
| 333 set_background(new views::BubbleBackground(bubble_border_)); | 336 set_background(new views::BubbleBackground(bubble_border_)); |
| 334 } | 337 } |
| 335 | 338 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 if (titlebar_extra_view_ != NULL) | 465 if (titlebar_extra_view_ != NULL) |
| 463 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); | 466 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); |
| 464 gfx::Size size(client_size); | 467 gfx::Size size(client_size); |
| 465 size.SetToMax(gfx::Size(title_bar_width, 0)); | 468 size.SetToMax(gfx::Size(title_bar_width, 0)); |
| 466 const gfx::Insets insets(GetInsets()); | 469 const gfx::Insets insets(GetInsets()); |
| 467 size.Enlarge(insets.width(), insets.height()); | 470 size.Enlarge(insets.width(), insets.height()); |
| 468 return size; | 471 return size; |
| 469 } | 472 } |
| 470 | 473 |
| 471 } // namespace views | 474 } // namespace views |
| OLD | NEW |