paint: meshes tab drag and drop

This commit is contained in:
luboslenco
2026-07-01 11:51:03 +02:00
parent 70ba58b9f7
commit e143270dd5
4 changed files with 36 additions and 3 deletions
+24 -3
View File
@@ -170,6 +170,18 @@ gpu_texture_t *base_get_drag_image() {
if (base_drag_layer != NULL) {
return base_drag_layer->fill_material != NULL ? base_drag_layer->fill_material->image_icon : base_drag_layer->texpaint_preview;
}
if (base_drag_mesh != NULL) {
gpu_texture_t *preview = tab_meshes_preview_map != NULL ? any_map_get(tab_meshes_preview_map, i32_to_string(base_drag_mesh->base->uid)) : NULL;
if (preview != NULL) {
return preview;
}
gpu_texture_t *icons = resource_get("icons.k");
gc_unroot(base_drag_rect);
base_drag_rect = resource_tile50(icons, ICON_CUBE);
gc_root(base_drag_rect);
base_drag_tint = g_theme->BUTTON_COL;
return icons;
}
return NULL;
}
@@ -201,7 +213,7 @@ void base_update(void *_) {
}
bool has_drag = base_drag_asset != NULL || base_drag_material != NULL || base_drag_layer != NULL || base_drag_file != NULL || base_drag_swatch != NULL ||
base_drag_brush != NULL || base_drag_font != NULL;
base_drag_brush != NULL || base_drag_font != NULL || base_drag_mesh != NULL;
if (g_config->touch_ui) {
// Touch and hold to activate dragging
@@ -232,6 +244,8 @@ void base_update(void *_) {
base_drag_material = NULL;
gc_unroot(base_drag_layer);
base_drag_layer = NULL;
gc_unroot(base_drag_mesh);
base_drag_mesh = NULL;
gc_unroot(base_drag_brush);
base_drag_brush = NULL;
gc_unroot(base_drag_font);
@@ -320,6 +334,13 @@ void base_update(void *_) {
gc_unroot(base_drag_layer);
base_drag_layer = NULL;
}
else if (base_drag_mesh != NULL) {
if (context_in_meshes() && base_is_dragging) {
tab_meshes_accept_mesh_drop(base_drag_mesh);
}
gc_unroot(base_drag_mesh);
base_drag_mesh = NULL;
}
else if (base_drag_brush != NULL) {
if (context_in_brushes()) {
tab_brushes_accept_brush_drop(base_drag_brush);
@@ -349,7 +370,7 @@ void base_update(void *_) {
g_context->ddirty = 0;
}
if (g_context->tool == TOOL_TYPE_CURSOR) {
if (g_context->tool == TOOL_TYPE_CURSOR && context_in_3d_view()) {
if (keyboard_down("control") && keyboard_started("d")) {
sim_duplicate();
}
@@ -904,7 +925,7 @@ void base_update_workspace() {
ui_base_htabs->buffer[TAB_AREA_SIDEBAR0]->i = 2; // Script
g_config->layout_tabs->buffer[TAB_AREA_SIDEBAR0] = 2;
g_config->layout->buffer[LAYOUT_SIZE_STATUS_H] = iron_window_height() * 0.3;
g_config->layout->buffer[LAYOUT_SIZE_STATUS_H] = iron_window_height() * 0.2;
g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = iron_window_width() * 0.52;
float h = UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 2;
h += UI_ELEMENT_H() * 3.5; // Small material panel
+5
View File
@@ -362,6 +362,11 @@ bool context_in_materials() {
return string_equals(tab, tr("Materials"));
}
bool context_in_meshes() {
char *tab = ui_hovered_tab_name();
return string_equals(tab, tr("Meshes"));
}
bool context_in_swatches() {
char *tab = ui_hovered_tab_name();
return string_equals(tab, tr("Swatches"));
+6
View File
@@ -242,6 +242,7 @@ bool context_in_3d_view();
bool context_in_paint_area();
bool context_in_layers();
bool context_in_materials();
bool context_in_meshes();
bool context_in_2d_view(view_2d_type_t type);
bool context_in_nodes();
bool context_in_swatches();
@@ -338,6 +339,8 @@ void import_mesh_run(char *path, bool _clear_layers, bool r
void import_mesh_finish_import(void *_);
void import_mesh_make_mesh(raw_mesh_t *mesh);
void import_mesh_add_mesh(raw_mesh_t *mesh);
bool _import_mesh_is_unique_name(char *s);
char *_import_mesh_number_ext(i32 i);
mesh_data_t *import_mesh_raw_mesh(raw_mesh_t *mesh);
void ui_menubar_init();
i32 ui_menu_top_y();
@@ -665,8 +668,11 @@ void ui_box_show_custom(void (*commands)(void), i32 mw,
void ui_box_hide();
void tab_meshes_draw(ui_handle_t *htab);
void tab_meshes_reset_preview_map();
void tab_meshes_accept_mesh_drop(mesh_object_t *mesh);
void tab_meshes_set_override(mesh_object_t *o, i32 mat_index);
i32 tab_meshes_get_override(mesh_object_t *o);
void tab_meshes_on_material_deleted(i32 deleted_index);
void tab_meshes_on_material_reordered(i32 old_index, i32 new_index);
void util_particle_init_physics();
void util_particle_update();
void tab_layers_apply_filter(i32 filter);
+1
View File
@@ -135,6 +135,7 @@ slot_material_t *base_drag_material = NULL;
slot_layer_t *base_drag_layer = NULL;
slot_brush_t *base_drag_brush = NULL;
slot_font_t *base_drag_font = NULL;
mesh_object_t *base_drag_mesh = NULL;
bool base_player_lock = false;
bool ui_base_show = true;