2024-02-29 15:26:02 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
#include "Subsurface.hpp"
|
2024-06-11 17:17:45 +02:00
|
|
|
#include "../helpers/signal/Signal.hpp"
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-11 00:28:33 +02:00
|
|
|
class CXDGPopupResource;
|
|
|
|
|
2024-02-29 15:26:02 +01:00
|
|
|
class CPopup {
|
|
|
|
public:
|
|
|
|
// dummy head nodes
|
2024-04-27 13:43:12 +02:00
|
|
|
CPopup(PHLWINDOW pOwner);
|
2024-04-30 03:41:27 +02:00
|
|
|
CPopup(PHLLS pOwner);
|
2024-02-29 15:26:02 +01:00
|
|
|
|
|
|
|
// real nodes
|
2024-05-11 00:28:33 +02:00
|
|
|
CPopup(SP<CXDGPopupResource> popup, CPopup* pOwner);
|
2024-02-29 15:26:02 +01:00
|
|
|
|
|
|
|
~CPopup();
|
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
Vector2D coordsRelativeToParent();
|
|
|
|
Vector2D coordsGlobal();
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
Vector2D size();
|
2024-02-29 16:07:11 +01:00
|
|
|
|
2024-05-11 00:28:33 +02:00
|
|
|
void onNewPopup(SP<CXDGPopupResource> popup);
|
2024-05-09 22:47:21 +02:00
|
|
|
void onDestroy();
|
|
|
|
void onMap();
|
|
|
|
void onUnmap();
|
|
|
|
void onCommit(bool ignoreSiblings = false);
|
|
|
|
void onReposition();
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
void recheckTree();
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
bool visible();
|
2024-05-05 00:46:10 +02:00
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
// will also loop over this node
|
|
|
|
void breadthfirst(std::function<void(CPopup*, void*)> fn, void* data);
|
|
|
|
CPopup* at(const Vector2D& globalCoords, bool allowsInput = false);
|
|
|
|
|
|
|
|
//
|
2024-06-08 10:07:59 +02:00
|
|
|
SP<CWLSurface> m_pWLSurface;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
// T1 owners, each popup has to have one of these
|
2024-04-30 03:41:27 +02:00
|
|
|
PHLWINDOWREF m_pWindowOwner;
|
2024-05-05 00:46:10 +02:00
|
|
|
PHLLSREF m_pLayerOwner;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
|
|
|
// T2 owners
|
2024-05-11 00:28:33 +02:00
|
|
|
CPopup* m_pParent = nullptr;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-11 00:28:33 +02:00
|
|
|
WP<CXDGPopupResource> m_pResource;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-11 00:28:33 +02:00
|
|
|
Vector2D m_vLastSize = {};
|
|
|
|
Vector2D m_vLastPos = {};
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-11 00:28:33 +02:00
|
|
|
bool m_bRequestedReposition = false;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-06-05 16:53:06 +02:00
|
|
|
bool m_bInert = false;
|
|
|
|
bool m_bMapped = false;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
|
|
|
//
|
2024-07-21 13:09:54 +02:00
|
|
|
std::vector<SP<CPopup>> m_vChildren;
|
|
|
|
std::unique_ptr<CSubsurface> m_pSubsurfaceHead;
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
struct {
|
|
|
|
CHyprSignalListener newPopup;
|
2024-05-11 00:28:33 +02:00
|
|
|
CHyprSignalListener destroy;
|
|
|
|
CHyprSignalListener map;
|
|
|
|
CHyprSignalListener unmap;
|
|
|
|
CHyprSignalListener commit;
|
2024-05-11 02:02:57 +02:00
|
|
|
CHyprSignalListener dismissed;
|
2024-05-11 00:28:33 +02:00
|
|
|
CHyprSignalListener reposition;
|
2024-05-09 22:47:21 +02:00
|
|
|
} listeners;
|
|
|
|
|
|
|
|
void initAllSignals();
|
|
|
|
void unconstrain();
|
|
|
|
void recheckChildrenRecursive();
|
|
|
|
void sendScale();
|
2024-02-29 15:26:02 +01:00
|
|
|
|
2024-05-09 22:47:21 +02:00
|
|
|
Vector2D localToGlobal(const Vector2D& rel);
|
|
|
|
Vector2D t1ParentCoords();
|
|
|
|
static void bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data);
|
2024-02-29 15:26:02 +01:00
|
|
|
};
|