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