| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 target_bounds_ = target_bounds; | 134 target_bounds_ = target_bounds; |
| 135 | 135 |
| 136 // Set the bounds of the transparent window handler to cover the entire | 136 // Set the bounds of the transparent window handler to cover the entire |
| 137 // bounding box area. | 137 // bounding box area. |
| 138 if (!activate_window_button_) { | 138 if (!activate_window_button_) { |
| 139 activate_window_button_.reset( | 139 activate_window_button_.reset( |
| 140 new TransparentActivateWindowButton(SelectionWindow())); | 140 new TransparentActivateWindowButton(SelectionWindow())); |
| 141 } | 141 } |
| 142 activate_window_button_->SetBounds(target_bounds); | 142 activate_window_button_->SetBounds(target_bounds); |
| 143 | 143 |
| 144 // TODO(nsatragno): Handle window title updates. | |
| 145 UpdateWindowLabels(target_bounds, root_window, animate); | 144 UpdateWindowLabels(target_bounds, root_window, animate); |
| 146 | 145 |
| 147 gfx::Rect inset_bounds(target_bounds); | 146 gfx::Rect inset_bounds(target_bounds); |
| 148 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 147 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
| 149 SetItemBounds(root_window, inset_bounds, animate); | 148 SetItemBounds(root_window, inset_bounds, animate); |
| 150 UpdateCloseButtonBounds(root_window, animate); | 149 UpdateCloseButtonBounds(root_window, animate); |
| 151 } | 150 } |
| 152 | 151 |
| 153 void WindowSelectorItem::RecomputeWindowTransforms() { | 152 void WindowSelectorItem::RecomputeWindowTransforms() { |
| 154 if (in_bounds_update_ || target_bounds_.IsEmpty()) | 153 if (in_bounds_update_ || target_bounds_.IsEmpty()) |
| 155 return; | 154 return; |
| 156 DCHECK(root_window_); | 155 DCHECK(root_window_); |
| 157 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 156 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
| 158 gfx::Rect inset_bounds(target_bounds_); | 157 gfx::Rect inset_bounds(target_bounds_); |
| 159 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 158 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
| 160 SetItemBounds(root_window_, inset_bounds, false); | 159 SetItemBounds(root_window_, inset_bounds, false); |
| 161 UpdateCloseButtonBounds(root_window_, false); | 160 UpdateCloseButtonBounds(root_window_, false); |
| 162 } | 161 } |
| 163 | 162 |
| 164 void WindowSelectorItem::SendFocusAlert() const { | 163 void WindowSelectorItem::SendFocusAlert() const { |
| 165 activate_window_button_->SendFocusAlert(); | 164 activate_window_button_->SendFocusAlert(); |
| 166 } | 165 } |
| 167 | 166 |
| 168 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 167 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
| 169 const ui::Event& event) { | 168 const ui::Event& event) { |
| 170 views::Widget::GetWidgetForNativeView(SelectionWindow())->Close(); | 169 views::Widget::GetWidgetForNativeView(SelectionWindow())->Close(); |
| 171 } | 170 } |
| 172 | 171 |
| 172 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window, |
| 173 const base::string16& new_title) { |
| 174 static_cast<views::Label*>( |
| 175 window_label_->GetContentsView())->SetText(new_title); |
| 176 } |
| 177 |
| 173 void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window, | 178 void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window, |
| 174 bool animate) { | 179 bool animate) { |
| 175 gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen( | 180 gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen( |
| 176 root_window, SelectionWindow()->layer()->bounds())); | 181 root_window, SelectionWindow()->layer()->bounds())); |
| 177 gfx::Transform window_transform; | 182 gfx::Transform window_transform; |
| 178 window_transform.Translate(align_bounds.x(), align_bounds.y()); | 183 window_transform.Translate(align_bounds.x(), align_bounds.y()); |
| 179 window_transform.PreconcatTransform(SelectionWindow()->layer()-> | 184 window_transform.PreconcatTransform(SelectionWindow()->layer()-> |
| 180 GetTargetTransform()); | 185 GetTargetTransform()); |
| 181 window_transform.Translate(-align_bounds.x(), -align_bounds.y()); | 186 window_transform.Translate(-align_bounds.x(), -align_bounds.y()); |
| 182 window_transform.TransformRect(&align_bounds); | 187 window_transform.TransformRect(&align_bounds); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 293 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 289 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 294 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 290 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 295 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| 291 } else { | 296 } else { |
| 292 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 297 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
| 293 } | 298 } |
| 294 } | 299 } |
| 295 } | 300 } |
| 296 | 301 |
| 297 } // namespace ash | 302 } // namespace ash |
| OLD | NEW |