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 <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/wm/overview/overview_animation_type.h" | 13 #include "ash/wm/overview/overview_animation_type.h" |
14 #include "ash/wm/overview/overview_window_targeter.h" | |
14 #include "ash/wm/overview/scoped_overview_animation_settings.h" | 15 #include "ash/wm/overview/scoped_overview_animation_settings.h" |
15 #include "ash/wm/overview/scoped_transform_overview_window.h" | 16 #include "ash/wm/overview/scoped_transform_overview_window.h" |
16 #include "ash/wm/overview/window_selector_controller.h" | 17 #include "ash/wm/overview/window_selector_controller.h" |
17 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
18 #include "base/auto_reset.h" | 19 #include "base/auto_reset.h" |
19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/time/time.h" | 22 #include "base/time/time.h" |
22 #include "grit/ash_resources.h" | 23 #include "grit/ash_resources.h" |
23 #include "grit/ash_strings.h" | 24 #include "grit/ash_strings.h" |
24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/gfx/geometry/vector2d.h" | 28 #include "ui/gfx/geometry/vector2d.h" |
28 #include "ui/gfx/transform_util.h" | 29 #include "ui/gfx/transform_util.h" |
29 #include "ui/strings/grit/ui_strings.h" | 30 #include "ui/strings/grit/ui_strings.h" |
31 #include "ui/views/border.h" | |
30 #include "ui/views/controls/button/image_button.h" | 32 #include "ui/views/controls/button/image_button.h" |
31 #include "ui/views/controls/label.h" | |
32 #include "ui/views/layout/box_layout.h" | 33 #include "ui/views/layout/box_layout.h" |
33 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
34 #include "ui/wm/core/window_util.h" | 35 #include "ui/wm/core/window_util.h" |
35 | 36 |
36 namespace ash { | 37 namespace ash { |
37 | 38 |
38 namespace { | 39 namespace { |
39 | 40 |
40 // In the conceptual overview table, the window margin is the space reserved | 41 // In the conceptual overview table, the window margin is the space reserved |
41 // around the window within the cell. This margin does not overlap so the | 42 // around the window within the cell. This margin does not overlap so the |
42 // closest distance between adjacent windows will be twice this amount. | 43 // closest distance between adjacent windows will be twice this amount. |
43 static const int kWindowMargin = 30; | 44 static const int kWindowMargin = 30; |
44 | 45 |
45 // Foreground label color. | 46 // Foreground label color. |
46 static const SkColor kLabelColor = SK_ColorWHITE; | 47 static const SkColor kLabelColor = SK_ColorWHITE; |
47 | 48 |
48 // Background label color. | |
49 static const SkColor kLabelBackground = SK_ColorTRANSPARENT; | |
50 | |
51 // Label shadow color. | 49 // Label shadow color. |
52 static const SkColor kLabelShadow = 0xB0000000; | 50 static const SkColor kLabelShadow = 0xB0000000; |
53 | 51 |
54 // Vertical padding for the label, both over and beneath it. | |
55 static const int kVerticalLabelPadding = 20; | |
56 | |
57 // Solid shadow length from the label | 52 // Solid shadow length from the label |
58 static const int kVerticalShadowOffset = 1; | 53 static const int kVerticalShadowOffset = 1; |
59 | 54 |
60 // Amount of blur applied to the label shadow | 55 // Amount of blur applied to the label shadow |
61 static const int kShadowBlur = 10; | 56 static const int kShadowBlur = 10; |
62 | 57 |
63 // Opacity for dimmed items. | 58 // Opacity for dimmed items. |
64 static const float kDimmedItemOpacity = 0.5f; | 59 static const float kDimmedItemOpacity = 0.5f; |
65 | 60 |
66 // Calculates the |window| bounds after being transformed to the selector's | 61 // Calculates the |window| bounds after being transformed to the selector's |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); | 101 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); |
107 SetImage(views::CustomButton::STATE_PRESSED, | 102 SetImage(views::CustomButton::STATE_PRESSED, |
108 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); | 103 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); |
109 } | 104 } |
110 | 105 |
111 OverviewCloseButton::~OverviewCloseButton() { | 106 OverviewCloseButton::~OverviewCloseButton() { |
112 } | 107 } |
113 | 108 |
114 } // namespace | 109 } // namespace |
115 | 110 |
111 // LabelButton shown under each of the windows. | |
112 class WindowSelectorItem::OverviewLabelButton : public views::LabelButton { | |
113 public: | |
114 OverviewLabelButton(views::ButtonListener* listener, | |
115 const base::string16& text) | |
116 : views::LabelButton(listener, text), | |
117 selector_item_bounds_(gfx::Rect()) {} | |
118 | |
119 ~OverviewLabelButton() override {} | |
120 | |
121 // Updates the |selector_item_bounds_|, converting them to our coordinates. | |
122 void SetSelectorItemBounds(const gfx::Rect& selector_item_bounds) { | |
123 selector_item_bounds_ = ScreenUtil::ConvertRectFromScreen( | |
124 GetWidget()->GetNativeWindow()->GetRootWindow(), selector_item_bounds); | |
125 gfx::Point origin = selector_item_bounds_.origin(); | |
126 gfx::Rect target_bounds = GetWidget()->GetNativeWindow()->GetTargetBounds(); | |
127 origin.Offset(-target_bounds.x(), -target_bounds.y()); | |
128 selector_item_bounds_.set_origin(origin); | |
129 } | |
130 | |
131 // views::View: | |
132 void OnMouseReleased(const ui::MouseEvent& event) override { | |
133 if (!selector_item_bounds_.Contains(event.location())) | |
134 return; | |
135 | |
136 NotifyClick(event); | |
137 } | |
138 | |
139 private: | |
140 // Bounds to check if a mouse release occurred outside the window item. | |
141 gfx::Rect selector_item_bounds_; | |
142 | |
143 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton); | |
144 }; | |
145 | |
116 WindowSelectorItem::WindowSelectorItem(aura::Window* window) | 146 WindowSelectorItem::WindowSelectorItem(aura::Window* window) |
117 : dimmed_(false), | 147 : dimmed_(false), |
118 root_window_(window->GetRootWindow()), | 148 root_window_(window->GetRootWindow()), |
119 transform_window_(window), | 149 transform_window_(window), |
120 in_bounds_update_(false), | 150 in_bounds_update_(false), |
121 window_label_view_(nullptr), | 151 window_label_button_view_(nullptr), |
122 close_button_(new OverviewCloseButton(this)), | 152 close_button_(new OverviewCloseButton(this)), |
123 selector_item_activate_window_button_( | 153 overview_window_targeter_(nullptr), |
124 new TransparentActivateWindowButton(root_window_, this)) { | 154 scoped_window_targeter_(nullptr) { |
125 views::Widget::InitParams params; | 155 views::Widget::InitParams params; |
126 params.type = views::Widget::InitParams::TYPE_POPUP; | 156 params.type = views::Widget::InitParams::TYPE_POPUP; |
127 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 157 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
128 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 158 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
129 params.parent = Shell::GetContainer(root_window_, | 159 params.parent = Shell::GetContainer(root_window_, |
130 kShellWindowId_OverlayContainer); | 160 kShellWindowId_OverlayContainer); |
131 close_button_widget_.set_focus_on_creation(false); | 161 close_button_widget_.set_focus_on_creation(false); |
132 close_button_widget_.Init(params); | 162 close_button_widget_.Init(params); |
133 close_button_->SetVisible(false); | 163 close_button_->SetVisible(false); |
134 close_button_widget_.SetContentsView(close_button_); | 164 close_button_widget_.SetContentsView(close_button_); |
135 close_button_widget_.SetSize(close_button_->GetPreferredSize()); | 165 close_button_widget_.SetSize(close_button_->GetPreferredSize()); |
136 close_button_widget_.Show(); | 166 close_button_widget_.Show(); |
137 | 167 |
138 gfx::Rect close_button_rect(close_button_widget_.GetNativeWindow()->bounds()); | 168 gfx::Rect close_button_rect(close_button_widget_.GetNativeWindow()->bounds()); |
139 // Align the center of the button with position (0, 0) so that the | 169 // Align the center of the button with position (0, 0) so that the |
140 // translate transform does not need to take the button dimensions into | 170 // translate transform does not need to take the button dimensions into |
141 // account. | 171 // account. |
142 close_button_rect.set_x(-close_button_rect.width() / 2); | 172 close_button_rect.set_x(-close_button_rect.width() / 2); |
143 close_button_rect.set_y(-close_button_rect.height() / 2); | 173 close_button_rect.set_y(-close_button_rect.height() / 2); |
144 close_button_widget_.GetNativeWindow()->SetBounds(close_button_rect); | 174 close_button_widget_.GetNativeWindow()->SetBounds(close_button_rect); |
145 | 175 |
146 GetWindow()->AddObserver(this); | 176 GetWindow()->AddObserver(this); |
177 CreateWindowLabel(); | |
147 | 178 |
148 UpdateCloseButtonAccessibilityName(); | 179 UpdateCloseButtonAccessibilityName(); |
180 | |
181 overview_window_targeter_ = | |
182 new OverviewWindowTargeter(window_label_->GetNativeWindow()); | |
183 scoped_window_targeter_.reset(new aura::ScopedWindowTargeter( | |
184 window, scoped_ptr<OverviewWindowTargeter>(overview_window_targeter_))); | |
149 } | 185 } |
150 | 186 |
151 WindowSelectorItem::~WindowSelectorItem() { | 187 WindowSelectorItem::~WindowSelectorItem() { |
152 GetWindow()->RemoveObserver(this); | 188 GetWindow()->RemoveObserver(this); |
153 } | 189 } |
154 | 190 |
155 aura::Window* WindowSelectorItem::GetWindow() { | 191 aura::Window* WindowSelectorItem::GetWindow() { |
156 return transform_window_.window(); | 192 return transform_window_.window(); |
157 } | 193 } |
158 | 194 |
(...skipping 22 matching lines...) Expand all Loading... | |
181 | 217 |
182 UpdateWindowLabels(target_bounds, animation_type); | 218 UpdateWindowLabels(target_bounds, animation_type); |
183 | 219 |
184 gfx::Rect inset_bounds(target_bounds); | 220 gfx::Rect inset_bounds(target_bounds); |
185 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 221 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
186 SetItemBounds(inset_bounds, animation_type); | 222 SetItemBounds(inset_bounds, animation_type); |
187 | 223 |
188 // SetItemBounds is called before UpdateCloseButtonLayout so the close button | 224 // SetItemBounds is called before UpdateCloseButtonLayout so the close button |
189 // can properly use the updated windows bounds. | 225 // can properly use the updated windows bounds. |
190 UpdateCloseButtonLayout(animation_type); | 226 UpdateCloseButtonLayout(animation_type); |
191 UpdateSelectorButtons(); | |
192 } | 227 } |
193 | 228 |
194 void WindowSelectorItem::RecomputeWindowTransforms() { | 229 void WindowSelectorItem::RecomputeWindowTransforms() { |
195 if (in_bounds_update_ || target_bounds_.IsEmpty()) | 230 if (in_bounds_update_ || target_bounds_.IsEmpty()) |
196 return; | 231 return; |
197 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 232 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
198 gfx::Rect inset_bounds(target_bounds_); | 233 gfx::Rect inset_bounds(target_bounds_); |
199 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 234 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
200 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 235 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
201 | |
202 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 236 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
203 UpdateSelectorButtons(); | |
204 } | 237 } |
205 | 238 |
206 void WindowSelectorItem::SendFocusAlert() const { | 239 void WindowSelectorItem::SendFocusAlert() const { |
207 selector_item_activate_window_button_->SendFocusAlert(); | 240 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
208 } | 241 } |
209 | 242 |
210 void WindowSelectorItem::SetDimmed(bool dimmed) { | 243 void WindowSelectorItem::SetDimmed(bool dimmed) { |
211 dimmed_ = dimmed; | 244 dimmed_ = dimmed; |
212 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); | 245 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); |
213 } | 246 } |
214 | 247 |
215 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 248 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
216 const ui::Event& event) { | 249 const ui::Event& event) { |
217 transform_window_.Close(); | 250 if (sender == close_button_) { |
251 transform_window_.Close(); | |
252 return; | |
253 } | |
254 DCHECK(sender == window_label_button_view_); | |
255 wm::GetWindowState(GetWindow())->Activate(); | |
218 } | 256 } |
219 | 257 |
220 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { | 258 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { |
221 window->RemoveObserver(this); | 259 window->RemoveObserver(this); |
222 transform_window_.OnWindowDestroyed(); | 260 transform_window_.OnWindowDestroyed(); |
223 } | 261 } |
224 | 262 |
225 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { | 263 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { |
226 // TODO(flackr): Maybe add the new title to a vector of titles so that we can | 264 // TODO(flackr): Maybe add the new title to a vector of titles so that we can |
227 // filter any of the titles the window had while in the overview session. | 265 // filter any of the titles the window had while in the overview session. |
228 if (window == GetWindow()) { | 266 window_label_button_view_->SetText(window->title()); |
229 window_label_view_->SetText(window->title()); | 267 UpdateCloseButtonAccessibilityName(); |
230 UpdateCloseButtonAccessibilityName(); | |
231 } | |
232 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | |
233 UpdateSelectorButtons(); | |
234 } | |
235 | |
236 void WindowSelectorItem::Select() { | |
237 aura::Window* selection_window = GetWindow(); | |
238 if (selection_window) | |
239 wm::GetWindowState(selection_window)->Activate(); | |
240 } | 268 } |
241 | 269 |
242 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, | 270 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, |
243 OverviewAnimationType animation_type) { | 271 OverviewAnimationType animation_type) { |
244 DCHECK(root_window_ == GetWindow()->GetRootWindow()); | 272 DCHECK(root_window_ == GetWindow()->GetRootWindow()); |
245 gfx::Rect screen_bounds = transform_window_.GetTargetBoundsInScreen(); | 273 gfx::Rect screen_bounds = transform_window_.GetTargetBoundsInScreen(); |
246 gfx::Rect selector_item_bounds = | 274 gfx::Rect selector_item_bounds = |
247 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( | 275 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( |
248 screen_bounds, target_bounds); | 276 screen_bounds, target_bounds); |
249 gfx::Transform transform = | 277 gfx::Transform transform = |
250 ScopedTransformOverviewWindow::GetTransformForRect(screen_bounds, | 278 ScopedTransformOverviewWindow::GetTransformForRect(screen_bounds, |
251 selector_item_bounds); | 279 selector_item_bounds); |
252 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; | 280 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; |
253 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); | 281 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); |
254 transform_window_.SetTransform(root_window_, transform); | 282 transform_window_.SetTransform(root_window_, transform); |
255 transform_window_.set_overview_transform(transform); | 283 transform_window_.set_overview_transform(transform); |
284 overview_window_targeter_->set_bounds( | |
285 ScreenUtil::ConvertRectFromScreen(root_window_, target_bounds)); | |
flackr
2015/01/22 23:21:17
Does this need to be updated here or can it be don
Nina
2015/01/23 18:38:58
Moved to the equivalent to UpdateWindowLabels on t
| |
256 } | 286 } |
257 | 287 |
258 void WindowSelectorItem::SetOpacity(float opacity) { | 288 void WindowSelectorItem::SetOpacity(float opacity) { |
259 window_label_->GetNativeWindow()->layer()->SetOpacity(opacity); | 289 window_label_->GetNativeWindow()->layer()->SetOpacity(opacity); |
260 close_button_widget_.GetNativeWindow()->layer()->SetOpacity(opacity); | 290 close_button_widget_.GetNativeWindow()->layer()->SetOpacity(opacity); |
261 | 291 |
262 transform_window_.SetOpacity(opacity); | 292 transform_window_.SetOpacity(opacity); |
263 } | 293 } |
264 | 294 |
265 void WindowSelectorItem::UpdateWindowLabels( | 295 void WindowSelectorItem::UpdateWindowLabels( |
266 const gfx::Rect& window_bounds, | 296 const gfx::Rect& window_bounds, |
267 OverviewAnimationType animation_type) { | 297 OverviewAnimationType animation_type) { |
268 | 298 if (!window_label_->IsVisible()) { |
269 if (!window_label_) { | 299 window_label_->Show(); |
270 CreateWindowLabel(GetWindow()->title()); | |
271 SetupFadeInAfterLayout(window_label_->GetNativeWindow()); | 300 SetupFadeInAfterLayout(window_label_->GetNativeWindow()); |
272 } | 301 } |
273 | |
274 gfx::Rect converted_bounds = ScreenUtil::ConvertRectFromScreen(root_window_, | 302 gfx::Rect converted_bounds = ScreenUtil::ConvertRectFromScreen(root_window_, |
275 window_bounds); | 303 window_bounds); |
276 gfx::Rect label_bounds(converted_bounds.x(), | 304 gfx::Rect label_bounds(converted_bounds.x(), |
277 converted_bounds.bottom(), | 305 converted_bounds.bottom(), |
278 converted_bounds.width(), | 306 converted_bounds.width(), |
279 0); | 307 0); |
280 label_bounds.set_height(window_label_->GetContentsView()-> | 308 label_bounds.set_height(window_label_->GetContentsView()-> |
281 GetPreferredSize().height()); | 309 GetPreferredSize().height()); |
282 label_bounds.set_y(label_bounds.y() - window_label_-> | 310 label_bounds.set_y(label_bounds.y() - window_label_-> |
283 GetContentsView()->GetPreferredSize().height()); | 311 GetContentsView()->GetPreferredSize().height()); |
284 | 312 |
285 ScopedOverviewAnimationSettings animation_settings(animation_type, | 313 ScopedOverviewAnimationSettings animation_settings(animation_type, |
286 window_label_->GetNativeWindow()); | 314 window_label_->GetNativeWindow()); |
287 | 315 |
288 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 316 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
317 window_label_button_view_->SetSelectorItemBounds(target_bounds_); | |
289 } | 318 } |
290 | 319 |
291 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { | 320 void WindowSelectorItem::CreateWindowLabel() { |
292 window_label_.reset(new views::Widget); | 321 window_label_.reset(new views::Widget); |
293 views::Widget::InitParams params; | 322 views::Widget::InitParams params; |
294 params.type = views::Widget::InitParams::TYPE_POPUP; | 323 params.type = views::Widget::InitParams::TYPE_POPUP; |
295 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 324 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
296 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 325 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
297 params.parent = Shell::GetContainer(root_window_, | 326 params.parent = Shell::GetContainer(root_window_, |
298 kShellWindowId_OverlayContainer); | 327 kShellWindowId_OverlayContainer); |
299 params.accept_events = false; | |
300 params.visible_on_all_workspaces = true; | 328 params.visible_on_all_workspaces = true; |
301 window_label_->set_focus_on_creation(false); | 329 window_label_->set_focus_on_creation(false); |
302 window_label_->Init(params); | 330 window_label_->Init(params); |
303 window_label_view_ = new views::Label; | 331 window_label_button_view_ = |
304 window_label_view_->SetEnabledColor(kLabelColor); | 332 new OverviewLabelButton(this, GetWindow()->title()); |
305 window_label_view_->SetBackgroundColor(kLabelBackground); | 333 window_label_button_view_->SetTextColor(views::LabelButton::STATE_NORMAL, |
306 window_label_view_->SetShadows(gfx::ShadowValues( | 334 kLabelColor); |
307 1, | 335 window_label_button_view_->SetTextColor(views::LabelButton::STATE_HOVERED, |
308 gfx::ShadowValue( | 336 kLabelColor); |
309 gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kLabelShadow))); | 337 window_label_button_view_->SetTextColor(views::LabelButton::STATE_PRESSED, |
338 kLabelColor); | |
339 window_label_button_view_->set_animate_on_state_change(false); | |
340 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
341 window_label_button_view_->SetBorder(views::Border::NullBorder()); | |
342 window_label_button_view_->SetTextShadows(gfx::ShadowValues( | |
343 1, gfx::ShadowValue(gfx::Point(0, kVerticalShadowOffset), kShadowBlur, | |
344 kLabelShadow))); | |
310 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 345 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
311 window_label_view_->SetFontList( | 346 window_label_button_view_->SetFontList( |
312 bundle.GetFontList(ui::ResourceBundle::BoldFont)); | 347 bundle.GetFontList(ui::ResourceBundle::BoldFont)); |
313 window_label_view_->SetText(title); | 348 window_label_->SetContentsView(window_label_button_view_); |
314 views::BoxLayout* layout = new views::BoxLayout(views::BoxLayout::kVertical, | |
315 0, | |
316 kVerticalLabelPadding, | |
317 0); | |
318 window_label_view_->SetLayoutManager(layout); | |
319 window_label_->SetContentsView(window_label_view_); | |
320 window_label_->Show(); | |
321 } | |
322 | |
323 void WindowSelectorItem::UpdateSelectorButtons() { | |
324 aura::Window* window = GetWindow(); | |
325 | |
326 selector_item_activate_window_button_->SetBounds(target_bounds()); | |
327 selector_item_activate_window_button_->SetAccessibleName(window->title()); | |
328 | |
329 TransparentActivateWindowButton* activate_button = | |
330 transform_window_.activate_button(); | |
331 activate_button->SetBounds(target_bounds()); | |
332 activate_button->SetAccessibleName(window->title()); | |
333 } | 349 } |
334 | 350 |
335 void WindowSelectorItem::UpdateCloseButtonLayout( | 351 void WindowSelectorItem::UpdateCloseButtonLayout( |
336 OverviewAnimationType animation_type) { | 352 OverviewAnimationType animation_type) { |
337 if (!close_button_->visible()) { | 353 if (!close_button_->visible()) { |
338 close_button_->SetVisible(true); | 354 close_button_->SetVisible(true); |
339 SetupFadeInAfterLayout(close_button_widget_.GetNativeWindow()); | 355 SetupFadeInAfterLayout(close_button_widget_.GetNativeWindow()); |
340 } | 356 } |
341 ScopedOverviewAnimationSettings animation_settings(animation_type, | 357 ScopedOverviewAnimationSettings animation_settings(animation_type, |
342 close_button_widget_.GetNativeWindow()); | 358 close_button_widget_.GetNativeWindow()); |
343 | 359 |
344 gfx::Rect transformed_window_bounds = ScreenUtil::ConvertRectFromScreen( | 360 gfx::Rect transformed_window_bounds = ScreenUtil::ConvertRectFromScreen( |
345 close_button_widget_.GetNativeWindow()->GetRootWindow(), | 361 close_button_widget_.GetNativeWindow()->GetRootWindow(), |
346 GetTransformedBounds(GetWindow())); | 362 GetTransformedBounds(GetWindow())); |
347 | 363 |
348 gfx::Transform close_button_transform; | 364 gfx::Transform close_button_transform; |
349 close_button_transform.Translate(transformed_window_bounds.right(), | 365 close_button_transform.Translate(transformed_window_bounds.right(), |
350 transformed_window_bounds.y()); | 366 transformed_window_bounds.y()); |
351 close_button_widget_.GetNativeWindow()->SetTransform( | 367 close_button_widget_.GetNativeWindow()->SetTransform( |
352 close_button_transform); | 368 close_button_transform); |
353 } | 369 } |
354 | 370 |
355 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { | 371 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { |
356 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( | 372 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( |
357 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, | 373 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, |
358 GetWindow()->title())); | 374 GetWindow()->title())); |
359 } | 375 } |
360 | 376 |
361 } // namespace ash | 377 } // namespace ash |
OLD | NEW |