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

Side by Side Diff: ash/shelf/app_list_button.cc

Issue 2972923002: Update voice interaction burst animation (Closed)
Patch Set: update formating 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/shelf/app_list_button.h" 5 #include "ash/shelf/app_list_button.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/public/cpp/shelf_types.h" 10 #include "ash/public/cpp/shelf_types.h"
(...skipping 27 matching lines...) Expand all
38 #include "ui/gfx/paint_vector_icon.h" 38 #include "ui/gfx/paint_vector_icon.h"
39 #include "ui/gfx/scoped_canvas.h" 39 #include "ui/gfx/scoped_canvas.h"
40 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" 40 #include "ui/views/animation/flood_fill_ink_drop_ripple.h"
41 #include "ui/views/animation/ink_drop_impl.h" 41 #include "ui/views/animation/ink_drop_impl.h"
42 #include "ui/views/animation/ink_drop_mask.h" 42 #include "ui/views/animation/ink_drop_mask.h"
43 #include "ui/views/painter.h" 43 #include "ui/views/painter.h"
44 44
45 namespace ash { 45 namespace ash {
46 namespace { 46 namespace {
47 constexpr int kVoiceInteractionAnimationDelayMs = 200; 47 constexpr int kVoiceInteractionAnimationDelayMs = 200;
48 constexpr int kVoiceInteractionAnimationHideDelayMs = 500;
48 } // namespace 49 } // namespace
49 50
50 constexpr uint8_t kVoiceInteractionRunningAlpha = 255; // 100% alpha 51 constexpr uint8_t kVoiceInteractionRunningAlpha = 255; // 100% alpha
51 constexpr uint8_t kVoiceInteractionNotRunningAlpha = 138; // 54% alpha 52 constexpr uint8_t kVoiceInteractionNotRunningAlpha = 138; // 54% alpha
52 53
53 AppListButton::AppListButton(InkDropButtonListener* listener, 54 AppListButton::AppListButton(InkDropButtonListener* listener,
54 ShelfView* shelf_view, 55 ShelfView* shelf_view,
55 Shelf* shelf) 56 Shelf* shelf)
56 : views::ImageButton(nullptr), 57 : views::ImageButton(nullptr),
57 is_showing_app_list_(false), 58 is_showing_app_list_(false),
(...skipping 12 matching lines...) Expand all
70 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE)); 71 l10n_util::GetStringUTF16(IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE));
71 SetSize(gfx::Size(kShelfSize, kShelfSize)); 72 SetSize(gfx::Size(kShelfSize, kShelfSize));
72 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); 73 SetFocusPainter(TrayPopupUtils::CreateFocusPainter());
73 set_notify_action(CustomButton::NOTIFY_ON_PRESS); 74 set_notify_action(CustomButton::NOTIFY_ON_PRESS);
74 75
75 if (chromeos::switches::IsVoiceInteractionEnabled()) { 76 if (chromeos::switches::IsVoiceInteractionEnabled()) {
76 voice_interaction_overlay_ = new VoiceInteractionOverlay(this); 77 voice_interaction_overlay_ = new VoiceInteractionOverlay(this);
77 AddChildView(voice_interaction_overlay_); 78 AddChildView(voice_interaction_overlay_);
78 voice_interaction_overlay_->SetVisible(false); 79 voice_interaction_overlay_->SetVisible(false);
79 voice_interaction_animation_delay_timer_.reset(new base::OneShotTimer()); 80 voice_interaction_animation_delay_timer_.reset(new base::OneShotTimer());
81 voice_interaction_animation_hide_delay_timer_.reset(
82 new base::OneShotTimer());
80 } else { 83 } else {
81 voice_interaction_overlay_ = nullptr; 84 voice_interaction_overlay_ = nullptr;
82 } 85 }
83 } 86 }
84 87
85 AppListButton::~AppListButton() { 88 AppListButton::~AppListButton() {
86 Shell::Get()->RemoveShellObserver(this); 89 Shell::Get()->RemoveShellObserver(this);
87 if (voice_interaction_animation_delay_timer_) 90 if (voice_interaction_animation_delay_timer_)
88 voice_interaction_animation_delay_timer_->Stop(); 91 voice_interaction_animation_delay_timer_->Stop();
92 if (voice_interaction_animation_hide_delay_timer_)
93 voice_interaction_animation_hide_delay_timer_->Stop();
oshima 2017/07/06 19:23:54 just curious. Timer's dtor automatically abandon t
xiaohuic 2017/07/06 20:55:41 Maybe I don't, removed.
89 } 94 }
90 95
91 void AppListButton::OnAppListShown() { 96 void AppListButton::OnAppListShown() {
92 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr); 97 AnimateInkDrop(views::InkDropState::ACTIVATED, nullptr);
93 is_showing_app_list_ = true; 98 is_showing_app_list_ = true;
94 shelf_->UpdateAutoHideState(); 99 shelf_->UpdateAutoHideState();
95 } 100 }
96 101
97 void AppListButton::OnAppListDismissed() { 102 void AppListButton::OnAppListDismissed() {
98 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); 103 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr);
(...skipping 29 matching lines...) Expand all
128 voice_interaction_animation_delay_timer_->Stop(); 133 voice_interaction_animation_delay_timer_->Stop();
129 } 134 }
130 ImageButton::OnGestureEvent(event); 135 ImageButton::OnGestureEvent(event);
131 return; 136 return;
132 case ui::ET_GESTURE_TAP_DOWN: 137 case ui::ET_GESTURE_TAP_DOWN:
133 if (voice_interaction_overlay_) { 138 if (voice_interaction_overlay_) {
134 voice_interaction_animation_delay_timer_->Start( 139 voice_interaction_animation_delay_timer_->Start(
135 FROM_HERE, 140 FROM_HERE,
136 base::TimeDelta::FromMilliseconds( 141 base::TimeDelta::FromMilliseconds(
137 kVoiceInteractionAnimationDelayMs), 142 kVoiceInteractionAnimationDelayMs),
138 base::Bind(&VoiceInteractionOverlay::StartAnimation, 143 base::Bind(&AppListButton::StartVoiceInteractionAnimation,
139 base::Unretained(voice_interaction_overlay_))); 144 base::Unretained(this)));
140 } 145 }
141 if (!Shell::Get()->IsAppListVisible()) 146 if (!Shell::Get()->IsAppListVisible())
142 AnimateInkDrop(views::InkDropState::ACTION_PENDING, event); 147 AnimateInkDrop(views::InkDropState::ACTION_PENDING, event);
143 ImageButton::OnGestureEvent(event); 148 ImageButton::OnGestureEvent(event);
144 return; 149 return;
145 case ui::ET_GESTURE_LONG_PRESS: 150 case ui::ET_GESTURE_LONG_PRESS:
146 if (chromeos::switches::IsVoiceInteractionEnabled()) { 151 if (chromeos::switches::IsVoiceInteractionEnabled()) {
147 base::RecordAction(base::UserMetricsAction( 152 base::RecordAction(base::UserMetricsAction(
148 "VoiceInteraction.Started.AppListButtonLongPress")); 153 "VoiceInteraction.Started.AppListButtonLongPress"));
149 Shell::Get()->app_list()->StartVoiceInteractionSession(); 154 Shell::Get()->app_list()->StartVoiceInteractionSession();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 318
314 if (shown) 319 if (shown)
315 OnAppListShown(); 320 OnAppListShown();
316 else 321 else
317 OnAppListDismissed(); 322 OnAppListDismissed();
318 } 323 }
319 324
320 void AppListButton::OnVoiceInteractionStatusChanged(bool running) { 325 void AppListButton::OnVoiceInteractionStatusChanged(bool running) {
321 voice_interaction_running_ = running; 326 voice_interaction_running_ = running;
322 SchedulePaint(); 327 SchedulePaint();
328
329 // Voice interaction window shows up, we start hiding the animation if it is
330 // running.
331 if (running && voice_interaction_overlay_->IsBursting()) {
332 voice_interaction_animation_hide_delay_timer_->Start(
333 FROM_HERE,
334 base::TimeDelta::FromMilliseconds(
335 kVoiceInteractionAnimationHideDelayMs),
336 base::Bind(&VoiceInteractionOverlay::HideAnimation,
337 base::Unretained(voice_interaction_overlay_)));
338 }
339 }
340
341 void AppListButton::StartVoiceInteractionAnimation() {
342 // We only show the voice interaction icon and related animation when the
343 // shelf is at the bottom position and voice interaction is not running.
344 ShelfAlignment alignment = shelf_->alignment();
345 bool show_icon = (alignment == SHELF_ALIGNMENT_BOTTOM ||
346 alignment == SHELF_ALIGNMENT_BOTTOM_LOCKED) &&
347 !voice_interaction_running_;
348 voice_interaction_overlay_->StartAnimation(show_icon);
323 } 349 }
324 350
325 } // namespace ash 351 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698