forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout_manager.h
64 lines (48 loc) · 1.89 KB
/
layout_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MASH_WM_LAYOUT_MANAGER_H_
#define MASH_WM_LAYOUT_MANAGER_H_
#include <stdint.h>
#include "base/macros.h"
#include "components/mus/public/cpp/window_observer.h"
namespace mash {
namespace wm {
// Base class for container layout managers. Derived classes override
// LayoutWindow() to perform layout and register properties to which
// changes trigger layout.
// LayoutManagers observe both the bound container and all its children.
// They must be attached prior to any windows being added to the
// container.
class LayoutManager : public mus::WindowObserver {
public:
~LayoutManager() override;
protected:
explicit LayoutManager(mus::Window* owner);
void Uninstall();
// Overridden from mus::WindowObserver:
void OnTreeChanged(
const mus::WindowObserver::TreeChangeParams& params) override;
void OnWindowDestroying(mus::Window* window) override;
void OnWindowBoundsChanged(mus::Window* window,
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) override;
void OnWindowSharedPropertyChanged(
mus::Window* window,
const std::string& name,
const std::vector<uint8_t>* old_data,
const std::vector<uint8_t>* new_data) override;
virtual void WindowAdded(mus::Window* window);
virtual void WindowRemoved(mus::Window* window);
virtual void LayoutWindow(mus::Window* window) = 0;
// Add a property that triggers layout when changed.
void AddLayoutProperty(const std::string& property);
mus::Window* owner() { return owner_; }
private:
mus::Window* owner_;
std::set<std::string> layout_properties_;
DISALLOW_COPY_AND_ASSIGN(LayoutManager);
};
} // namespace wm
} // namespace mash
#endif // MASH_WM_LAYOUT_MANAGER_H_