OLD | NEW |
---|---|
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" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 return std::min(1.0, std::max(0.0, value)); | 102 return std::min(1.0, std::max(0.0, value)); |
103 } | 103 } |
104 | 104 |
105 } // namespace | 105 } // namespace |
106 | 106 |
107 // static | 107 // static |
108 const char FrameCaptionButtonContainerView::kViewClassName[] = | 108 const char FrameCaptionButtonContainerView::kViewClassName[] = |
109 "FrameCaptionButtonContainerView"; | 109 "FrameCaptionButtonContainerView"; |
110 | 110 |
111 FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( | 111 FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( |
112 views::Widget* frame, | 112 views::Widget* frame) |
113 MinimizeAllowed minimize_allowed) | |
114 : frame_(frame), | 113 : frame_(frame), |
115 minimize_button_(NULL), | 114 minimize_button_(NULL), |
116 size_button_(NULL), | 115 size_button_(NULL), |
117 close_button_(NULL) { | 116 close_button_(NULL) { |
118 bool size_button_visibility = ShouldSizeButtonBeVisible(); | 117 bool size_button_visibility = ShouldSizeButtonBeVisible(); |
119 maximize_mode_animation_.reset(new gfx::SlideAnimation(this)); | 118 maximize_mode_animation_.reset(new gfx::SlideAnimation(this)); |
120 maximize_mode_animation_->SetTweenType(gfx::Tween::LINEAR); | 119 maximize_mode_animation_->SetTweenType(gfx::Tween::LINEAR); |
121 | 120 |
122 // Ensure animation tracks visibility of size button. | 121 // Ensure animation tracks visibility of size button. |
123 if (size_button_visibility) | 122 if (size_button_visibility) |
124 maximize_mode_animation_->Reset(1.0f); | 123 maximize_mode_animation_->Reset(1.0f); |
125 | 124 |
126 // Insert the buttons left to right. | 125 // Insert the buttons left to right. |
127 minimize_button_ = new FrameCaptionButton(this, CAPTION_BUTTON_ICON_MINIMIZE); | 126 minimize_button_ = new FrameCaptionButton(this, CAPTION_BUTTON_ICON_MINIMIZE); |
128 minimize_button_->SetAccessibleName( | 127 minimize_button_->SetAccessibleName( |
129 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); | 128 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); |
130 minimize_button_->SetVisible(minimize_allowed == MINIMIZE_ALLOWED); | |
131 AddChildView(minimize_button_); | 129 AddChildView(minimize_button_); |
132 | 130 |
133 size_button_ = new FrameSizeButton(this, frame, this); | 131 size_button_ = new FrameSizeButton(this, frame, this); |
134 size_button_->SetAccessibleName( | 132 size_button_->SetAccessibleName( |
135 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE)); | 133 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MAXIMIZE)); |
136 size_button_->SetVisible(size_button_visibility); | 134 size_button_->SetVisible(size_button_visibility); |
137 AddChildView(size_button_); | 135 AddChildView(size_button_); |
138 | 136 |
139 close_button_ = new FrameCaptionButton(this, CAPTION_BUTTON_ICON_CLOSE); | 137 close_button_ = new FrameCaptionButton(this, CAPTION_BUTTON_ICON_CLOSE); |
140 close_button_->SetAccessibleName( | 138 close_button_->SetAccessibleName( |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 } else if (sender == close_button_) { | 350 } else if (sender == close_button_) { |
353 frame_->Close(); | 351 frame_->Close(); |
354 action = ash::UMA_WINDOW_CLOSE_BUTTON_CLICK; | 352 action = ash::UMA_WINDOW_CLOSE_BUTTON_CLICK; |
355 } else { | 353 } else { |
356 return; | 354 return; |
357 } | 355 } |
358 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(action); | 356 ash::Shell::GetInstance()->metrics()->RecordUserMetricsAction(action); |
359 } | 357 } |
360 | 358 |
361 bool FrameCaptionButtonContainerView::IsMinimizeButtonVisible() const { | 359 bool FrameCaptionButtonContainerView::IsMinimizeButtonVisible() const { |
362 return minimize_button_->visible(); | 360 return minimize_button_->visible(); |
pkotwicz
2014/09/19 03:34:31
Can you please remove this method and its callers?
| |
363 } | 361 } |
364 | 362 |
365 void FrameCaptionButtonContainerView::SetButtonsToNormal(Animate animate) { | 363 void FrameCaptionButtonContainerView::SetButtonsToNormal(Animate animate) { |
366 SetButtonIcons(CAPTION_BUTTON_ICON_MINIMIZE, CAPTION_BUTTON_ICON_CLOSE, | 364 SetButtonIcons(CAPTION_BUTTON_ICON_MINIMIZE, CAPTION_BUTTON_ICON_CLOSE, |
367 animate); | 365 animate); |
368 minimize_button_->SetState(views::Button::STATE_NORMAL); | 366 minimize_button_->SetState(views::Button::STATE_NORMAL); |
369 size_button_->SetState(views::Button::STATE_NORMAL); | 367 size_button_->SetState(views::Button::STATE_NORMAL); |
370 close_button_->SetState(views::Button::STATE_NORMAL); | 368 close_button_->SetState(views::Button::STATE_NORMAL); |
371 } | 369 } |
372 | 370 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 : icon_image_id(icon_id), | 439 : icon_image_id(icon_id), |
442 inactive_icon_image_id(inactive_icon_id), | 440 inactive_icon_image_id(inactive_icon_id), |
443 hovered_background_image_id(hovered_background_id), | 441 hovered_background_image_id(hovered_background_id), |
444 pressed_background_image_id(pressed_background_id) { | 442 pressed_background_image_id(pressed_background_id) { |
445 } | 443 } |
446 | 444 |
447 FrameCaptionButtonContainerView::ButtonIconIds::~ButtonIconIds() { | 445 FrameCaptionButtonContainerView::ButtonIconIds::~ButtonIconIds() { |
448 } | 446 } |
449 | 447 |
450 } // namespace ash | 448 } // namespace ash |
OLD | NEW |