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_delegate.h" | 5 #include "ui/views/bubble/bubble_delegate.h" |
6 | 6 |
7 #include "ui/accessibility/ax_view_state.h" | 7 #include "ui/accessibility/ax_view_state.h" |
| 8 #include "ui/base/resource/resource_bundle.h" |
8 #include "ui/gfx/color_utils.h" | 9 #include "ui/gfx/color_utils.h" |
9 #include "ui/gfx/rect.h" | 10 #include "ui/gfx/rect.h" |
10 #include "ui/native_theme/native_theme.h" | 11 #include "ui/native_theme/native_theme.h" |
11 #include "ui/views/bubble/bubble_frame_view.h" | 12 #include "ui/views/bubble/bubble_frame_view.h" |
12 #include "ui/views/focus/view_storage.h" | 13 #include "ui/views/focus/view_storage.h" |
13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
14 #include "ui/views/widget/widget_observer.h" | 15 #include "ui/views/widget/widget_observer.h" |
15 | 16 |
16 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
17 #include "ui/base/win/shell.h" | 18 #include "ui/base/win/shell.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return false; | 125 return false; |
125 } | 126 } |
126 | 127 |
127 View* BubbleDelegateView::GetContentsView() { | 128 View* BubbleDelegateView::GetContentsView() { |
128 return this; | 129 return this; |
129 } | 130 } |
130 | 131 |
131 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView( | 132 NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView( |
132 Widget* widget) { | 133 Widget* widget) { |
133 BubbleFrameView* frame = new BubbleFrameView(margins()); | 134 BubbleFrameView* frame = new BubbleFrameView(margins()); |
| 135 // Note: In CreateBubble, the call to SizeToContents() will cause |
| 136 // the relayout that this call requires. |
| 137 frame->SetTitleFontList(GetTitleFontList()); |
134 BubbleBorder::Arrow adjusted_arrow = arrow(); | 138 BubbleBorder::Arrow adjusted_arrow = arrow(); |
135 if (base::i18n::IsRTL()) | 139 if (base::i18n::IsRTL()) |
136 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); | 140 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); |
137 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>( | 141 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>( |
138 new BubbleBorder(adjusted_arrow, shadow(), color()))); | 142 new BubbleBorder(adjusted_arrow, shadow(), color()))); |
139 return frame; | 143 return frame; |
140 } | 144 } |
141 | 145 |
142 void BubbleDelegateView::GetAccessibleState(ui::AXViewState* state) { | 146 void BubbleDelegateView::GetAccessibleState(ui::AXViewState* state) { |
143 state->role = ui::AX_ROLE_DIALOG; | 147 state->role = ui::AX_ROLE_DIALOG; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 274 } |
271 | 275 |
272 gfx::Rect BubbleDelegateView::GetBubbleBounds() { | 276 gfx::Rect BubbleDelegateView::GetBubbleBounds() { |
273 // The argument rect has its origin at the bubble's arrow anchor point; | 277 // The argument rect has its origin at the bubble's arrow anchor point; |
274 // its size is the preferred size of the bubble's client view (this view). | 278 // its size is the preferred size of the bubble's client view (this view). |
275 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); | 279 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); |
276 return GetBubbleFrameView()->GetUpdatedWindowBounds(GetAnchorRect(), | 280 return GetBubbleFrameView()->GetUpdatedWindowBounds(GetAnchorRect(), |
277 GetPreferredSize(), adjust_if_offscreen_ && !anchor_minimized); | 281 GetPreferredSize(), adjust_if_offscreen_ && !anchor_minimized); |
278 } | 282 } |
279 | 283 |
| 284 const gfx::FontList& BubbleDelegateView::GetTitleFontList() const { |
| 285 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 286 return rb.GetFontList(ui::ResourceBundle::MediumFont); |
| 287 } |
| 288 |
| 289 |
280 void BubbleDelegateView::UpdateColorsFromTheme(const ui::NativeTheme* theme) { | 290 void BubbleDelegateView::UpdateColorsFromTheme(const ui::NativeTheme* theme) { |
281 if (!color_explicitly_set_) | 291 if (!color_explicitly_set_) |
282 color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 292 color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); |
283 set_background(Background::CreateSolidBackground(color())); | 293 set_background(Background::CreateSolidBackground(color())); |
284 BubbleFrameView* frame_view = GetBubbleFrameView(); | 294 BubbleFrameView* frame_view = GetBubbleFrameView(); |
285 if (frame_view) | 295 if (frame_view) |
286 frame_view->bubble_border()->set_background_color(color()); | 296 frame_view->bubble_border()->set_background_color(color()); |
287 } | 297 } |
288 | 298 |
289 void BubbleDelegateView::HandleVisibilityChanged(Widget* widget, bool visible) { | 299 void BubbleDelegateView::HandleVisibilityChanged(Widget* widget, bool visible) { |
290 if (widget == GetWidget() && anchor_widget() && | 300 if (widget == GetWidget() && anchor_widget() && |
291 anchor_widget()->GetTopLevelWidget()) { | 301 anchor_widget()->GetTopLevelWidget()) { |
292 if (visible) | 302 if (visible) |
293 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); | 303 anchor_widget()->GetTopLevelWidget()->DisableInactiveRendering(); |
294 else | 304 else |
295 anchor_widget()->GetTopLevelWidget()->EnableInactiveRendering(); | 305 anchor_widget()->GetTopLevelWidget()->EnableInactiveRendering(); |
296 } | 306 } |
297 } | 307 } |
298 | 308 |
299 } // namespace views | 309 } // namespace views |
OLD | NEW |