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

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

Issue 2305933002: Update dialog close buttons to use vector icons and ripples. (Closed)
Patch Set: delegate Created 4 years, 3 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 (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 #include <utility> 8 #include <utility>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "ui/base/default_style.h" 11 #include "ui/base/default_style.h"
12 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/material_design/material_design_controller.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/compositor/paint_context.h" 16 #include "ui/compositor/paint_context.h"
16 #include "ui/compositor/paint_recorder.h" 17 #include "ui/compositor/paint_recorder.h"
17 #include "ui/display/display.h" 18 #include "ui/display/display.h"
18 #include "ui/display/screen.h" 19 #include "ui/display/screen.h"
19 #include "ui/gfx/geometry/vector2d.h" 20 #include "ui/gfx/geometry/vector2d.h"
20 #include "ui/gfx/path.h" 21 #include "ui/gfx/path.h"
21 #include "ui/gfx/skia_util.h" 22 #include "ui/gfx/skia_util.h"
23 #include "ui/gfx/vector_icons_public.h"
22 #include "ui/native_theme/native_theme.h" 24 #include "ui/native_theme/native_theme.h"
23 #include "ui/resources/grit/ui_resources.h" 25 #include "ui/resources/grit/ui_resources.h"
24 #include "ui/strings/grit/ui_strings.h" 26 #include "ui/strings/grit/ui_strings.h"
25 #include "ui/views/bubble/bubble_border.h" 27 #include "ui/views/bubble/bubble_border.h"
26 #include "ui/views/controls/button/label_button.h" 28 #include "ui/views/controls/button/label_button.h"
29 #include "ui/views/controls/button/vector_icon_button.h"
27 #include "ui/views/controls/image_view.h" 30 #include "ui/views/controls/image_view.h"
28 #include "ui/views/layout/box_layout.h" 31 #include "ui/views/layout/box_layout.h"
29 #include "ui/views/layout/layout_constants.h" 32 #include "ui/views/layout/layout_constants.h"
30 #include "ui/views/resources/grit/views_resources.h" 33 #include "ui/views/resources/grit/views_resources.h"
31 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
32 #include "ui/views/widget/widget_delegate.h" 35 #include "ui/views/widget/widget_delegate.h"
33 #include "ui/views/window/client_view.h" 36 #include "ui/views/window/client_view.h"
34 37
35 namespace views { 38 namespace views {
36 39
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 title_ = new Label(base::string16(), 89 title_ = new Label(base::string16(),
87 rb.GetFontListWithDelta(ui::kTitleFontSizeDelta)); 90 rb.GetFontListWithDelta(ui::kTitleFontSizeDelta));
88 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 91 title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
89 title_->set_collapse_when_hidden(true); 92 title_->set_collapse_when_hidden(true);
90 title_->SetVisible(false); 93 title_->SetVisible(false);
91 title_->SetMultiLine(true); 94 title_->SetMultiLine(true);
92 AddChildView(title_); 95 AddChildView(title_);
93 96
94 close_ = CreateCloseButton(this); 97 close_ = CreateCloseButton(this);
95 close_->SetVisible(false); 98 close_->SetVisible(false);
99 #if defined(OS_WIN)
sky 2016/09/07 03:42:18 Why do you prefer this here and not in the CreateC
Evan Stade 2016/09/07 16:17:37 because the HTCLOSE exception only makes sense in
100 // Windows will automatically create a tooltip for the close button based on
101 // the HTCLOSE result from NonClientHitTest().
102 close_->SetTooltipText(base::string16());
103 #endif
96 AddChildView(close_); 104 AddChildView(close_);
97 } 105 }
98 106
99 BubbleFrameView::~BubbleFrameView() {} 107 BubbleFrameView::~BubbleFrameView() {}
100 108
101 // static 109 // static
102 LabelButton* BubbleFrameView::CreateCloseButton(ButtonListener* listener) { 110 Button* BubbleFrameView::CreateCloseButton(VectorIconButtonDelegate* delegate) {
103 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 111 Button* close_button = nullptr;
104 LabelButton* close = new LabelButton(listener, base::string16()); 112 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
105 close->SetImage(CustomButton::STATE_NORMAL, 113 VectorIconButton* close = new VectorIconButton(delegate);
106 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia()); 114 close->SetIcon(gfx::VectorIconId::BAR_CLOSE);
107 close->SetImage(CustomButton::STATE_HOVERED, 115 close->SetSize(close->GetPreferredSize());
108 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia()); 116 close_button = close;
109 close->SetImage(CustomButton::STATE_PRESSED, 117 } else {
110 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia()); 118 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
111 close->SetBorder(nullptr); 119 LabelButton* close = new LabelButton(delegate, base::string16());
112 close->SetSize(close->GetPreferredSize()); 120 close->SetImage(CustomButton::STATE_NORMAL,
113 #if !defined(OS_WIN) 121 *rb.GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia());
114 // Windows will automatically create a tooltip for the close button based on 122 close->SetImage(CustomButton::STATE_HOVERED,
115 // the HTCLOSE result from NonClientHitTest(). 123 *rb.GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia());
116 close->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE)); 124 close->SetImage(CustomButton::STATE_PRESSED,
117 #endif 125 *rb.GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia());
118 return close; 126 close->SetBorder(nullptr);
127 close->SetSize(close->GetPreferredSize());
128 close_button = close;
129 }
130 close_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
131 return close_button;
119 } 132 }
120 133
121 gfx::Rect BubbleFrameView::GetBoundsForClientView() const { 134 gfx::Rect BubbleFrameView::GetBoundsForClientView() const {
122 gfx::Rect client_bounds = GetContentsBounds(); 135 gfx::Rect client_bounds = GetContentsBounds();
123 client_bounds.Inset(GetInsets()); 136 client_bounds.Inset(GetInsets());
124 if (footnote_container_) { 137 if (footnote_container_) {
125 client_bounds.set_height(client_bounds.height() - 138 client_bounds.set_height(client_bounds.height() -
126 footnote_container_->height()); 139 footnote_container_->height());
127 } 140 }
128 return client_bounds; 141 return client_bounds;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 size.Enlarge(client_insets.width(), client_insets.height()); 528 size.Enlarge(client_insets.width(), client_insets.height());
516 size.SetToMax(gfx::Size(title_bar_width, 0)); 529 size.SetToMax(gfx::Size(title_bar_width, 0));
517 530
518 if (footnote_container_) 531 if (footnote_container_)
519 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); 532 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width()));
520 533
521 return size; 534 return size;
522 } 535 }
523 536
524 } // namespace views 537 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698