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

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

Issue 1566563002: Vectorize CrOS window control icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dummy GetIcon impl in TestToolbarModel 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 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/frame/caption_buttons/frame_caption_button_container_view.h" 5 #include "ash/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/ash_switches.h" 10 #include "ash/ash_switches.h"
11 #include "ash/frame/caption_buttons/frame_caption_button.h" 11 #include "ash/frame/caption_buttons/frame_caption_button.h"
12 #include "ash/frame/caption_buttons/frame_size_button.h" 12 #include "ash/frame/caption_buttons/frame_size_button.h"
13 #include "ash/metrics/user_metrics_recorder.h" 13 #include "ash/metrics/user_metrics_recorder.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/touch/touch_uma.h" 15 #include "ash/touch/touch_uma.h"
16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
17 #include "ui/base/hit_test.h" 17 #include "ui/base/hit_test.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 19 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
20 #include "ui/gfx/animation/slide_animation.h" 20 #include "ui/gfx/animation/slide_animation.h"
21 #include "ui/gfx/animation/tween.h" 21 #include "ui/gfx/animation/tween.h"
22 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
24 #include "ui/gfx/geometry/point.h" 24 #include "ui/gfx/geometry/point.h"
25 #include "ui/gfx/vector_icons_public.h"
25 #include "ui/strings/grit/ui_strings.h" // Accessibility names 26 #include "ui/strings/grit/ui_strings.h" // Accessibility names
26 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
27 #include "ui/views/widget/widget_delegate.h" 28 #include "ui/views/widget/widget_delegate.h"
28 29
29 namespace ash { 30 namespace ash {
30 31
31 namespace { 32 namespace {
32 33
33 // Duration of the animation of the position of |minimize_button_|. 34 // Duration of the animation of the position of |minimize_button_|.
34 const int kPositionAnimationDurationMs = 500; 35 const int kPositionAnimationDurationMs = 500;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 AddChildView(close_button_); 143 AddChildView(close_button_);
143 } 144 }
144 145
145 FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() { 146 FrameCaptionButtonContainerView::~FrameCaptionButtonContainerView() {
146 } 147 }
147 148
148 void FrameCaptionButtonContainerView::TestApi::EndAnimations() { 149 void FrameCaptionButtonContainerView::TestApi::EndAnimations() {
149 container_view_->maximize_mode_animation_->End(); 150 container_view_->maximize_mode_animation_->End();
150 } 151 }
151 152
152 void FrameCaptionButtonContainerView::SetButtonImage(CaptionButtonIcon icon, 153 void FrameCaptionButtonContainerView::SetButtonImage(
153 int icon_image_id) { 154 CaptionButtonIcon icon,
155 gfx::VectorIconId icon_image_id) {
154 button_icon_id_map_[icon] = icon_image_id; 156 button_icon_id_map_[icon] = icon_image_id;
155 157
156 FrameCaptionButton* buttons[] = { 158 FrameCaptionButton* buttons[] = {
157 minimize_button_, size_button_, close_button_ 159 minimize_button_, size_button_, close_button_
158 }; 160 };
159 for (size_t i = 0; i < arraysize(buttons); ++i) { 161 for (size_t i = 0; i < arraysize(buttons); ++i) {
160 if (buttons[i]->icon() == icon) 162 if (buttons[i]->icon() == icon)
161 buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO, icon_image_id); 163 buttons[i]->SetImage(icon, FrameCaptionButton::ANIMATE_NO, icon_image_id);
162 } 164 }
163 } 165 }
164 166
165 void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) { 167 void FrameCaptionButtonContainerView::SetPaintAsActive(bool paint_as_active) {
166 minimize_button_->set_paint_as_active(paint_as_active); 168 minimize_button_->set_paint_as_active(paint_as_active);
167 size_button_->set_paint_as_active(paint_as_active); 169 size_button_->set_paint_as_active(paint_as_active);
168 close_button_->set_paint_as_active(paint_as_active); 170 close_button_->set_paint_as_active(paint_as_active);
169 } 171 }
170 172
173 void FrameCaptionButtonContainerView::SetUseLightImages(bool light) {
174 minimize_button_->set_use_light_images(light);
175 size_button_->set_use_light_images(light);
176 close_button_->set_use_light_images(light);
177 }
178
171 void FrameCaptionButtonContainerView::ResetWindowControls() { 179 void FrameCaptionButtonContainerView::ResetWindowControls() {
172 SetButtonsToNormal(ANIMATE_NO); 180 SetButtonsToNormal(ANIMATE_NO);
173 } 181 }
174 182
175 int FrameCaptionButtonContainerView::NonClientHitTest( 183 int FrameCaptionButtonContainerView::NonClientHitTest(
176 const gfx::Point& point) const { 184 const gfx::Point& point) const {
177 if (close_button_->visible() && 185 if (close_button_->visible() &&
178 ConvertPointToViewAndHitTest(this, close_button_, point)) { 186 ConvertPointToViewAndHitTest(this, close_button_, point)) {
179 return HTCLOSE; 187 return HTCLOSE;
180 } else if (size_button_->visible() && 188 } else if (size_button_->visible() &&
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 views::Button::ButtonState new_state = views::Button::STATE_NORMAL; 411 views::Button::ButtonState new_state = views::Button::STATE_NORMAL;
404 if (button == to_hover) 412 if (button == to_hover)
405 new_state = views::Button::STATE_HOVERED; 413 new_state = views::Button::STATE_HOVERED;
406 else if (button == to_press) 414 else if (button == to_press)
407 new_state = views::Button::STATE_PRESSED; 415 new_state = views::Button::STATE_PRESSED;
408 button->SetState(new_state); 416 button->SetState(new_state);
409 } 417 }
410 } 418 }
411 419
412 } // namespace ash 420 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698