Cleanup widgets

This commit is contained in:
IlyaShurupov 2024-06-26 11:30:02 +03:00
parent 9e7704a446
commit 15127c5122
19 changed files with 455 additions and 221 deletions

View file

@ -0,0 +1,47 @@
#include "FloatSpaceWidget.hpp"
using namespace tp;
FloatSpaceWidget::FloatSpaceWidget() = default;
void FloatSpaceWidget::eventProcess(const tp::Events& events) {
updateActiveWindow(events);
}
void FloatSpaceWidget::updateActiveWindow(const tp::Events& events) {
mIsPassThrough = true;
for (auto childNode = this->mChildWidgets.firstNode(); childNode; childNode = childNode->next) {
auto child = childNode->data;
if (child->mArea.isInside(events.getPointer())) {
mIsPassThrough = false;
}
}
if (events.isPressed(InputID::MOUSE1)) {
Widget* activeChild = nullptr;
for (auto childNode = this->mChildWidgets.firstNode(); childNode; childNode = childNode->next) {
auto child = childNode->data;
if (child->mArea.isInside(events.getPointer())) {
mChildWidgets.detach(childNode);
mChildWidgets.pushFront(childNode);
child->mHandlesEvents = true;
activeChild = child;
break;
}
}
if (activeChild) {
for (auto child : this->mChildWidgets) {
if (activeChild != child.data() && !child->mIsDocked) child->mHandlesEvents = false;
}
}
}
}
bool FloatSpaceWidget::handlesEvent() const { return !mIsPassThrough; }