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

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

Issue 2618383004: Revert of Move more vector icons to respective directories and update code to (Closed)
Patch Set: 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_icon_types.h" 22 #include "ui/gfx/vector_icons_public.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 const gfx::VectorIcon& icon_definition) { 151 gfx::VectorIconId icon_image_id) {
152 button_icon_map_[icon] = &icon_definition; 152 button_icon_id_map_[icon] = icon_image_id;
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, 158 buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO, icon_image_id);
159 icon_definition);
160 } 159 }
161 } 160 }
162 161
163 void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) { 162 void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) {
164 minimize_button_->set_paint_as_active(paint_as_active); 163 minimize_button_->set_paint_as_active(paint_as_active);
165 size_button_->set_paint_as_active(paint_as_active); 164 size_button_->set_paint_as_active(paint_as_active);
166 close_button_->set_paint_as_active(paint_as_active); 165 close_button_->set_paint_as_active(paint_as_active);
167 } 166 }
168 167
169 void FrameCaptionButtonContainerView::SetUseLightImages(bool light) { 168 void FrameCaptionButtonContainerView::SetUseLightImages(bool light) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // SetButtonIcon() with ANIMATE_NO to progress |button|'s crossfade animation 292 // SetButtonIcon() with ANIMATE_NO to progress |button|'s crossfade animation
294 // to the end. 293 // to the end.
295 if (button->icon() == icon && 294 if (button->icon() == icon &&
296 (animate == ANIMATE_YES || !button->IsAnimatingImageSwap())) { 295 (animate == ANIMATE_YES || !button->IsAnimatingImageSwap())) {
297 return; 296 return;
298 } 297 }
299 298
300 FrameCaptionButton::Animate fcb_animate = 299 FrameCaptionButton::Animate fcb_animate =
301 (animate == ANIMATE_YES) ? FrameCaptionButton::ANIMATE_YES 300 (animate == ANIMATE_YES) ? FrameCaptionButton::ANIMATE_YES
302 : FrameCaptionButton::ANIMATE_NO; 301 : FrameCaptionButton::ANIMATE_NO;
303 auto it = button_icon_map_.find(icon); 302 auto it = button_icon_id_map_.find(icon);
304 if (it != button_icon_map_.end()) 303 if (it != button_icon_id_map_.end())
305 button->SetImage(icon, fcb_animate, *it->second); 304 button->SetImage(icon, fcb_animate, it->second);
306 } 305 }
307 306
308 bool FrameCaptionButtonContainerView::ShouldSizeButtonBeVisible() const { 307 bool FrameCaptionButtonContainerView::ShouldSizeButtonBeVisible() const {
309 return !WmShell::Get() 308 return !WmShell::Get()
310 ->maximize_mode_controller() 309 ->maximize_mode_controller()
311 ->IsMaximizeModeWindowManagerEnabled() && 310 ->IsMaximizeModeWindowManagerEnabled() &&
312 frame_->widget_delegate()->CanMaximize(); 311 frame_->widget_delegate()->CanMaximize();
313 } 312 }
314 313
315 void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender, 314 void FrameCaptionButtonContainerView::ButtonPressed(views::Button* sender,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 views::Button::ButtonState new_state = views::Button::STATE_NORMAL; 402 views::Button::ButtonState new_state = views::Button::STATE_NORMAL;
404 if (button == to_hover) 403 if (button == to_hover)
405 new_state = views::Button::STATE_HOVERED; 404 new_state = views::Button::STATE_HOVERED;
406 else if (button == to_press) 405 else if (button == to_press)
407 new_state = views::Button::STATE_PRESSED; 406 new_state = views::Button::STATE_PRESSED;
408 button->SetState(new_state); 407 button->SetState(new_state);
409 } 408 }
410 } 409 }
411 410
412 } // namespace ash 411 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698