core/popupanchor: rework popup anchoring and add PopupAnchor

This commit is contained in:
outfoxxed 2024-07-23 22:12:27 -07:00
parent 14910b1b60
commit ebfa8ec448
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
14 changed files with 770 additions and 108 deletions

23
src/core/types.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "types.hpp"
#include <qdebug.h>
#include <qnamespace.h>
#include <qrect.h>
QRect Box::qrect() const { return {this->x, this->y, this->w, this->h}; }
bool Box::operator==(const Box& other) const {
return this->x == other.x && this->y == other.y && this->w == other.w && this->h == other.h;
}
QDebug operator<<(QDebug debug, const Box& box) {
auto saver = QDebugStateSaver(debug);
debug.nospace() << "Box(" << box.x << ',' << box.y << ' ' << box.w << 'x' << box.h << ')';
return debug;
}
Qt::Edges Edges::toQt(Edges::Flags edges) { return Qt::Edges(edges.toInt()); }
bool Edges::isOpposing(Edges::Flags edges) {
return edges.testFlags(Edges::Top | Edges::Bottom) || edges.testFlags(Edges::Left | Edges::Right);
}