summaryrefslogtreecommitdiff
path: root/editor.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-14 22:20:27 +1100
committerquou <quou@disroot.org>2025-01-14 22:20:27 +1100
commitb759bfe01cc0ac065b776231e4ac3210832e6b56 (patch)
treeda96e7991b9ca9e89c5bdc0033f922ce7273b858 /editor.cpp
parent45237f681c2ec503893efb64b65d11058241a372 (diff)
clean up editor a bit
Diffstat (limited to 'editor.cpp')
-rw-r--r--editor.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/editor.cpp b/editor.cpp
index 05362e5..da83e15 100644
--- a/editor.cpp
+++ b/editor.cpp
@@ -8,6 +8,7 @@ static struct {
UI::Toolbar* toolbar;
UI::Button* mat_btn;
UI::Modal* mat_win;
+ UI::Label* mat_name;
UI::Slider* metalness_input;
Model_Instance* selected_inst;
int selected_mesh;
@@ -20,6 +21,20 @@ static int mat_win_handler(UI::Element* e, const UI::Message& m) {
return 0;
}
+static void setup_mat_edit() {
+ if (editor.selected_inst) {
+ Mesh* meshes = editor.selected_inst->m->get_meshes();
+ Mesh& msh = meshes[editor.selected_mesh];
+ Material* mat = msh.material;
+ editor.metalness_input->enable();
+ editor.metalness_input->input->set_val(mat->metalness);
+ editor.mat_name->set_text(mat->name);
+ } else {
+ editor.metalness_input->disable();
+ editor.mat_name->set_text("<no material>");
+ }
+}
+
static int mat_btn_handler(UI::Element* e, const UI::Message& m) {
(void)e;
if (m.type == UI::Message::Type::click) {
@@ -32,13 +47,15 @@ static int mat_btn_handler(UI::Element* e, const UI::Message& m) {
);
editor.mat_win->handler = mat_win_handler;
editor.mat_btn->disable();
+ editor.mat_name = editor.ui->create_element<UI::Label>(
+ container,
+ ""
+ );
editor.metalness_input = editor.ui->create_element<UI::Slider>(
container,
0.0f,
1.0f
);
- if (!editor.selected_inst)
- editor.metalness_input->disable();
editor.metalness_input->input->handler = [](
UI::Element* e,
const UI::Message& m
@@ -52,6 +69,7 @@ static int mat_btn_handler(UI::Element* e, const UI::Message& m) {
}
return 0;
};
+ setup_mat_edit();
}
return 0;
}
@@ -76,14 +94,7 @@ void editor_on_select(Model_Instance* instance, int mesh) {
editor.selected_inst = instance;
editor.selected_mesh = mesh;
if (editor.mat_win) {
- if (instance) {
- Mesh* meshes = instance->m->get_meshes();
- Mesh& msh = meshes[mesh];
- Material* mat = msh.material;
- editor.metalness_input->enable();
- editor.metalness_input->input->set_val(mat->metalness);
- } else
- editor.metalness_input->disable();
+ setup_mat_edit();
}
}
}