Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: ui/views/bubble/bubble_dialog_delegate.cc

Issue 2907983002: Allow dialogs to use a custom View as their title. (Closed)
Patch Set: merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_dialog_delegate.h" 5 #include "ui/views/bubble/bubble_dialog_delegate.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/accessibility/ax_node_data.h" 10 #include "ui/accessibility/ax_node_data.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // BubbleFrameView in CreateNonClientFrameView(). 103 // BubbleFrameView in CreateNonClientFrameView().
104 client->SetButtonRowInsets(gfx::Insets( 104 client->SetButtonRowInsets(gfx::Insets(
105 provider->GetDistanceMetric(DISTANCE_BUBBLE_BUTTON_TOP_MARGIN), 0, 0, 0)); 105 provider->GetDistanceMetric(DISTANCE_BUBBLE_BUTTON_TOP_MARGIN), 0, 0, 0));
106 widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_); 106 widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_);
107 return client; 107 return client;
108 } 108 }
109 109
110 NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView( 110 NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
111 Widget* widget) { 111 Widget* widget) {
112 BubbleFrameView* frame = new BubbleFrameView(title_margins_, margins_); 112 BubbleFrameView* frame = new BubbleFrameView(title_margins_, margins_);
113 // Note: In CreateBubble, the call to SizeToContents() will cause
114 // the relayout that this call requires.
115 frame->SetTitleFontList(GetTitleFontList());
116 frame->SetFootnoteView(CreateFootnoteView()); 113 frame->SetFootnoteView(CreateFootnoteView());
117 114
118 BubbleBorder::Arrow adjusted_arrow = arrow(); 115 BubbleBorder::Arrow adjusted_arrow = arrow();
119 if (base::i18n::IsRTL() && mirror_arrow_in_rtl_) 116 if (base::i18n::IsRTL() && mirror_arrow_in_rtl_)
120 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); 117 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow);
121 frame->SetBubbleBorder(std::unique_ptr<BubbleBorder>( 118 frame->SetBubbleBorder(std::unique_ptr<BubbleBorder>(
122 new BubbleBorder(adjusted_arrow, shadow(), color()))); 119 new BubbleBorder(adjusted_arrow, shadow(), color())));
123 return frame; 120 return frame;
124 } 121 }
125 122
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 228
232 gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() { 229 gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() {
233 // The argument rect has its origin at the bubble's arrow anchor point; 230 // The argument rect has its origin at the bubble's arrow anchor point;
234 // its size is the preferred size of the bubble's client view (this view). 231 // its size is the preferred size of the bubble's client view (this view).
235 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); 232 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized();
236 return GetBubbleFrameView()->GetUpdatedWindowBounds( 233 return GetBubbleFrameView()->GetUpdatedWindowBounds(
237 GetAnchorRect(), GetWidget()->client_view()->GetPreferredSize(), 234 GetAnchorRect(), GetWidget()->client_view()->GetPreferredSize(),
238 adjust_if_offscreen_ && !anchor_minimized); 235 adjust_if_offscreen_ && !anchor_minimized);
239 } 236 }
240 237
241 const gfx::FontList& BubbleDialogDelegateView::GetTitleFontList() const {
242 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
243 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
244 return rb.GetFontListWithDelta(ui::kTitleFontSizeDelta);
245 return rb.GetFontList(ui::ResourceBundle::MediumFont);
246 }
247
248 void BubbleDialogDelegateView::OnNativeThemeChanged( 238 void BubbleDialogDelegateView::OnNativeThemeChanged(
249 const ui::NativeTheme* theme) { 239 const ui::NativeTheme* theme) {
250 UpdateColorsFromTheme(theme); 240 UpdateColorsFromTheme(theme);
251 } 241 }
252 242
253 void BubbleDialogDelegateView::Init() {} 243 void BubbleDialogDelegateView::Init() {}
254 244
255 void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) { 245 void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) {
256 // When the anchor view gets set the associated anchor widget might 246 // When the anchor view gets set the associated anchor widget might
257 // change as well. 247 // change as well.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // http://crbug.com/474622 for details. 311 // http://crbug.com/474622 for details.
322 if (widget == GetWidget() && visible) { 312 if (widget == GetWidget() && visible) {
323 ui::AXNodeData node_data; 313 ui::AXNodeData node_data;
324 GetAccessibleNodeData(&node_data); 314 GetAccessibleNodeData(&node_data);
325 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) 315 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG)
326 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 316 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
327 } 317 }
328 } 318 }
329 319
330 } // namespace views 320 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_dialog_delegate.h ('k') | ui/views/bubble/bubble_dialog_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698