summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmwindowtreenode.h
blob: 344fdb43cbd628f9b89487f68e716bb2b957cb89 (plain)
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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef QWASMWINDOWTREENODE_H
#define QWASMWINDOWTREENODE_H

#include "qwasmwindowstack.h"

namespace emscripten {
class val;
}

class QWasmWindow;

enum class QWasmWindowTreeNodeChangeType {
    NodeInsertion,
    NodeRemoval,
};

class QWasmWindowTreeNode
{
public:
    QWasmWindowTreeNode();
    virtual ~QWasmWindowTreeNode();

    virtual emscripten::val containerElement() = 0;
    virtual QWasmWindowTreeNode *parentNode() = 0;

protected:
    virtual void onParentChanged(QWasmWindowTreeNode *previous, QWasmWindowTreeNode *current,
                                 QWasmWindowStack::PositionPreference positionPreference);
    virtual QWasmWindow *asWasmWindow();
    virtual void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType,
                                  QWasmWindowTreeNode *parent, QWasmWindow *child);
    virtual void setWindowZOrder(QWasmWindow *window, int z);

    void onPositionPreferenceChanged(QWasmWindowStack::PositionPreference positionPreference);
    void setAsActiveNode();
    void bringToTop();
    void sendToBottom();

    const QWasmWindowStack &childStack() const { return m_childStack; }
    QWasmWindow *activeChild() const { return m_activeChild; }

private:
    void onTopWindowChanged();
    void setActiveChildNode(QWasmWindow *activeChild);

    QWasmWindowStack m_childStack;
    QWasmWindow *m_activeChild = nullptr;
};

#endif // QWASMWINDOWTREENODE_H