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

Side by Side Diff: ash/wm/overview/window_selector_item.cc

Issue 331643004: Update the window labels if they change in overview mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Rob's nits Created 6 years, 6 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/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
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& title) {
174 if (window == SelectionWindow()) {
175 static_cast<views::Label*>(
sky 2014/06/25 16:24:44 static_casts like this are often times fragile, in
Nina 2014/06/25 19:54:40 Okay, naturally I also replaced the other places i
176 window_label_->GetContentsView())->SetText(title);
177 }
178 }
179
173 void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window, 180 void WindowSelectorItem::UpdateCloseButtonBounds(aura::Window* root_window,
174 bool animate) { 181 bool animate) {
175 gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen( 182 gfx::RectF align_bounds(ScreenUtil::ConvertRectFromScreen(
176 root_window, SelectionWindow()->layer()->bounds())); 183 root_window, SelectionWindow()->layer()->bounds()));
177 gfx::Transform window_transform; 184 gfx::Transform window_transform;
178 window_transform.Translate(align_bounds.x(), align_bounds.y()); 185 window_transform.Translate(align_bounds.x(), align_bounds.y());
179 window_transform.PreconcatTransform(SelectionWindow()->layer()-> 186 window_transform.PreconcatTransform(SelectionWindow()->layer()->
180 GetTargetTransform()); 187 GetTargetTransform());
181 window_transform.Translate(-align_bounds.x(), -align_bounds.y()); 188 window_transform.Translate(-align_bounds.x(), -align_bounds.y());
182 window_transform.TransformRect(&align_bounds); 189 window_transform.TransformRect(&align_bounds);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 295 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
289 ScopedTransformOverviewWindow::kTransitionMilliseconds)); 296 ScopedTransformOverviewWindow::kTransitionMilliseconds));
290 window_label_->GetNativeWindow()->SetBounds(label_bounds); 297 window_label_->GetNativeWindow()->SetBounds(label_bounds);
291 } else { 298 } else {
292 window_label_->GetNativeWindow()->SetBounds(label_bounds); 299 window_label_->GetNativeWindow()->SetBounds(label_bounds);
293 } 300 }
294 } 301 }
295 } 302 }
296 303
297 } // namespace ash 304 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698