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

Side by Side Diff: ash/shelf/shelf_widget.cc

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/shelf/shelf_widget.h ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_state_delegate.h" 10 #include "ash/session_state_delegate.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Alpha to paint dimming image with. 45 // Alpha to paint dimming image with.
46 const int kDimAlpha = 128; 46 const int kDimAlpha = 128;
47 47
48 // The time to dim and un-dim. 48 // The time to dim and un-dim.
49 const int kTimeToDimMs = 3000; // Slow in dimming. 49 const int kTimeToDimMs = 3000; // Slow in dimming.
50 const int kTimeToUnDimMs = 200; // Fast in activating. 50 const int kTimeToUnDimMs = 200; // Fast in activating.
51 51
52 // Class used to slightly dim shelf items when maximized and visible. 52 // Class used to slightly dim shelf items when maximized and visible.
53 class DimmerView : public views::View, 53 class DimmerView : public views::View,
54 public views::WidgetDelegate, 54 public views::WidgetDelegate,
55 ash::internal::BackgroundAnimatorDelegate { 55 ash::BackgroundAnimatorDelegate {
56 public: 56 public:
57 // If |disable_dimming_animations_for_test| is set, all alpha animations will 57 // If |disable_dimming_animations_for_test| is set, all alpha animations will
58 // be performed instantly. 58 // be performed instantly.
59 DimmerView(ash::ShelfWidget* shelf_widget, 59 DimmerView(ash::ShelfWidget* shelf_widget,
60 bool disable_dimming_animations_for_test); 60 bool disable_dimming_animations_for_test);
61 virtual ~DimmerView(); 61 virtual ~DimmerView();
62 62
63 // Called by |DimmerEventFilter| when the mouse |hovered| state changes. 63 // Called by |DimmerEventFilter| when the mouse |hovered| state changes.
64 void SetHovered(bool hovered); 64 void SetHovered(bool hovered);
65 65
66 // Force the dimmer to be undimmed. 66 // Force the dimmer to be undimmed.
67 void ForceUndimming(bool force); 67 void ForceUndimming(bool force);
68 68
69 // views::WidgetDelegate overrides: 69 // views::WidgetDelegate overrides:
70 virtual views::Widget* GetWidget() OVERRIDE { 70 virtual views::Widget* GetWidget() OVERRIDE {
71 return View::GetWidget(); 71 return View::GetWidget();
72 } 72 }
73 virtual const views::Widget* GetWidget() const OVERRIDE { 73 virtual const views::Widget* GetWidget() const OVERRIDE {
74 return View::GetWidget(); 74 return View::GetWidget();
75 } 75 }
76 76
77 // ash::internal::BackgroundAnimatorDelegate overrides: 77 // ash::BackgroundAnimatorDelegate overrides:
78 virtual void UpdateBackground(int alpha) OVERRIDE { 78 virtual void UpdateBackground(int alpha) OVERRIDE {
79 alpha_ = alpha; 79 alpha_ = alpha;
80 SchedulePaint(); 80 SchedulePaint();
81 } 81 }
82 82
83 // views::View overrides: 83 // views::View overrides:
84 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE; 84 virtual void OnPaintBackground(gfx::Canvas* canvas) OVERRIDE;
85 85
86 // A function to test the current alpha used. 86 // A function to test the current alpha used.
87 int get_dimming_alpha_for_test() { return alpha_; } 87 int get_dimming_alpha_for_test() { return alpha_; }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // True if the event filter claims that we should not be dimmed. 119 // True if the event filter claims that we should not be dimmed.
120 bool is_hovered_; 120 bool is_hovered_;
121 121
122 // True if someone forces us not to be dimmed (e.g. a menu is open). 122 // True if someone forces us not to be dimmed (e.g. a menu is open).
123 bool force_hovered_; 123 bool force_hovered_;
124 124
125 // True if animations should be suppressed for a test. 125 // True if animations should be suppressed for a test.
126 bool disable_dimming_animations_for_test_; 126 bool disable_dimming_animations_for_test_;
127 127
128 // The animator for the background transitions. 128 // The animator for the background transitions.
129 ash::internal::BackgroundAnimator background_animator_; 129 ash::BackgroundAnimator background_animator_;
130 130
131 // Notification of entering / exiting of the shelf area by mouse. 131 // Notification of entering / exiting of the shelf area by mouse.
132 scoped_ptr<DimmerEventFilter> event_filter_; 132 scoped_ptr<DimmerEventFilter> event_filter_;
133 133
134 DISALLOW_COPY_AND_ASSIGN(DimmerView); 134 DISALLOW_COPY_AND_ASSIGN(DimmerView);
135 }; 135 };
136 136
137 DimmerView::DimmerView(ash::ShelfWidget* shelf_widget, 137 DimmerView::DimmerView(ash::ShelfWidget* shelf_widget,
138 bool disable_dimming_animations_for_test) 138 bool disable_dimming_animations_for_test)
139 : shelf_(shelf_widget), 139 : shelf_(shelf_widget),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 bool touch_inside = false; 227 bool touch_inside = false;
228 if (event->type() != ui::ET_TOUCH_RELEASED && 228 if (event->type() != ui::ET_TOUCH_RELEASED &&
229 event->type() != ui::ET_TOUCH_CANCELLED) 229 event->type() != ui::ET_TOUCH_CANCELLED)
230 touch_inside = owner_->GetBoundsInScreen().Contains(event->root_location()); 230 touch_inside = owner_->GetBoundsInScreen().Contains(event->root_location());
231 231
232 if (mouse_inside_ || touch_inside_ != mouse_inside_ || touch_inside) 232 if (mouse_inside_ || touch_inside_ != mouse_inside_ || touch_inside)
233 owner_->SetHovered(mouse_inside_ || touch_inside); 233 owner_->SetHovered(mouse_inside_ || touch_inside);
234 touch_inside_ = touch_inside; 234 touch_inside_ = touch_inside;
235 } 235 }
236 236
237 using ash::internal::ShelfLayoutManager; 237 using ash::ShelfLayoutManager;
238 238
239 // ShelfWindowTargeter makes it easier to resize windows with the mouse when the 239 // ShelfWindowTargeter makes it easier to resize windows with the mouse when the
240 // window-edge slightly overlaps with the shelf edge. The targeter also makes it 240 // window-edge slightly overlaps with the shelf edge. The targeter also makes it
241 // easier to drag the shelf out with touch while it is hidden. 241 // easier to drag the shelf out with touch while it is hidden.
242 class ShelfWindowTargeter : public wm::EasyResizeWindowTargeter, 242 class ShelfWindowTargeter : public wm::EasyResizeWindowTargeter,
243 public ash::ShelfLayoutManagerObserver { 243 public ash::ShelfLayoutManagerObserver {
244 public: 244 public:
245 ShelfWindowTargeter(aura::Window* container, 245 ShelfWindowTargeter(aura::Window* container,
246 ShelfLayoutManager* shelf) 246 ShelfLayoutManager* shelf)
247 : wm::EasyResizeWindowTargeter(container, gfx::Insets(), gfx::Insets()), 247 : wm::EasyResizeWindowTargeter(container, gfx::Insets(), gfx::Insets()),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 }; 306 };
307 307
308 } // namespace 308 } // namespace
309 309
310 namespace ash { 310 namespace ash {
311 311
312 // The contents view of the Shelf. This view contains ShelfView and 312 // The contents view of the Shelf. This view contains ShelfView and
313 // sizes it to the width of the shelf minus the size of the status area. 313 // sizes it to the width of the shelf minus the size of the status area.
314 class ShelfWidget::DelegateView : public views::WidgetDelegate, 314 class ShelfWidget::DelegateView : public views::WidgetDelegate,
315 public views::AccessiblePaneView, 315 public views::AccessiblePaneView,
316 public internal::BackgroundAnimatorDelegate, 316 public BackgroundAnimatorDelegate,
317 public aura::WindowObserver { 317 public aura::WindowObserver {
318 public: 318 public:
319 explicit DelegateView(ShelfWidget* shelf); 319 explicit DelegateView(ShelfWidget* shelf);
320 virtual ~DelegateView(); 320 virtual ~DelegateView();
321 321
322 void set_focus_cycler(internal::FocusCycler* focus_cycler) { 322 void set_focus_cycler(FocusCycler* focus_cycler) {
323 focus_cycler_ = focus_cycler; 323 focus_cycler_ = focus_cycler;
324 } 324 }
325 internal::FocusCycler* focus_cycler() { 325 FocusCycler* focus_cycler() { return focus_cycler_; }
326 return focus_cycler_;
327 }
328 326
329 ui::Layer* opaque_background() { return &opaque_background_; } 327 ui::Layer* opaque_background() { return &opaque_background_; }
330 328
331 // Set if the shelf area is dimmed (eg when a window is maximized). 329 // Set if the shelf area is dimmed (eg when a window is maximized).
332 void SetDimmed(bool dimmed); 330 void SetDimmed(bool dimmed);
333 bool GetDimmed() const; 331 bool GetDimmed() const;
334 332
335 void SetParentLayer(ui::Layer* layer); 333 void SetParentLayer(ui::Layer* layer);
336 334
337 // views::View overrides: 335 // views::View overrides:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 374
377 // Disable dimming animations for running tests. This needs to be called 375 // Disable dimming animations for running tests. This needs to be called
378 // prior to the creation of of the |dimmer_|. 376 // prior to the creation of of the |dimmer_|.
379 void disable_dimming_animations_for_test() { 377 void disable_dimming_animations_for_test() {
380 disable_dimming_animations_for_test_ = true; 378 disable_dimming_animations_for_test_ = true;
381 } 379 }
382 380
383 private: 381 private:
384 ShelfWidget* shelf_; 382 ShelfWidget* shelf_;
385 scoped_ptr<views::Widget> dimmer_; 383 scoped_ptr<views::Widget> dimmer_;
386 internal::FocusCycler* focus_cycler_; 384 FocusCycler* focus_cycler_;
387 int alpha_; 385 int alpha_;
388 ui::Layer opaque_background_; 386 ui::Layer opaque_background_;
389 387
390 // The view which does the dimming. 388 // The view which does the dimming.
391 DimmerView* dimmer_view_; 389 DimmerView* dimmer_view_;
392 390
393 // True if dimming animations should be turned off. 391 // True if dimming animations should be turned off.
394 bool disable_dimming_animations_for_test_; 392 bool disable_dimming_animations_for_test_;
395 393
396 DISALLOW_COPY_AND_ASSIGN(DelegateView); 394 DISALLOW_COPY_AND_ASSIGN(DelegateView);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return gfx::Rect(); 592 return gfx::Rect();
595 } 593 }
596 594
597 void ShelfWidget::DelegateView::UpdateBackground(int alpha) { 595 void ShelfWidget::DelegateView::UpdateBackground(int alpha) {
598 alpha_ = alpha; 596 alpha_ = alpha;
599 SchedulePaint(); 597 SchedulePaint();
600 } 598 }
601 599
602 ShelfWidget::ShelfWidget(aura::Window* shelf_container, 600 ShelfWidget::ShelfWidget(aura::Window* shelf_container,
603 aura::Window* status_container, 601 aura::Window* status_container,
604 internal::WorkspaceController* workspace_controller) 602 WorkspaceController* workspace_controller)
605 : delegate_view_(new DelegateView(this)), 603 : delegate_view_(new DelegateView(this)),
606 background_animator_(delegate_view_, 0, kShelfBackgroundAlpha), 604 background_animator_(delegate_view_, 0, kShelfBackgroundAlpha),
607 activating_as_fallback_(false), 605 activating_as_fallback_(false),
608 window_container_(shelf_container) { 606 window_container_(shelf_container) {
609 views::Widget::InitParams params( 607 views::Widget::InitParams params(
610 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 608 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
611 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 609 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
612 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 610 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
613 params.parent = shelf_container; 611 params.parent = shelf_container;
614 params.delegate = delegate_view_; 612 params.delegate = delegate_view_;
615 Init(params); 613 Init(params);
616 614
617 // The shelf should not take focus when initially shown. 615 // The shelf should not take focus when initially shown.
618 set_focus_on_creation(false); 616 set_focus_on_creation(false);
619 SetContentsView(delegate_view_); 617 SetContentsView(delegate_view_);
620 delegate_view_->SetParentLayer(GetLayer()); 618 delegate_view_->SetParentLayer(GetLayer());
621 619
622 status_area_widget_ = new internal::StatusAreaWidget(status_container); 620 status_area_widget_ = new StatusAreaWidget(status_container);
623 status_area_widget_->CreateTrayViews(); 621 status_area_widget_->CreateTrayViews();
624 if (Shell::GetInstance()->session_state_delegate()-> 622 if (Shell::GetInstance()->session_state_delegate()->
625 IsActiveUserSessionStarted()) { 623 IsActiveUserSessionStarted()) {
626 status_area_widget_->Show(); 624 status_area_widget_->Show();
627 } 625 }
628 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); 626 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_);
629 627
630 shelf_layout_manager_ = new internal::ShelfLayoutManager(this); 628 shelf_layout_manager_ = new ShelfLayoutManager(this);
631 shelf_layout_manager_->AddObserver(this); 629 shelf_layout_manager_->AddObserver(this);
632 shelf_container->SetLayoutManager(shelf_layout_manager_); 630 shelf_container->SetLayoutManager(shelf_layout_manager_);
633 shelf_layout_manager_->set_workspace_controller(workspace_controller); 631 shelf_layout_manager_->set_workspace_controller(workspace_controller);
634 workspace_controller->SetShelf(shelf_layout_manager_); 632 workspace_controller->SetShelf(shelf_layout_manager_);
635 633
636 status_container->SetLayoutManager( 634 status_container->SetLayoutManager(new StatusAreaLayoutManager(this));
637 new internal::StatusAreaLayoutManager(this));
638 635
639 shelf_container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(new 636 shelf_container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(new
640 ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); 637 ShelfWindowTargeter(shelf_container, shelf_layout_manager_)));
641 status_container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(new 638 status_container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(new
642 ShelfWindowTargeter(status_container, shelf_layout_manager_))); 639 ShelfWindowTargeter(status_container, shelf_layout_manager_)));
643 640
644 views::Widget::AddObserver(this); 641 views::Widget::AddObserver(this);
645 } 642 }
646 643
647 ShelfWidget::~ShelfWidget() { 644 ShelfWidget::~ShelfWidget() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 // This needs to be called before shelf_model(). 733 // This needs to be called before shelf_model().
737 ShelfDelegate* shelf_delegate = shell->GetShelfDelegate(); 734 ShelfDelegate* shelf_delegate = shell->GetShelfDelegate();
738 if (!shelf_delegate) 735 if (!shelf_delegate)
739 return; // Not ready to create Shelf. 736 return; // Not ready to create Shelf.
740 737
741 shelf_.reset( 738 shelf_.reset(
742 new Shelf(shell->shelf_model(), shell->GetShelfDelegate(), this)); 739 new Shelf(shell->shelf_model(), shell->GetShelfDelegate(), this));
743 SetFocusCycler(shell->focus_cycler()); 740 SetFocusCycler(shell->focus_cycler());
744 741
745 // Inform the root window controller. 742 // Inform the root window controller.
746 internal::RootWindowController::ForWindow(window_container_) 743 RootWindowController::ForWindow(window_container_)->OnShelfCreated();
747 ->OnShelfCreated();
748 744
749 shelf_->SetVisible( 745 shelf_->SetVisible(
750 shell->session_state_delegate()->IsActiveUserSessionStarted()); 746 shell->session_state_delegate()->IsActiveUserSessionStarted());
751 shelf_layout_manager_->LayoutShelf(); 747 shelf_layout_manager_->LayoutShelf();
752 Show(); 748 Show();
753 } 749 }
754 750
755 bool ShelfWidget::IsShelfVisible() const { 751 bool ShelfWidget::IsShelfVisible() const {
756 return shelf_.get() && shelf_->IsVisible(); 752 return shelf_.get() && shelf_->IsVisible();
757 } 753 }
758 754
759 void ShelfWidget::SetShelfVisibility(bool visible) { 755 void ShelfWidget::SetShelfVisibility(bool visible) {
760 if (shelf_) 756 if (shelf_)
761 shelf_->SetVisible(visible); 757 shelf_->SetVisible(visible);
762 } 758 }
763 759
764 void ShelfWidget::SetFocusCycler(internal::FocusCycler* focus_cycler) { 760 void ShelfWidget::SetFocusCycler(FocusCycler* focus_cycler) {
765 delegate_view_->set_focus_cycler(focus_cycler); 761 delegate_view_->set_focus_cycler(focus_cycler);
766 if (focus_cycler) 762 if (focus_cycler)
767 focus_cycler->AddWidget(this); 763 focus_cycler->AddWidget(this);
768 } 764 }
769 765
770 internal::FocusCycler* ShelfWidget::GetFocusCycler() { 766 FocusCycler* ShelfWidget::GetFocusCycler() {
771 return delegate_view_->focus_cycler(); 767 return delegate_view_->focus_cycler();
772 } 768 }
773 769
774 void ShelfWidget::ShutdownStatusAreaWidget() { 770 void ShelfWidget::ShutdownStatusAreaWidget() {
775 if (status_area_widget_) 771 if (status_area_widget_)
776 status_area_widget_->Shutdown(); 772 status_area_widget_->Shutdown();
777 status_area_widget_ = NULL; 773 status_area_widget_ = NULL;
778 } 774 }
779 775
780 void ShelfWidget::ForceUndimming(bool force) { 776 void ShelfWidget::ForceUndimming(bool force) {
(...skipping 25 matching lines...) Expand all
806 DCHECK(delegate_view_); 802 DCHECK(delegate_view_);
807 return delegate_view_->disable_dimming_animations_for_test(); 803 return delegate_view_->disable_dimming_animations_for_test();
808 } 804 }
809 805
810 void ShelfWidget::WillDeleteShelf() { 806 void ShelfWidget::WillDeleteShelf() {
811 shelf_layout_manager_->RemoveObserver(this); 807 shelf_layout_manager_->RemoveObserver(this);
812 shelf_layout_manager_ = NULL; 808 shelf_layout_manager_ = NULL;
813 } 809 }
814 810
815 } // namespace ash 811 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_widget.h ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698