OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/message_center/views/notification_header_view.h" | 5 #include "ui/message_center/views/notification_header_view.h" |
6 | 6 |
7 #include "ui/base/l10n/l10n_util.h" | 7 #include "ui/base/l10n/l10n_util.h" |
8 #include "ui/gfx/color_palette.h" | 8 #include "ui/gfx/color_palette.h" |
9 #include "ui/gfx/font_list.h" | 9 #include "ui/gfx/font_list.h" |
10 #include "ui/gfx/paint_vector_icon.h" | 10 #include "ui/gfx/paint_vector_icon.h" |
11 #include "ui/message_center/message_center_style.h" | 11 #include "ui/message_center/message_center_style.h" |
12 #include "ui/message_center/vector_icons.h" | 12 #include "ui/message_center/vector_icons.h" |
13 #include "ui/message_center/views/padded_button.h" | 13 #include "ui/message_center/views/padded_button.h" |
14 #include "ui/strings/grit/ui_strings.h" | 14 #include "ui/strings/grit/ui_strings.h" |
15 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | |
16 #include "ui/views/animation/ink_drop_highlight.h" | |
17 #include "ui/views/animation/ink_drop_impl.h" | |
15 #include "ui/views/controls/button/image_button.h" | 18 #include "ui/views/controls/button/image_button.h" |
16 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
17 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
18 #include "ui/views/layout/box_layout.h" | 21 #include "ui/views/layout/box_layout.h" |
19 #include "ui/views/painter.h" | 22 #include "ui/views/painter.h" |
20 | 23 |
21 namespace message_center { | 24 namespace message_center { |
22 | 25 |
23 namespace { | 26 namespace { |
24 | 27 |
25 constexpr int kHeaderHeight = 28; | 28 constexpr int kHeaderHeight = 28; |
26 constexpr int kAppIconSize = 12; | 29 constexpr int kAppIconSize = 12; |
27 constexpr int kExpandIconSize = 12; | 30 constexpr int kExpandIconSize = 12; |
28 constexpr gfx::Insets kHeaderPadding(0, 12, 0, 2); | 31 constexpr gfx::Insets kHeaderPadding(0, 12, 0, 2); |
29 constexpr int kHeaderHorizontalSpacing = 2; | 32 constexpr int kHeaderHorizontalSpacing = 2; |
30 constexpr int kAppInfoConatainerTopPadding = 12; | 33 constexpr int kAppInfoConatainerTopPadding = 12; |
31 | 34 |
35 // Base ink drop color of action buttons. | |
36 const SkColor kInkDropBaseColor = SkColorSetRGB(0x0, 0x0, 0x0); | |
37 // Ripple ink drop opacity of action buttons. | |
38 const float kInkDropRippleVisibleOpacity = 0.08f; | |
39 // Highlight (hover) ink drop opacity of action buttons. | |
40 const float kInkDropHighlightVisibleOpacity = 0.08f; | |
41 | |
32 } // namespace | 42 } // namespace |
33 | 43 |
34 NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) | 44 NotificationHeaderView::NotificationHeaderView(views::ButtonListener* listener) |
35 : views::CustomButton(listener) { | 45 : views::CustomButton(listener) { |
46 SetFocusBehavior(FocusBehavior::ALWAYS); | |
47 SetInkDropMode(InkDropMode::ON); | |
48 set_has_ink_drop_action_on_click(true); | |
49 set_animate_on_state_change(true); | |
50 set_notify_enter_exit_on_child(true); | |
51 set_ink_drop_base_color(kInkDropBaseColor); | |
52 set_ink_drop_visible_opacity(kInkDropRippleVisibleOpacity); | |
53 | |
36 views::BoxLayout* layout = new views::BoxLayout( | 54 views::BoxLayout* layout = new views::BoxLayout( |
37 views::BoxLayout::kHorizontal, kHeaderPadding, kHeaderHorizontalSpacing); | 55 views::BoxLayout::kHorizontal, kHeaderPadding, kHeaderHorizontalSpacing); |
38 layout->set_cross_axis_alignment( | 56 layout->set_cross_axis_alignment( |
39 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 57 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
40 SetLayoutManager(layout); | 58 SetLayoutManager(layout); |
41 | 59 |
42 views::View* app_info_container = new views::View(); | 60 views::View* app_info_container = new views::View(); |
43 views::BoxLayout* app_info_layout = | 61 views::BoxLayout* app_info_layout = |
44 new views::BoxLayout(views::BoxLayout::kHorizontal, | 62 new views::BoxLayout(views::BoxLayout::kHorizontal, |
45 gfx::Insets(kAppInfoConatainerTopPadding, 0, 0, 0), | 63 gfx::Insets(kAppInfoConatainerTopPadding, 0, 0, 0), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 } | 162 } |
145 | 163 |
146 bool NotificationHeaderView::IsSettingsButtonEnabled() { | 164 bool NotificationHeaderView::IsSettingsButtonEnabled() { |
147 return settings_button_enabled_; | 165 return settings_button_enabled_; |
148 } | 166 } |
149 | 167 |
150 bool NotificationHeaderView::IsCloseButtonEnabled() { | 168 bool NotificationHeaderView::IsCloseButtonEnabled() { |
151 return close_button_enabled_; | 169 return close_button_enabled_; |
152 } | 170 } |
153 | 171 |
172 std::unique_ptr<views::InkDrop> NotificationHeaderView::CreateInkDrop() { | |
173 return InkDropHostView::CreateDefaultFloodFillInkDropImpl(); | |
174 } | |
175 | |
176 std::unique_ptr<views::InkDropRipple> | |
177 NotificationHeaderView::CreateInkDropRipple() const { | |
178 return base::MakeUnique<views::FloodFillInkDropRipple>( | |
179 size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), | |
180 ink_drop_visible_opacity()); | |
181 } | |
182 | |
183 std::unique_ptr<views::InkDropHighlight> | |
184 NotificationHeaderView::CreateInkDropHighlight() const { | |
185 std::unique_ptr<views::InkDropHighlight> highlight = | |
186 base::MakeUnique<views::InkDropHighlight>( | |
187 size(), kInkDropSmallCornerRadius, | |
188 gfx::RectF(GetLocalBounds()).CenterPoint(), GetInkDropBaseColor()); | |
189 highlight->set_visible_opacity(kInkDropHighlightVisibleOpacity); | |
190 return highlight; | |
191 } | |
192 | |
193 void NotificationHeaderView::OnMouseEvent(ui::MouseEvent* event) { | |
194 // Prevent updating SetHovered in InkDropHostView. | |
195 View::OnMouseEvent(event); | |
fukino
2017/06/29 04:30:42
This looks hacky (and scary)...
In ash system menu
tetsui
2017/06/29 07:49:14
Done.
| |
196 } | |
197 | |
154 void NotificationHeaderView::UpdateControlButtonsVisibility() { | 198 void NotificationHeaderView::UpdateControlButtonsVisibility() { |
155 settings_button_->SetVisible(settings_button_enabled_ && | 199 settings_button_->SetVisible(settings_button_enabled_ && |
156 is_control_buttons_visible_); | 200 is_control_buttons_visible_); |
157 close_button_->SetVisible(close_button_enabled_ && | 201 close_button_->SetVisible(close_button_enabled_ && |
158 is_control_buttons_visible_); | 202 is_control_buttons_visible_); |
159 Layout(); | 203 Layout(); |
160 } | 204 } |
161 | 205 |
162 } // namespace message_center | 206 } // namespace message_center |
OLD | NEW |