From c3623b12f5756453bca00f0882498f0536f94f4c Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 8 Jun 2026 11:54:42 +0200 Subject: [PATCH] paint: cleanup --- paint/sources/context.c | 330 +++++++++--------- paint/sources/history.c | 18 +- paint/sources/io/export_arm.c | 73 ++-- paint/sources/io/export_obj.c | 36 +- paint/sources/io/export_player.c | 8 +- paint/sources/io/export_texture.c | 2 +- paint/sources/io/import_arm.c | 16 +- paint/sources/io/import_audio.c | 5 +- paint/sources/io/import_mesh.c | 10 +- paint/sources/io/import_texture.c | 2 +- paint/sources/main.c | 4 +- paint/sources/nodes_material/tilesheet_node.c | 14 +- paint/sources/project.c | 20 +- paint/sources/render/make_material.c | 2 +- paint/sources/render/render_path_paint.c | 8 +- paint/sources/slot_layer.c | 12 +- paint/sources/types.h | 22 +- paint/sources/ui/box_export.c | 10 +- paint/sources/ui/box_import_mesh.c | 4 +- paint/sources/ui/box_new_project.c | 2 +- paint/sources/ui/box_preferences.c | 12 +- paint/sources/ui/box_projects.c | 6 +- paint/sources/ui/tab_browser.c | 6 +- paint/sources/ui/tab_brushes.c | 5 +- paint/sources/ui/tab_console.c | 8 +- paint/sources/ui/tab_layers.c | 33 +- paint/sources/ui/tab_materials.c | 5 +- paint/sources/ui/tab_meshes.c | 8 +- paint/sources/ui/tab_scripts.c | 2 +- paint/sources/ui/tab_swatches.c | 12 +- paint/sources/ui/tab_textures.c | 4 +- paint/sources/ui/tab_timeline.c | 4 +- paint/sources/ui/ui_base.c | 2 +- paint/sources/ui/ui_header.c | 16 +- paint/sources/ui/ui_menu.c | 18 +- paint/sources/ui/ui_menubar.c | 6 +- paint/sources/ui/ui_nodes.c | 79 ++--- paint/sources/ui/ui_search.c | 6 +- paint/sources/ui/ui_sidebar.c | 10 +- paint/sources/ui/ui_toolbar.c | 30 +- paint/sources/ui/ui_view2d.c | 16 +- paint/sources/uniforms.c | 6 +- paint/sources/util/util_brush.c | 16 +- paint/sources/util/util_layer.c | 4 +- paint/sources/util/util_nodes.c | 2 +- paint/sources/util/util_shortcut.c | 24 +- paint/sources/util/util_uv.c | 9 +- paint/sources/viewport.c | 6 +- 48 files changed, 479 insertions(+), 474 deletions(-) diff --git a/paint/sources/context.c b/paint/sources/context.c index 60ec5b08..a2da5350 100644 --- a/paint/sources/context.c +++ b/paint/sources/context.c @@ -5,171 +5,171 @@ void context_init() { g_context = GC_ALLOC_INIT(context_t, {0}); gc_root(g_context); - g_context->merged_object_is_atlas = false; // Only objects referenced by atlas are merged - g_context->ddirty = 0; // depth - g_context->pdirty = 0; // paint - g_context->rdirty = 0; // render - g_context->brush_blend_dirty = true; - g_context->split_view = false; - g_context->view_index = -1; - g_context->view_index_last = -1; - g_context->picked_color = project_make_swatch(0xffffffff); - g_context->envmap_loaded = false; - g_context->show_envmap = false; - g_context->show_envmap_blur = false; - g_context->show_envmap_spheres = false; - g_context->capturing_screenshot = false; - g_context->capture_background = false; - g_context->envmap_angle = 0.0; - g_context->light_angle = 0.0; - g_context->cull_backfaces = true; - g_context->texture_filter = true; - g_context->format_type = TEXTURE_LDR_FORMAT_PNG; - g_context->format_quality = 100.0; - g_context->layers_destination = EXPORT_DESTINATION_DISK; - g_context->split_by = SPLIT_TYPE_OBJECT; - g_context->select_time = 0.0; - g_context->viewport_mode = g_config->viewport_mode; - g_context->hscale_was_changed = false; - g_context->export_mesh_format = MESH_FORMAT_OBJ; - g_context->export_mesh_index = 0; - g_context->pack_assets_on_export = true; - g_context->pack_assets_on_save = false; - g_context->paint_vec = (vec4_t){0.0, 0.0, 0.0, 1.0}; - g_context->last_paint_x = -1.0; - g_context->last_paint_y = -1.0; - g_context->foreground_event = false; - g_context->painted = 0; - g_context->brush_time = 0.0; - g_context->clone_start_x = -1.0; - g_context->clone_start_y = -1.0; - g_context->clone_delta_x = 0.0; - g_context->clone_delta_y = 0.0; - g_context->show_compass = true; - g_context->last_paint_vec_x = -1.0; - g_context->last_paint_vec_y = -1.0; - g_context->prev_paint_vec_x = -1.0; - g_context->prev_paint_vec_y = -1.0; - g_context->frame = 0; - g_context->paint2d_view = false; - g_context->brush_locked = false; - g_context->camera_type = CAMERA_TYPE_PERSPECTIVE; - g_context->texture_export_path = ""; - g_context->last_status_position = 0; - g_context->camera_pivot = CAMERA_PIVOT_CURSOR; - g_context->camera_controls = CAMERA_CONTROLS_ORBIT; - g_context->pen_painting_only = false; // Reject painting with finger when using pen - g_context->layer_preview_dirty = true; - g_context->layers_preview_dirty = false; - g_context->node_preview_name = ""; - g_context->node_preview_socket_map = any_map_create(); - g_context->node_preview_map = any_map_create(); - g_context->selected_node_preview = true; - g_context->material_preview = false; // Drawing material previews - g_context->saved_camera = mat4_identity(); - g_context->materialid_picked = 0; - g_context->uvx_picked = 0.0; - g_context->uvy_picked = 0.0; - g_context->picker_select_material = false; - g_context->picker_mask = 0; - g_context->pick_pos_nor_tex = false; - g_context->pick_object_id = false; - g_context->posx_picked = 0.0; - g_context->posy_picked = 0.0; - g_context->posz_picked = 0.0; - g_context->norx_picked = 0.0; - g_context->nory_picked = 0.0; - g_context->norz_picked = 0.0; - g_context->draw_wireframe = false; - g_context->draw_texels = false; - g_context->colorid = 0; - g_context->colorid_picked = false; - g_context->layers_export = EXPORT_MODE_VISIBLE; - g_context->decal_preview = false; - g_context->decal_x = 0.0; - g_context->decal_y = 0.0; - g_context->write_icon_on_export = false; - g_context->particle_hit_x = 0.0; - g_context->particle_hit_y = 0.0; - g_context->particle_hit_z = 0.0; - g_context->last_particle_hit_x = 0.0; - g_context->last_particle_hit_y = 0.0; - g_context->last_particle_hit_z = 0.0; - g_context->particle_friction = 0.1; - g_context->particle_bounciness = 0.0; - g_context->particle_gravity_x = 0.0; - g_context->particle_gravity_y = 0.0; - g_context->particle_gravity_z = -9.81; - g_context->particle_lifetime = 5.0; - g_context->particle_mass = 1.0; - g_context->particle_random = 0.1; - g_context->particle_spawn_distance = 0.3; - g_context->layer_filter = 0; - g_context->gizmo_started = false; - g_context->gizmo_offset = 0.0; - g_context->gizmo_drag = 0.0; - g_context->gizmo_drag_last = 0.0; - g_context->translate_x = false; - g_context->translate_y = false; - g_context->translate_z = false; - g_context->scale_x = false; - g_context->scale_y = false; - g_context->scale_z = false; - g_context->rotate_x = false; - g_context->rotate_y = false; - g_context->rotate_z = false; - g_context->brush_nodes_radius = 1.0; - g_context->brush_nodes_opacity = 1.0; - g_context->brush_nodes_uses_random = false; - g_context->brush_mask_image_is_alpha = false; - g_context->brush_stencil_image_is_alpha = false; - g_context->brush_stencil_x = 0.02; - g_context->brush_stencil_y = 0.02; - g_context->brush_stencil_scale = 0.9; - g_context->brush_stencil_scaling = false; - g_context->brush_stencil_angle = 0.0; - g_context->brush_stencil_rotating = false; - g_context->brush_nodes_scale = 1.0; - g_context->brush_nodes_angle = 0.0; - g_context->brush_nodes_hardness = 1.0; - g_context->brush_directional = false; - g_context->brush_scale_x = 1.0; - g_context->brush_decal_mask_radius = 0.5; - g_context->brush_blending = BLEND_TYPE_MIX; - g_context->brush_opacity = 1.0; - g_context->brush_scale = 1.0; - g_context->brush_angle = 0.0; - g_context->brush_lazy_radius = 0.0; - g_context->brush_lazy_step = 0.0; - g_context->brush_lazy_x = 0.0; - g_context->brush_lazy_y = 0.0; - g_context->brush_paint = UV_TYPE_UVMAP; - g_context->brush_angle_reject_dot = 0.5; - g_context->bake_type = BAKE_TYPE_CURVATURE; - g_context->bake_axis = BAKE_AXIS_XYZ; - g_context->bake_up_axis = BAKE_UP_AXIS_Z; - g_context->bake_samples = 128; - g_context->bake_ao_strength = 1.0; - g_context->bake_ao_radius = 1.0; - g_context->bake_ao_offset = 1.0; - g_context->bake_curv_strength = 1.0; - g_context->bake_curv_radius = 1.0; - g_context->bake_curv_offset = 0.0; - g_context->bake_curv_smooth = 1; - g_context->bake_high_poly = 0; - g_context->xray = false; - g_context->sym_x = false; - g_context->sym_y = false; - g_context->sym_z = false; - g_context->fill_type = FILL_TYPE_OBJECT; - g_context->blur_type = BLUR_TYPE_BLUR; - g_context->paint2d = false; - g_context->maximized_sidebar_width = 0; - g_context->drag_dest = 0; - g_context->tool = TOOL_TYPE_BRUSH; - g_context->color_picker_previous_tool = TOOL_TYPE_BRUSH; - g_context->brush_radius = 0.5; - g_context->brush_hardness = 1.0; + g_context->merged_object_is_atlas = false; // Only objects referenced by atlas are merged + g_context->ddirty = 0; // depth + g_context->pdirty = 0; // paint + g_context->rdirty = 0; // render + g_context->brush_blend_dirty = true; + g_context->split_view = false; + g_context->view_index = -1; + g_context->view_index_last = -1; + g_context->picked_color = project_make_swatch(0xffffffff); + g_context->envmap_loaded = false; + g_context->show_envmap = false; + g_context->show_envmap_blur = false; + g_context->show_envmap_spheres = false; + g_context->capturing_screenshot = false; + g_context->capture_background = false; + g_context->envmap_angle = 0.0; + g_context->light_angle = 0.0; + g_context->cull_backfaces = true; + g_context->texture_filter = true; + g_context->format_type = TEXTURE_LDR_FORMAT_PNG; + g_context->format_quality = 100.0; + g_context->layers_destination = EXPORT_DESTINATION_DISK; + g_context->split_by = SPLIT_TYPE_OBJECT; + g_context->select_time = 0.0; + g_context->viewport_mode = g_config->viewport_mode; + g_context->hscale_was_changed = false; + g_context->export_mesh_format = MESH_FORMAT_OBJ; + g_context->export_mesh_index = 0; + g_context->pack_assets_on_export = true; + g_context->pack_assets_on_save = false; + g_context->paint_vec = (vec4_t){0.0, 0.0, 0.0, 1.0}; + g_context->last_paint_x = -1.0; + g_context->last_paint_y = -1.0; + g_context->foreground_event = false; + g_context->painted = 0; + g_context->brush_time = 0.0; + g_context->clone_start_x = -1.0; + g_context->clone_start_y = -1.0; + g_context->clone_delta_x = 0.0; + g_context->clone_delta_y = 0.0; + g_context->show_compass = true; + g_context->last_paint_vec_x = -1.0; + g_context->last_paint_vec_y = -1.0; + g_context->prev_paint_vec_x = -1.0; + g_context->prev_paint_vec_y = -1.0; + g_context->frame = 0; + g_context->paint2d_view = false; + g_context->brush_locked = false; + g_context->camera_type = CAMERA_TYPE_PERSPECTIVE; + g_context->texture_export_path = ""; + g_context->last_status_position = 0; + g_context->camera_pivot = CAMERA_PIVOT_CURSOR; + g_context->camera_controls = CAMERA_CONTROLS_ORBIT; + g_context->pen_painting_only = false; // Reject painting with finger when using pen + g_context->layer_preview_dirty = true; + g_context->layers_preview_dirty = false; + g_context->node_preview_name = ""; + g_context->node_preview_socket_map = any_map_create(); + g_context->node_preview_map = any_map_create(); + g_context->selected_node_preview = true; + g_context->material_preview = false; // Drawing material previews + g_context->saved_camera = mat4_identity(); + g_context->materialid_picked = 0; + g_context->uvx_picked = 0.0; + g_context->uvy_picked = 0.0; + g_context->picker_select_material = false; + g_context->picker_mask = 0; + g_context->pick_pos_nor_tex = false; + g_context->pick_object_id = false; + g_context->posx_picked = 0.0; + g_context->posy_picked = 0.0; + g_context->posz_picked = 0.0; + g_context->norx_picked = 0.0; + g_context->nory_picked = 0.0; + g_context->norz_picked = 0.0; + g_context->draw_wireframe = false; + g_context->draw_texels = false; + g_context->colorid = 0; + g_context->colorid_picked = false; + g_context->layers_export = EXPORT_MODE_VISIBLE; + g_context->decal_preview = false; + g_context->decal_x = 0.0; + g_context->decal_y = 0.0; + g_context->write_icon_on_export = false; + g_context->particle_hit_x = 0.0; + g_context->particle_hit_y = 0.0; + g_context->particle_hit_z = 0.0; + g_context->last_particle_hit_x = 0.0; + g_context->last_particle_hit_y = 0.0; + g_context->last_particle_hit_z = 0.0; + g_context->particle_friction = 0.1; + g_context->particle_bounciness = 0.0; + g_context->particle_gravity_x = 0.0; + g_context->particle_gravity_y = 0.0; + g_context->particle_gravity_z = -9.81; + g_context->particle_lifetime = 5.0; + g_context->particle_mass = 1.0; + g_context->particle_random = 0.1; + g_context->particle_spawn_distance = 0.3; + g_context->layer_filter = 0; + g_context->gizmo_started = false; + g_context->gizmo_offset = 0.0; + g_context->gizmo_drag = 0.0; + g_context->gizmo_drag_last = 0.0; + g_context->translate_x = false; + g_context->translate_y = false; + g_context->translate_z = false; + g_context->scale_x = false; + g_context->scale_y = false; + g_context->scale_z = false; + g_context->rotate_x = false; + g_context->rotate_y = false; + g_context->rotate_z = false; + g_context->brush_nodes_radius = 1.0; + g_context->brush_nodes_opacity = 1.0; + g_context->brush_nodes_uses_random = false; + g_context->brush_mask_image_is_alpha = false; + g_context->brush_stencil_image_is_alpha = false; + g_context->brush_stencil_x = 0.02; + g_context->brush_stencil_y = 0.02; + g_context->brush_stencil_scale = 0.9; + g_context->brush_stencil_scaling = false; + g_context->brush_stencil_angle = 0.0; + g_context->brush_stencil_rotating = false; + g_context->brush_nodes_scale = 1.0; + g_context->brush_nodes_angle = 0.0; + g_context->brush_nodes_hardness = 1.0; + g_context->brush_directional = false; + g_context->brush_scale_x = 1.0; + g_context->brush_decal_mask_radius = 0.5; + g_context->brush_blending = BLEND_TYPE_MIX; + g_context->brush_opacity = 1.0; + g_context->brush_scale = 1.0; + g_context->brush_angle = 0.0; + g_context->brush_lazy_radius = 0.0; + g_context->brush_lazy_step = 0.0; + g_context->brush_lazy_x = 0.0; + g_context->brush_lazy_y = 0.0; + g_context->brush_paint = UV_TYPE_UVMAP; + g_context->brush_angle_reject_dot = 0.5; + g_context->bake_type = BAKE_TYPE_CURVATURE; + g_context->bake_axis = BAKE_AXIS_XYZ; + g_context->bake_up_axis = BAKE_UP_AXIS_Z; + g_context->bake_samples = 128; + g_context->bake_ao_strength = 1.0; + g_context->bake_ao_radius = 1.0; + g_context->bake_ao_offset = 1.0; + g_context->bake_curv_strength = 1.0; + g_context->bake_curv_radius = 1.0; + g_context->bake_curv_offset = 0.0; + g_context->bake_curv_smooth = 1; + g_context->bake_high_poly = 0; + g_context->xray = false; + g_context->sym_x = false; + g_context->sym_y = false; + g_context->sym_z = false; + g_context->fill_type = FILL_TYPE_OBJECT; + g_context->blur_type = BLUR_TYPE_BLUR; + g_context->paint2d = false; + g_context->maximized_sidebar_width = 0; + g_context->drag_dest = 0; + g_context->tool = TOOL_TYPE_BRUSH; + g_context->color_picker_previous_tool = TOOL_TYPE_BRUSH; + g_context->brush_radius = 0.5; + g_context->brush_hardness = 1.0; } bool context_use_deferred() { diff --git a/paint/sources/history.c b/paint/sources/history.c index 8274791d..f8263a5c 100644 --- a/paint/sources/history.c +++ b/paint/sources/history.c @@ -100,10 +100,10 @@ void history_swap_canvas(history_step_t *step) { g_context->material = g_project->_->materials->buffer[step->material]; } else { - ui_node_canvas_t *_canvas = g_project->_->brushes->buffer[step->brush]->canvas; + ui_node_canvas_t *_canvas = g_project->_->brushes->buffer[step->brush]->canvas; g_project->_->brushes->buffer[step->brush]->canvas = step->canvas; - step->canvas = _canvas; - g_context->brush = g_project->_->brushes->buffer[step->brush]; + step->canvas = _canvas; + g_context->brush = g_project->_->brushes->buffer[step->brush]; } ui_nodes_t *nodes = ui_nodes_get_nodes(); @@ -169,7 +169,7 @@ void history_undo() { slot_layer_delete(g_context->layer); } else if (step->action == HISTORY_ACTION_ORDER_LAYERS) { - slot_layer_t *target = g_project->_->layers->buffer[step->prev_order]; + slot_layer_t *target = g_project->_->layers->buffer[step->prev_order]; g_project->_->layers->buffer[step->prev_order] = g_project->_->layers->buffer[step->layer]; g_project->_->layers->buffer[step->layer] = target; } @@ -493,7 +493,7 @@ void history_redo() { sys_notify_on_next_frame(&history_redo_duplicate_layer, NULL); } else if (step->action == HISTORY_ACTION_ORDER_LAYERS) { - slot_layer_t *target = g_project->_->layers->buffer[step->prev_order]; + slot_layer_t *target = g_project->_->layers->buffer[step->prev_order]; g_project->_->layers->buffer[step->prev_order] = g_project->_->layers->buffer[step->layer]; g_project->_->layers->buffer[step->layer] = target; } @@ -538,7 +538,7 @@ void history_redo() { slot_layer_t *lay = history_undo_layers->buffer[history_undo_i]; slot_layer_swap(g_context->layer, lay); g_context->layer->fill_material = g_project->_->materials->buffer[step->material]; - history_undo_i = (history_undo_i + 1) % g_config->undo_steps; + history_undo_i = (history_undo_i + 1) % g_config->undo_steps; } else if (step->action == HISTORY_ACTION_TO_PAINT_LAYER || step->action == HISTORY_ACTION_TO_PAINT_MASK) { slot_layer_to_paint_layer(g_context->layer); @@ -627,9 +627,9 @@ void history_reset() { history_step_t *history_push(history_action_t action) { char *name = history_action_to_string(action); #if defined(IRON_WINDOWS) || defined(IRON_LINUX) || defined(IRON_MACOS) - char *filename = string_equals(g_project->_->filepath, "") - ? ui_files_filename - : substring(g_project->_->filepath, string_last_index_of(g_project->_->filepath, PATH_SEP) + 1, string_length(g_project->_->filepath) - 4); + char *filename = string_equals(g_project->_->filepath, "") ? ui_files_filename + : substring(g_project->_->filepath, string_last_index_of(g_project->_->filepath, PATH_SEP) + 1, + string_length(g_project->_->filepath) - 4); sys_title_set(string("%s* - %s", filename, manifest_title)); #endif diff --git a/paint/sources/io/export_arm.c b/paint/sources/io/export_arm.c index 244cf305..0498f548 100644 --- a/paint/sources/io/export_arm.c +++ b/paint/sources/io/export_arm.c @@ -180,41 +180,42 @@ void export_arm_run_project() { layer_data_t_array_t *ld = any_array_create_from_raw((void *[]){}, 0); for (i32 i = 0; i < g_project->_->layers->length; ++i) { slot_layer_t *l = g_project->_->layers->buffer[i]; - layer_data_t *d = GC_ALLOC_INIT(layer_data_t, {.name = l->name, - .res = l->texpaint != NULL ? l->texpaint->width : g_project->_->layers->buffer[0]->texpaint->width, - .bpp = bpp, - .texpaint = l->texpaint != NULL ? lz4_encode(gpu_get_texture_pixels(l->texpaint)) : NULL, - .uv_scale = l->scale, - .uv_rot = l->angle, - .uv_type = l->uv_type, - .uv_map = l->uv_map, - .decal_mat = l->uv_type == UV_TYPE_PROJECT ? mat4_to_f32_array(l->decal_mat) : NULL, - .opacity_mask = l->mask_opacity, - .fill_material = l->fill_material != NULL ? array_index_of(g_project->_->materials, l->fill_material) : -1, - .object_mask = l->object_mask, - .blending = l->blending, - .parent = l->parent != NULL ? array_index_of(g_project->_->layers, l->parent) : -1, - .visible = l->visible, - .texpaint_nor = l->texpaint_nor != NULL ? lz4_encode(gpu_get_texture_pixels(l->texpaint_nor)) : NULL, - .texpaint_pack = l->texpaint_pack != NULL ? lz4_encode(gpu_get_texture_pixels(l->texpaint_pack)) : NULL, - .paint_base = l->paint_base, - .paint_opac = l->paint_opac, - .paint_occ = l->paint_occ, - .paint_rough = l->paint_rough, - .paint_met = l->paint_met, - .paint_nor = l->paint_nor, - .paint_nor_blend = l->paint_nor_blend, - .paint_height = l->paint_height, - .paint_height_blend = l->paint_height_blend, - .paint_emis = l->paint_emis, - .paint_subs = l->paint_subs, - .path_points = l->path_points, - .path_points_world = l->path_points_world, - .path_points_camera = l->path_points_camera, - .path_points_parent = l->path_points_parent, - .path_tool = l->path_tool, - .path_curved = l->path_curved, - .path_material = l->path_material != NULL ? array_index_of(g_project->_->materials, l->path_material) : -1}); + layer_data_t *d = + GC_ALLOC_INIT(layer_data_t, {.name = l->name, + .res = l->texpaint != NULL ? l->texpaint->width : g_project->_->layers->buffer[0]->texpaint->width, + .bpp = bpp, + .texpaint = l->texpaint != NULL ? lz4_encode(gpu_get_texture_pixels(l->texpaint)) : NULL, + .uv_scale = l->scale, + .uv_rot = l->angle, + .uv_type = l->uv_type, + .uv_map = l->uv_map, + .decal_mat = l->uv_type == UV_TYPE_PROJECT ? mat4_to_f32_array(l->decal_mat) : NULL, + .opacity_mask = l->mask_opacity, + .fill_material = l->fill_material != NULL ? array_index_of(g_project->_->materials, l->fill_material) : -1, + .object_mask = l->object_mask, + .blending = l->blending, + .parent = l->parent != NULL ? array_index_of(g_project->_->layers, l->parent) : -1, + .visible = l->visible, + .texpaint_nor = l->texpaint_nor != NULL ? lz4_encode(gpu_get_texture_pixels(l->texpaint_nor)) : NULL, + .texpaint_pack = l->texpaint_pack != NULL ? lz4_encode(gpu_get_texture_pixels(l->texpaint_pack)) : NULL, + .paint_base = l->paint_base, + .paint_opac = l->paint_opac, + .paint_occ = l->paint_occ, + .paint_rough = l->paint_rough, + .paint_met = l->paint_met, + .paint_nor = l->paint_nor, + .paint_nor_blend = l->paint_nor_blend, + .paint_height = l->paint_height, + .paint_height_blend = l->paint_height_blend, + .paint_emis = l->paint_emis, + .paint_subs = l->paint_subs, + .path_points = l->path_points, + .path_points_world = l->path_points_world, + .path_points_camera = l->path_points_camera, + .path_points_parent = l->path_points_parent, + .path_tool = l->path_tool, + .path_curved = l->path_curved, + .path_material = l->path_material != NULL ? array_index_of(g_project->_->materials, l->path_material) : -1}); any_array_push(ld, d); } @@ -231,7 +232,7 @@ void export_arm_run_project() { g_project->assets = texture_files; g_project->packed_assets = packed_assets; g_project->swatches = g_project->swatches; - g_project->envmap = g_project->envmap != NULL ? (same_drive ? path_to_relative(g_project->_->filepath, g_project->envmap) : g_project->envmap) : NULL; + g_project->envmap = g_project->envmap != NULL ? (same_drive ? path_to_relative(g_project->_->filepath, g_project->envmap) : g_project->envmap) : NULL; g_project->envmap_strength = scene_world->strength; g_project->envmap_angle = g_context->envmap_angle; g_project->envmap_blur = g_context->show_envmap_blur; diff --git a/paint/sources/io/export_obj.c b/paint/sources/io/export_obj.c index 1e9efa8d..fa599665 100644 --- a/paint/sources/io/export_obj.c +++ b/paint/sources/io/export_obj.c @@ -303,7 +303,7 @@ void export_obj_run_sculpt(char *path, mesh_object_t_array_t *paint_objects) { export_obj_write_string(o, string("o %s\n", p->base->name)); for (i32 i = 0; i < len; ++i) { - f32 x = buffer_get_f32(pixels, i * 16) * sc; + f32 x = buffer_get_f32(pixels, i * 16) * sc; f32 y = buffer_get_f32(pixels, i * 16 + 4) * sc; f32 z = buffer_get_f32(pixels, i * 16 + 8) * sc; export_obj_write_string(o, "v "); @@ -317,22 +317,26 @@ void export_obj_run_sculpt(char *path, mesh_object_t_array_t *paint_objects) { for (i32 t = 0; t < tris; ++t) { i32 i0 = t * 3, i1 = t * 3 + 1, i2 = t * 3 + 2; - f32 x0 = buffer_get_f32(pixels, i0 * 16) * sc; - f32 y0 = buffer_get_f32(pixels, i0 * 16 + 4) * sc; - f32 z0 = buffer_get_f32(pixels, i0 * 16 + 8) * sc; - f32 x1 = buffer_get_f32(pixels, i1 * 16) * sc; - f32 y1 = buffer_get_f32(pixels, i1 * 16 + 4) * sc; - f32 z1 = buffer_get_f32(pixels, i1 * 16 + 8) * sc; - f32 x2 = buffer_get_f32(pixels, i2 * 16) * sc; - f32 y2 = buffer_get_f32(pixels, i2 * 16 + 4) * sc; - f32 z2 = buffer_get_f32(pixels, i2 * 16 + 8) * sc; + f32 x0 = buffer_get_f32(pixels, i0 * 16) * sc; + f32 y0 = buffer_get_f32(pixels, i0 * 16 + 4) * sc; + f32 z0 = buffer_get_f32(pixels, i0 * 16 + 8) * sc; + f32 x1 = buffer_get_f32(pixels, i1 * 16) * sc; + f32 y1 = buffer_get_f32(pixels, i1 * 16 + 4) * sc; + f32 z1 = buffer_get_f32(pixels, i1 * 16 + 8) * sc; + f32 x2 = buffer_get_f32(pixels, i2 * 16) * sc; + f32 y2 = buffer_get_f32(pixels, i2 * 16 + 4) * sc; + f32 z2 = buffer_get_f32(pixels, i2 * 16 + 8) * sc; f32 e1x = x1 - x0, e1y = y1 - y0, e1z = z1 - z0; f32 e2x = x2 - x0, e2y = y2 - y0, e2z = z2 - z0; - f32 nx = e1y * e2z - e1z * e2y; - f32 ny = e1z * e2x - e1x * e2z; - f32 nz = e1x * e2y - e1y * e2x; - f32 nl = math_sqrt(nx * nx + ny * ny + nz * nz); - if (nl > 0.0) { nx /= nl; ny /= nl; nz /= nl; } + f32 nx = e1y * e2z - e1z * e2y; + f32 ny = e1z * e2x - e1x * e2z; + f32 nz = e1x * e2y - e1y * e2x; + f32 nl = math_sqrt(nx * nx + ny * ny + nz * nz); + if (nl > 0.0) { + nx /= nl; + ny /= nl; + nz /= nl; + } export_obj_write_string(o, "vn "); export_obj_write_string(o, f32_to_string(nx)); export_obj_write_string(o, " "); @@ -343,7 +347,7 @@ void export_obj_run_sculpt(char *path, mesh_object_t_array_t *paint_objects) { } for (i32 i = 0; i < len; ++i) { - f32 u = texa->buffer[i * 2] * inv; + f32 u = texa->buffer[i * 2] * inv; f32 v = 1.0 - texa->buffer[i * 2 + 1] * inv; export_obj_write_string(o, "vt "); export_obj_write_string(o, f32_to_string(u)); diff --git a/paint/sources/io/export_player.c b/paint/sources/io/export_player.c index 97123110..f9789064 100644 --- a/paint/sources/io/export_player.c +++ b/paint/sources/io/export_player.c @@ -109,20 +109,20 @@ static char *export_player_index = "\ static void export_player_run_on_download(char *url, buffer_t *ab) {} void export_player_run(char *path) { - #ifndef NDEBUG +#ifndef NDEBUG console_error(tr("Not available in debug build")); // Requires --embed return; - #endif +#endif char *path_base = path_base_dir(path); char *_project_filepath = string_copy(g_project->_->filepath); - g_project->_->filepath = string("%s/%s", path_base, "start.arm"); + g_project->_->filepath = string("%s/%s", path_base, "start.arm"); bool _pack_assets_on_save = g_context->pack_assets_on_save; g_context->pack_assets_on_save = true; export_arm_run_project(); g_context->pack_assets_on_save = _pack_assets_on_save; - g_project->_->filepath = _project_filepath; + g_project->_->filepath = _project_filepath; if (box_export_h_export_player_target->i == PLAYER_TARGET_WEB) { char *start_js = string("%s/start.js", path_base); diff --git a/paint/sources/io/export_texture.c b/paint/sources/io/export_texture.c index d7ff14cb..f9156da8 100644 --- a/paint/sources/io/export_texture.c +++ b/paint/sources/io/export_texture.c @@ -41,7 +41,7 @@ static void export_texture_write_texture(char *file, buffer_t *pixels, i32 type, g_project->assets = any_array_create_from_raw((void *[]){}, 0); } any_array_push(g_project->assets, asset->file); - asset->image = image; + asset->image = image; asset_t_array_t *assets = any_array_create_from_raw( (void *[]){ asset, diff --git a/paint/sources/io/import_arm.c b/paint/sources/io/import_arm.c index 71ae3692..48f1decc 100644 --- a/paint/sources/io/import_arm.c +++ b/paint/sources/io/import_arm.c @@ -365,11 +365,11 @@ void import_arm_run_project(char *path) { g_context->paint_object->base->transform->scale = (vec4_t){1, 1, 1, 1.0}; transform_build_matrix(g_context->paint_object->base->transform); g_context->paint_object->base->name = md->name; - g_project->_->paint_objects = any_array_create_from_raw( - (void *[]){ - g_context->paint_object, - }, - 1); + g_project->_->paint_objects = any_array_create_from_raw( + (void *[]){ + g_context->paint_object, + }, + 1); for (i32 i = 1; i < project->mesh_datas->length; ++i) { mesh_data_t *raw = project->mesh_datas->buffer[i]; @@ -387,8 +387,8 @@ void import_arm_run_project(char *path) { } if (project->mesh_assets != NULL && project->mesh_assets->length > 0) { - char *file = project->mesh_assets->buffer[0]; - char *abs = data_is_abs(file) ? file : string("%s%s", base, file); + char *file = project->mesh_assets->buffer[0]; + char *abs = data_is_abs(file) ? file : string("%s%s", base, file); g_project->mesh_assets = any_array_create_from_raw( (void *[]){ abs, @@ -536,7 +536,7 @@ void import_arm_run_project(char *path) { context_set_layer(g_project->_->layers->buffer[0]); // Materials - material_data_t *m0 = data_get_material("Scene", "Material"); + material_data_t *m0 = data_get_material("Scene", "Material"); g_project->_->materials = any_array_create_from_raw((void *[]){}, 0); for (i32 i = 0; i < project->material_nodes->length; ++i) { ui_node_canvas_t *n = project->material_nodes->buffer[i]; diff --git a/paint/sources/io/import_audio.c b/paint/sources/io/import_audio.c index 9534c566..4754b72a 100644 --- a/paint/sources/io/import_audio.c +++ b/paint/sources/io/import_audio.c @@ -4,12 +4,11 @@ void import_audio_run(char *path) { #ifdef IRON_AUDIO - sound_t *s = data_get_sound(path); - iron_a1_play_sound(s->sound_, false, 1, false); + sound_t *s = data_get_sound(path); + iron_a1_play_sound(s->sound_, false, 1, false); string_array_t *ar = string_split(path, PATH_SEP); char *name = ar->buffer[ar->length - 1]; console_info(string("%s %s", tr("Audio imported:"), name)); #endif - } diff --git a/paint/sources/io/import_mesh.c b/paint/sources/io/import_mesh.c index 0e91d9c7..11d3fca7 100644 --- a/paint/sources/io/import_mesh.c +++ b/paint/sources/io/import_mesh.c @@ -184,11 +184,11 @@ void import_mesh_make_mesh(raw_mesh_t *mesh) { mesh_object_set_data(g_context->paint_object, md); g_context->paint_object->base->name = mesh->name; - g_project->_->paint_objects = any_array_create_from_raw( - (void *[]){ - g_context->paint_object, - }, - 1); + g_project->_->paint_objects = any_array_create_from_raw( + (void *[]){ + g_context->paint_object, + }, + 1); md->_->handle = string_copy(raw->name); any_map_set(data_cached_meshes, md->_->handle, md); diff --git a/paint/sources/io/import_texture.c b/paint/sources/io/import_texture.c index 7d5d67d3..e9356845 100644 --- a/paint/sources/io/import_texture.c +++ b/paint/sources/io/import_texture.c @@ -61,7 +61,7 @@ void import_texture_run(char *path, bool hdr_as_envmap) { if (g_context->texture == NULL) { g_context->texture = asset; } - asset->image = image; + asset->image = image; ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; console_info(string("%s %s", tr("Texture imported:"), name)); diff --git a/paint/sources/main.c b/paint/sources/main.c index 1cf11b61..c7c5e2a9 100644 --- a/paint/sources/main.c +++ b/paint/sources/main.c @@ -380,9 +380,9 @@ void _kickstart() { g_project = GC_ALLOC_INIT(project_t, {0}); gc_root(g_project); - g_project->_ = gc_alloc(sizeof(project_runtime_t)); + g_project->_ = gc_alloc(sizeof(project_runtime_t)); g_project->_->filepath = ""; - g_project->_->assets = any_array_create_from_raw((void *[]){}, 0); + g_project->_->assets = any_array_create_from_raw((void *[]){}, 0); g_project->mesh_assets = any_array_create_from_raw((void *[]){}, 0); diff --git a/paint/sources/nodes_material/tilesheet_node.c b/paint/sources/nodes_material/tilesheet_node.c index ab1fefb9..fa9f563e 100644 --- a/paint/sources/nodes_material/tilesheet_node.c +++ b/paint/sources/nodes_material/tilesheet_node.c @@ -13,13 +13,13 @@ char *tilesheet_node_vector(ui_node_t *node, ui_node_socket_t *socket) { void tilesheet_node_init() { ui_node_t *tilesheet_node_def = - GC_ALLOC_INIT(ui_node_t, {.id = 0, - .name = _tr("Tilesheet"), - .type = "TILESHEET", - .x = 0, - .y = 0, - .color = 0xffb34f5a, - .inputs = any_array_create_from_raw( + GC_ALLOC_INIT(ui_node_t, {.id = 0, + .name = _tr("Tilesheet"), + .type = "TILESHEET", + .x = 0, + .y = 0, + .color = 0xffb34f5a, + .inputs = any_array_create_from_raw( (void *[]){ GC_ALLOC_INIT(ui_node_socket_t, {.id = 0, .node_id = 0, diff --git a/paint/sources/project.c b/paint/sources/project.c index be77b195..70affbea 100644 --- a/paint/sources/project.c +++ b/paint/sources/project.c @@ -41,7 +41,7 @@ void project_save(bool save_and_quit) { #ifdef IRON_IOS char *document_directory = iron_save_dialog("", ""); document_directory = string_copy(substring(document_directory, 0, string_length(document_directory) - 8)); // Strip /"untitled" - g_project->_->filepath = string("%s/%s.arm", document_directory, sys_title()); + g_project->_->filepath = string("%s/%s.arm", document_directory, sys_title()); #elif defined(IRON_ANDROID) g_project->_->filepath = string("%s/%s.arm", iron_internal_save_path(), sys_title()); #else @@ -134,7 +134,7 @@ void project_new(bool reset_layers) { g_context->layer_preview_dirty = true; g_context->layer_filter = 0; g_context->texture = NULL; - g_project->mesh_assets = any_array_create_from_raw((void *[]){}, 0); + g_project->mesh_assets = any_array_create_from_raw((void *[]){}, 0); mesh_data_t *raw = NULL; char *mesh_name = project_default_mesh_list == NULL ? "box_bevel" : project_default_mesh_list->buffer[g_context->project_type]; @@ -199,12 +199,12 @@ void project_new(bool reset_layers) { ui_nodes_group_stack = any_array_create_from_raw((void *[]){}, 0); gc_root(ui_nodes_group_stack); g_project->_->material_groups = any_array_create_from_raw((void *[]){}, 0); - g_project->_->brushes = any_array_create_from_raw( - (void *[]){ - slot_brush_create(NULL), - }, - 1); - g_context->brush = g_project->_->brushes->buffer[0]; + g_project->_->brushes = any_array_create_from_raw( + (void *[]){ + slot_brush_create(NULL), + }, + 1); + g_context->brush = g_project->_->brushes->buffer[0]; g_project->_->fonts = any_array_create_from_raw( (void *[]){ slot_font_create("default.ttf", base_font, ""), @@ -221,8 +221,8 @@ void project_new(bool reset_layers) { make_material_parse_paint_material(true); make_material_parse_brush(); - g_project->_->assets = any_array_create_from_raw((void *[]){}, 0); - g_project->_->next_asset_id = 0; + g_project->_->assets = any_array_create_from_raw((void *[]){}, 0); + g_project->_->next_asset_id = 0; g_project->packed_assets = any_array_create_from_raw((void *[]){}, 0); g_context->ddirty = 4; ui_base_hwnds->buffer[TAB_AREA_SIDEBAR0]->redraws = 2; diff --git a/paint/sources/render/make_material.c b/paint/sources/render/make_material.c index 367c35df..47b89643 100644 --- a/paint/sources/render/make_material.c +++ b/paint/sources/render/make_material.c @@ -85,7 +85,7 @@ void make_material_parse_mesh_material() { any_array_push(m->contexts, mcon); } - g_context->ddirty = 2; + g_context->ddirty = 2; g_context->rtdirty = 1; if (make_material_transluc_used) { diff --git a/paint/sources/render/render_path_paint.c b/paint/sources/render/render_path_paint.c index 2782bb54..5e6fad55 100644 --- a/paint/sources/render/render_path_paint.c +++ b/paint/sources/render/render_path_paint.c @@ -675,10 +675,10 @@ void render_path_paint_draw_cursor_decal(f32 mx, f32 my, f32 radius, f32 opacity // Prevent cursor jumping constantly if randomness is used in brush nodes f32 brush_nodes_opacity = g_context->brush_nodes_opacity; - f32 brush_nodes_angle = g_context->brush_nodes_angle; + f32 brush_nodes_angle = g_context->brush_nodes_angle; if (g_context->brush_nodes_uses_random) { brush_nodes_opacity = 1.0; - brush_nodes_angle = 0.0; + brush_nodes_angle = 0.0; } render_path_set_target("", NULL, NULL, GPU_CLEAR_NONE, 0, 0.0); @@ -725,8 +725,8 @@ void render_path_paint_commands_cursor() { return; } - f32 mx = g_context->paint_vec.x; - f32 my = 1.0 - g_context->paint_vec.y; + f32 mx = g_context->paint_vec.x; + f32 my = 1.0 - g_context->paint_vec.y; // Prevent cursor jumping constantly if randomness is used in brush nodes f32 brush_nodes_radius = g_context->brush_nodes_radius; diff --git a/paint/sources/slot_layer.c b/paint/sources/slot_layer.c index a33ce5c3..dfa2b48e 100644 --- a/paint/sources/slot_layer.c +++ b/paint/sources/slot_layer.c @@ -665,7 +665,8 @@ bool slot_layer_can_move(slot_layer_t *raw, i32 to) { // If the layer is moved up, all layers between the old position and the new one move one down // The layers above the new position stay where they are // If the new position is on top or on bottom no upper resp. lower layer exists - slot_layer_t *new_upper_layer = delta > 0 ? (to < g_project->_->layers->length - 1 ? g_project->_->layers->buffer[to + 1] : NULL) : g_project->_->layers->buffer[to]; + slot_layer_t *new_upper_layer = + delta > 0 ? (to < g_project->_->layers->length - 1 ? g_project->_->layers->buffer[to + 1] : NULL) : g_project->_->layers->buffer[to]; // Group or layer is collapsed so we check below and update the upper layer if (new_upper_layer != NULL && !new_upper_layer->show_panel) { @@ -761,10 +762,11 @@ void slot_layer_move(slot_layer_t *raw, i32 to) { return; } - i32_map_t *pointers = tab_layers_init_layer_map(); - i32 old_index = array_index_of(g_project->_->layers, raw); - i32 delta = to - old_index; - slot_layer_t *new_upper_layer = delta > 0 ? (to < g_project->_->layers->length - 1 ? g_project->_->layers->buffer[to + 1] : NULL) : g_project->_->layers->buffer[to]; + i32_map_t *pointers = tab_layers_init_layer_map(); + i32 old_index = array_index_of(g_project->_->layers, raw); + i32 delta = to - old_index; + slot_layer_t *new_upper_layer = + delta > 0 ? (to < g_project->_->layers->length - 1 ? g_project->_->layers->buffer[to + 1] : NULL) : g_project->_->layers->buffer[to]; // Group or layer is collapsed so we check below and update the upper layer if (new_upper_layer != NULL && !new_upper_layer->show_panel) { diff --git a/paint/sources/types.h b/paint/sources/types.h index 87625a88..1d008194 100644 --- a/paint/sources/types.h +++ b/paint/sources/types.h @@ -407,16 +407,16 @@ typedef struct context { struct physics_body *body; struct object *bullet; } particles[32]; - i32 particle_index; - f32 particle_friction; - f32 particle_bounciness; - f32 particle_gravity_x; - f32 particle_gravity_y; - f32 particle_gravity_z; - f32 particle_lifetime; - f32 particle_mass; - f32 particle_random; - f32 particle_spawn_distance; + i32 particle_index; + f32 particle_friction; + f32 particle_bounciness; + f32 particle_gravity_x; + f32 particle_gravity_y; + f32 particle_gravity_z; + f32 particle_lifetime; + f32 particle_mass; + f32 particle_random; + f32 particle_spawn_distance; struct any_map *keymap; } context_t; @@ -566,7 +566,7 @@ typedef struct project { i32 timeline_max_frames; struct timeline_layer_keyframe_data_t_array *timeline_layers; struct timeline_mesh_keyframe_data_t_array *timeline_meshes; - project_runtime_t *_; + project_runtime_t *_; } project_t; typedef struct asset { diff --git a/paint/sources/ui/box_export.c b/paint/sources/ui/box_export.c index bd5f988d..21516754 100644 --- a/paint/sources/ui/box_export.c +++ b/paint/sources/ui/box_export.c @@ -109,7 +109,7 @@ void box_export_tab_export_textures(char *title, bool bake_material) { g_ui->enabled = true; ui_row2(); - g_ui->enabled = !bake_material; + g_ui->enabled = !bake_material; ui_handle_t *layers_export_handle = ui_handle(__ID__); layers_export_handle->i = g_context->layers_export; string_array_t *layers_export_combo = any_array_create_from_raw( @@ -121,7 +121,7 @@ void box_export_tab_export_textures(char *title, bool bake_material) { }, 4); g_context->layers_export = ui_combo(layers_export_handle, layers_export_combo, tr("Layers"), true, UI_ALIGN_LEFT, true); - g_ui->enabled = true; + g_ui->enabled = true; ui_combo(box_export_hpreset, box_export_files, tr("Preset"), true, UI_ALIGN_LEFT, true); if (box_export_hpreset->changed) { @@ -396,7 +396,7 @@ void box_export_tab_atlases() { if (ui_tab(box_export_htab, tr("Atlases"), tab_vertical, -1, false)) { if (g_project->atlas_objects == NULL || g_project->atlas_objects->length != g_project->_->paint_objects->length) { g_project->atlas_objects = i32_array_create_from_raw((i32[]){}, 0); - g_project->atlas_names = any_array_create_from_raw((void *[]){}, 0); + g_project->atlas_names = any_array_create_from_raw((void *[]){}, 0); for (i32 i = 0; i < g_project->_->paint_objects->length; ++i) { i32_array_push(g_project->atlas_objects, 0); i32 i1 = i + 1; @@ -406,8 +406,8 @@ void box_export_tab_atlases() { for (i32 i = 0; i < g_project->_->paint_objects->length; ++i) { ui_row2(); ui_text(g_project->_->paint_objects->buffer[i]->base->name, UI_ALIGN_LEFT, 0x00000000); - ui_handle_t *hatlas = ui_nest(ui_handle(__ID__), i); - hatlas->i = g_project->atlas_objects->buffer[i]; + ui_handle_t *hatlas = ui_nest(ui_handle(__ID__), i); + hatlas->i = g_project->atlas_objects->buffer[i]; g_project->atlas_objects->buffer[i] = ui_combo(hatlas, g_project->atlas_names, tr("Atlas"), false, UI_ALIGN_LEFT, true); } } diff --git a/paint/sources/ui/box_import_mesh.c b/paint/sources/ui/box_import_mesh.c index 1eb349e1..8f22343a 100644 --- a/paint/sources/ui/box_import_mesh.c +++ b/paint/sources/ui/box_import_mesh.c @@ -39,9 +39,9 @@ void project_import_mesh_box_draw() { if (ends_with(to_lower_case(path), ".fbx") || ends_with(to_lower_case(path), ".gltf") || ends_with(to_lower_case(path), ".glb")) { ui_row2(); bool b = ui_check(ui_handle(__ID__), tr("Apply Skinning"), ""); - g_ui->enabled = b; + g_ui->enabled = b; plugins_skinning_frame = ui_slider(ui_handle(__ID__), tr("Frame"), 1, 99, false, 1, true, UI_ALIGN_RIGHT, true); - g_ui->enabled = true; + g_ui->enabled = true; if (!b) { plugins_skinning_frame = -1; } diff --git a/paint/sources/ui/box_new_project.c b/paint/sources/ui/box_new_project.c index 777e719e..12946d31 100644 --- a/paint/sources/ui/box_new_project.c +++ b/paint/sources/ui/box_new_project.c @@ -7,7 +7,7 @@ void project_fetch_default_meshes() { project_default_mesh_list = file_read_directory(string("%s%smeshes", path_data(), PATH_SEP)); gc_root(project_default_mesh_list); for (i32 i = 0; i < project_default_mesh_list->length; ++i) { - char *s = project_default_mesh_list->buffer[i]; + char *s = project_default_mesh_list->buffer[i]; project_default_mesh_list->buffer[i] = substring(project_default_mesh_list->buffer[i], 0, string_length(s) - 4); // Trim .arm } any_array_push(project_default_mesh_list, "plane"); diff --git a/paint/sources/ui/box_preferences.c b/paint/sources/ui/box_preferences.c index 006cd42f..1689e646 100644 --- a/paint/sources/ui/box_preferences.c +++ b/paint/sources/ui/box_preferences.c @@ -138,7 +138,7 @@ void box_preferences_interface_tab() { ui_tooltip(tr("Wrap mouse around view boundaries during camera control")); } - g_ui->changed = false; + g_ui->changed = false; ui_handle_t *h_show_asset_names = ui_handle(__ID__); h_show_asset_names->b = g_config->show_asset_names; g_config->show_asset_names = ui_check(h_show_asset_names, tr("Show Asset Names"), ""); @@ -146,7 +146,7 @@ void box_preferences_interface_tab() { base_redraw_ui(); } - g_ui->changed = false; + g_ui->changed = false; ui_handle_t *h_touch_ui = ui_handle(__ID__); h_touch_ui->b = g_config->touch_ui; g_config->touch_ui = ui_check(h_touch_ui, tr("Touch UI"), ""); @@ -190,7 +190,7 @@ void box_preferences_interface_tab() { // ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝ void box_preferences_theme_tab_theme_field_menu() { - g_ui->changed = false; + g_ui->changed = false; i32 color = ui_color_wheel(_box_preferences_h, false, -1, 11 * g_ui->ops->theme->ELEMENT_H * UI_SCALE(), true, NULL, NULL); u32 *u32_theme = base_theme; *(u32_theme + _box_preferences_i) = color; @@ -290,7 +290,7 @@ void box_preferences_theme_tab() { char *theme_search = to_lower_case(box_preferences_theme_hsearch->text); ui_handle_t *h_list = ui_handle(__ID__); u32 *u32_theme = base_theme; - g_ui->input_enabled = !ui_menu_show; + g_ui->input_enabled = !ui_menu_show; for (i32 i = 0; i < ui_theme_keys_count; ++i) { char *key = ui_theme_keys[i]; if (!string_equals(theme_search, "") && string_index_of(to_lower_case(key), theme_search) == -1) { @@ -849,7 +849,7 @@ void box_preferences_model_panel(neural_node_model_t *m) { box_preferences_htab->redraws = 2; iron_delay_idle_sleep(); - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->HIGHLIGHT_COL; ui_handle_t *h = ui_handle(__ID__); @@ -975,7 +975,7 @@ void box_preferences_keymap_tab() { ui_separator(8, false); i32 index = 0; - g_ui->changed = false; + g_ui->changed = false; string_array_t *keys = map_keys(g_keymap); array_sort(keys, NULL); char *search = to_lower_case(box_preferences_keymap_hsearch->text); diff --git a/paint/sources/ui/box_projects.c b/paint/sources/ui/box_projects.c index 2199228e..1d8cdde5 100644 --- a/paint/sources/ui/box_projects.c +++ b/paint/sources/ui/box_projects.c @@ -124,7 +124,7 @@ void box_projects_tab() { i32 state = ui_image(icon, 0xffffffff, 128 * UI_SCALE()); if (state == UI_STATE_RELEASED) { i32 _uix = g_ui->_x; - g_ui->_x = uix; + g_ui->_x = uix; ui_fill(0, 0, 128, 128, 0x66000000); g_ui->_x = _uix; #if defined(IRON_ANDROID) || defined(IRON_IOS) @@ -239,9 +239,9 @@ void box_projects_recent_tab() { box_projects_draw_badge(); - g_ui->enabled = g_config->recent_projects->length > 0; + g_ui->enabled = g_config->recent_projects->length > 0; box_projects_hsearch->text = string_copy(ui_text_input(box_projects_hsearch, tr("Search"), UI_ALIGN_LEFT, true, true)); - g_ui->enabled = true; + g_ui->enabled = true; for (i32 i = 0; i < g_config->recent_projects->length; ++i) { char *path = g_config->recent_projects->buffer[i]; #ifdef IRON_WINDOWS diff --git a/paint/sources/ui/tab_browser.c b/paint/sources/ui/tab_browser.c index 97e00172..35c71c95 100644 --- a/paint/sources/ui/tab_browser.c +++ b/paint/sources/ui/tab_browser.c @@ -311,9 +311,9 @@ void tab_browser_draw(ui_handle_t *htab) { if (show_full) { i32 bottom_y = g_ui->_y; - g_ui->_x = 0; - g_ui->_y = _y; - g_ui->_w = bookmarks_w; + g_ui->_x = 0; + g_ui->_y = _y; + g_ui->_w = bookmarks_w; if (ui_icon_button(tr("Cloud"), ICON_CLOUD, UI_ALIGN_LEFT)) { tab_browser_go_to_cloud(); diff --git a/paint/sources/ui/tab_brushes.c b/paint/sources/ui/tab_brushes.c index f6d481bf..c23a4887 100644 --- a/paint/sources/ui/tab_brushes.c +++ b/paint/sources/ui/tab_brushes.c @@ -134,8 +134,9 @@ void tab_brushes_draw(ui_handle_t *htab) { ui_fill(-1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); } - ui_state_t state = g_project->_->brushes->buffer[i]->preview_ready ? ui_image(img, 0xffffffff, -1.0) - : ui_sub_image(resource_get("icons.k"), -1, -1.0, tile * 5, tile, tile, tile); + ui_state_t state = g_project->_->brushes->buffer[i]->preview_ready + ? ui_image(img, 0xffffffff, -1.0) + : ui_sub_image(resource_get("icons.k"), -1, -1.0, tile * 5, tile, tile, tile); if (state == UI_STATE_HOVERED && base_drag_brush != NULL) { tab_brushes_drag_pos = (mouse_x > uix + g_ui->_window_x + imgw_val / 2.0) ? i + 1 : i; diff --git a/paint/sources/ui/tab_console.c b/paint/sources/ui/tab_console.c index 01175bc2..9f895320 100644 --- a/paint/sources/ui/tab_console.c +++ b/paint/sources/ui/tab_console.c @@ -124,11 +124,11 @@ void tab_console_draw(ui_handle_t *htab) { ui_end_sticky(); - draw_font_t *_font = g_ui->ops->font; - i32 _font_size = g_ui->font_size; - i32 _element_offset = g_ui->ops->theme->ELEMENT_OFFSET; + draw_font_t *_font = g_ui->ops->font; + i32 _font_size = g_ui->font_size; + i32 _element_offset = g_ui->ops->theme->ELEMENT_OFFSET; g_ui->ops->theme->ELEMENT_OFFSET = 0; - draw_font_t *f = data_get_font("font_mono.ttf"); + draw_font_t *f = data_get_font("font_mono.ttf"); ui_set_font(g_ui, f); g_ui->font_size = math_floor(15 * UI_SCALE()); for (i32 i = 0; i < console_last_traces->length; ++i) { diff --git a/paint/sources/ui/tab_layers.c b/paint/sources/ui/tab_layers.c index 2ab0646b..ce8f728f 100644 --- a/paint/sources/ui/tab_layers.c +++ b/paint/sources/ui/tab_layers.c @@ -1,9 +1,9 @@ #include "../global.h" -i32 tab_layers_layer_name_edit = -1; -bool tab_layers_show_context_menu = false; -bool tab_layers_mini; +i32 tab_layers_layer_name_edit = -1; +bool tab_layers_show_context_menu = false; +bool tab_layers_mini; void tab_layers_button_2d_view() { if (ui_button(tr("2D View"), UI_ALIGN_CENTER, "")) { @@ -365,8 +365,8 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { ui_row(row); gpu_texture_t *icons = resource_get("icons.k"); rect_t *r = resource_tile18(icons, l->visible ? ICON18_EYE_ON : ICON18_EYE_OFF); - g_ui->_x = uix + 4; - g_ui->_y = uiy + 3 + center; + g_ui->_x = uix + 4; + g_ui->_y = uiy + 3 + center; i32 col = g_ui->ops->theme->HOVER_COL + 0x00282828; bool parent_hidden = l->parent != NULL && (!l->parent->visible || (l->parent->parent != NULL && !l->parent->parent->visible)); if (parent_hidden) { @@ -387,9 +387,9 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { // Layer icon i32 icon_h = (UI_ELEMENT_H() - 3) * 2; - g_ui->_x = uix + uiw * 0.08 + offx; - g_ui->_y = uiy + 3; - g_ui->_w = math_max(uiw * 0.16, icon_h); + g_ui->_x = uix + uiw * 0.08 + offx; + g_ui->_y = uiy + 3; + g_ui->_w = math_max(uiw * 0.16, icon_h); ui_state_t state = tab_layers_draw_layer_icon(l, i, uix, uiy, false); tab_layers_handle_layer_icon_state(l, i, state, uix, uiy); @@ -397,9 +397,9 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { bool has_blending = !slot_layer_is_group(l) && !slot_layer_is_mask(l) && !slot_layer_is_filter(l); f32 name_x = math_max(uix + uiw * 0.25 + offx, uix + uiw * 0.08 + offx + icon_h + 4 * UI_SCALE()); f32 name_right = has_blending ? uix + uiw * 0.60 : (has_children ? uix + uiw * 0.90 : uix + uiw); // Blending combo / panel / window edge - g_ui->_x = name_x; - g_ui->_y = uiy + center; - g_ui->_w = name_right - name_x; + g_ui->_x = name_x; + g_ui->_y = uiy + center; + g_ui->_w = name_right - name_x; if (tab_layers_layer_name_edit == l->id) { tab_layers_layer_name_handle->text = string_copy(l->name); l->name = string_copy(ui_text_input(tab_layers_layer_name_handle, "", UI_ALIGN_LEFT, true, false)); @@ -464,9 +464,9 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { // Panel if (has_children) { - g_ui->_x = uix + uiw * 0.90; - g_ui->_y = uiy + center; - g_ui->_w = uiw * 0.15; + g_ui->_x = uix + uiw * 0.90; + g_ui->_y = uiy + center; + g_ui->_w = uiw * 0.15; ui_handle_t *layer_panel = ui_nest(ui_handle(__ID__), l->id); layer_panel->b = l->show_panel; l->show_panel = ui_panel(layer_panel, "", false, false, true); @@ -541,7 +541,8 @@ bool tab_layers_can_merge_down(slot_layer_t *l) { return false; } // The lowest toplevel layer is a group - if (slot_layer_is_group(l) && slot_layer_is_in_group(g_project->_->layers->buffer[0]) && slot_layer_get_containing_group(g_project->_->layers->buffer[0]) == l) { + if (slot_layer_is_group(l) && slot_layer_is_in_group(g_project->_->layers->buffer[0]) && + slot_layer_get_containing_group(g_project->_->layers->buffer[0]) == l) { return false; } // Masks must be merged down to masks @@ -1155,7 +1156,7 @@ void tab_layers_combo_filter() { void tab_layers_draw_mini(ui_handle_t *htab) { ui_set_hovered_tab_name(tr("Layers")); - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; + i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->ELEMENT_H = math_floor(ui_sidebar_w_mini / 2.0 / (float)UI_SCALE()); ui_begin_sticky(); diff --git a/paint/sources/ui/tab_materials.c b/paint/sources/ui/tab_materials.c index 83373665..39e86aa8 100644 --- a/paint/sources/ui/tab_materials.c +++ b/paint/sources/ui/tab_materials.c @@ -239,8 +239,9 @@ void tab_materials_draw_slots(bool mini) { ui_fill(-1, -2, 2, imgw_val + 4, g_ui->ops->theme->HIGHLIGHT_COL); } - ui_state_t state = g_project->_->materials->buffer[i]->preview_ready ? ui_image(img, 0xffffffff, imgh) - : ui_sub_image(resource_get("icons.k"), 0xffffffff, -1.0, tile, tile, tile, tile); + ui_state_t state = g_project->_->materials->buffer[i]->preview_ready + ? ui_image(img, 0xffffffff, imgh) + : ui_sub_image(resource_get("icons.k"), 0xffffffff, -1.0, tile, tile, tile, tile); if (state == UI_STATE_HOVERED && base_drag_material != NULL) { tab_materials_drag_pos = (mouse_x > uix + g_ui->_window_x + imgw_val / 2.0) ? i + 1 : i; diff --git a/paint/sources/ui/tab_meshes.c b/paint/sources/ui/tab_meshes.c index 0276f87f..93914630 100644 --- a/paint/sources/ui/tab_meshes.c +++ b/paint/sources/ui/tab_meshes.c @@ -63,7 +63,7 @@ void tab_meshes_draw_context_menu() { rot = vec4_mult(rot, 180 / 3.141592); f32 f = 0.0; bool changed = false; - g_ui->changed = false; + g_ui->changed = false; ui_row4(); ui_text("Loc", UI_ALIGN_LEFT, 0x00000000); @@ -606,8 +606,8 @@ void tab_meshes_draw(ui_handle_t *htab) { if (g_context->paint_object == o) { f32 _uix = g_ui->_x; f32 _uiy = g_ui->_y; - g_ui->_x = uix; - g_ui->_y = uiy + 4; + g_ui->_x = uix; + g_ui->_y = uiy + 4; i32 hoff = i % 2 == 1 ? 1 : 0; i32 w = 75; ui_fill(0, 0, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); @@ -647,7 +647,7 @@ void tab_meshes_draw(ui_handle_t *htab) { i32 check_w = UI_ELEMENT_H(); i32 text_w = draw_string_width(g_ui->ops->font, g_ui->font_size, o->base->name); i32 center_x = (slotw - check_w - text_w) / 2; - g_ui->_x = uix + (center_x > 0 ? center_x : 0); + g_ui->_x = uix + (center_x > 0 ? center_x : 0); g_ui->_y += slotw * 0.9 + 8; ui_handle_t *h = ui_handle(__ID__); diff --git a/paint/sources/ui/tab_scripts.c b/paint/sources/ui/tab_scripts.c index 3706aa21..09ec4b70 100644 --- a/paint/sources/ui/tab_scripts.c +++ b/paint/sources/ui/tab_scripts.c @@ -149,7 +149,7 @@ void tab_scripts_draw(ui_handle_t *htab) { i32 _font_size = g_ui->font_size; draw_font_t *f = data_get_font("font_mono.ttf"); ui_set_font(g_ui, f); - g_ui->font_size = math_floor(15 * UI_SCALE()); + g_ui->font_size = math_floor(15 * UI_SCALE()); ui_text_area_line_numbers = true; ui_text_area_scroll_past_end = true; gc_unroot(ui_text_area_coloring); diff --git a/paint/sources/ui/tab_swatches.c b/paint/sources/ui/tab_swatches.c index 2aeb2806..3a325fe4 100644 --- a/paint/sources/ui/tab_swatches.c +++ b/paint/sources/ui/tab_swatches.c @@ -20,7 +20,7 @@ gpu_texture_t *tab_swatches_empty_get() { } void tab_swatches_delete_swatch(swatch_color_t *swatch) { - i32 i = array_index_of(g_project->swatches, swatch); + i32 i = array_index_of(g_project->swatches, swatch); g_context->swatch = g_project->swatches->buffer[i == g_project->swatches->length - 1 ? i - 1 : i + 1]; array_splice(g_project->swatches, i, 1); ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 2; @@ -67,7 +67,7 @@ void tab_swatches_draw_color_picker() { } void tab_swatches_draw_edit_menu() { - g_ui->changed = false; + g_ui->changed = false; ui_handle_t *h = ui_handle(__ID__); h->color = g_context->swatch->base; @@ -96,7 +96,7 @@ void tab_swatches_draw_edit_menu() { ui_menu_keep_open = true; } if (g_ui->input_released) { - g_context->swatch = g_context->swatch; // Trigger material preview update + g_context->swatch = g_context->swatch; // Trigger material preview update g_context->picked_color = util_clone_swatch_color(g_context->swatch); ui_header_handle->redraws = 2; } @@ -150,7 +150,7 @@ void tab_swatches_draw(ui_handle_t *htab) { } if (ui_icon_button(tr("Clear"), ICON_ERASE, UI_ALIGN_CENTER)) { - g_context->swatch = project_make_swatch(0xffffffff); + g_context->swatch = project_make_swatch(0xffffffff); g_project->swatches = any_array_create_from_raw( (void *[]){ g_context->swatch, @@ -214,8 +214,8 @@ void tab_swatches_draw(ui_handle_t *htab) { if (state == UI_STATE_STARTED) { g_context->swatch = g_project->swatches->buffer[i]; - base_drag_off_x = -(mouse_x - uix - g_ui->_window_x); - base_drag_off_y = -(mouse_y - uiy - g_ui->_window_y + 1); + base_drag_off_x = -(mouse_x - uix - g_ui->_window_x); + base_drag_off_y = -(mouse_y - uiy - g_ui->_window_y + 1); gc_unroot(base_drag_swatch); base_drag_swatch = g_context->swatch; gc_root(base_drag_swatch); diff --git a/paint/sources/ui/tab_textures.c b/paint/sources/ui/tab_textures.c index e4ffea02..613e263f 100644 --- a/paint/sources/ui/tab_textures.c +++ b/paint/sources/ui/tab_textures.c @@ -258,8 +258,8 @@ void tab_textures_draw(ui_handle_t *htab) { if (asset == g_context->texture) { f32 _uix = g_ui->_x; f32 _uiy = g_ui->_y; - g_ui->_x = uix; - g_ui->_y = uiy; + g_ui->_x = uix; + g_ui->_y = uiy; i32 off = i % 2 == 1 ? 1 : 0; i32 w = 50; ui_fill(0, 0, w + 3, 2, g_ui->ops->theme->HIGHLIGHT_COL); diff --git a/paint/sources/ui/tab_timeline.c b/paint/sources/ui/tab_timeline.c index c67e18f6..ea067100 100644 --- a/paint/sources/ui/tab_timeline.c +++ b/paint/sources/ui/tab_timeline.c @@ -899,7 +899,7 @@ void tab_timeline_draw_frame_context_menu() { tab_timeline_edit_script(tab_timeline_selected_row, tab_timeline_selected_frame); } - g_ui->enabled = has_kf; + g_ui->enabled = has_kf; ui_handle_t *h_tween = ui_handle(__ID__); h_tween->b = false; if (g_ui->enabled) { @@ -918,7 +918,7 @@ void tab_timeline_draw_frame_context_menu() { } bool has_script = tab_timeline_has_script(tab_timeline_selected_row, tab_timeline_selected_frame); - g_ui->enabled = has_kf || has_script; + g_ui->enabled = has_kf || has_script; if (ui_menu_button(tr("Delete"), "delete", ICON_DELETE)) { tab_timeline_delete_selected(); } diff --git a/paint/sources/ui/ui_base.c b/paint/sources/ui/ui_base.c index d5ea72c4..616f2c45 100644 --- a/paint/sources/ui/ui_base.c +++ b/paint/sources/ui/ui_base.c @@ -187,7 +187,7 @@ void ui_base_menu_draw_viewport_mode() { i32 index = string_array_index_of(shortcuts, keyboard_key_code(g_ui->key_code)); if (g_ui->is_key_pressed && index != -1) { mode_handle->i = index; - g_ui->changed = true; + g_ui->changed = true; context_set_viewport_mode(mode_handle->i); } else if (mode_handle->changed) { diff --git a/paint/sources/ui/ui_header.c b/paint/sources/ui/ui_header.c index 1c9f8fba..2f3c213c 100644 --- a/paint/sources/ui/ui_header.c +++ b/paint/sources/ui/ui_header.c @@ -438,7 +438,7 @@ void ui_header_draw_tool_properties() { g_ui->_w *= 3; } g_context->text_tool_text = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, true)); - g_ui->_w = w; + g_ui->_w = w; if (h->changed) { gpu_texture_t *current = _draw_current; draw_end(); @@ -516,23 +516,23 @@ void ui_header_draw_tool_properties() { if (g_config->layout->buffer[LAYOUT_SIZE_HEADER] == 1) { if (g_config->touch_ui) { - g_ui->_w = math_floor(19 * sc); + g_ui->_w = math_floor(19 * sc); g_context->sym_x = ui_check(sym_x_handle, "", ""); g_ui->_x -= 4 * sc; g_context->sym_y = ui_check(sym_y_handle, "", ""); g_ui->_x -= 4 * sc; g_context->sym_z = ui_check(sym_z_handle, "", ""); g_ui->_x -= 4 * sc; - g_ui->_w = math_floor(40 * sc); - char *x = tr("X"); - char *y = tr("Y"); - char *z = tr("Z"); + g_ui->_w = math_floor(40 * sc); + char *x = tr("X"); + char *y = tr("Y"); + char *z = tr("Z"); ui_text(string("%s%s%s", x, y, z), UI_ALIGN_LEFT, 0x00000000); } else { g_ui->_w = math_floor(56 * sc); ui_text(tr("Symmetry"), UI_ALIGN_LEFT, 0x00000000); - g_ui->_w = math_floor(25 * sc); + g_ui->_w = math_floor(25 * sc); g_context->sym_x = ui_check(sym_x_handle, tr("X"), ""); g_context->sym_y = ui_check(sym_y_handle, tr("Y"), ""); g_context->sym_z = ui_check(sym_z_handle, tr("Z"), ""); @@ -541,7 +541,7 @@ void ui_header_draw_tool_properties() { } else { // Popup - g_ui->_w = _w; + g_ui->_w = _w; g_context->sym_x = ui_check(sym_x_handle, string("%s %s", tr("Symmetry"), tr("X")), ""); g_context->sym_y = ui_check(sym_y_handle, string("%s %s", tr("Symmetry"), tr("Y")), ""); g_context->sym_z = ui_check(sym_z_handle, string("%s %s", tr("Symmetry"), tr("Z")), ""); diff --git a/paint/sources/ui/ui_menu.c b/paint/sources/ui/ui_menu.c index bd2acecd..94da4ab9 100644 --- a/paint/sources/ui/ui_menu.c +++ b/paint/sources/ui/ui_menu.c @@ -37,11 +37,11 @@ void ui_menu_fit_to_screen() { void ui_menu_render() { i32 menu_w = ui_menu_commands != NULL ? math_floor(base_default_element_w * UI_SCALE() * 2.3) : math_floor(UI_ELEMENT_W() * 2.3); - i32 _FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; + i32 _FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; g_ui->ops->theme->FILL_BUTTON_BG = false; - i32 _ELEMENT_OFFSET = g_ui->ops->theme->ELEMENT_OFFSET; + i32 _ELEMENT_OFFSET = g_ui->ops->theme->ELEMENT_OFFSET; g_ui->ops->theme->ELEMENT_OFFSET = 0; - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; + i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->ELEMENT_H = g_config->touch_ui ? (28 + 2) : 28; if (ui_menu_nested) { @@ -130,8 +130,8 @@ bool ui_menu_button(char *text, char *label, icon_t icon) { gpu_texture_t *icons = resource_get("icons05x.k"); rect_t *rect = resource_tile50(icons, icon); i32 icon_h = 25 * UI_SCALE(); - g_ui->_x = _x_left - 5 * UI_SCALE(); - g_ui->_y = _y_top - 1; + g_ui->_x = _x_left - 5 * UI_SCALE(); + g_ui->_y = _y_top - 1; if (g_config->touch_ui) { g_ui->_x = _x_left - 2 * UI_SCALE(); g_ui->_y = _y_top + 2 * UI_SCALE(); @@ -177,8 +177,8 @@ bool ui_icon_button(char *text, icon_t icon, ui_align_t align) { gpu_texture_t *icons = resource_get("icons05x.k"); rect_t *rect = resource_tile50(icons, icon); i32 icon_h = 25 * UI_SCALE(); - g_ui->_x = align == UI_ALIGN_LEFT ? _x_left : _x_left + _w / 2.0 - textw / 2.0 - icon_h / 2.0; - g_ui->_y = _y_top; + g_ui->_x = align == UI_ALIGN_LEFT ? _x_left : _x_left + _w / 2.0 - textw / 2.0 - icon_h / 2.0; + g_ui->_y = _y_top; if (g_config->touch_ui) { g_ui->_x += 1 * UI_SCALE(); @@ -218,8 +218,8 @@ bool ui_menu_sub_button(ui_handle_t *handle, char *text) { } void ui_menu_label(char *text, char *shortcut) { - i32 _y = g_ui->_y; - i32 _TEXT_COL = g_ui->ops->theme->TEXT_COL; + i32 _y = g_ui->_y; + i32 _TEXT_COL = g_ui->ops->theme->TEXT_COL; g_ui->ops->theme->TEXT_COL = g_ui->ops->theme->LABEL_COL; ui_text(text, UI_ALIGN_LEFT, 0x00000000); if (shortcut != NULL) { diff --git a/paint/sources/ui/ui_menubar.c b/paint/sources/ui/ui_menubar.c index ae5e0ea5..ca9c25f1 100644 --- a/paint/sources/ui/ui_menubar.c +++ b/paint/sources/ui/ui_menubar.c @@ -269,7 +269,7 @@ void ui_menubar_draw_category_items() { project_save_as(false); } - g_ui->changed = false; + g_ui->changed = false; ui_handle_t *h_pack_assets = ui_handle(__ID__); h_pack_assets->b = g_context->pack_assets_on_save; g_context->pack_assets_on_save = ui_check(h_pack_assets, tr("Pack Assets"), ""); @@ -346,7 +346,7 @@ void ui_menubar_draw_category_items() { step_redo = string_copy(history_steps->buffer[history_steps->length - history_redos]->name); } - g_ui->enabled = history_undos > 0; + g_ui->enabled = history_undos > 0; any_map_t *vars_undo = any_map_create(); any_map_set(vars_undo, "step", step_undo); if (ui_menu_button(vtr("Undo {step}", vars_undo), any_map_get(g_keymap, "edit_undo"), ICON_UNDO)) { @@ -354,7 +354,7 @@ void ui_menubar_draw_category_items() { ui_menu_keep_open = true; } - g_ui->enabled = history_redos > 0; + g_ui->enabled = history_redos > 0; any_map_t *vars_redo = any_map_create(); any_map_set(vars_redo, "step", step_redo); if (ui_menu_button(vtr("Redo {step}", vars_redo), any_map_get(g_keymap, "edit_redo"), ICON_REDO)) { diff --git a/paint/sources/ui/ui_nodes.c b/paint/sources/ui/ui_nodes.c index 5c8f9a7f..e6c67c96 100644 --- a/paint/sources/ui/ui_nodes.c +++ b/paint/sources/ui/ui_nodes.c @@ -68,7 +68,7 @@ void ui_nodes_node_search_menu() { ui_menu_h = UI_ELEMENT_H() * 8; ui_handle_t *search_handle = ui_handle(__ID__); char *search = to_lower_case(ui_text_input(search_handle, "", UI_ALIGN_LEFT, true, true)); - g_ui->changed = false; + g_ui->changed = false; if (_ui_nodes_node_search_first) { _ui_nodes_node_search_first = false; search_handle->text = ""; @@ -87,10 +87,10 @@ void ui_nodes_node_search_menu() { ui_nodes_node_search_offset--; } } - bool enter = keyboard_down("enter"); - i32 count = 0; - i32 BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - bool FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; + bool enter = keyboard_down("enter"); + i32 count = 0; + i32 BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + bool FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; g_ui->ops->theme->FILL_BUTTON_BG = true; node_list_t_array_t *node_list = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_list : nodes_brush_list; @@ -119,7 +119,7 @@ void ui_nodes_node_search_menu() { ui_nodes_hwnd->redraws = 2; if (enter) { g_ui->changed = true; - count = 6; // Trigger break + count = 6; // Trigger break } if (_ui_nodes_node_search_done != NULL) { _ui_nodes_node_search_done(); @@ -135,7 +135,7 @@ void ui_nodes_node_search_menu() { } } if (enter && count == 0) { // Hide popup on enter when node is not found - g_ui->changed = true; + g_ui->changed = true; search_handle->text = ""; } g_ui->ops->theme->BUTTON_COL = BUTTON_COL; @@ -316,7 +316,7 @@ void ui_viewnodes_on_canvas_context_menu() { if (ui_menu_button(tr("Add Swatch"), "", ICON_PALETTE)) { f32_array_t *color = selected->outputs->buffer[0]->default_value; swatch_color_t *new_swatch = project_make_swatch(color_from_floats(color->buffer[0], color->buffer[1], color->buffer[2], color->buffer[3])); - g_context->swatch = new_swatch; + g_context->swatch = new_swatch; any_array_push(g_project->swatches, new_swatch); ui_base_hwnds->buffer[TAB_AREA_STATUS]->redraws = 1; } @@ -334,7 +334,8 @@ void ui_viewnodes_on_canvas_context_menu() { } void ui_viewnodes_on_canvas_released() { - if (g_ui->input_released_r && context_in_nodes() && math_abs(g_ui->input_x - g_ui->input_started_x) < 2 && math_abs(g_ui->input_y - g_ui->input_started_y) < 2) { + if (g_ui->input_released_r && context_in_nodes() && math_abs(g_ui->input_x - g_ui->input_started_x) < 2 && + math_abs(g_ui->input_y - g_ui->input_started_y) < 2) { // Node selection ui_nodes_t *nodes = ui_nodes_get_nodes(); @@ -461,12 +462,12 @@ ui_canvas_control_t *ui_nodes_get_canvas_control(bool controls_down, bool is_nod return cc; } - bool pan = g_ui->input_down_r || operator_shortcut(any_map_get(g_keymap, "action_pan"), SHORTCUT_TYPE_DOWN); - f32 zoom_delta = operator_shortcut(any_map_get(g_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN) ? ui_nodes_get_zoom_delta() / 100.0 : 0.0; - ui_canvas_control_t *control = GC_ALLOC_INIT(ui_canvas_control_t, {.pan_x = pan ? g_ui->input_dx : 0.0, - .pan_y = pan ? g_ui->input_dy : 0.0, - .zoom = g_ui->input_wheel_delta != 0.0 ? -g_ui->input_wheel_delta / 10 : zoom_delta, - .controls_down = controls_down}); + bool pan = g_ui->input_down_r || operator_shortcut(any_map_get(g_keymap, "action_pan"), SHORTCUT_TYPE_DOWN); + f32 zoom_delta = operator_shortcut(any_map_get(g_keymap, "action_zoom"), SHORTCUT_TYPE_DOWN) ? ui_nodes_get_zoom_delta() / 100.0 : 0.0; + ui_canvas_control_t *control = GC_ALLOC_INIT(ui_canvas_control_t, {.pan_x = pan ? g_ui->input_dx : 0.0, + .pan_y = pan ? g_ui->input_dy : 0.0, + .zoom = g_ui->input_wheel_delta != 0.0 ? -g_ui->input_wheel_delta / 10 : zoom_delta, + .controls_down = controls_down}); if (is_node_view && g_ui->input_x < g_ui->_window_x) { control->pan_x = 0.0; @@ -559,14 +560,14 @@ void ui_nodes_draw_menubar() { draw_set_color(0xffffffff); i32 start_y = top_y + UI_ELEMENT_OFFSET(); - g_ui->_x = 0; - g_ui->_y = 2 + start_y; - g_ui->_w = ew; + g_ui->_x = 0; + g_ui->_y = 2 + start_y; + g_ui->_w = ew; // Editable canvas name ui_handle_t *h = ui_handle(__ID__); h->text = string_copy(c->name); - g_ui->_w = math_floor(math_min(draw_string_width(g_ui->ops->font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); + g_ui->_w = math_floor(math_min(draw_string_width(g_ui->ops->font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false); g_ui->_x += g_ui->_w + 3; g_ui->_y = 2 + start_y; @@ -607,11 +608,11 @@ void ui_nodes_draw_menubar() { c->name = string_copy(new_name); } } - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - bool _SHADOWS = g_ui->ops->theme->SHADOWS; + i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + bool _SHADOWS = g_ui->ops->theme->SHADOWS; g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; g_ui->ops->theme->SHADOWS = false; - string_array_t *cats = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_categories : nodes_brush_categories; + string_array_t *cats = ui_nodes_canvas_type == CANVAS_TYPE_MATERIAL ? nodes_material_categories : nodes_brush_categories; for (i32 i = 0; i < cats->length; ++i) { if ((ui_menubar_button(tr(cats->buffer[i]))) || (g_ui->is_hovered && ui_nodes_show_menu)) { ui_nodes_show_menu = true; @@ -629,7 +630,7 @@ void ui_nodes_draw_menubar() { g_ui->_y = 2 + start_y; } if (g_config->touch_ui) { - i32 _w = g_ui->_w; + i32 _w = g_ui->_w; g_ui->_w = math_floor(36 * UI_SCALE()); g_ui->_y = 4 * UI_SCALE() + start_y; if (ui_menubar_icon_button(ICON_SEARCH)) { @@ -694,8 +695,8 @@ void ui_nodes_update(void *_) { ui_nodes_wh -= ui_header_h * 4; } - i32 mx = mouse_x; - i32 my = mouse_y; + i32 mx = mouse_x; + i32 my = mouse_y; bool enabled = true; if (mx < ui_nodes_wx || mx > ui_nodes_wx + ww || my < ui_nodes_wy) { enabled = false; @@ -933,9 +934,9 @@ void ui_nodes_update(void *_) { } // Nodes - bool _input_enabled = g_ui->input_enabled; - i32 header_h = UI_ELEMENT_H() * 2 + UI_ELEMENT_OFFSET() * 2; - bool header_hover = g_ui->input_y < g_ui->_window_y + header_h; + bool _input_enabled = g_ui->input_enabled; + i32 header_h = UI_ELEMENT_H() * 2 + UI_ELEMENT_OFFSET() * 2; + bool header_hover = g_ui->input_y < g_ui->_window_y + header_h; g_ui->input_enabled = _input_enabled && !ui_nodes_show_menu && !header_hover; g_ui->window_border_right = g_config->layout->buffer[LAYOUT_SIZE_SIDEBAR_W]; g_ui->window_border_top = ui_header_h * 2; @@ -990,9 +991,9 @@ void ui_nodes_update(void *_) { } if (ui_nodes_is_node_menu_op) { - ui_is_copy = false; - ui_is_cut = false; - ui_is_paste = false; + ui_is_copy = false; + ui_is_cut = false; + ui_is_paste = false; g_ui->is_delete_down = false; } @@ -1049,13 +1050,13 @@ void ui_nodes_update(void *_) { i32 menuw = math_floor(ew * 2.3); draw_begin(NULL, false, 0); ui_begin_region(g_ui, math_floor(ui_nodes_popup_x), math_floor(py), menuw); - i32 _FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; + i32 _FILL_BUTTON_BG = g_ui->ops->theme->FILL_BUTTON_BG; g_ui->ops->theme->FILL_BUTTON_BG = false; - i32 _ELEMENT_OFFSET = g_ui->ops->theme->ELEMENT_OFFSET; + i32 _ELEMENT_OFFSET = g_ui->ops->theme->ELEMENT_OFFSET; g_ui->ops->theme->ELEMENT_OFFSET = 0; - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; + i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->ELEMENT_H = g_config->touch_ui ? (28 + 2) : 28; - ui_menu_h = category->length * UI_ELEMENT_H(); + ui_menu_h = category->length * UI_ELEMENT_H(); if (is_group_category) { ui_menu_h += g_project->_->material_groups->length * UI_ELEMENT_H(); } @@ -1084,7 +1085,7 @@ void ui_nodes_update(void *_) { if (is_group_category) { for (i32 i = 0; i < g_project->_->material_groups->length; ++i) { node_group_t *g = g_project->_->material_groups->buffer[i]; - g_ui->enabled = ui_nodes_can_place_group(g->canvas->name); + g_ui->enabled = ui_nodes_can_place_group(g->canvas->name); f32_array_t *row = f32_array_create_from_raw( (f32[]){ 5 / 6.0, @@ -1113,9 +1114,9 @@ void ui_nodes_update(void *_) { g_ui->enabled = true; } } - ui_nodes_hide_menu = - g_ui->combo_selected_handle == NULL && !ui_nodes_show_menu_first && (g_ui->changed || g_ui->input_released || g_ui->input_released_r || g_ui->is_escape_down); - ui_nodes_show_menu_first = false; + ui_nodes_hide_menu = g_ui->combo_selected_handle == NULL && !ui_nodes_show_menu_first && + (g_ui->changed || g_ui->input_released || g_ui->input_released_r || g_ui->is_escape_down); + ui_nodes_show_menu_first = false; g_ui->ops->theme->FILL_BUTTON_BG = _FILL_BUTTON_BG; g_ui->ops->theme->ELEMENT_OFFSET = _ELEMENT_OFFSET; g_ui->ops->theme->ELEMENT_H = _ELEMENT_H; diff --git a/paint/sources/ui/ui_search.c b/paint/sources/ui/ui_search.c index 703f2812..d718462e 100644 --- a/paint/sources/ui/ui_search.c +++ b/paint/sources/ui/ui_search.c @@ -8,7 +8,7 @@ void ui_base_operator_search_menu_draw() { ui_menu_h = UI_ELEMENT_H() * 8; ui_handle_t *search_handle = ui_handle(__ID__); char *search = ui_text_input(search_handle, "", UI_ALIGN_LEFT, true, true); - g_ui->changed = false; + g_ui->changed = false; if (_ui_base_operator_search_first) { _ui_base_operator_search_first = false; search_handle->text = ""; @@ -39,7 +39,7 @@ void ui_base_operator_search_menu_draw() { if (ui_button(n, UI_ALIGN_LEFT, any_map_get(g_keymap, n)) || (enter && count == ui_base_operator_search_offset)) { if (enter) { g_ui->changed = true; - count = 6; // Trigger break + count = 6; // Trigger break } operator_run(n); } @@ -50,7 +50,7 @@ void ui_base_operator_search_menu_draw() { } if (enter && count == 0) { // Hide popup on enter when command is not found - g_ui->changed = true; + g_ui->changed = true; search_handle->text = ""; } g_ui->ops->theme->BUTTON_COL = BUTTON_COL; diff --git a/paint/sources/ui/ui_sidebar.c b/paint/sources/ui/ui_sidebar.c index bcbcfdf0..ef49cfe4 100644 --- a/paint/sources/ui/ui_sidebar.c +++ b/paint/sources/ui/ui_sidebar.c @@ -12,9 +12,9 @@ void ui_sidebar_render_ui() { if (ui_window(ui_sidebar_hminimized, iron_window_width() - width, -1, width, math_floor(UI_ELEMENT_H() + 4 * UI_SCALE()), false)) { ui_fill(0, 0, g_ui->_window_w, g_ui->_window_h + 1, g_ui->ops->theme->SEPARATOR_COL); g_ui->_w = width; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - i32 _TEXT_COL = g_ui->ops->theme->TEXT_COL; + i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; + i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + i32 _TEXT_COL = g_ui->ops->theme->TEXT_COL; g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->SEPARATOR_COL; g_ui->ops->theme->TEXT_COL = g_ui->ops->theme->HOVER_COL; @@ -87,8 +87,8 @@ void ui_sidebar_render_ui() { i32 height = math_floor(UI_ELEMENT_H() + UI_ELEMENT_OFFSET()); if (ui_window(ui_handle(__ID__), iron_window_width() - width, iron_window_height() - height, width, height + 1, false)) { g_ui->_w = width; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; + i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; if (ui_button(mini ? "<" : ">", UI_ALIGN_CENTER, "")) { diff --git a/paint/sources/ui/ui_toolbar.c b/paint/sources/ui/ui_toolbar.c index 46227733..dee07458 100644 --- a/paint/sources/ui/ui_toolbar.c +++ b/paint/sources/ui/ui_toolbar.c @@ -128,16 +128,16 @@ void ui_toolbar_draw_show_3d_view() { } if (ui_window(ui_toolbar_handle, ui_toolbar_x(), y, toolbar_w, toolbar_w, false)) { - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - i32 _fontOffsetY = g_ui->font_offset_y; + i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; + i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; + i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + i32 _fontOffsetY = g_ui->font_offset_y; g_ui->ops->theme->ELEMENT_H = math_floor(g_ui->ops->theme->ELEMENT_H * 1.5); g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; - i32 font_height = draw_font_height(g_ui->ops->font, g_ui->font_size); + i32 font_height = draw_font_height(g_ui->ops->font, g_ui->font_size); g_ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; - i32 _w = g_ui->_w; + i32 _w = g_ui->_w; g_ui->_w = toolbar_w; if (ui_icon_button("", ICON_CUBE, UI_ALIGN_CENTER)) { ui_base_show_3d_view(); @@ -174,7 +174,7 @@ void ui_toolbar_render_ui() { if (context_is_floating_toolbar()) { x += ui_toolbar_x(); y += ui_toolbar_x() + 3 * UI_SCALE(); - h = (ui_toolbar_tool_names->length + 1) * (ui_toolbar_w(false) + 2); + h = (ui_toolbar_tool_names->length + 1) * (ui_toolbar_w(false) + 2); g_ui->ops->theme->WINDOW_BG_COL = g_ui->ops->theme->SEPARATOR_COL; if (!base_view3d_show && ui_view2d_show && !g_config->touch_ui) { y += ui_toolbar_w(false); @@ -189,7 +189,7 @@ void ui_toolbar_render_ui() { if (ui_window(ui_toolbar_handle, x, y, ui_toolbar_w(false), h, false)) { g_ui->_y -= 4 * UI_SCALE(); - g_ui->image_scroll_align = false; + g_ui->image_scroll_align = false; gpu_texture_t *img = resource_get("icons.k"); u32 col = g_ui->ops->theme->WINDOW_BG_COL; bool light = col > 0xff666666; @@ -204,16 +204,16 @@ void ui_toolbar_render_ui() { } // Draw ">" button if header is hidden else { - i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; - i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; - i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; - i32 _fontOffsetY = g_ui->font_offset_y; + i32 _ELEMENT_H = g_ui->ops->theme->ELEMENT_H; + i32 _BUTTON_H = g_ui->ops->theme->BUTTON_H; + i32 _BUTTON_COL = g_ui->ops->theme->BUTTON_COL; + i32 _fontOffsetY = g_ui->font_offset_y; g_ui->ops->theme->ELEMENT_H = math_floor(g_ui->ops->theme->ELEMENT_H * 1.5); g_ui->ops->theme->BUTTON_H = g_ui->ops->theme->ELEMENT_H; g_ui->ops->theme->BUTTON_COL = g_ui->ops->theme->WINDOW_BG_COL; - i32 font_height = draw_font_height(g_ui->ops->font, g_ui->font_size); + i32 font_height = draw_font_height(g_ui->ops->font, g_ui->font_size); g_ui->font_offset_y = (UI_ELEMENT_H() - font_height) / 2.0; - i32 _w = g_ui->_w; + i32 _w = g_ui->_w; g_ui->_w = ui_toolbar_w(false); if (ui_button(">", UI_ALIGN_CENTER, "")) { @@ -244,7 +244,7 @@ void ui_toolbar_render_ui() { if (g_config->touch_ui) { // Hide scrollbar - i32 _SCROLL_W = g_ui->ops->theme->SCROLL_W; + i32 _SCROLL_W = g_ui->ops->theme->SCROLL_W; g_ui->ops->theme->SCROLL_W = 0; ui_end_window(); g_ui->ops->theme->SCROLL_W = _SCROLL_W; diff --git a/paint/sources/ui/ui_view2d.c b/paint/sources/ui/ui_view2d.c index 276f1ed9..3772a9f4 100644 --- a/paint/sources/ui/ui_view2d.c +++ b/paint/sources/ui/ui_view2d.c @@ -181,8 +181,8 @@ void ui_view2d_update(void *_) { if (ui_view2d_type == VIEW_2D_TYPE_LAYER && !ui_view2d_text_input_hover && (operator_shortcut(any_map_get(g_keymap, "action_paint"), SHORTCUT_TYPE_DOWN) || - operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN) || - decal_mask || set_clone_source || g_config->brush_live)) { + operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN) || decal_mask || + set_clone_source || g_config->brush_live)) { if (g_config->touch_ui) { // Paint only when clicking on the layer rect @@ -305,8 +305,8 @@ void ui_view2d_update(void *_) { ui_begin(g_ui); - headerh = g_config->layout->buffer[LAYOUT_SIZE_HEADER] == 1 ? ui_header_h * 2 : ui_header_h; - i32 apph = iron_window_height() - g_config->layout->buffer[LAYOUT_SIZE_STATUS_H] + headerh; + headerh = g_config->layout->buffer[LAYOUT_SIZE_HEADER] == 1 ? ui_header_h * 2 : ui_header_h; + i32 apph = iron_window_height() - g_config->layout->buffer[LAYOUT_SIZE_STATUS_H] + headerh; if (!base_view3d_show) { apph = base_h(); } @@ -492,9 +492,9 @@ void ui_view2d_update(void *_) { draw_set_color(0xffffffff); f32 start_y = top_y + UI_ELEMENT_OFFSET(); - g_ui->_x = 2; - g_ui->_y = 2 + start_y; - g_ui->_w = ew; + g_ui->_x = 2; + g_ui->_y = 2 + start_y; + g_ui->_w = ew; // Editable layer name ui_handle_t *h = ui_handle(__ID__); @@ -576,7 +576,7 @@ void ui_view2d_update(void *_) { ui_handle_t *h_zoom = ui_handle(__ID__); i32 scale_percent = math_round((tw / (float)tex->width) * 100); h_zoom->f = scale_percent; - g_ui->_w = math_floor(ew + 3); + g_ui->_w = math_floor(ew + 3); f32 new_percent = ui_slider(h_zoom, string("%d%%", scale_percent), 1, 100, true, 1, false, UI_ALIGN_LEFT, true); if (h_zoom->changed) { ui_view2d_pan_scale = new_percent / 100.0 * tex->width / (wm * 0.9); diff --git a/paint/sources/uniforms.c b/paint/sources/uniforms.c index 422cb78a..7b04a002 100644 --- a/paint/sources/uniforms.c +++ b/paint/sources/uniforms.c @@ -10,9 +10,9 @@ i32 uniforms_ext_i32_link(object_t *object, material_data_t *mat, char *link) { f32 uniforms_ext_f32_link(object_t *object, material_data_t *mat, char *link) { if (string_equals(link, "_brush_radius")) { - bool decal = context_is_decal(); - bool decal_mask = decal && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "action_paint")), - SHORTCUT_TYPE_DOWN); + bool decal = context_is_decal(); + bool decal_mask = + decal && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN); f32 brush_decal_mask_radius = g_context->brush_decal_mask_radius; bool paint2d = g_context->paint2d || g_context->paint2d_view; brush_decal_mask_radius *= 2.0; diff --git a/paint/sources/util/util_brush.c b/paint/sources/util/util_brush.c index d26c00b9..a036042b 100644 --- a/paint/sources/util/util_brush.c +++ b/paint/sources/util/util_brush.c @@ -2,16 +2,15 @@ #include "../global.h" void util_brush_update() { - bool set_clone_source = g_context->tool == TOOL_TYPE_CLONE && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "set_clone_source"), - any_map_get(g_keymap, "action_paint")), - SHORTCUT_TYPE_DOWN); + bool set_clone_source = + g_context->tool == TOOL_TYPE_CLONE && + operator_shortcut(string("%s+%s", any_map_get(g_keymap, "set_clone_source"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN); bool decal_mask = context_is_decal_mask_paint(); - bool down = - operator_shortcut(any_map_get(g_keymap, "action_paint"), SHORTCUT_TYPE_DOWN) || decal_mask || set_clone_source || - operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN) || - (pen_down("tip") && !keyboard_down("alt")); + bool down = operator_shortcut(any_map_get(g_keymap, "action_paint"), SHORTCUT_TYPE_DOWN) || decal_mask || set_clone_source || + operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN) || + (pen_down("tip") && !keyboard_down("alt")); if (g_config->touch_ui) { if (pen_down("tip")) { @@ -50,8 +49,7 @@ void util_brush_update() { if (g_context->brush_time == 0 && !base_is_dragging && !base_is_resizing && g_ui->combo_selected_handle == NULL) { // Paint started // Draw line - if (operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), - SHORTCUT_TYPE_DOWN)) { + if (operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN)) { g_context->last_paint_vec_x = g_context->last_paint_x; g_context->last_paint_vec_y = g_context->last_paint_y; } diff --git a/paint/sources/util/util_layer.c b/paint/sources/util/util_layer.c index f2c86424..c0893750 100644 --- a/paint/sources/util/util_layer.c +++ b/paint/sources/util/util_layer.c @@ -506,8 +506,8 @@ void layers_set_object_mask() { context_select_paint_object(o); } else { - i32 atlas_mask = g_context->layer_filter > g_project->_->paint_objects->length ? g_context->layer_filter : slot_layer_get_object_mask(g_context->layer); - bool is_atlas = atlas_mask > g_project->_->paint_objects->length; + i32 atlas_mask = g_context->layer_filter > g_project->_->paint_objects->length ? g_context->layer_filter : slot_layer_get_object_mask(g_context->layer); + bool is_atlas = atlas_mask > g_project->_->paint_objects->length; if (g_context->merged_object == NULL || is_atlas || g_context->merged_object_is_atlas) { mesh_object_t_array_t *visibles = is_atlas ? project_get_atlas_objects(atlas_mask) : NULL; util_mesh_merge(visibles); diff --git a/paint/sources/util/util_nodes.c b/paint/sources/util/util_nodes.c index 20bc59ca..1de7914b 100644 --- a/paint/sources/util/util_nodes.c +++ b/paint/sources/util/util_nodes.c @@ -249,7 +249,7 @@ void ui_viewnodes_on_canvas_released_duplicate(void *_) { void ui_viewnodes_on_canvas_delete_on_next_frame(void *_) { ui_nodes_hwnd->redraws = 2; - g_ui->is_delete_down = true; + g_ui->is_delete_down = true; ui_nodes_is_node_menu_op = true; } diff --git a/paint/sources/util/util_shortcut.c b/paint/sources/util/util_shortcut.c index 68357b27..e75b415d 100644 --- a/paint/sources/util/util_shortcut.c +++ b/paint/sources/util/util_shortcut.c @@ -6,8 +6,7 @@ static f32 util_shortcut_redo_tap_time = 0.0; void util_shortcut_undo_redo() { bool undo_pressed = operator_shortcut(any_map_get(g_keymap, "edit_undo"), SHORTCUT_TYPE_STARTED); - bool redo_pressed = - operator_shortcut(any_map_get(g_keymap, "edit_redo"), SHORTCUT_TYPE_STARTED) || (keyboard_down("control") && keyboard_started("y")); + bool redo_pressed = operator_shortcut(any_map_get(g_keymap, "edit_redo"), SHORTCUT_TYPE_STARTED) || (keyboard_down("control") && keyboard_started("y")); // Two-finger tap to undo, three-finger tap to redo if (context_in_3d_view() && g_config->touch_ui) { @@ -111,11 +110,11 @@ void util_shortcut_brush() { bool decal_mask = context_is_decal_mask(); - bool adjusting = operator_shortcut(any_map_get(g_keymap, "brush_radius"), SHORTCUT_TYPE_DOWN) || - operator_shortcut(any_map_get(g_keymap, "brush_opacity"), SHORTCUT_TYPE_DOWN) || - operator_shortcut(any_map_get(g_keymap, "brush_angle"), SHORTCUT_TYPE_DOWN) || - (decal_mask && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius")), - SHORTCUT_TYPE_DOWN)); + bool adjusting = + operator_shortcut(any_map_get(g_keymap, "brush_radius"), SHORTCUT_TYPE_DOWN) || + operator_shortcut(any_map_get(g_keymap, "brush_opacity"), SHORTCUT_TYPE_DOWN) || + operator_shortcut(any_map_get(g_keymap, "brush_angle"), SHORTCUT_TYPE_DOWN) || + (decal_mask && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius")), SHORTCUT_TYPE_DOWN)); if (!adjusting) { iron_mouse_unlock(); @@ -142,9 +141,7 @@ void util_shortcut_brush() { g_context->brush_angle += 360; make_material_parse_paint_material(true); } - else if (decal_mask && - operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius")), - SHORTCUT_TYPE_DOWN)) { + else if (decal_mask && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius")), SHORTCUT_TYPE_DOWN)) { g_context->brush_decal_mask_radius += mouse_movement_x / 150.0; g_context->brush_decal_mask_radius = math_max(0.01, math_min(4.0, g_context->brush_decal_mask_radius)); g_context->brush_decal_mask_radius = math_round(g_context->brush_decal_mask_radius * 100) / 100.0; @@ -235,8 +232,8 @@ void util_shortcut_viewport() { if (operator_shortcut(any_map_get(g_keymap, "brush_radius"), SHORTCUT_TYPE_STARTED) || operator_shortcut(any_map_get(g_keymap, "brush_opacity"), SHORTCUT_TYPE_STARTED) || operator_shortcut(any_map_get(g_keymap, "brush_angle"), SHORTCUT_TYPE_STARTED) || - (decal_mask && operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius")), - SHORTCUT_TYPE_STARTED))) { + (decal_mask && + operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius")), SHORTCUT_TYPE_STARTED))) { g_context->brush_locked = true; if (!pen_connected) { iron_mouse_lock(); @@ -259,8 +256,7 @@ void util_shortcut_viewport() { g_context->brush_decal_mask_radius = math_max(math_round(g_context->brush_decal_mask_radius * 100) / 100.0, 0.01); ui_header_handle->redraws = 2; } - else if (operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), - any_map_get(g_keymap, "brush_radius_increase")), + else if (operator_shortcut(string("%s+%s", any_map_get(g_keymap, "decal_mask"), any_map_get(g_keymap, "brush_radius_increase")), SHORTCUT_TYPE_REPEAT)) { g_context->brush_decal_mask_radius += ui_base_get_radius_increment(); g_context->brush_decal_mask_radius = math_round(g_context->brush_decal_mask_radius * 100) / 100.0; diff --git a/paint/sources/util/util_uv.c b/paint/sources/util/util_uv.c index 98369c41..a568ae0e 100644 --- a/paint/sources/util/util_uv.c +++ b/paint/sources/util/util_uv.c @@ -24,10 +24,11 @@ void util_uv_cache_uv_map() { gc_root(util_uv_uvmap); } - util_uv_uvmap_cached = true; - i32 mask = slot_layer_get_object_mask(g_context->layer); - mesh_object_t *merged = (mask > 0 && mask <= g_project->_->paint_objects->length) ? g_project->_->paint_objects->buffer[mask - 1] : g_context->merged_object; - mesh_data_t *mesh = (g_context->layer_filter == 0 && merged != NULL) ? merged->data : g_context->paint_object->data; + util_uv_uvmap_cached = true; + i32 mask = slot_layer_get_object_mask(g_context->layer); + mesh_object_t *merged = + (mask > 0 && mask <= g_project->_->paint_objects->length) ? g_project->_->paint_objects->buffer[mask - 1] : g_context->merged_object; + mesh_data_t *mesh = (g_context->layer_filter == 0 && merged != NULL) ? merged->data : g_context->paint_object->data; i16_array_t *texa = mesh->vertex_arrays->buffer[2]->values; u32_array_t *inda = mesh->index_array; diff --git a/paint/sources/viewport.c b/paint/sources/viewport.c index 0201e971..a74e7157 100644 --- a/paint/sources/viewport.c +++ b/paint/sources/viewport.c @@ -27,9 +27,9 @@ void viewport_reset() { if (string_equals(o->type, "camera_object")) { cam->base->transform->local = mat4_from_f32_array(o->transform, 0); transform_decompose(cam->base->transform); - cam->data->fov = g_config->camera_fov; - g_context->camera_type = 0; - cam->data->ortho = NULL; + cam->data->fov = g_config->camera_fov; + g_context->camera_type = 0; + cam->data->ortho = NULL; camera_object_build_proj(cam, -1.0); g_context->ddirty = 2; camera_reset(-1);