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 "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return gfx::Insets(kTitleTopInset, kTitleLeftInset, kTitleBottomInset, 0); | 60 return gfx::Insets(kTitleTopInset, kTitleLeftInset, kTitleBottomInset, 0); |
61 } | 61 } |
62 | 62 |
63 BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins) | 63 BubbleFrameView::BubbleFrameView(const gfx::Insets& content_margins) |
64 : bubble_border_(NULL), | 64 : bubble_border_(NULL), |
65 content_margins_(content_margins), | 65 content_margins_(content_margins), |
66 title_(NULL), | 66 title_(NULL), |
67 close_(NULL), | 67 close_(NULL), |
68 titlebar_extra_view_(NULL) { | 68 titlebar_extra_view_(NULL) { |
69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 69 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
70 title_ = new Label(string16(), rb.GetFont(ui::ResourceBundle::MediumFont)); | 70 title_ = |
| 71 new Label(base::string16(), rb.GetFont(ui::ResourceBundle::MediumFont)); |
71 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 72 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
72 AddChildView(title_); | 73 AddChildView(title_); |
73 | 74 |
74 close_ = new LabelButton(this, string16()); | 75 close_ = new LabelButton(this, base::string16()); |
75 close_->SetImage(CustomButton::STATE_NORMAL, | 76 close_->SetImage(CustomButton::STATE_NORMAL, |
76 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia()); | 77 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia()); |
77 close_->SetImage(CustomButton::STATE_HOVERED, | 78 close_->SetImage(CustomButton::STATE_HOVERED, |
78 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia()); | 79 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia()); |
79 close_->SetImage(CustomButton::STATE_PRESSED, | 80 close_->SetImage(CustomButton::STATE_PRESSED, |
80 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia()); | 81 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia()); |
81 close_->SetSize(close_->GetPreferredSize()); | 82 close_->SetSize(close_->GetPreferredSize()); |
82 close_->set_border(NULL); | 83 close_->set_border(NULL); |
83 close_->SetVisible(false); | 84 close_->SetVisible(false); |
84 AddChildView(close_); | 85 AddChildView(close_); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 148 } |
148 | 149 |
149 void BubbleFrameView::ResetWindowControls() { | 150 void BubbleFrameView::ResetWindowControls() { |
150 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); | 151 close_->SetVisible(GetWidget()->widget_delegate()->ShouldShowCloseButton()); |
151 } | 152 } |
152 | 153 |
153 void BubbleFrameView::UpdateWindowIcon() {} | 154 void BubbleFrameView::UpdateWindowIcon() {} |
154 | 155 |
155 void BubbleFrameView::UpdateWindowTitle() { | 156 void BubbleFrameView::UpdateWindowTitle() { |
156 title_->SetText(GetWidget()->widget_delegate()->ShouldShowWindowTitle() ? | 157 title_->SetText(GetWidget()->widget_delegate()->ShouldShowWindowTitle() ? |
157 GetWidget()->widget_delegate()->GetWindowTitle() : string16()); | 158 GetWidget()->widget_delegate()->GetWindowTitle() : base::string16()); |
158 // Update the close button visibility too, otherwise it's not intialized. | 159 // Update the close button visibility too, otherwise it's not intialized. |
159 ResetWindowControls(); | 160 ResetWindowControls(); |
160 } | 161 } |
161 | 162 |
162 gfx::Insets BubbleFrameView::GetInsets() const { | 163 gfx::Insets BubbleFrameView::GetInsets() const { |
163 gfx::Insets insets = content_margins_; | 164 gfx::Insets insets = content_margins_; |
164 const int title_height = title_->text().empty() ? 0 : | 165 const int title_height = title_->text().empty() ? 0 : |
165 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; | 166 title_->GetPreferredSize().height() + kTitleTopInset + kTitleBottomInset; |
166 const int close_height = close_->visible() ? close_->height() : 0; | 167 const int close_height = close_->visible() ? close_->height() : 0; |
167 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); | 168 insets += gfx::Insets(std::max(title_height, close_height), 0, 0, 0); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width(); | 347 title_bar_width += kTitleLeftInset + title_->GetPreferredSize().width(); |
347 if (close_->visible()) | 348 if (close_->visible()) |
348 title_bar_width += close_->width() + 1; | 349 title_bar_width += close_->width() + 1; |
349 if (titlebar_extra_view_ != NULL) | 350 if (titlebar_extra_view_ != NULL) |
350 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); | 351 title_bar_width += titlebar_extra_view_->GetPreferredSize().width(); |
351 size.SetToMax(gfx::Size(title_bar_width, 0)); | 352 size.SetToMax(gfx::Size(title_bar_width, 0)); |
352 return size; | 353 return size; |
353 } | 354 } |
354 | 355 |
355 } // namespace views | 356 } // namespace views |
OLD | NEW |