Skip to content

Commit

Permalink
✅ testing views
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarrr committed Nov 26, 2024
1 parent f5b55a4 commit 1fd5cc2
Showing 1 changed file with 54 additions and 19 deletions.
73 changes: 54 additions & 19 deletions ashura/editor/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ int main()
Logger::init();
CHECK(logger->add_sink(&stdio_sink));
Scheduler::init(default_allocator, std::this_thread::get_id(),
span({0ns, 0ns}), span({0ns, 0ns, 0ns, 0ns, 0ns, 0ns}));
span<nanoseconds>({2ms, 2ms}),
span<nanoseconds>({2ms, 2ms, 2ms, 2ms}));

Engine::init(
default_allocator, nullptr,
Expand All @@ -16,31 +17,65 @@ int main()

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

ScrollView view;
TextButton btn;
TextButton btn2;
ScrollView view;
TextButton btn;
TextButton btn_home;
TextButton btn2;
Switch sw[4];
Slider slider;
ScalarBox scalar;
ComboBoxScrollView combo_box;
RadioBox radio;

btn.text(U"Hiya"_utf)
.style(
TextStyle{.foreground = colors::BLACK, .background = colors::WHITE},
FontStyle{.font = engine->default_font,
.font_height = 100,
.line_height = 1.2})
.frame(200, 200);
sw[0].on();

scalar.frame(250, 100);

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

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

btn.text(U"replay RELOAD"_utf)
.style(TextStyle{.foreground = colors::WHITE, .background = colors::BLUE},
FontStyle{.font = engine->assets.fonts["RobotoMono"_span].get(),
.font_height = 50,
.line_height = 1.2F})
.style(TextStyle{.foreground = colors::WHITE, .background = colors::BLUE},
FontStyle{.font = engine->assets.fonts["MaterialIcons"_span].get(),
.font_height = 40,
.line_height = 1},
0, 6)
.padding(10, 10)
.color(colors::CYAN);
btn_home.text(U"home HOME"_utf)
.style(TextStyle{.foreground = colors::WHITE, .background = colors::BLUE},
FontStyle{.font = engine->assets.fonts["RobotoMono"_span].get(),
.font_height = 50,
.line_height = 1.2F})
.style(TextStyle{.foreground = colors::WHITE, .background = colors::BLUE},
FontStyle{.font = engine->assets.fonts["MaterialIcons"_span].get(),
.font_height = 40,
.line_height = 1},
0, 4)
.frame(200, 200)
.color(colors::CYAN);

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

FlexView flex{};
flex.items({&btn, &btn2})
flex.items({&btn, &btn2, &btn_home, sw + 0, sw + 1, sw + 2, &slider, &scalar,
&radio, &combo_box})
.axis(Axis::X)
.cross_align(0)
.main_align(MainAlign::SpaceEvenly)
.main_align(MainAlign::SpaceBetween)
.frame(1920, 1080);

engine->run(flex);
Expand Down

0 comments on commit 1fd5cc2

Please sign in to comment.