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 // The button is activated as soon as the mouse is pressed to avoid relying on | |
113 // the mouse up to target this view. | |
tdanderson
2015/01/22 20:43:58
Since you're activating on mouse release (the curr
Nina
2015/01/22 22:25:39
Done.
| |
114 class WindowSelectorItem::OverviewLabelButton : public views::LabelButton { | |
115 public: | |
116 OverviewLabelButton(views::ButtonListener* listener, | |
117 const base::string16& text) | |
118 : views::LabelButton(listener, text), event_bounds_(gfx::Rect()) {} | |
119 | |
120 ~OverviewLabelButton() override {} | |
121 | |
122 // Updates the |event_bounds|, converting them to our coordinates. | |
tdanderson
2015/01/22 20:43:58
|event_bounds_|.
Nina
2015/01/22 22:25:39
Done.
| |
123 void SetEventBounds(const gfx::Rect& event_bounds) { | |
124 event_bounds_ = ScreenUtil::ConvertRectFromScreen( | |
125 GetWidget()->GetNativeWindow()->GetRootWindow(), event_bounds); | |
126 gfx::Point origin = event_bounds_.origin(); | |
127 gfx::Rect target_bounds = GetWidget()->GetNativeWindow()->GetTargetBounds(); | |
128 origin.Offset(-target_bounds.x(), -target_bounds.y()); | |
129 event_bounds_.set_origin(origin); | |
130 } | |
131 | |
132 // views::View: | |
133 void OnMouseReleased(const ui::MouseEvent& event) override { | |
134 if (!event_bounds_.Contains(event.location())) | |
135 return; | |
136 | |
137 NotifyClick(event); | |
138 } | |
139 | |
140 private: | |
141 // Bounds to check if a mouse release occurred outside the window item. | |
142 gfx::Rect event_bounds_; | |
tdanderson
2015/01/22 20:43:58
It's not immediately clear what "event bounds" mea
Nina
2015/01/22 22:25:39
Done.
| |
143 | |
144 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton); | |
145 }; | |
146 | |
116 WindowSelectorItem::WindowSelectorItem(aura::Window* window) | 147 WindowSelectorItem::WindowSelectorItem(aura::Window* window) |
117 : dimmed_(false), | 148 : dimmed_(false), |
118 root_window_(window->GetRootWindow()), | 149 root_window_(window->GetRootWindow()), |
119 transform_window_(window), | 150 transform_window_(window), |
120 in_bounds_update_(false), | 151 in_bounds_update_(false), |
121 window_label_view_(nullptr), | 152 window_label_button_view_(nullptr), |
122 close_button_(new OverviewCloseButton(this)), | 153 close_button_(new OverviewCloseButton(this)), |
123 selector_item_activate_window_button_( | 154 overview_window_targeter_(nullptr), |
124 new TransparentActivateWindowButton(root_window_, this)) { | 155 scoped_window_targeter_(nullptr) { |
125 views::Widget::InitParams params; | 156 views::Widget::InitParams params; |
126 params.type = views::Widget::InitParams::TYPE_POPUP; | 157 params.type = views::Widget::InitParams::TYPE_POPUP; |
127 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 158 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
128 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 159 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
129 params.parent = Shell::GetContainer(root_window_, | 160 params.parent = Shell::GetContainer(root_window_, |
130 kShellWindowId_OverlayContainer); | 161 kShellWindowId_OverlayContainer); |
131 close_button_widget_.set_focus_on_creation(false); | 162 close_button_widget_.set_focus_on_creation(false); |
132 close_button_widget_.Init(params); | 163 close_button_widget_.Init(params); |
133 close_button_->SetVisible(false); | 164 close_button_->SetVisible(false); |
134 close_button_widget_.SetContentsView(close_button_); | 165 close_button_widget_.SetContentsView(close_button_); |
135 close_button_widget_.SetSize(close_button_->GetPreferredSize()); | 166 close_button_widget_.SetSize(close_button_->GetPreferredSize()); |
136 close_button_widget_.Show(); | 167 close_button_widget_.Show(); |
137 | 168 |
138 gfx::Rect close_button_rect(close_button_widget_.GetNativeWindow()->bounds()); | 169 gfx::Rect close_button_rect(close_button_widget_.GetNativeWindow()->bounds()); |
139 // Align the center of the button with position (0, 0) so that the | 170 // 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 | 171 // translate transform does not need to take the button dimensions into |
141 // account. | 172 // account. |
142 close_button_rect.set_x(-close_button_rect.width() / 2); | 173 close_button_rect.set_x(-close_button_rect.width() / 2); |
143 close_button_rect.set_y(-close_button_rect.height() / 2); | 174 close_button_rect.set_y(-close_button_rect.height() / 2); |
144 close_button_widget_.GetNativeWindow()->SetBounds(close_button_rect); | 175 close_button_widget_.GetNativeWindow()->SetBounds(close_button_rect); |
145 | 176 |
146 GetWindow()->AddObserver(this); | 177 GetWindow()->AddObserver(this); |
178 CreateWindowLabel(); | |
147 | 179 |
148 UpdateCloseButtonAccessibilityName(); | 180 UpdateCloseButtonAccessibilityName(); |
181 | |
182 overview_window_targeter_ = | |
183 new OverviewWindowTargeter(window_label_->GetNativeWindow()); | |
184 scoped_window_targeter_.reset(new aura::ScopedWindowTargeter( | |
185 window, scoped_ptr<OverviewWindowTargeter>(overview_window_targeter_))); | |
149 } | 186 } |
150 | 187 |
151 WindowSelectorItem::~WindowSelectorItem() { | 188 WindowSelectorItem::~WindowSelectorItem() { |
152 GetWindow()->RemoveObserver(this); | 189 GetWindow()->RemoveObserver(this); |
153 } | 190 } |
154 | 191 |
155 aura::Window* WindowSelectorItem::GetWindow() { | 192 aura::Window* WindowSelectorItem::GetWindow() { |
156 return transform_window_.window(); | 193 return transform_window_.window(); |
157 } | 194 } |
158 | 195 |
(...skipping 22 matching lines...) Expand all Loading... | |
181 | 218 |
182 UpdateWindowLabels(target_bounds, animation_type); | 219 UpdateWindowLabels(target_bounds, animation_type); |
183 | 220 |
184 gfx::Rect inset_bounds(target_bounds); | 221 gfx::Rect inset_bounds(target_bounds); |
185 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 222 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
186 SetItemBounds(inset_bounds, animation_type); | 223 SetItemBounds(inset_bounds, animation_type); |
187 | 224 |
188 // SetItemBounds is called before UpdateCloseButtonLayout so the close button | 225 // SetItemBounds is called before UpdateCloseButtonLayout so the close button |
189 // can properly use the updated windows bounds. | 226 // can properly use the updated windows bounds. |
190 UpdateCloseButtonLayout(animation_type); | 227 UpdateCloseButtonLayout(animation_type); |
191 UpdateSelectorButtons(); | |
192 } | 228 } |
193 | 229 |
194 void WindowSelectorItem::RecomputeWindowTransforms() { | 230 void WindowSelectorItem::RecomputeWindowTransforms() { |
195 if (in_bounds_update_ || target_bounds_.IsEmpty()) | 231 if (in_bounds_update_ || target_bounds_.IsEmpty()) |
196 return; | 232 return; |
197 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 233 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
198 gfx::Rect inset_bounds(target_bounds_); | 234 gfx::Rect inset_bounds(target_bounds_); |
199 inset_bounds.Inset(kWindowMargin, kWindowMargin); | 235 inset_bounds.Inset(kWindowMargin, kWindowMargin); |
200 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 236 SetItemBounds(inset_bounds, OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
201 | |
202 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 237 UpdateCloseButtonLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
203 UpdateSelectorButtons(); | |
204 } | 238 } |
205 | 239 |
206 void WindowSelectorItem::SendFocusAlert() const { | 240 void WindowSelectorItem::SendFocusAlert() const { |
207 selector_item_activate_window_button_->SendFocusAlert(); | 241 window_label_button_view_->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); |
208 } | 242 } |
209 | 243 |
210 void WindowSelectorItem::SetDimmed(bool dimmed) { | 244 void WindowSelectorItem::SetDimmed(bool dimmed) { |
211 dimmed_ = dimmed; | 245 dimmed_ = dimmed; |
212 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); | 246 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); |
213 } | 247 } |
214 | 248 |
215 void WindowSelectorItem::ButtonPressed(views::Button* sender, | 249 void WindowSelectorItem::ButtonPressed(views::Button* sender, |
216 const ui::Event& event) { | 250 const ui::Event& event) { |
217 transform_window_.Close(); | 251 if (sender == close_button_) { |
252 transform_window_.Close(); | |
253 return; | |
254 } | |
255 DCHECK(sender == window_label_button_view_); | |
256 wm::GetWindowState(GetWindow())->Activate(); | |
218 } | 257 } |
219 | 258 |
220 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { | 259 void WindowSelectorItem::OnWindowDestroying(aura::Window* window) { |
221 window->RemoveObserver(this); | 260 window->RemoveObserver(this); |
222 transform_window_.OnWindowDestroyed(); | 261 transform_window_.OnWindowDestroyed(); |
223 } | 262 } |
224 | 263 |
225 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { | 264 void WindowSelectorItem::OnWindowTitleChanged(aura::Window* window) { |
226 // TODO(flackr): Maybe add the new title to a vector of titles so that we can | 265 // 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. | 266 // filter any of the titles the window had while in the overview session. |
228 if (window == GetWindow()) { | 267 window_label_button_view_->SetText(window->title()); |
229 window_label_view_->SetText(window->title()); | 268 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 } | 269 } |
241 | 270 |
242 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, | 271 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, |
243 OverviewAnimationType animation_type) { | 272 OverviewAnimationType animation_type) { |
244 DCHECK(root_window_ == GetWindow()->GetRootWindow()); | 273 DCHECK(root_window_ == GetWindow()->GetRootWindow()); |
245 gfx::Rect screen_bounds = transform_window_.GetTargetBoundsInScreen(); | 274 gfx::Rect screen_bounds = transform_window_.GetTargetBoundsInScreen(); |
246 gfx::Rect selector_item_bounds = | 275 gfx::Rect selector_item_bounds = |
247 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( | 276 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( |
248 screen_bounds, target_bounds); | 277 screen_bounds, target_bounds); |
249 gfx::Transform transform = | 278 gfx::Transform transform = |
250 ScopedTransformOverviewWindow::GetTransformForRect(screen_bounds, | 279 ScopedTransformOverviewWindow::GetTransformForRect(screen_bounds, |
251 selector_item_bounds); | 280 selector_item_bounds); |
252 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; | 281 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; |
253 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); | 282 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); |
254 transform_window_.SetTransform(root_window_, transform); | 283 transform_window_.SetTransform(root_window_, transform); |
255 transform_window_.set_overview_transform(transform); | 284 transform_window_.set_overview_transform(transform); |
285 overview_window_targeter_->set_bounds( | |
286 ScreenUtil::ConvertRectFromScreen(root_window_, target_bounds)); | |
256 } | 287 } |
257 | 288 |
258 void WindowSelectorItem::SetOpacity(float opacity) { | 289 void WindowSelectorItem::SetOpacity(float opacity) { |
259 window_label_->GetNativeWindow()->layer()->SetOpacity(opacity); | 290 window_label_->GetNativeWindow()->layer()->SetOpacity(opacity); |
260 close_button_widget_.GetNativeWindow()->layer()->SetOpacity(opacity); | 291 close_button_widget_.GetNativeWindow()->layer()->SetOpacity(opacity); |
261 | 292 |
262 transform_window_.SetOpacity(opacity); | 293 transform_window_.SetOpacity(opacity); |
263 } | 294 } |
264 | 295 |
265 void WindowSelectorItem::UpdateWindowLabels( | 296 void WindowSelectorItem::UpdateWindowLabels( |
266 const gfx::Rect& window_bounds, | 297 const gfx::Rect& window_bounds, |
267 OverviewAnimationType animation_type) { | 298 OverviewAnimationType animation_type) { |
268 | 299 if (!window_label_->IsVisible()) { |
269 if (!window_label_) { | 300 window_label_->Show(); |
270 CreateWindowLabel(GetWindow()->title()); | |
271 SetupFadeInAfterLayout(window_label_->GetNativeWindow()); | 301 SetupFadeInAfterLayout(window_label_->GetNativeWindow()); |
272 } | 302 } |
273 | |
274 gfx::Rect converted_bounds = ScreenUtil::ConvertRectFromScreen(root_window_, | 303 gfx::Rect converted_bounds = ScreenUtil::ConvertRectFromScreen(root_window_, |
275 window_bounds); | 304 window_bounds); |
276 gfx::Rect label_bounds(converted_bounds.x(), | 305 gfx::Rect label_bounds(converted_bounds.x(), |
277 converted_bounds.bottom(), | 306 converted_bounds.bottom(), |
278 converted_bounds.width(), | 307 converted_bounds.width(), |
279 0); | 308 0); |
280 label_bounds.set_height(window_label_->GetContentsView()-> | 309 label_bounds.set_height(window_label_->GetContentsView()-> |
281 GetPreferredSize().height()); | 310 GetPreferredSize().height()); |
282 label_bounds.set_y(label_bounds.y() - window_label_-> | 311 label_bounds.set_y(label_bounds.y() - window_label_-> |
283 GetContentsView()->GetPreferredSize().height()); | 312 GetContentsView()->GetPreferredSize().height()); |
284 | 313 |
285 ScopedOverviewAnimationSettings animation_settings(animation_type, | 314 ScopedOverviewAnimationSettings animation_settings(animation_type, |
286 window_label_->GetNativeWindow()); | 315 window_label_->GetNativeWindow()); |
287 | 316 |
288 window_label_->GetNativeWindow()->SetBounds(label_bounds); | 317 window_label_->GetNativeWindow()->SetBounds(label_bounds); |
318 window_label_button_view_->SetEventBounds(target_bounds_); | |
289 } | 319 } |
290 | 320 |
291 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { | 321 void WindowSelectorItem::CreateWindowLabel() { |
292 window_label_.reset(new views::Widget); | 322 window_label_.reset(new views::Widget); |
293 views::Widget::InitParams params; | 323 views::Widget::InitParams params; |
294 params.type = views::Widget::InitParams::TYPE_POPUP; | 324 params.type = views::Widget::InitParams::TYPE_POPUP; |
295 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 325 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
296 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 326 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
297 params.parent = Shell::GetContainer(root_window_, | 327 params.parent = Shell::GetContainer(root_window_, |
298 kShellWindowId_OverlayContainer); | 328 kShellWindowId_OverlayContainer); |
299 params.accept_events = false; | |
300 params.visible_on_all_workspaces = true; | 329 params.visible_on_all_workspaces = true; |
301 window_label_->set_focus_on_creation(false); | 330 window_label_->set_focus_on_creation(false); |
302 window_label_->Init(params); | 331 window_label_->Init(params); |
303 window_label_view_ = new views::Label; | 332 window_label_button_view_ = |
304 window_label_view_->SetEnabledColor(kLabelColor); | 333 new OverviewLabelButton(this, GetWindow()->title()); |
305 window_label_view_->SetBackgroundColor(kLabelBackground); | 334 window_label_button_view_->SetTextColor(views::LabelButton::STATE_NORMAL, |
306 window_label_view_->SetShadows(gfx::ShadowValues( | 335 kLabelColor); |
307 1, | 336 window_label_button_view_->SetTextColor(views::LabelButton::STATE_HOVERED, |
308 gfx::ShadowValue( | 337 kLabelColor); |
309 gfx::Point(0, kVerticalShadowOffset), kShadowBlur, kLabelShadow))); | 338 window_label_button_view_->SetTextColor(views::LabelButton::STATE_PRESSED, |
339 kLabelColor); | |
340 window_label_button_view_->set_animate_on_state_change(false); | |
341 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
342 window_label_button_view_->SetBorder(views::Border::NullBorder()); | |
343 window_label_button_view_->SetTextShadows(gfx::ShadowValues( | |
344 1, gfx::ShadowValue(gfx::Point(0, kVerticalShadowOffset), kShadowBlur, | |
345 kLabelShadow))); | |
310 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 346 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
311 window_label_view_->SetFontList( | 347 window_label_button_view_->SetFontList( |
312 bundle.GetFontList(ui::ResourceBundle::BoldFont)); | 348 bundle.GetFontList(ui::ResourceBundle::BoldFont)); |
313 window_label_view_->SetText(title); | 349 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 } | 350 } |
334 | 351 |
335 void WindowSelectorItem::UpdateCloseButtonLayout( | 352 void WindowSelectorItem::UpdateCloseButtonLayout( |
336 OverviewAnimationType animation_type) { | 353 OverviewAnimationType animation_type) { |
337 if (!close_button_->visible()) { | 354 if (!close_button_->visible()) { |
338 close_button_->SetVisible(true); | 355 close_button_->SetVisible(true); |
339 SetupFadeInAfterLayout(close_button_widget_.GetNativeWindow()); | 356 SetupFadeInAfterLayout(close_button_widget_.GetNativeWindow()); |
340 } | 357 } |
341 ScopedOverviewAnimationSettings animation_settings(animation_type, | 358 ScopedOverviewAnimationSettings animation_settings(animation_type, |
342 close_button_widget_.GetNativeWindow()); | 359 close_button_widget_.GetNativeWindow()); |
343 | 360 |
344 gfx::Rect transformed_window_bounds = ScreenUtil::ConvertRectFromScreen( | 361 gfx::Rect transformed_window_bounds = ScreenUtil::ConvertRectFromScreen( |
345 close_button_widget_.GetNativeWindow()->GetRootWindow(), | 362 close_button_widget_.GetNativeWindow()->GetRootWindow(), |
346 GetTransformedBounds(GetWindow())); | 363 GetTransformedBounds(GetWindow())); |
347 | 364 |
348 gfx::Transform close_button_transform; | 365 gfx::Transform close_button_transform; |
349 close_button_transform.Translate(transformed_window_bounds.right(), | 366 close_button_transform.Translate(transformed_window_bounds.right(), |
350 transformed_window_bounds.y()); | 367 transformed_window_bounds.y()); |
351 close_button_widget_.GetNativeWindow()->SetTransform( | 368 close_button_widget_.GetNativeWindow()->SetTransform( |
352 close_button_transform); | 369 close_button_transform); |
353 } | 370 } |
354 | 371 |
355 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { | 372 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { |
356 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( | 373 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( |
357 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, | 374 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, |
358 GetWindow()->title())); | 375 GetWindow()->title())); |
359 } | 376 } |
360 | 377 |
361 } // namespace ash | 378 } // namespace ash |
OLD | NEW |