| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ui/aura/window_observer.h" | 27 #include "ui/aura/window_observer.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
| 30 #include "ui/compositor/scoped_layer_animation_settings.h" | 30 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 31 #include "ui/events/event_constants.h" | 31 #include "ui/events/event_constants.h" |
| 32 #include "ui/gfx/canvas.h" | 32 #include "ui/gfx/canvas.h" |
| 33 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
| 34 #include "ui/gfx/image/image_skia_operations.h" | 34 #include "ui/gfx/image/image_skia_operations.h" |
| 35 #include "ui/gfx/skbitmap_operations.h" | 35 #include "ui/gfx/skbitmap_operations.h" |
| 36 #include "ui/views/accessible_pane_view.h" | 36 #include "ui/views/accessible_pane_view.h" |
| 37 #include "ui/views/layout/fill_layout.h" |
| 37 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
| 38 #include "ui/views/widget/widget_delegate.h" | 39 #include "ui/views/widget/widget_delegate.h" |
| 39 #include "ui/wm/core/coordinate_conversion.h" | 40 #include "ui/wm/core/coordinate_conversion.h" |
| 40 #include "ui/wm/core/easy_resize_window_targeter.h" | 41 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 41 #include "ui/wm/public/activation_client.h" | 42 #include "ui/wm/public/activation_client.h" |
| 42 | 43 |
| 43 namespace { | 44 namespace { |
| 44 // Size of black border at bottom (or side) of shelf. | 45 // Size of black border at bottom (or side) of shelf. |
| 45 const int kNumBlackPixels = 3; | 46 const int kNumBlackPixels = 3; |
| 46 // Alpha to paint dimming image with. | 47 // Alpha to paint dimming image with. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 void SetParentLayer(ui::Layer* layer); | 337 void SetParentLayer(ui::Layer* layer); |
| 337 | 338 |
| 338 // views::View overrides: | 339 // views::View overrides: |
| 339 void OnPaintBackground(gfx::Canvas* canvas) override; | 340 void OnPaintBackground(gfx::Canvas* canvas) override; |
| 340 | 341 |
| 341 // views::WidgetDelegateView overrides: | 342 // views::WidgetDelegateView overrides: |
| 342 views::Widget* GetWidget() override { return View::GetWidget(); } | 343 views::Widget* GetWidget() override { return View::GetWidget(); } |
| 343 const views::Widget* GetWidget() const override { return View::GetWidget(); } | 344 const views::Widget* GetWidget() const override { return View::GetWidget(); } |
| 344 | 345 |
| 345 bool CanActivate() const override; | 346 bool CanActivate() const override; |
| 346 void Layout() override; | |
| 347 void ReorderChildLayers(ui::Layer* parent_layer) override; | 347 void ReorderChildLayers(ui::Layer* parent_layer) override; |
| 348 // This will be called when the parent local bounds change. | 348 // This will be called when the parent local bounds change. |
| 349 void OnBoundsChanged(const gfx::Rect& old_bounds) override; | 349 void OnBoundsChanged(const gfx::Rect& old_bounds) override; |
| 350 | 350 |
| 351 // aura::WindowObserver overrides: | 351 // aura::WindowObserver overrides: |
| 352 // This will be called when the shelf itself changes its absolute position. | 352 // This will be called when the shelf itself changes its absolute position. |
| 353 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs | 353 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs |
| 354 // to be repositioned. The difference to the OnBoundsChanged call above is | 354 // to be repositioned. The difference to the OnBoundsChanged call above is |
| 355 // that this gets also triggered when the shelf only moves. | 355 // that this gets also triggered when the shelf only moves. |
| 356 void OnWindowBoundsChanged(aura::Window* window, | 356 void OnWindowBoundsChanged(aura::Window* window, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 }; | 399 }; |
| 400 | 400 |
| 401 ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf) | 401 ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf) |
| 402 : shelf_(shelf), | 402 : shelf_(shelf), |
| 403 focus_cycler_(NULL), | 403 focus_cycler_(NULL), |
| 404 alpha_(0), | 404 alpha_(0), |
| 405 opaque_background_(ui::LAYER_SOLID_COLOR), | 405 opaque_background_(ui::LAYER_SOLID_COLOR), |
| 406 opaque_foreground_(ui::LAYER_SOLID_COLOR), | 406 opaque_foreground_(ui::LAYER_SOLID_COLOR), |
| 407 dimmer_view_(NULL), | 407 dimmer_view_(NULL), |
| 408 disable_dimming_animations_for_test_(false) { | 408 disable_dimming_animations_for_test_(false) { |
| 409 SetLayoutManager(new views::FillLayout()); |
| 409 set_allow_deactivate_on_esc(true); | 410 set_allow_deactivate_on_esc(true); |
| 410 opaque_background_.SetColor(SK_ColorBLACK); | 411 opaque_background_.SetColor(SK_ColorBLACK); |
| 411 opaque_background_.SetBounds(GetLocalBounds()); | 412 opaque_background_.SetBounds(GetLocalBounds()); |
| 412 opaque_background_.SetOpacity(0.0f); | 413 opaque_background_.SetOpacity(0.0f); |
| 413 opaque_foreground_.SetColor(SK_ColorBLACK); | 414 opaque_foreground_.SetColor(SK_ColorBLACK); |
| 414 opaque_foreground_.SetBounds(GetLocalBounds()); | 415 opaque_foreground_.SetBounds(GetLocalBounds()); |
| 415 opaque_foreground_.SetOpacity(0.0f); | 416 opaque_foreground_.SetOpacity(0.0f); |
| 416 } | 417 } |
| 417 | 418 |
| 418 ShelfWidget::DelegateView::~DelegateView() { | 419 ShelfWidget::DelegateView::~DelegateView() { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 // Allow to activate as fallback. | 544 // Allow to activate as fallback. |
| 544 if (shelf_->activating_as_fallback_) | 545 if (shelf_->activating_as_fallback_) |
| 545 return true; | 546 return true; |
| 546 // Allow to activate from the focus cycler. | 547 // Allow to activate from the focus cycler. |
| 547 if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget()) | 548 if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget()) |
| 548 return true; | 549 return true; |
| 549 // Disallow activating in other cases, especially when using mouse. | 550 // Disallow activating in other cases, especially when using mouse. |
| 550 return false; | 551 return false; |
| 551 } | 552 } |
| 552 | 553 |
| 553 void ShelfWidget::DelegateView::Layout() { | |
| 554 for(int i = 0; i < child_count(); ++i) { | |
| 555 if (shelf_->shelf_layout_manager()->IsHorizontalAlignment()) { | |
| 556 child_at(i)->SetBounds(child_at(i)->x(), child_at(i)->y(), | |
| 557 child_at(i)->width(), height()); | |
| 558 } else { | |
| 559 child_at(i)->SetBounds(child_at(i)->x(), child_at(i)->y(), | |
| 560 width(), child_at(i)->height()); | |
| 561 } | |
| 562 } | |
| 563 } | |
| 564 | |
| 565 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { | 554 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { |
| 566 views::View::ReorderChildLayers(parent_layer); | 555 views::View::ReorderChildLayers(parent_layer); |
| 567 parent_layer->StackAtBottom(&opaque_background_); | 556 parent_layer->StackAtBottom(&opaque_background_); |
| 568 parent_layer->StackAtTop(&opaque_foreground_); | 557 parent_layer->StackAtTop(&opaque_foreground_); |
| 569 } | 558 } |
| 570 | 559 |
| 571 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 560 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
| 572 opaque_background_.SetBounds(GetLocalBounds()); | 561 opaque_background_.SetBounds(GetLocalBounds()); |
| 573 opaque_foreground_.SetBounds(GetLocalBounds()); | 562 opaque_foreground_.SetBounds(GetLocalBounds()); |
| 574 if (dimmer_) | 563 if (dimmer_) |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 DCHECK(delegate_view_); | 832 DCHECK(delegate_view_); |
| 844 return delegate_view_->disable_dimming_animations_for_test(); | 833 return delegate_view_->disable_dimming_animations_for_test(); |
| 845 } | 834 } |
| 846 | 835 |
| 847 void ShelfWidget::WillDeleteShelf() { | 836 void ShelfWidget::WillDeleteShelf() { |
| 848 shelf_layout_manager_->RemoveObserver(this); | 837 shelf_layout_manager_->RemoveObserver(this); |
| 849 shelf_layout_manager_ = NULL; | 838 shelf_layout_manager_ = NULL; |
| 850 } | 839 } |
| 851 | 840 |
| 852 } // namespace ash | 841 } // namespace ash |
| OLD | NEW |