From 1fd5cc2018a62ae52fde39f5e044becc56888f8d Mon Sep 17 00:00:00 2001 From: Basit Ayantunde Date: Tue, 26 Nov 2024 19:04:53 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20testing=20views?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ashura/editor/editor.cc | 73 ++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/ashura/editor/editor.cc b/ashura/editor/editor.cc index c351d8047..d551c8a50 100644 --- a/ashura/editor/editor.cc +++ b/ashura/editor/editor.cc @@ -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({2ms, 2ms}), + span({2ms, 2ms, 2ms, 2ms})); Engine::init( default_allocator, nullptr, @@ -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);