OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mash/shelf/shelf_view.h" | 5 #include "mash/shelf/shelf_view.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "mojo/common/common_type_converters.h" | 9 #include "mojo/common/common_type_converters.h" |
10 #include "mojo/shell/public/cpp/application_impl.h" | 10 #include "mojo/shell/public/cpp/application_impl.h" |
11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
12 #include "ui/views/controls/button/label_button.h" | 12 #include "ui/views/controls/button/label_button.h" |
13 #include "ui/views/layout/box_layout.h" | 13 #include "ui/views/layout/box_layout.h" |
14 | 14 |
15 namespace mash { | 15 namespace mash { |
16 namespace shelf { | 16 namespace shelf { |
17 | 17 |
18 ShelfView::ShelfView(mojo::ApplicationImpl* app) : binding_(this) { | 18 ShelfView::ShelfView(mojo::ApplicationImpl* app) : binding_(this) { |
19 app->ConnectToService("mojo:desktop_wm", &user_window_controller_); | 19 app->ConnectToService("mojo:desktop_wm", &user_window_controller_); |
20 | 20 |
21 mash::wm::mojom::UserWindowObserverPtr observer; | 21 user_window_controller_->AddUserWindowObserver( |
22 mojo::InterfaceRequest<mash::wm::mojom::UserWindowObserver> request = | 22 binding_.CreateInterfacePtrAndBind()); |
23 mojo::GetProxy(&observer); | |
24 user_window_controller_->AddUserWindowObserver(std::move(observer)); | |
25 binding_.Bind(std::move(request)); | |
26 | 23 |
27 SetLayoutManager( | 24 SetLayoutManager( |
28 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 25 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
29 } | 26 } |
30 | 27 |
31 ShelfView::~ShelfView() {} | 28 ShelfView::~ShelfView() {} |
32 | 29 |
33 size_t ShelfView::GetButtonIndexById(uint32_t window_id) const { | 30 size_t ShelfView::GetButtonIndexById(uint32_t window_id) const { |
34 for (size_t i = 0; i < open_window_buttons_.size(); ++i) | 31 for (size_t i = 0; i < open_window_buttons_.size(); ++i) |
35 if (static_cast<uint32_t>(open_window_buttons_[i]->tag()) == window_id) | 32 if (static_cast<uint32_t>(open_window_buttons_[i]->tag()) == window_id) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return; | 87 return; |
91 | 88 |
92 open_window_buttons_[index]->SetText(window_title.To<base::string16>()); | 89 open_window_buttons_[index]->SetText(window_title.To<base::string16>()); |
93 open_window_buttons_[index]->SetMinSize(gfx::Size()); | 90 open_window_buttons_[index]->SetMinSize(gfx::Size()); |
94 Layout(); | 91 Layout(); |
95 SchedulePaint(); | 92 SchedulePaint(); |
96 } | 93 } |
97 | 94 |
98 } // namespace shelf | 95 } // namespace shelf |
99 } // namespace mash | 96 } // namespace mash |
OLD | NEW |