Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Dec 17, 2024
1 parent 55cc542 commit 871f575
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
7 changes: 6 additions & 1 deletion Submodules/UIKit/lib/NXTransform3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ NXTransform3D NXTransform3D::interpolateTo(const NXTransform3D& matrix, const NX
getPartsFromMatrix(currentM, &angle, &translation, &scale);
getPartsFromMatrix(newM, &dAngle, &dTranslation, &dScale);
//
auto from = angle;
angle = angle + (dAngle - angle) * progress;
scale = scale + (dScale - scale) * progress;// (scale - NXPoint(1, 1)) * progress + NXPoint(1, 1);
translation = translation + (dTranslation - translation) * progress;
// printf("Angle: from - %f | to - %f | %f - %f\n", from, dAngle, angle, progress);

return NXTransform3D::translationBy(translation.x, translation.y, 0) * NXTransform3D::scaleBy(scale.x, scale.y, 1) * NXTransform3D::rotationBy(angle, 0, 0, 1);
auto affineResult = NXAffineTransform::translationBy(translation.x, translation.y) * NXAffineTransform::scaleBy(scale.x, scale.y) * NXAffineTransform::rotationBy(angle);
return NXTransform3DMakeAffineTransform(affineResult);
// return NXTransform3D::translationBy(translation.x, translation.y, 0) * NXTransform3D::scaleBy(scale.x, scale.y, 1) * NXTransform3D::rotationBy(angle, 0, 0, 1);
}

Vector3 NXTransform3D::transformingVector(NXFloat x, NXFloat y, NXFloat z) const {
Expand Down Expand Up @@ -172,6 +176,7 @@ NXTransform3D CATransform3DMakeScale(NXFloat tx, NXFloat ty, NXFloat tz) {
0, 0, 0, 1);
}

// TODO: NOT WORKING!!!!!!!
NXTransform3D CATransform3DMakeRotation(NXFloat angle, NXFloat x, NXFloat y, NXFloat z) {
NXFloat p, radians, c, s, c_, zc_, yc_, xzc_, xyc_, yzc_, xs, ys, zs;

Expand Down
1 change: 1 addition & 0 deletions Submodules/UIKit/lib/UILabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void UILabel::draw() {
paragraph->paint(&canvas, 0, 0);

layer()->setContents(new_shared<CGImage>(bitmap.asImage()));
layer()->setContentsScale(scale);
}

void UILabel::updateParagraph() {
Expand Down
23 changes: 15 additions & 8 deletions app/Screens/TestViewController/TestViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
using namespace NXKit;

void animateCube(std::shared_ptr<UIView> view) {
UIView::animate(2.5, [view]() {
view->setTransform(NXAffineTransform::identity.rotationBy(45));
UIView::animate(2.5, 0, 0.5, 2, UIViewAnimationOptions::none, [view]() {
view->setTransform(NXAffineTransform::identity.rotationBy(55));
view->setBackgroundColor(UIColor::orange);
}, [view](bool res) {
UIView::animate(2.5, [view]() {
view->setTransform(NXAffineTransform::identity);
view->setBackgroundColor(UIColor::blue);
}, [view](bool res) {
animateCube(view);
DispatchQueue::main()->asyncAfter(1, [view]() {
UIView::animate(2.5, [view]() {
view->setTransform(NXAffineTransform::identity.rotationBy(10));
view->setBackgroundColor(UIColor::blue);
}, [view](bool res) {
DispatchQueue::main()->asyncAfter(1, [view]() {
animateCube(view);
});
});
});
});
}
Expand Down Expand Up @@ -105,7 +109,7 @@ void TestViewController::loadView() {
label->setText("Привет\nебать,\nэто\nкириллица,\nнахуй!!!!");
label->setTextAlignment(NSTextAlignment::center);
label->setBackgroundColor(UIColor::red);
// label->setContentMode(NXKit::UIViewContentMode::redraw);
label->setContentMode(NXKit::UIViewContentMode::center);
rootView->addSubview(label);

auto blur = new_shared<UIBlurView>();
Expand All @@ -131,6 +135,9 @@ void TestViewController::loadView() {
void TestViewController::viewDidLoad() {
UIViewController::viewDidLoad();
animateLabel(label);

auto testMatrix = CATransform3DMakeRotation(45, 0, 0, 1);
printf("");
}

void TestViewController::viewDidLayoutSubviews() {
Expand Down

0 comments on commit 871f575

Please sign in to comment.