WidgetsNew Initial
This commit is contained in:
parent
450a816b2b
commit
49cfe70c0d
15 changed files with 741 additions and 0 deletions
50
WidgetsNew/private/Widget.cpp
Normal file
50
WidgetsNew/private/Widget.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#include "Widget.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
Widget::Widget() {
|
||||
mArea.setTargetRect({ 10, 10, 100, 40, });
|
||||
mArea.endAnimation();
|
||||
}
|
||||
|
||||
void Widget::setArea(const RectF& area) {
|
||||
mArea.setTargetRect(area);
|
||||
}
|
||||
|
||||
void Widget::draw(Canvas& canvas) {
|
||||
canvas.rect(mArea.getCurrentRect(), RGBA(1.f), 10);
|
||||
}
|
||||
|
||||
RectF Widget::getArea() const {
|
||||
return mArea.getCurrentRect();
|
||||
}
|
||||
|
||||
RectF Widget::getRelativeArea() const {
|
||||
return { {}, mArea.getCurrentRect().size };
|
||||
}
|
||||
|
||||
void Widget::setActive(bool active) {
|
||||
mIsActive = active;
|
||||
}
|
||||
|
||||
void Widget::addChild(Widget* widget) {
|
||||
if (widget->mParent) {
|
||||
widget->mParent->removeChild(widget);
|
||||
}
|
||||
mChildWidgets.pushBack(widget);
|
||||
widget->mParent = this;
|
||||
}
|
||||
|
||||
void Widget::removeChild(Widget* widget) {
|
||||
auto node = mChildWidgets.find(widget);
|
||||
node->data->mParent = nullptr;
|
||||
mChildWidgets.removeNode(node);
|
||||
}
|
||||
|
||||
bool Widget::needUpdate() const {
|
||||
return !mArea.checkAnimationShouldEnd();
|
||||
}
|
||||
|
||||
void Widget::finishAnimations() {
|
||||
mArea.endAnimation();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue