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

Side by Side Diff: ash/common/frame/caption_buttons/frame_caption_button_container_view.cc

Issue 2622893003: Reland f5157480667e99269e0062e9df1df3875db with fix for compile failure. (Closed)
Patch Set: fix in two BUILD.gns Created 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/frame/caption_buttons/frame_caption_button_container_view.h " 5 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h "
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <map> 8 #include <map>
9 9
10 #include "ash/common/frame/caption_buttons/frame_caption_button.h" 10 #include "ash/common/frame/caption_buttons/frame_caption_button.h"
11 #include "ash/common/frame/caption_buttons/frame_size_button.h" 11 #include "ash/common/frame/caption_buttons/frame_size_button.h"
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ui/base/hit_test.h" 14 #include "ui/base/hit_test.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 16 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
17 #include "ui/gfx/animation/slide_animation.h" 17 #include "ui/gfx/animation/slide_animation.h"
18 #include "ui/gfx/animation/tween.h" 18 #include "ui/gfx/animation/tween.h"
19 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/geometry/insets.h" 20 #include "ui/gfx/geometry/insets.h"
21 #include "ui/gfx/geometry/point.h" 21 #include "ui/gfx/geometry/point.h"
22 #include "ui/gfx/vector_icons_public.h" 22 #include "ui/gfx/vector_icon_types.h"
23 #include "ui/strings/grit/ui_strings.h" // Accessibility names 23 #include "ui/strings/grit/ui_strings.h" // Accessibility names
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_delegate.h" 25 #include "ui/views/widget/widget_delegate.h"
26 26
27 namespace ash { 27 namespace ash {
28 28
29 namespace { 29 namespace {
30 30
31 // Duration of the animation of the position of |minimize_button_|. 31 // Duration of the animation of the position of |minimize_button_|.
32 const int kPositionAnimationDurationMs = 500; 32 const int kPositionAnimationDurationMs = 500;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 142
143 FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() {} 143 FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() {}
144 144
145 void FrameCaptionButtonContainerView::TestApi::EndAnimations() { 145 void FrameCaptionButtonContainerView::TestApi::EndAnimations() {
146 container_view_->maximize_mode_animation_->End(); 146 container_view_->maximize_mode_animation_->End();
147 } 147 }
148 148
149 void FrameCaptionButtonContainerView::SetButtonImage( 149 void FrameCaptionButtonContainerView::SetButtonImage(
150 CaptionButtonIcon icon, 150 CaptionButtonIcon icon,
151 gfx::VectorIconId icon_image_id) { 151 const gfx::VectorIcon& icon_definition) {
152 button_icon_id_map_[icon] = icon_image_id; 152 button_icon_map_[icon] = &icon_definition;
153 153
154 FrameCaptionButton* buttons[] = {minimize_button_, size_button_, 154 FrameCaptionButton* buttons[] = {minimize_button_, size_button_,
155 close_button_}; 155 close_button_};
156 for (size_t i = 0; i < arraysize(buttons); ++i) { 156 for (size_t i = 0; i < arraysize(buttons); ++i) {
157 if (buttons[i]->icon() == icon) 157 if (buttons[i]->icon() == icon)
158 buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO, icon_image_id); 158 buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO,
159 icon_definition);
159 } 160 }
160 } 161 }
161 162
162 void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) { 163 void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) {
163 minimize_button_->set_paint_as_active(paint_as_active); 164 minimize_button_->set_paint_as_active(paint_as_active);
164 size_button_->set_paint_as_active(paint_as_active); 165 size_button_->set_paint_as_active(paint_as_active);
165 close_button_->set_paint_as_active(paint_as_active); 166 close_button_->set_paint_as_active(paint_as_active);
166 } 167 }
167 168
168 void FrameCaptionButtonContainerView::SetUseLightImages(bool light) { 169 void FrameCaptionButtonContainerView::SetUseLightImages(bool light) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // SetButtonIcon() with ANIMATE_NO to progress |button|'s crossfade animation 293 // SetButtonIcon() with ANIMATE_NO to progress |button|'s crossfade animation
293 // to the end. 294 // to the end.
294 if (button->icon() == icon && 295 if (button->icon() == icon &&
295 (animate == ANIMATE_YES || !button->IsAnimatingImageSwap())) { 296 (animate == ANIMATE_YES || !button->IsAnimatingImageSwap())) {
296 return; 297 return;
297 } 298 }
298 299
299 FrameCaptionButton::Animate fcb_animate = 300 FrameCaptionButton::Animate fcb_animate =
300 (animate == ANIMATE_YES) ? FrameCaptionButton::ANIMATE_YES 301 (animate == ANIMATE_YES) ? FrameCaptionButton::ANIMATE_YES
301 : FrameCaptionButton::ANIMATE_NO; 302 : FrameCaptionButton::ANIMATE_NO;
302 auto it = button_icon_id_map_.find(icon); 303 auto it = button_icon_map_.find(icon);
303 if (it != button_icon_id_map_.end()) 304 if (it != button_icon_map_.end())
304 button->SetImage(icon, fcb_animate, it->second); 305 button->SetImage(icon, fcb_animate, *it->second);
305 } 306 }
306 307
307 bool FrameCaptionButtonContainerView::ShouldSizeButtonBeVisible() const { 308 bool FrameCaptionButtonContainerView::ShouldSizeButtonBeVisible() const {
308 return !WmShell::Get() 309 return !WmShell::Get()
309 ->maximize_mode_controller() 310 ->maximize_mode_controller()
310 ->IsMaximizeModeWindowManagerEnabled() && 311 ->IsMaximizeModeWindowManagerEnabled() &&
311 frame_->widget_delegate()->CanMaximize(); 312 frame_->widget_delegate()->CanMaximize();
312 } 313 }
313 314
314 void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender, 315 void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 views::Button::ButtonState new_state = views::Button::STATE_NORMAL; 403 views::Button::ButtonState new_state = views::Button::STATE_NORMAL;
403 if (button == to_hover) 404 if (button == to_hover)
404 new_state = views::Button::STATE_HOVERED; 405 new_state = views::Button::STATE_HOVERED;
405 else if (button == to_press) 406 else if (button == to_press)
406 new_state = views::Button::STATE_PRESSED; 407 new_state = views::Button::STATE_PRESSED;
407 button->SetState(new_state); 408 button->SetState(new_state);
408 } 409 }
409 } 410 }
410 411
411 } // namespace ash 412 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698