dockspce widget initial
This commit is contained in:
parent
fcd0209710
commit
9cc4819524
8 changed files with 72 additions and 12 deletions
|
|
@ -110,6 +110,7 @@ namespace tp {
|
|||
}
|
||||
|
||||
void attach(Node* node, Node* node_to) {
|
||||
node->next = node->prev = nullptr;
|
||||
if (node_to) {
|
||||
if (node_to->next) {
|
||||
node->next = node_to->next;
|
||||
|
|
|
|||
|
|
@ -23,15 +23,21 @@ namespace tp {
|
|||
NamedSliderWidget mSlider;
|
||||
};
|
||||
|
||||
class SimpleWidget2 : public Widget {
|
||||
class SimpleWidget2 : public DockSpaceWidget {
|
||||
public:
|
||||
SimpleWidget2() {
|
||||
this->mChildWidgets.pushBack(&mFloating);
|
||||
mFloating.addWidgetToMenu(&mWidget);
|
||||
mFloating.addWidgetToMenu(&mWidget2);
|
||||
|
||||
// this->mChildWidgets.pushBack(&mFloating2);
|
||||
// mFloating2.addWidgetToMenu(&mWidget2);
|
||||
this->mChildWidgets.pushBack(&mFloating2);
|
||||
mFloating2.addWidgetToMenu(&mWidget2);
|
||||
|
||||
mFloating2.mArea = { 200, 100, 100, 100 };
|
||||
|
||||
this->mChildWidgets.pushBack(&mFloating3);
|
||||
mFloating3.addWidgetToMenu(&mWidget3);
|
||||
|
||||
mFloating3.mArea = { 400, 100, 100, 100 };
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
@ -40,5 +46,8 @@ namespace tp {
|
|||
|
||||
FloatingWidget mFloating2;
|
||||
SimpleWidget mWidget2;
|
||||
|
||||
FloatingWidget mFloating3;
|
||||
SimpleWidget mWidget3;
|
||||
};
|
||||
}
|
||||
34
Widgets/private/DockspaceWidget.cpp
Normal file
34
Widgets/private/DockspaceWidget.cpp
Normal 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);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,15 @@ void Widget::procWrapper(const Events& events, const RectF& parentArea) {
|
|||
|
||||
checkClicked(events);
|
||||
|
||||
if (mHandlesEvents) {
|
||||
|
||||
eventProcess(events);
|
||||
|
||||
for (auto child : mChildWidgets) {
|
||||
child->procWrapper(events, getArea());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::drawWrapper(Canvas& canvas) {
|
||||
if (!mEnable || !mVisible) return;
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
11
Widgets/public/DockspaceWidget.hpp
Normal file
11
Widgets/public/DockspaceWidget.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#include "FloatingWidget.hpp"
|
||||
|
||||
namespace tp {
|
||||
class DockSpaceWidget : public Widget {
|
||||
public:
|
||||
DockSpaceWidget() = default;
|
||||
|
||||
void eventProcess(const Events& events) override;
|
||||
void eventDraw(Canvas& canvas) override;
|
||||
};
|
||||
}
|
||||
|
|
@ -57,6 +57,7 @@ namespace tp {
|
|||
|
||||
bool mVisible = false;
|
||||
bool mEnable = true;
|
||||
bool mHandlesEvents = true;
|
||||
bool mInFocus = false;
|
||||
|
||||
bool mHolding = false;
|
||||
|
|
|
|||
|
|
@ -9,3 +9,4 @@
|
|||
#include "CollapsableMenu.hpp"
|
||||
#include "FloatingWidget.hpp"
|
||||
#include "Animations.hpp"
|
||||
#include "DockspaceWidget.hpp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue