WidgetsNew Initial
This commit is contained in:
parent
450a816b2b
commit
49cfe70c0d
15 changed files with 741 additions and 0 deletions
29
WidgetsNew/private/AnimationTestWidget.cpp
Normal file
29
WidgetsNew/private/AnimationTestWidget.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "AnimationTestWidget.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
void AnimationTestWidget::process(const EventHandler& events) {
|
||||
if (events.isDown(tp::InputID::MOUSE1)) {
|
||||
mTestSpring.getStart().setTargetPosition(events.getPointer());
|
||||
}
|
||||
|
||||
if (events.isDown(tp::InputID::MOUSE2)) {
|
||||
mTestSpring.getEnd().setTargetPosition(events.getPointer());
|
||||
}
|
||||
|
||||
mTestSpring.updateCurrentRect();
|
||||
|
||||
if (mTestSpring.checkAnimationShouldEnd()) {
|
||||
mTestSpring.endAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationTestWidget::draw(Canvas& canvas) {
|
||||
canvas.rect(getRelativeArea(), { 0, 0, 0, 1 }, 10);
|
||||
canvas.rect(mTestSpring.getCurrentRect(), RGBA(1.f), 10);
|
||||
}
|
||||
|
||||
bool AnimationTestWidget::needUpdate() const {
|
||||
if (Widget::needUpdate()) return true;
|
||||
return !mTestSpring.checkAnimationShouldEnd();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue