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

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

Issue 2744463002: Add VectorIconButton functionality to ImageButton. (Closed)
Patch Set: check details Created 3 years, 9 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
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/controls/button/image_button.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/material_design/material_design_controller.h"
15 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/compositor/paint_context.h" 16 #include "ui/compositor/paint_context.h"
17 #include "ui/compositor/paint_recorder.h" 17 #include "ui/compositor/paint_recorder.h"
18 #include "ui/display/display.h" 18 #include "ui/display/display.h"
19 #include "ui/display/screen.h" 19 #include "ui/display/screen.h"
20 #include "ui/gfx/geometry/vector2d.h" 20 #include "ui/gfx/geometry/vector2d.h"
21 #include "ui/gfx/path.h" 21 #include "ui/gfx/path.h"
22 #include "ui/gfx/skia_util.h" 22 #include "ui/gfx/skia_util.h"
23 #include "ui/native_theme/native_theme.h" 23 #include "ui/native_theme/native_theme.h"
24 #include "ui/resources/grit/ui_resources.h" 24 #include "ui/resources/grit/ui_resources.h"
25 #include "ui/strings/grit/ui_strings.h" 25 #include "ui/strings/grit/ui_strings.h"
26 #include "ui/vector_icons/vector_icons.h" 26 #include "ui/vector_icons/vector_icons.h"
27 #include "ui/views/bubble/bubble_border.h" 27 #include "ui/views/bubble/bubble_border.h"
28 #include "ui/views/controls/button/vector_icon_button.h" 28 #include "ui/views/controls/button/image_button.h"
29 #include "ui/views/controls/button/image_button_factory.h"
29 #include "ui/views/controls/image_view.h" 30 #include "ui/views/controls/image_view.h"
30 #include "ui/views/controls/label.h" 31 #include "ui/views/controls/label.h"
31 #include "ui/views/layout/box_layout.h" 32 #include "ui/views/layout/box_layout.h"
32 #include "ui/views/layout/layout_constants.h" 33 #include "ui/views/layout/layout_constants.h"
33 #include "ui/views/resources/grit/views_resources.h" 34 #include "ui/views/resources/grit/views_resources.h"
34 #include "ui/views/views_delegate.h" 35 #include "ui/views/views_delegate.h"
35 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
36 #include "ui/views/widget/widget_delegate.h" 37 #include "ui/views/widget/widget_delegate.h"
37 #include "ui/views/window/client_view.h" 38 #include "ui/views/window/client_view.h"
38 39
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Windows will automatically create a tooltip for the close button based on 102 // Windows will automatically create a tooltip for the close button based on
102 // the HTCLOSE result from NonClientHitTest(). 103 // the HTCLOSE result from NonClientHitTest().
103 close_->SetTooltipText(base::string16()); 104 close_->SetTooltipText(base::string16());
104 #endif 105 #endif
105 AddChildView(close_); 106 AddChildView(close_);
106 } 107 }
107 108
108 BubbleFrameView::~BubbleFrameView() {} 109 BubbleFrameView::~BubbleFrameView() {}
109 110
110 // static 111 // static
111 Button* BubbleFrameView::CreateCloseButton(VectorIconButtonDelegate* delegate) { 112 Button* BubbleFrameView::CreateCloseButton(ButtonListener* listener) {
112 ImageButton* close_button = nullptr; 113 ImageButton* close_button = nullptr;
113 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { 114 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
114 VectorIconButton* close = new VectorIconButton(delegate); 115 close_button = CreateVectorImageButton(listener);
115 close->SetIcon(ui::kCloseIcon); 116 SetImageFromVectorIcon(close_button, ui::kCloseIcon);
116 close_button = close;
117 } else { 117 } else {
118 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 118 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
119 close_button = new ImageButton(delegate); 119 close_button = new ImageButton(listener);
120 close_button->SetImage(CustomButton::STATE_NORMAL, 120 close_button->SetImage(CustomButton::STATE_NORMAL,
121 *rb->GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia()); 121 *rb->GetImageNamed(IDR_CLOSE_DIALOG).ToImageSkia());
122 close_button->SetImage( 122 close_button->SetImage(
123 CustomButton::STATE_HOVERED, 123 CustomButton::STATE_HOVERED,
124 *rb->GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia()); 124 *rb->GetImageNamed(IDR_CLOSE_DIALOG_H).ToImageSkia());
125 close_button->SetImage( 125 close_button->SetImage(
126 CustomButton::STATE_PRESSED, 126 CustomButton::STATE_PRESSED,
127 *rb->GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia()); 127 *rb->GetImageNamed(IDR_CLOSE_DIALOG_P).ToImageSkia());
128 } 128 }
129 close_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE)); 129 close_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 size.Enlarge(client_insets.width(), client_insets.height()); 530 size.Enlarge(client_insets.width(), client_insets.height());
531 size.SetToMax(gfx::Size(title_bar_width, 0)); 531 size.SetToMax(gfx::Size(title_bar_width, 0));
532 532
533 if (footnote_container_) 533 if (footnote_container_)
534 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); 534 size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width()));
535 535
536 return size; 536 return size;
537 } 537 }
538 538
539 } // namespace views 539 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/bubble/bubble_frame_view.h ('k') | ui/views/controls/button/image_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698