OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ash/wm/aura/wm_shelf_aura.h" | |
6 | |
7 #include "ash/common/wm/shelf/wm_shelf_observer.h" | |
8 #include "ash/common/wm/wm_window.h" | |
9 #include "ash/shelf/shelf.h" | |
10 #include "ash/shelf/shelf_layout_manager.h" | |
11 #include "ash/wm/aura/wm_window_aura.h" | |
12 #include "ui/views/widget/widget.h" | |
13 | |
14 namespace ash { | |
15 namespace wm { | |
16 | |
17 WmShelfAura::WmShelfAura(Shelf* shelf) | |
18 : shelf_(shelf), shelf_layout_manager_(shelf->shelf_layout_manager()) { | |
19 shelf_layout_manager_->AddObserver(this); | |
20 shelf_->AddIconObserver(this); | |
21 } | |
22 | |
23 WmShelfAura::~WmShelfAura() { | |
24 shelf_->RemoveIconObserver(this); | |
25 if (shelf_layout_manager_) | |
26 shelf_layout_manager_->RemoveObserver(this); | |
27 } | |
28 | |
29 // static | |
30 Shelf* WmShelfAura::GetShelf(WmShelf* shelf) { | |
31 return static_cast<WmShelfAura*>(shelf)->shelf_; | |
32 } | |
33 | |
34 WmWindow* WmShelfAura::GetWindow() { | |
35 return WmWindowAura::Get(shelf_->shelf_widget()->GetNativeView()); | |
36 } | |
37 | |
38 ShelfAlignment WmShelfAura::GetAlignment() const { | |
39 return shelf_->alignment(); | |
40 } | |
41 | |
42 ShelfBackgroundType WmShelfAura::GetBackgroundType() const { | |
43 return shelf_->shelf_widget()->GetBackgroundType(); | |
44 } | |
45 | |
46 void WmShelfAura::UpdateVisibilityState() { | |
47 shelf_->shelf_layout_manager()->UpdateVisibilityState(); | |
48 } | |
49 | |
50 ShelfVisibilityState WmShelfAura::GetVisibilityState() const { | |
51 return shelf_layout_manager_ ? shelf_layout_manager_->visibility_state() | |
52 : SHELF_HIDDEN; | |
53 } | |
54 | |
55 void WmShelfAura::UpdateIconPositionForWindow(WmWindow* window) { | |
56 shelf_->UpdateIconPositionForWindow(WmWindowAura::GetAuraWindow(window)); | |
57 } | |
58 | |
59 gfx::Rect WmShelfAura::GetScreenBoundsOfItemIconForWindow( | |
60 wm::WmWindow* window) { | |
61 return shelf_->GetScreenBoundsOfItemIconForWindow( | |
62 WmWindowAura::GetAuraWindow(window)); | |
63 } | |
64 | |
65 void WmShelfAura::AddObserver(WmShelfObserver* observer) { | |
66 observers_.AddObserver(observer); | |
67 } | |
68 | |
69 void WmShelfAura::RemoveObserver(WmShelfObserver* observer) { | |
70 observers_.RemoveObserver(observer); | |
71 } | |
72 | |
73 void WmShelfAura::WillDeleteShelfLayoutManager() { | |
74 shelf_layout_manager_->RemoveObserver(this); | |
75 shelf_layout_manager_ = nullptr; | |
76 } | |
77 | |
78 void WmShelfAura::OnBackgroundUpdated( | |
79 wm::ShelfBackgroundType background_type, | |
80 BackgroundAnimatorChangeType change_type) { | |
81 FOR_EACH_OBSERVER(WmShelfObserver, observers_, | |
82 OnBackgroundUpdated(background_type, change_type)); | |
83 } | |
84 | |
85 void WmShelfAura::WillChangeVisibilityState(ShelfVisibilityState new_state) { | |
86 FOR_EACH_OBSERVER(WmShelfObserver, observers_, | |
87 WillChangeVisibilityState(new_state)); | |
88 } | |
89 | |
90 void WmShelfAura::OnShelfIconPositionsChanged() { | |
91 FOR_EACH_OBSERVER(WmShelfObserver, observers_, OnShelfIconPositionsChanged()); | |
92 } | |
93 | |
94 } // namespace wm | |
95 } // namespace ash | |
OLD | NEW |