From dc6335a4abf5b64371f121e501382bf6eab27d84 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 27 Apr 2023 01:17:03 +0300 Subject: [PATCH] Remove ui example --- examples/ui.cpp | 122 ------------------------------------------------ 1 file changed, 122 deletions(-) delete mode 100644 examples/ui.cpp diff --git a/examples/ui.cpp b/examples/ui.cpp deleted file mode 100644 index 2a7ffcc2..00000000 --- a/examples/ui.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -using namespace psemek; - -static std::string const lorem_ipsum = -R"(Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)"; - -static std::string const to_be = -R"(To be, or not to be, that is the question: -Whether 'tis nobler in the mind to suffer -The slings and arrows of outrageous fortune, -Or to take Arms against a Sea of troubles, -And by opposing end them: to die, to sleep; -No more; and by a sleep, to say we end -The heart-ache, and the thousand natural shocks -That Flesh is heir to? 'Tis a consummation)"; - -struct ui_example - : app::app -{ - ui_example() - : app("UI example", 1) - , ui_controller(&loop) - { - auto style = std::make_shared(); - style->font = ui::make_default_9x12_font(); - style->text_scale = 2; - - auto screen = element_factory.make_screen(); - screen->set_style(style); - - auto window = element_factory.make_window("Settings"); - auto frame = element_factory.make_frame(); - { - auto style = std::make_shared(); - style->border_width = 0; - style->shadow_offset = {0, 0}; - frame->set_style(style); - } - auto label = element_factory.make_label(to_be); - label->set_overflow(ui::label::overflow_mode::ellipsis); - frame->set_child(label); - window->set_child(frame); - screen->add_child(window, ui::screen::x_policy::center, ui::screen::y_policy::center); - - ui_controller.set_root(std::move(screen)); - } - - void on_resize(int width, int height) override - { - app::on_resize(width, height); - ui_controller.reshape({{{0, width}, {0, height}}}); - } - - void on_mouse_move(int x, int y, int dx, int dy) override - { - app::on_mouse_move(x, y, dx, dy); - ui_controller.event(ui::mouse_move{{x, y}}); - } - - void on_left_button_down() override - { - app::on_left_button_down(); - ui_controller.event(ui::mouse_click{ui::mouse_button::left, true}); - } - - void on_left_button_up() override - { - app::on_left_button_up(); - ui_controller.event(ui::mouse_click{ui::mouse_button::left, false}); - } - - void update() override; - - void present() override; - - async::event_loop loop; - ui::controller ui_controller; - ui::default_element_factory element_factory; -}; - -void ui_example::update() -{ - loop.pump(); -} - -void ui_example::present() -{ - gl::ClearColor(0.8f, 0.8f, 0.8f, 1.f); - gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT); - - gfx::render_target rt; - rt.framebuffer = &gfx::framebuffer::null(); - rt.draw_buffer = gl::BACK_LEFT; - rt.viewport = {{{0, width()}, {0, height()}}}; - - ui_controller.render(rt); -} - -int main() -{ - return app::main(); -}