| 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/wm/overview/window_selector_item.h" | 5 #include "ash/wm/overview/window_selector_item.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/overview/scoped_transform_overview_window.h" | 10 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 WindowSelectorItem::~WindowSelectorItem() { | 114 WindowSelectorItem::~WindowSelectorItem() { |
| 115 } | 115 } |
| 116 | 116 |
| 117 void WindowSelectorItem::RemoveWindow(const aura::Window* window) { | 117 void WindowSelectorItem::RemoveWindow(const aura::Window* window) { |
| 118 // If empty WindowSelectorItem will be destroyed immediately after this by | 118 // If empty WindowSelectorItem will be destroyed immediately after this by |
| 119 // its owner. | 119 // its owner. |
| 120 if (empty()) | 120 if (empty()) |
| 121 return; | 121 return; |
| 122 |
| 122 window_label_.reset(); | 123 window_label_.reset(); |
| 123 UpdateWindowLabels(target_bounds_, root_window_, false); | 124 UpdateWindowLabels(target_bounds_, root_window_, false); |
| 124 UpdateCloseButtonBounds(root_window_, false); | 125 UpdateCloseButtonBounds(root_window_, false); |
| 125 } | 126 } |
| 126 | 127 |
| 127 void WindowSelectorItem::SetBounds(aura::Window* root_window, | 128 void WindowSelectorItem::SetBounds(aura::Window* root_window, |
| 128 const gfx::Rect& target_bounds, | 129 const gfx::Rect& target_bounds, |
| 129 bool animate) { | 130 bool animate) { |
| 130 if (in_bounds_update_) | 131 if (in_bounds_update_) |
| 131 return; | 132 return; |
| 132 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 133 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
| 133 root_window_ = root_window; | 134 root_window_ = root_window; |
| 134 target_bounds_ = target_bounds; | 135 target_bounds_ = target_bounds; |
| 135 | 136 |
| 136 // Set the bounds of the transparent window handler to cover the entire | 137 // Set the bounds of the transparent window handler to cover the entire |
| 137 // bounding box area. | 138 // bounding box area. |
| 138 if (!activate_window_button_) { | 139 if (!activate_window_button_) { |
| 139 activate_window_button_.reset( | 140 activate_window_button_.reset( |
| 140 new TransparentActivateWindowButton(SelectionWindow())); | 141 new TransparentActivateWindowButton(SelectionWindow())); |
| 141 } | 142 } |
| 142 activate_window_button_->SetBounds(target_bounds); | 143 activate_window_button_->SetBounds(target_bounds); |
| 143 | 144 |
| 144 // TODO(nsatragno): Handle window title updates. | |
| 145 UpdateWindowLabels(target_bounds, root_window, animate); | 145 UpdateWindowLabels(target_bounds, root_window, animate); |
| 146 | 146 |
| 147 gfx::Rect inset_bounds(target_bounds); | 147 gfx::Rect inset_bounds(target_bounds); |
| 148 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 148 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
| 149 SetItemBounds(root_window, inset_bounds, animate); | 149 SetItemBounds(root_window, inset_bounds, animate); |
| 150 UpdateCloseButtonBounds(root_window, animate); | 150 UpdateCloseButtonBounds(root_window, animate); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void WindowSelectorItem::RecomputeWindowTransforms() { | 153 void WindowSelectorItem::RecomputeWindowTransforms() { |
| 154 if (in_bounds_update_ || target_bounds_.IsEmpty()) | 154 if (in_bounds_update_ || target_bounds_.IsEmpty()) |
| 155 return; | 155 return; |
| 156 DCHECK(root_window_); | 156 DCHECK(root_window_); |
| 157 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 157 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
| 158 gfx::Rect inset_bounds(target_bounds_); | 158 gfx::Rect inset_bounds(target_bounds_); |
| 159 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 159 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
| 160 SetItemBounds(root_window_, inset_bounds, false); | 160 SetItemBounds(root_window_, inset_bounds, false); |
| 161 UpdateCloseButtonBounds(root_window_, false); | 161 UpdateCloseButtonBounds(root_window_, false); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void WindowSelectorItem::SendFocusAlert() const { | 164 void WindowSelectorItem::SendFocusAlert() const { |
| 165 activate_window_button_->SendFocusAlert(); | 165 activate_window_button_->SendFocusAlert(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 168 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
| 169 const ui::Event& event) { | 169 const ui::Event& event) { |
| 170 views::Widget::GetWidgetForNativeView(SelectionWindow())->Close(); | 170 views::Widget::GetWidgetForNativeView(SelectionWindow())->Close(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window, |
| 174 const base::string16& new_title) { |
| 175 static_cast<views::Label*>( |
| 176 window_label_->GetContentsView())->SetText(new_title); |
| 177 } |
| 178 |
| 173 void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window, | 179 void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window, |
| 174 bool animate) { | 180 bool animate) { |
| 175 gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen( | 181 gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen( |
| 176 root_window, SelectionWindow()->layer()->bounds())); | 182 root_window, SelectionWindow()->layer()->bounds())); |
| 177 gfx::Transform window_transform; | 183 gfx::Transform window_transform; |
| 178 window_transform.Translate(align_bounds.x(), align_bounds.y()); | 184 window_transform.Translate(align_bounds.x(), align_bounds.y()); |
| 179 window_transform.PreconcatTransform(SelectionWindow()->layer()-> | 185 window_transform.PreconcatTransform(SelectionWindow()->layer()-> |
| 180 GetTargetTransform()); | 186 GetTargetTransform()); |
| 181 window_transform.Translate(-align_bounds.x(), -align_bounds.y()); | 187 window_transform.Translate(-align_bounds.x(), -align_bounds.y()); |
| 182 window_transform.TransformRect(&align_bounds); | 188 window_transform.TransformRect(&align_bounds); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 294 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 289 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 295 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 290 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 296 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| 291 } else { | 297 } else { |
| 292 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 298 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| 293 } | 299 } |
| 294 } | 300 } |
| 295 } | 301 } |
| 296 | 302 |
| 297 } // namespace ash | 303 } // namespace ash |
| OLD | NEW |