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

Side by Side Diff: ash/mus/shelf_delegate_mus.cc

Issue 1835403002: Support additional mash shelf alignments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync and rebase; address comments (sorry). Created 4 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
« no previous file with comments | « ash/mus/shelf_delegate_mus.h ('k') | mash/shelf/public/interfaces/BUILD.gn » ('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 2016 The Chromium Authors. All rights reserved. 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 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/mus/shelf_delegate_mus.h" 5 #include "ash/mus/shelf_delegate_mus.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/shelf/shelf.h" 9 #include "ash/shelf/shelf.h"
10 #include "ash/shelf/shelf_item_delegate.h" 10 #include "ash/shelf/shelf_item_delegate.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 SkBitmap bitmap = mojo::ConvertTo<SkBitmap>(serialized_bitmap.storage()); 109 SkBitmap bitmap = mojo::ConvertTo<SkBitmap>(serialized_bitmap.storage());
110 return GetShelfIconFromBitmap(bitmap); 110 return GetShelfIconFromBitmap(bitmap);
111 } 111 }
112 112
113 } // namespace 113 } // namespace
114 114
115 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) 115 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model)
116 : model_(model), binding_(this) { 116 : model_(model), binding_(this) {
117 ::shell::Connector* connector = 117 ::shell::Connector* connector =
118 views::WindowManagerConnection::Get()->connector(); 118 views::WindowManagerConnection::Get()->connector();
119 connector->ConnectToInterface("mojo:desktop_wm", &shelf_layout_);
119 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); 120 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_);
120 user_window_controller_->AddUserWindowObserver( 121 user_window_controller_->AddUserWindowObserver(
121 binding_.CreateInterfacePtrAndBind()); 122 binding_.CreateInterfacePtrAndBind());
122 } 123 }
123 124
124 ShelfDelegateMus::~ShelfDelegateMus() {} 125 ShelfDelegateMus::~ShelfDelegateMus() {}
125 126
126 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { 127 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) {
127 ShelfWidget* widget = shelf->shelf_widget(); 128 SetShelfPreferredSizes(shelf);
128 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager();
129 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow());
130 gfx::Size size = layout_manager->GetIdealBounds().size();
131 window->SetSharedProperty<gfx::Size>(
132 mus::mojom::WindowManager::kPreferredSize_Property, size);
133
134 StatusAreaWidget* status_widget = widget->status_area_widget();
135 mus::Window* status_window =
136 aura::GetMusWindow(status_widget->GetNativeWindow());
137 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size();
138 status_window->SetSharedProperty<gfx::Size>(
139 mus::mojom::WindowManager::kPreferredSize_Property, status_size);
140 } 129 }
141 130
142 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { 131 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) {
143 NOTIMPLEMENTED(); 132 NOTIMPLEMENTED();
144 } 133 }
145 134
146 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { 135 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) {
147 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { 136 SetShelfPreferredSizes(shelf);
148 observer->OnAlignmentChanged( 137 mash::shelf::mojom::Alignment alignment =
149 static_cast<mash::shelf::mojom::Alignment>(shelf->GetAlignment())); 138 static_cast<mash::shelf::mojom::Alignment>(shelf->GetAlignment());
150 }); 139 shelf_layout_->SetAlignment(alignment);
140
141 observers_.ForAllPtrs(
142 [alignment](mash::shelf::mojom::ShelfObserver* observer) {
143 observer->OnAlignmentChanged(alignment);
144 });
151 } 145 }
152 146
153 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { 147 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) {
154 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { 148 mash::shelf::mojom::AutoHideBehavior behavior =
155 observer->OnAutoHideBehaviorChanged( 149 static_cast<mash::shelf::mojom::AutoHideBehavior>(
156 static_cast<mash::shelf::mojom::AutoHideBehavior>( 150 shelf->auto_hide_behavior());
157 shelf->auto_hide_behavior())); 151 shelf_layout_->SetAutoHideBehavior(behavior);
158 }); 152
153 observers_.ForAllPtrs(
154 [behavior](mash::shelf::mojom::ShelfObserver* observer) {
155 observer->OnAutoHideBehaviorChanged(behavior);
156 });
159 } 157 }
160 158
161 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { 159 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) {
162 NOTIMPLEMENTED(); 160 NOTIMPLEMENTED();
163 return 0; 161 return 0;
164 } 162 }
165 163
166 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { 164 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const {
167 NOTIMPLEMENTED(); 165 NOTIMPLEMENTED();
168 return false; 166 return false;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; 312 ShelfID shelf_id = window_id_to_shelf_id_[window_id];
315 int index = model_->ItemIndexByID(shelf_id); 313 int index = model_->ItemIndexByID(shelf_id);
316 DCHECK_GE(index, 0); 314 DCHECK_GE(index, 0);
317 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); 315 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id);
318 DCHECK(iter != model_->items().end()); 316 DCHECK(iter != model_->items().end());
319 ShelfItem item = *iter; 317 ShelfItem item = *iter;
320 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; 318 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING;
321 model_->Set(index, item); 319 model_->Set(index, item);
322 } 320 }
323 321
322 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) {
323 ShelfWidget* widget = shelf->shelf_widget();
324 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager();
325 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow());
326 gfx::Size size = layout_manager->GetIdealBounds().size();
327 window->SetSharedProperty<gfx::Size>(
328 mus::mojom::WindowManager::kPreferredSize_Property, size);
329
330 StatusAreaWidget* status_widget = widget->status_area_widget();
331 mus::Window* status_window =
332 aura::GetMusWindow(status_widget->GetNativeWindow());
333 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size();
334 status_window->SetSharedProperty<gfx::Size>(
335 mus::mojom::WindowManager::kPreferredSize_Property, status_size);
336 }
337
324 } // namespace sysui 338 } // namespace sysui
325 } // namespace ash 339 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/shelf_delegate_mus.h ('k') | mash/shelf/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698