Cleanup widgets
This commit is contained in:
parent
242cd93589
commit
da6990ddc8
30 changed files with 705 additions and 654 deletions
47
Widgets/private/FloatSpaceWidget.cpp
Normal file
47
Widgets/private/FloatSpaceWidget.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "FloatingLayoutWidget.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
FloatingLayoutWidget::FloatingLayoutWidget() = default;
|
||||
|
||||
void FloatingLayoutWidget::eventProcess(const tp::Events& events) {
|
||||
updateActiveWindow(events);
|
||||
}
|
||||
|
||||
void FloatingLayoutWidget::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 FloatingLayoutWidget::handlesEvent() const { return !mIsPassThrough; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue