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

Side by Side Diff: mash/wm/frame/caption_buttons/frame_caption_button.cc

Issue 1534303002: CustomButton cleanup: make protected members private, create accessors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dont move declaration randomly Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "mash/wm/frame/caption_buttons/frame_caption_button.h" 5 #include "mash/wm/frame/caption_buttons/frame_caption_button.h"
6 6
7 #include "ui/base/resource/resource_bundle.h" 7 #include "ui/base/resource/resource_bundle.h"
8 #include "ui/gfx/animation/slide_animation.h" 8 #include "ui/gfx/animation/slide_animation.h"
9 #include "ui/gfx/animation/throb_animation.h" 9 #include "ui/gfx/animation/throb_animation.h"
10 #include "ui/gfx/canvas.h" 10 #include "ui/gfx/canvas.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 gfx::Size FrameCaptionButton::GetPreferredSize() const { 104 gfx::Size FrameCaptionButton::GetPreferredSize() const {
105 return hovered_background_image_.isNull() ? gfx::Size() 105 return hovered_background_image_.isNull() ? gfx::Size()
106 : hovered_background_image_.size(); 106 : hovered_background_image_.size();
107 } 107 }
108 108
109 const char* FrameCaptionButton::GetClassName() const { 109 const char* FrameCaptionButton::GetClassName() const {
110 return kViewClassName; 110 return kViewClassName;
111 } 111 }
112 112
113 void FrameCaptionButton::OnPaint(gfx::Canvas* canvas) { 113 void FrameCaptionButton::OnPaint(gfx::Canvas* canvas) {
114 if (hover_animation_->is_animating() || state() == STATE_HOVERED) { 114 if (hover_animation().is_animating() || state() == STATE_HOVERED) {
115 int hovered_background_alpha = 115 int hovered_background_alpha =
116 hover_animation_->is_animating() 116 hover_animation().CurrentValueBetween(0, 255);
117 ? hover_animation_->CurrentValueBetween(0, 255)
118 : 255;
119 SkPaint paint; 117 SkPaint paint;
120 paint.setAlpha(hovered_background_alpha); 118 paint.setAlpha(hovered_background_alpha);
121 canvas->DrawImageInt(hovered_background_image_, 0, 0, paint); 119 canvas->DrawImageInt(hovered_background_image_, 0, 0, paint);
122 } else if (state() == STATE_PRESSED) { 120 } else if (state() == STATE_PRESSED) {
123 canvas->DrawImageInt(pressed_background_image_, 0, 0); 121 canvas->DrawImageInt(pressed_background_image_, 0, 0);
124 } 122 }
125 123
126 int icon_alpha = swap_images_animation_->CurrentValueBetween(0, 255); 124 int icon_alpha = swap_images_animation_->CurrentValueBetween(0, 255);
127 int crossfade_icon_alpha = 0; 125 int crossfade_icon_alpha = 0;
128 if (icon_alpha < static_cast<int>(kFadeOutRatio * 255)) 126 if (icon_alpha < static_cast<int>(kFadeOutRatio * 255))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 167 }
170 CustomButton::OnGestureEvent(event); 168 CustomButton::OnGestureEvent(event);
171 } 169 }
172 170
173 void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas, 171 void FrameCaptionButton::PaintCentered(gfx::Canvas* canvas,
174 const gfx::ImageSkia& to_center, 172 const gfx::ImageSkia& to_center,
175 int alpha) { 173 int alpha) {
176 if (!paint_as_active_) { 174 if (!paint_as_active_) {
177 // Paint icons as active when they are hovered over or pressed. 175 // Paint icons as active when they are hovered over or pressed.
178 double inactive_alpha = kInactiveIconAlpha; 176 double inactive_alpha = kInactiveIconAlpha;
179 if (hover_animation_->is_animating()) { 177 if (hover_animation().is_animating()) {
180 inactive_alpha = 178 inactive_alpha =
181 hover_animation_->CurrentValueBetween(inactive_alpha, 1.0f); 179 hover_animation().CurrentValueBetween(inactive_alpha, 1.0f);
182 } else if (state() == STATE_PRESSED || state() == STATE_HOVERED) { 180 } else if (state() == STATE_PRESSED || state() == STATE_HOVERED) {
183 inactive_alpha = 1.0f; 181 inactive_alpha = 1.0f;
184 } 182 }
185 alpha *= inactive_alpha; 183 alpha *= inactive_alpha;
186 } 184 }
187 185
188 SkPaint paint; 186 SkPaint paint;
189 paint.setAlpha(alpha); 187 paint.setAlpha(alpha);
190 canvas->DrawImageInt(to_center, (width() - to_center.width()) / 2, 188 canvas->DrawImageInt(to_center, (width() - to_center.width()) / 2,
191 (height() - to_center.height()) / 2, paint); 189 (height() - to_center.height()) / 2, paint);
192 } 190 }
193 191
194 } // namespace wm 192 } // namespace wm
195 } // namespace mash 193 } // namespace mash
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/toolbar_button.cc ('k') | ui/app_list/views/app_list_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698