Skip to content

Commit

Permalink
✨ updated gui test
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarrr committed Dec 15, 2024
1 parent 51b9c13 commit 94c89c1
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions ashura/editor/editor.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "ashura/engine/animation.h"
#include "ashura/engine/engine.h"
#include "ashura/engine/views.h"

struct Animated;

int main()
{
using namespace ash;
Expand All @@ -15,6 +18,9 @@ int main()
R"(C:\Users\rlama\Documents\workspace\oss\ashura\ashura\config.json)"_str,
R"(C:\Users\rlama\Documents\workspace\oss\ashura\assets)"_str);

// [ ] revamp views
// [ ] forward pointer and key events to views

defer engine_{[&] { Engine::uninit(); }};

ScrollView view;
Expand All @@ -33,8 +39,6 @@ int main()

slider.range(0, 100).interp(0).axis(Axis::Y);

// Don't use whole font metrics for line metrics

btn.text(U"replay RELOAD"_str)
.style(TextStyle{.foreground = colors::WHITE, .background = colors::BLUE},
FontStyle{.font = engine->assets.fonts["RobotoMono"_str].get(),
Expand All @@ -45,8 +49,8 @@ int main()
.font_height = 40,
.line_height = 1},
0, 6)
.padding(10, 10)
.color(colors::CYAN);
.padding(10, 10);

btn_home.text(U"home HOME"_str)
.style(TextStyle{.foreground = colors::WHITE, .background = colors::BLUE},
FontStyle{.font = engine->assets.fonts["RobotoMono"_str].get(),
Expand All @@ -57,18 +61,15 @@ int main()
.font_height = 40,
.line_height = 1},
0, 4)
.frame(200, 200);

btn2.text(U"بِسْمِ ٱللَّهِ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ"_str)
.style(TextStyle{.foreground = colors::WHITE, .background = colors::NONE},
FontStyle{.font = engine->assets.fonts["Amiri"_str].get(),
.font_height = 25,
.line_height = 1.2F})
.frame(200, 200)
.color(colors::CYAN);

btn2.text(
U"بِسْمِ ٱللَّهِ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ ١ ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَـٰلَمِينَ ٢ ٱلرَّحْمَـٰنِ ٱلرَّحِيمِ ٣ مَـٰلِكِ يَوْمِ ٱلدِّينِ ٤ إِيَّاكَ نَعْبُدُ وَإِيَّاكَ نَسْتَعِينُ ٥ ٱهْدِنَا ٱلصِّرَٰطَ ٱلْمُسْتَقِيمَ ٦ صِرَٰطَ ٱلَّذِينَ أَنْعَمْتَ عَلَيْهِمْ غَيْرِ ٱلْمَغْضُوبِ عَلَيْهِمْ وَلَا ٱلضَّآلِّينَ ٧"_str)
.style(
TextStyle{.foreground = colors::WHITE, .background = colors::YELLOW},
FontStyle{.font = engine->assets.fonts["Amiri"_str].get(),
.font_height = 50,
.line_height = 1.2F})
.frame(200, 200)
.color(colors::MAGENTA);
.padding(10, 10);

FlexView flex{};
flex.items({&btn, &btn2, &btn_home, sw + 0, sw + 1, sw + 2, &slider, &scalar,
Expand All @@ -78,5 +79,15 @@ int main()
.main_align(MainAlign::SpaceBetween)
.frame(1'920, 1'080);

engine->run(flex);
auto animation = StaggeredAnimation<f32>::make(4, 8, RippleStagger{});

animation.timelines().v0.frame(1'920 * 0.25F, 1'920, 400ms, easing::out());

// [ ] do we really need a tick function?
auto loop = [&](time_point, nanoseconds delta) {
animation.tick(delta);
flex.frame(animation.animate(0).v0, 1'080);
};

engine->run(flex, fn(loop));
}

0 comments on commit 94c89c1

Please sign in to comment.