Replace Old Widgets
This commit is contained in:
parent
cce8f0e1bc
commit
fcd5eb2d2a
81 changed files with 388 additions and 278 deletions
28
Widgets/private/widgets/AnimationTestWidget.cpp
Normal file
28
Widgets/private/widgets/AnimationTestWidget.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#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.shouldEndTransition()) {
|
||||
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::needsNextFrame() const {
|
||||
return Widget::needsNextFrame() || !mTestSpring.shouldEndTransition();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue