dockspce widget initial

This commit is contained in:
IlyaShurupov 2024-06-25 18:34:38 +03:00 committed by Ilya Shurupov
parent fcd0209710
commit 9cc4819524
8 changed files with 72 additions and 12 deletions

View file

@ -0,0 +1,34 @@
#include "DockspaceWidget.hpp"
using namespace tp;
void DockSpaceWidget::eventProcess(const tp::Events& events) {
if (this->mChildWidgets.size() > 1 && 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->mHandlesEvents = false;
}
}
}
}
void DockSpaceWidget::eventDraw(Canvas& canvas) {
canvas.rect(this->mArea, RGBA(0, 0, 0, 1), 0);
}

View file

@ -9,11 +9,11 @@ FloatingWidget::FloatingWidget() {
}
void FloatingWidget::eventProcess(const Events& events) {
mActionStartRelativePos = events.getPointerPrev() - this->mArea.pos;
checkFloating(events);
checkResizing(events);
mActionStartRelativePos = events.getPointer() - this->mArea.pos;
CollapsableMenu::eventProcess(events);
}

View file

@ -17,10 +17,13 @@ void Widget::procWrapper(const Events& events, const RectF& parentArea) {
checkClicked(events);
eventProcess(events);
if (mHandlesEvents) {
for (auto child : mChildWidgets) {
child->procWrapper(events, getArea());
eventProcess(events);
for (auto child : mChildWidgets) {
child->procWrapper(events, getArea());
}
}
}
@ -31,8 +34,8 @@ void Widget::drawWrapper(Canvas& canvas) {
// draw child widgets
canvas.pushClamp(this->mArea);
for (auto child : mChildWidgets) {
child->drawWrapper(canvas);
for (auto child = mChildWidgets.lastNode(); child; child = child->prev) {
child->data->drawWrapper(canvas);
}
canvas.popClamp();
}