blob: c75001157a06bf92e22f7a9713b9b9559b1ec4e8 (
plain)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 | // Copyright (C) 2022 The Qt Company Ltd.// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only#ifndef QWASMWINDOWSTACK_H#define QWASMWINDOWSTACK_H#include <qglobal.h>#include <QtCore/qlist.h>#include <vector> QT_BEGIN_NAMESPACE class QWasmWindow;// Maintains a z-order hierarchy for a set of windows. The first added window is always treated as// the 'root', which always stays at the bottom. Other windows are 'regular', which means they are// subject to z-order changes via |raise| and |lower|/// If the root is ever removed, all of the current and future windows in the stack are treated as// regular.// Access to the top element is facilitated by |topWindow|.// Changes to the top element are signaled via the |topWindowChangedCallback| supplied at// construction.class Q_AUTOTEST_EXPORT QWasmWindowStack {public:using WindowOrderChangedCallbackType =std::function<void()>;using StorageType = QList<QWasmWindow *>;using iterator =StorageType::reverse_iterator;using const_iterator =StorageType::const_reverse_iterator;using const_reverse_iterator =StorageType::const_iterator;enumclass PositionPreference { StayOnBottom, Regular, StayOnTop,};explicitQWasmWindowStack(WindowOrderChangedCallbackType topWindowChangedCallback);~QWasmWindowStack();voidpushWindow(QWasmWindow *window, PositionPreference position);voidremoveWindow(QWasmWindow *window);voidraise(QWasmWindow *window);voidlower(QWasmWindow *window);voidwindowPositionPreferenceChanged(QWasmWindow *window, PositionPreference position);// Iterates top-to-bottom iterator begin(); iterator end(); const_iterator begin()const; const_iterator end()const;// Iterates bottom-to-top const_reverse_iterator rbegin()const; const_reverse_iterator rend()const;boolempty()const;size_tsize()const; QWasmWindow *topWindow()const;private: PositionPreference getWindowPositionPreference(StorageType::iterator windowIt)const; WindowOrderChangedCallbackType m_windowOrderChangedCallback; QList<QWasmWindow *> m_windowStack;StorageType::iterator m_regularWindowsBegin;StorageType::iterator m_alwaysOnTopWindowsBegin;}; QT_END_NAMESPACE #endif// QWASMWINDOWSTACK_H
|