diff options
author | quou <quou@disroot.org> | 2025-01-14 00:04:55 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-01-14 00:04:55 +1100 |
commit | fd488f9603f22db0312eadcdb93b7880922dc9a7 (patch) | |
tree | 15b7986e2c06eea57575f4c97811cbc65eaa120a /editor.cpp | |
parent | dfa0b6de5a070d1be63d04574c3b8ce469518250 (diff) |
misc refactoring
Diffstat (limited to 'editor.cpp')
-rw-r--r-- | editor.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/editor.cpp b/editor.cpp new file mode 100644 index 0000000..b4555f3 --- /dev/null +++ b/editor.cpp @@ -0,0 +1,61 @@ +#include "debugdraw.hpp" +#include "editor.hpp" +#include "model.hpp" +#include "ui.hpp" + +static struct { + UI* ui; + UI::Toolbar* toolbar; + UI::Button* mat_btn; + UI::Modal* mat_win; + Model_Instance* selected_inst; + int selected_mesh; +} editor; + +static int mat_win_handler(UI::Element* e, const UI::Message& m) { + (void)e; + if (m.type == UI::Message::Type::destroy) + editor.mat_btn->enable(); + return 0; +} + +static int mat_btn_handler(UI::Element* e, const UI::Message& m) { + (void)e; + if (m.type == UI::Message::Type::click) { + editor.mat_win = editor.ui->create_element<UI::Modal>( + editor.ui->root, + "Material Editor" + ); + editor.mat_win->handler = mat_win_handler; + editor.mat_btn->disable(); + } + return 0; +} + +void init_editor(UI* ui) { + editor.ui = ui; + editor.toolbar = ui->create_element<UI::Toolbar>(ui->root); + editor.mat_btn = ui->create_element<UI::Button>( + editor.toolbar, + "Edit Material" + ); + editor.mat_win = 0; + editor.mat_btn->handler = mat_btn_handler; +} + +void deinit_editor() { + +} + +void editor_on_select(Model_Instance* instance, int mesh) { + editor.selected_inst = instance; + editor.selected_mesh = mesh; +} + +void editor_draw(Line_Renderer& lr) { + if (editor.selected_inst) { + lr.add_box( + editor.selected_inst->bounds[editor.selected_mesh] + ); + } +} |