new widgets
This commit is contained in:
parent
3dce41ea39
commit
8f62c8f387
18 changed files with 373 additions and 43 deletions
46
Widgets/public/FloatingWidget.hpp
Normal file
46
Widgets/public/FloatingWidget.hpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include "CollapsableMenu.hpp"
|
||||
|
||||
namespace tp {
|
||||
template <typename Events, typename Canvas>
|
||||
class FloatingWidget : public CollapsableMenu<Events, Canvas> {
|
||||
public:
|
||||
FloatingWidget() {
|
||||
this->mArea = { 0, 0, 300, 300 };
|
||||
}
|
||||
|
||||
virtual void procWrapper(const Events& events, const RectF& parentArea) override {
|
||||
if (!this->mEnable) return;
|
||||
|
||||
this->checkVisibility(events, parentArea);
|
||||
|
||||
if (!this->mVisible) return;
|
||||
|
||||
this->checkFocus(events);
|
||||
|
||||
this->checkClicked(events);
|
||||
|
||||
mParentArea = parentArea;
|
||||
this->eventProcess(events);
|
||||
|
||||
for (auto child : this->mChildWidgets) {
|
||||
child->procWrapper(events, this->getArea());
|
||||
}
|
||||
}
|
||||
|
||||
void eventProcess(const Events& events) override {
|
||||
CollapsableMenu<Events, Canvas>::eventProcess(events);
|
||||
|
||||
if (this->mHeader.isHolding()) {
|
||||
this->mArea.pos += events.getPointerDelta();
|
||||
if (!this->mArea.isEnclosedIn(mParentArea)) {
|
||||
this->mArea.pos -= events.getPointerDelta();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RectF mParentArea;
|
||||
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue