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

Side by Side Diff: views/bubble/bubble_delegate.cc

Issue 8319008: aura: brightness and volume bubble. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update comments Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/bubble/bubble_delegate.h" 5 #include "views/bubble/bubble_delegate.h"
6 6
7 #include "ui/base/animation/slide_animation.h" 7 #include "ui/base/animation/slide_animation.h"
8 #include "views/bubble/bubble_frame_view.h" 8 #include "views/bubble/bubble_frame_view.h"
9 #include "views/widget/widget.h" 9 #include "views/widget/widget.h"
10 10
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 BubbleDelegateView::BubbleDelegateView( 24 BubbleDelegateView::BubbleDelegateView(
25 const gfx::Point& anchor_point, 25 const gfx::Point& anchor_point,
26 BubbleBorder::ArrowLocation arrow_location, 26 BubbleBorder::ArrowLocation arrow_location,
27 const SkColor& color) 27 const SkColor& color)
28 : WidgetDelegateView(), 28 : WidgetDelegateView(),
29 close_on_esc_(true), 29 close_on_esc_(true),
30 anchor_point_(anchor_point), 30 anchor_point_(anchor_point),
31 arrow_location_(arrow_location), 31 arrow_location_(arrow_location),
32 color_(color) { 32 color_(color),
33 original_opacity_(255) {
33 AddAccelerator(Accelerator(ui::VKEY_ESCAPE, 0)); 34 AddAccelerator(Accelerator(ui::VKEY_ESCAPE, 0));
34 } 35 }
35 36
36 BubbleDelegateView::~BubbleDelegateView() {} 37 BubbleDelegateView::~BubbleDelegateView() {}
37 38
38 // static 39 // static
39 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate, 40 Widget* BubbleDelegateView::CreateBubble(BubbleDelegateView* bubble_delegate,
40 Widget* parent_widget) { 41 Widget* parent_widget) {
41 bubble_delegate->Init(); 42 bubble_delegate->Init();
42 views::Widget* bubble_widget = new views::Widget(); 43 views::Widget* bubble_widget = new views::Widget();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return color_; 82 return color_;
82 } 83 }
83 84
84 void BubbleDelegateView::Init() {} 85 void BubbleDelegateView::Init() {}
85 86
86 void BubbleDelegateView::StartFade(bool fade_in) { 87 void BubbleDelegateView::StartFade(bool fade_in) {
87 fade_animation_.reset(new ui::SlideAnimation(this)); 88 fade_animation_.reset(new ui::SlideAnimation(this));
88 fade_animation_->SetSlideDuration(kHideFadeDurationMS); 89 fade_animation_->SetSlideDuration(kHideFadeDurationMS);
89 fade_animation_->Reset(fade_in ? 0.0 : 1.0); 90 fade_animation_->Reset(fade_in ? 0.0 : 1.0);
90 if (fade_in) { 91 if (fade_in) {
91 GetWidget()->SetOpacity(0); 92 original_opacity_ = 0;
93 GetWidget()->SetOpacity(original_opacity_);
92 GetWidget()->Show(); 94 GetWidget()->Show();
93 fade_animation_->Show(); 95 fade_animation_->Show();
94 } else { 96 } else {
97 original_opacity_ = 255;
95 fade_animation_->Hide(); 98 fade_animation_->Hide();
96 } 99 }
97 } 100 }
98 101
102 void BubbleDelegateView::ResetFade() {
103 fade_animation_.reset();
104 GetWidget()->SetOpacity(original_opacity_);
105 }
106
99 bool BubbleDelegateView::AcceleratorPressed(const Accelerator& accelerator) { 107 bool BubbleDelegateView::AcceleratorPressed(const Accelerator& accelerator) {
100 if (!close_on_esc() || accelerator.key_code() != ui::VKEY_ESCAPE) 108 if (!close_on_esc() || accelerator.key_code() != ui::VKEY_ESCAPE)
101 return false; 109 return false;
102 if (fade_animation_.get()) 110 if (fade_animation_.get())
103 fade_animation_->Reset(); 111 fade_animation_->Reset();
104 GetWidget()->Close(); 112 GetWidget()->Close();
105 return true; 113 return true;
106 } 114 }
107 115
108 void BubbleDelegateView::AnimationEnded(const ui::Animation* animation) { 116 void BubbleDelegateView::AnimationEnded(const ui::Animation* animation) {
(...skipping 21 matching lines...) Expand all
130 } 138 }
131 139
132 gfx::Rect BubbleDelegateView::GetBubbleBounds() { 140 gfx::Rect BubbleDelegateView::GetBubbleBounds() {
133 // The argument rect has its origin at the bubble's arrow anchor point; 141 // The argument rect has its origin at the bubble's arrow anchor point;
134 // its size is the preferred size of the bubble's client view (this view). 142 // its size is the preferred size of the bubble's client view (this view).
135 return GetBubbleFrameView()->GetWindowBoundsForClientBounds( 143 return GetBubbleFrameView()->GetWindowBoundsForClientBounds(
136 gfx::Rect(GetAnchorPoint(), GetPreferredSize())); 144 gfx::Rect(GetAnchorPoint(), GetPreferredSize()));
137 } 145 }
138 146
139 } // namespace views 147 } // namespace views
OLDNEW
« chrome/browser/chromeos/volume_bubble_browsertest.cc ('K') | « views/bubble/bubble_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698