ui_header_ext.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. let _ui_header_draw_tool_properties_h: ui_handle_t;
  2. function ui_header_draw_tool_properties(ui: ui_t) {
  3. if (context_raw.tool == workspace_tool_t.COLORID) {
  4. ui_text(tr("Picked Color"));
  5. if (context_raw.colorid_picked) {
  6. let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid");
  7. ui_image(rt._image, 0xffffffff, 64);
  8. }
  9. ui.enabled = context_raw.colorid_picked;
  10. if (ui_button(tr("Clear"))) {
  11. context_raw.colorid_picked = false;
  12. ui_toolbar_handle.redraws = 1;
  13. }
  14. ui.enabled = true;
  15. ui_text(tr("Color ID Map"));
  16. if (project_asset_names.length > 0) {
  17. let cid: i32 = ui_combo(context_raw.colorid_handle, base_enum_texts("TEX_IMAGE"), tr("Color ID"));
  18. if (context_raw.colorid_handle.changed) {
  19. context_raw.ddirty = 2;
  20. context_raw.colorid_picked = false;
  21. ui_toolbar_handle.redraws = 1;
  22. }
  23. ui_image(project_get_image(project_assets[cid]));
  24. if (ui.is_hovered) {
  25. ui_tooltip_image(project_get_image(project_assets[cid]), 256);
  26. }
  27. }
  28. if (ui_button(tr("Import"))) {
  29. ui_files_show(string_array_join(path_texture_formats, ","), false, true, function (path: string) {
  30. import_asset_run(path, -1.0, -1.0, true, false);
  31. context_raw.colorid_handle.position = project_asset_names.length - 1;
  32. for (let i: i32 = 0; i < project_assets.length; ++i) {
  33. let a: asset_t = project_assets[i];
  34. // Already imported
  35. if (a.file == path) {
  36. context_raw.colorid_handle.position = array_index_of(project_assets, a);
  37. }
  38. }
  39. context_raw.ddirty = 2;
  40. context_raw.colorid_picked = false;
  41. ui_toolbar_handle.redraws = 1;
  42. ui_base_hwnds[2].redraws = 2;
  43. });
  44. }
  45. ui.enabled = context_raw.colorid_picked;
  46. if (ui_button(tr("To Mask"))) {
  47. if (slot_layer_is_mask(context_raw.layer)) {
  48. context_set_layer(context_raw.layer.parent);
  49. }
  50. let m: slot_layer_t = layers_new_mask(false, context_raw.layer);
  51. sys_notify_on_next_frame(function (m: slot_layer_t) {
  52. _gpu_begin(m.texpaint);
  53. gpu_set_pipeline(pipes_colorid_to_mask);
  54. let rt: render_target_t = map_get(render_path_render_targets, "texpaint_colorid");
  55. gpu_set_texture(pipes_texpaint_colorid, rt._image);
  56. gpu_set_texture(pipes_tex_colorid, project_get_image(project_assets[context_raw.colorid_handle.position]));
  57. gpu_set_vertex_buffer(const_data_screen_aligned_vb);
  58. gpu_set_index_buffer(const_data_screen_aligned_ib);
  59. gpu_draw();
  60. gpu_end();
  61. context_raw.colorid_picked = false;
  62. ui_toolbar_handle.redraws = 1;
  63. ui_header_handle.redraws = 1;
  64. context_raw.layer_preview_dirty = true;
  65. layers_update_fill_layers();
  66. }, m);
  67. history_new_white_mask();
  68. }
  69. ui.enabled = true;
  70. }
  71. else if (context_raw.tool == workspace_tool_t.PICKER || context_raw.tool == workspace_tool_t.MATERIAL) {
  72. let base_r_picked: f32 = math_round(color_get_rb(context_raw.picked_color.base) / 255 * 10) / 10;
  73. let base_g_picked: f32 = math_round(color_get_gb(context_raw.picked_color.base) / 255 * 10) / 10;
  74. let base_b_picked: f32 = math_round(color_get_bb(context_raw.picked_color.base) / 255 * 10) / 10;
  75. let normal_r_picked: f32 = math_round(color_get_rb(context_raw.picked_color.normal) / 255 * 10) / 10;
  76. let normal_g_picked: f32 = math_round(color_get_gb(context_raw.picked_color.normal) / 255 * 10) / 10;
  77. let normal_b_picked: f32 = math_round(color_get_bb(context_raw.picked_color.normal) / 255 * 10) / 10;
  78. let occlusion_picked: f32 = math_round(context_raw.picked_color.occlusion * 100) / 100;
  79. let roughness_picked: f32 = math_round(context_raw.picked_color.roughness * 100) / 100;
  80. let metallic_picked: f32 = math_round(context_raw.picked_color.metallic * 100) / 100;
  81. let height_picked: f32 = math_round(context_raw.picked_color.height * 100) / 100;
  82. let opacity_picked: f32 = math_round(context_raw.picked_color.opacity * 100) / 100;
  83. let h: ui_handle_t = ui_handle(__ID__);
  84. let color: color_t = 0xffffffff;
  85. color = color_set_rb(color, base_r_picked * 255);
  86. color = color_set_gb(color, base_g_picked * 255);
  87. color = color_set_bb(color, base_b_picked * 255);
  88. h.color = color;
  89. let state: ui_state_t = ui_text("", 0, h.color);
  90. if (state == ui_state_t.STARTED) {
  91. let uix: i32 = ui._x;
  92. let uiy: i32 = ui._y;
  93. base_drag_off_x = -(mouse_x - uix - ui._window_x - 3);
  94. base_drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
  95. base_drag_swatch = project_clone_swatch(context_raw.picked_color);
  96. }
  97. if (ui.is_hovered) {
  98. ui_tooltip(tr("Drag and drop picked color to swatches, materials, layers or to the node editor"));
  99. }
  100. if (ui.is_hovered && ui.input_released) {
  101. _ui_header_draw_tool_properties_h = h;
  102. ui_menu_draw(function (ui: ui_t) {
  103. ui_fill(0, 0, ui._w / ui_SCALE(ui), ui.ops.theme.ELEMENT_H * 9, ui.ops.theme.SEPARATOR_COL);
  104. ui.changed = false;
  105. ui_color_wheel(_ui_header_draw_tool_properties_h, false, -1, 10 * ui.ops.theme.ELEMENT_H * ui_SCALE(ui), false);
  106. if (ui.changed) {
  107. ui_menu_keep_open = true;
  108. }
  109. });
  110. }
  111. if (ui_button(tr("Add Swatch"))) {
  112. let new_swatch: swatch_color_t = project_clone_swatch(context_raw.picked_color);
  113. context_set_swatch(new_swatch);
  114. array_push(project_raw.swatches, new_swatch);
  115. ui_base_hwnds[2].redraws = 1;
  116. }
  117. if (ui.is_hovered) {
  118. ui_tooltip(tr("Add picked color to swatches"));
  119. }
  120. ui_text(tr("Base") + " (" + base_r_picked + "," + base_g_picked + "," + base_b_picked + ")");
  121. ui_text(tr("Normal") + " (" + normal_r_picked + "," + normal_g_picked + "," + normal_b_picked + ")");
  122. ui_text(tr("Occlusion") + " (" + occlusion_picked + ")");
  123. ui_text(tr("Roughness") + " (" + roughness_picked + ")");
  124. ui_text(tr("Metallic") + " (" + metallic_picked + ")");
  125. ui_text(tr("Height") + " (" + height_picked + ")");
  126. ui_text(tr("Opacity") + " (" + opacity_picked + ")");
  127. let h_select_mat: ui_handle_t = ui_handle(__ID__);
  128. if (h_select_mat.init) {
  129. h_select_mat.selected = context_raw.picker_select_material;
  130. }
  131. context_raw.picker_select_material = ui_check(h_select_mat, tr("Select Material"));
  132. let picker_mask_combo: string[] = [tr("None"), tr("Material")];
  133. ui_combo(context_raw.picker_mask_handle, picker_mask_combo, tr("Mask"), true);
  134. if (context_raw.picker_mask_handle.changed) {
  135. make_material_parse_paint_material();
  136. }
  137. }
  138. else if (context_raw.tool == workspace_tool_t.BAKE) {
  139. ui.changed = false;
  140. let baking: bool = context_raw.pdirty > 0;
  141. let rt_bake: bool = render_path_paint_is_rt_bake();
  142. if (baking && ui_button(tr("Stop"))) {
  143. context_raw.pdirty = 0;
  144. context_raw.rdirty = 2;
  145. }
  146. if (!baking && ui_button(tr("Bake"))) {
  147. context_raw.pdirty = rt_bake ? context_raw.bake_samples : 1;
  148. context_raw.rdirty = 3;
  149. sys_notify_on_next_frame(function () {
  150. context_raw.layer_preview_dirty = true;
  151. });
  152. ui_base_hwnds[0].redraws = 2;
  153. history_push_undo = true;
  154. render_path_raytrace_bake_current_sample = 0;
  155. }
  156. let bake_handle: ui_handle_t = ui_handle(__ID__);
  157. if (bake_handle.init) {
  158. bake_handle.position = context_raw.bake_type;
  159. }
  160. let bakes: string[] = [
  161. tr("AO"),
  162. tr("Curvature"),
  163. tr("Normal"),
  164. tr("Object Normal"),
  165. tr("Height"),
  166. tr("Derivative"),
  167. tr("Position"),
  168. tr("TexCoord"),
  169. tr("Material ID"),
  170. tr("Object ID"),
  171. tr("Vertex Color"),
  172. ];
  173. if (gpu_raytrace_supported()) {
  174. array_push(bakes, tr("Lightmap"));
  175. array_push(bakes, tr("Bent Normal"));
  176. array_push(bakes, tr("Thickness"));
  177. }
  178. else {
  179. array_shift(bakes); // Remove AO
  180. }
  181. context_raw.bake_type = ui_combo(bake_handle, bakes, tr("Bake"));
  182. if (!gpu_raytrace_supported()) {
  183. context_raw.bake_type += 1; // Offset for removed AO
  184. }
  185. if (rt_bake) {
  186. let samples_handle: ui_handle_t = ui_handle(__ID__);
  187. if (samples_handle.init) {
  188. samples_handle.value = context_raw.bake_samples;
  189. }
  190. context_raw.bake_samples = math_floor(ui_slider(samples_handle, tr("Samples"), 1, 512, true, 1));
  191. }
  192. if (context_raw.bake_type == bake_type_t.NORMAL_OBJECT ||
  193. context_raw.bake_type == bake_type_t.POSITION ||
  194. context_raw.bake_type == bake_type_t.BENT_NORMAL
  195. ) {
  196. let bake_up_axis_handle: ui_handle_t = ui_handle(__ID__);
  197. if (bake_up_axis_handle.init) {
  198. bake_up_axis_handle.position = context_raw.bake_up_axis;
  199. }
  200. let bake_up_axis_combo: string[] = [tr("Z"), tr("Y")];
  201. context_raw.bake_up_axis = ui_combo(bake_up_axis_handle, bake_up_axis_combo, tr("Up Axis"), true);
  202. }
  203. if (context_raw.bake_type == bake_type_t.AO || context_raw.bake_type == bake_type_t.CURVATURE) {
  204. let bake_axis_handle: ui_handle_t = ui_handle(__ID__);
  205. if (bake_axis_handle.init) {
  206. bake_axis_handle.position = context_raw.bake_axis;
  207. }
  208. let bake_axis_combo: string[] = [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")];
  209. context_raw.bake_axis = ui_combo(bake_axis_handle, bake_axis_combo, tr("Axis"), true);
  210. }
  211. if (context_raw.bake_type == bake_type_t.AO) {
  212. let strength_handle: ui_handle_t = ui_handle(__ID__);
  213. if (strength_handle.init) {
  214. strength_handle.value = context_raw.bake_ao_strength;
  215. }
  216. context_raw.bake_ao_strength = ui_slider(strength_handle, tr("Strength"), 0.0, 2.0, true);
  217. let radius_handle: ui_handle_t = ui_handle(__ID__);
  218. if (radius_handle.init) {
  219. radius_handle.value = context_raw.bake_ao_radius;
  220. }
  221. context_raw.bake_ao_radius = ui_slider(radius_handle, tr("Radius"), 0.0, 2.0, true);
  222. let offset_handle: ui_handle_t = ui_handle(__ID__);
  223. if (offset_handle.init) {
  224. offset_handle.value = context_raw.bake_ao_offset;
  225. }
  226. context_raw.bake_ao_offset = ui_slider(offset_handle, tr("Offset"), 0.0, 2.0, true);
  227. }
  228. if (rt_bake) {
  229. let progress: f32 = render_path_raytrace_bake_current_sample / context_raw.bake_samples;
  230. if (progress > 1.0) progress = 1.0;
  231. // Progress bar
  232. draw_set_color(ui.ops.theme.SEPARATOR_COL);
  233. ui_draw_rect(true, ui._x + 1, ui._y, ui._w - 2, ui_ELEMENT_H(ui));
  234. draw_set_color(ui.ops.theme.HIGHLIGHT_COL);
  235. ui_draw_rect(true, ui._x + 1, ui._y, (ui._w - 2) * progress, ui_ELEMENT_H(ui));
  236. draw_set_color(0xffffffff);
  237. ui_text(tr("Samples") + ": " + render_path_raytrace_bake_current_sample);
  238. ui_text(tr("Rays/pixel") + ": " + render_path_raytrace_bake_rays_pix);
  239. ui_text(tr("Rays/second") + ": " + render_path_raytrace_bake_rays_sec);
  240. }
  241. if (context_raw.bake_type == bake_type_t.CURVATURE) {
  242. let strength_handle: ui_handle_t = ui_handle(__ID__);
  243. if (strength_handle.init) {
  244. strength_handle.value = context_raw.bake_curv_strength;
  245. }
  246. context_raw.bake_curv_strength = ui_slider(strength_handle, tr("Strength"), 0.0, 2.0, true);
  247. let radius_handle: ui_handle_t = ui_handle(__ID__);
  248. if (radius_handle.init) {
  249. radius_handle.value = context_raw.bake_curv_radius;
  250. }
  251. context_raw.bake_curv_radius = ui_slider(radius_handle, tr("Radius"), 0.0, 2.0, true);
  252. let offset_handle: ui_handle_t = ui_handle(__ID__);
  253. if (offset_handle.init) {
  254. offset_handle.value = context_raw.bake_curv_offset;
  255. }
  256. context_raw.bake_curv_offset = ui_slider(offset_handle, tr("Offset"), -2.0, 2.0, true);
  257. let smooth_handle: ui_handle_t = ui_handle(__ID__);
  258. if (smooth_handle.init) {
  259. smooth_handle.value = context_raw.bake_curv_smooth;
  260. }
  261. context_raw.bake_curv_smooth = math_floor(ui_slider(smooth_handle, tr("Smooth"), 0, 5, false, 1));
  262. }
  263. if (context_raw.bake_type == bake_type_t.NORMAL || context_raw.bake_type == bake_type_t.HEIGHT || context_raw.bake_type == bake_type_t.DERIVATIVE) {
  264. let ar: string[] = [];
  265. for (let i: i32 = 0; i < project_paint_objects.length; ++i) {
  266. let p: mesh_object_t = project_paint_objects[i];
  267. array_push(ar, p.base.name);
  268. }
  269. let poly_handle: ui_handle_t = ui_handle(__ID__);
  270. if (poly_handle.init) {
  271. poly_handle.position = context_raw.bake_high_poly;
  272. }
  273. context_raw.bake_high_poly = ui_combo(poly_handle, ar, tr("High Poly"));
  274. }
  275. if (ui.changed) {
  276. make_material_parse_paint_material();
  277. }
  278. }
  279. else if (context_raw.tool == workspace_tool_t.BRUSH ||
  280. context_raw.tool == workspace_tool_t.ERASER ||
  281. context_raw.tool == workspace_tool_t.FILL ||
  282. context_raw.tool == workspace_tool_t.DECAL ||
  283. context_raw.tool == workspace_tool_t.TEXT ||
  284. context_raw.tool == workspace_tool_t.CLONE ||
  285. context_raw.tool == workspace_tool_t.BLUR ||
  286. context_raw.tool == workspace_tool_t.SMUDGE ||
  287. context_raw.tool == workspace_tool_t.PARTICLE) {
  288. let decal: bool = context_is_decal();
  289. let decal_mask: bool = context_is_decal_mask();
  290. if (context_raw.tool != workspace_tool_t.FILL) {
  291. if (decal_mask) {
  292. context_raw.brush_decal_mask_radius = ui_slider(context_raw.brush_decal_mask_radius_handle, tr("Radius"), 0.01, 2.0, true);
  293. if (ui.is_hovered) {
  294. let vars: map_t<string, string> = map_create();
  295. map_set(vars, "brush_radius", map_get(config_keymap, "brush_radius"));
  296. map_set(vars, "brush_radius_decrease", map_get(config_keymap, "brush_radius_decrease"));
  297. map_set(vars, "brush_radius_increase", map_get(config_keymap, "brush_radius_increase"));
  298. ui_tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", vars));
  299. }
  300. }
  301. else {
  302. context_raw.brush_radius = ui_slider(context_raw.brush_radius_handle, tr("Radius"), 0.01, 2.0, true);
  303. if (ui.is_hovered) {
  304. let vars: map_t<string, string> = map_create();
  305. map_set(vars, "brush_radius", map_get(config_keymap, "brush_radius"));
  306. map_set(vars, "brush_radius_decrease", map_get(config_keymap, "brush_radius_decrease"));
  307. map_set(vars, "brush_radius_increase", map_get(config_keymap, "brush_radius_increase"));
  308. ui_tooltip(tr("Hold {brush_radius} and move mouse to the left or press {brush_radius_decrease} to decrease the radius\nHold {brush_radius} and move mouse to the right or press {brush_radius_increase} to increase the radius", vars));
  309. }
  310. }
  311. }
  312. if (context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT) {
  313. context_raw.brush_scale_x = ui_slider(context_raw.brush_scale_x_handle, tr("Scale X"), 0.01, 2.0, true);
  314. }
  315. if (context_raw.tool == workspace_tool_t.BRUSH ||
  316. context_raw.tool == workspace_tool_t.FILL ||
  317. context_raw.tool == workspace_tool_t.DECAL ||
  318. context_raw.tool == workspace_tool_t.TEXT) {
  319. let brush_scale_handle: ui_handle_t = ui_handle(__ID__);
  320. if (brush_scale_handle.init) {
  321. brush_scale_handle.value = context_raw.brush_scale;
  322. }
  323. context_raw.brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true);
  324. if (brush_scale_handle.changed) {
  325. if (context_raw.tool == workspace_tool_t.DECAL || context_raw.tool == workspace_tool_t.TEXT) {
  326. let current: gpu_texture_t = _draw_current;
  327. draw_end();
  328. util_render_make_decal_preview();
  329. draw_begin(current);
  330. }
  331. }
  332. context_raw.brush_angle = ui_slider(context_raw.brush_angle_handle, tr("Angle"), 0.0, 360.0, true, 1);
  333. if (ui.is_hovered) {
  334. let vars: map_t<string, string> = map_create();
  335. map_set(vars, "brush_angle", map_get(config_keymap, "brush_angle"));
  336. ui_tooltip(tr("Hold {brush_angle} and move mouse to the left to decrease the angle\nHold {brush_angle} and move mouse to the right to increase the angle", vars));
  337. }
  338. if (context_raw.brush_angle_handle.changed) {
  339. make_material_parse_paint_material();
  340. }
  341. }
  342. context_raw.brush_opacity = ui_slider(context_raw.brush_opacity_handle, tr("Opacity"), 0.0, 1.0, true);
  343. if (ui.is_hovered) {
  344. let vars: map_t<string, string> = map_create();
  345. map_set(vars, "brush_opacity", map_get(config_keymap, "brush_opacity"));
  346. ui_tooltip(tr("Hold {brush_opacity} and move mouse to the left to decrease the opacity\nHold {brush_opacity} and move mouse to the right to increase the opacity", vars));
  347. }
  348. if (context_raw.tool == workspace_tool_t.BRUSH || context_raw.tool == workspace_tool_t.ERASER || context_raw.tool == workspace_tool_t.CLONE || decal_mask) {
  349. let h: ui_handle_t = ui_handle(__ID__);
  350. if (h.init) {
  351. h.value = context_raw.brush_hardness;
  352. }
  353. context_raw.brush_hardness = ui_slider(h, tr("Hardness"), 0.0, 1.0, true);
  354. }
  355. if (context_raw.tool != workspace_tool_t.ERASER) {
  356. let brush_blending_handle: ui_handle_t = ui_handle(__ID__);
  357. if (brush_blending_handle.init) {
  358. brush_blending_handle.value = context_raw.brush_blending;
  359. }
  360. let brush_blending_combo: string[] = [
  361. tr("Mix"),
  362. tr("Darken"),
  363. tr("Multiply"),
  364. tr("Burn"),
  365. tr("Lighten"),
  366. tr("Screen"),
  367. tr("Dodge"),
  368. tr("Add"),
  369. tr("Overlay"),
  370. tr("Soft Light"),
  371. tr("Linear Light"),
  372. tr("Difference"),
  373. tr("Subtract"),
  374. tr("Divide"),
  375. tr("Hue"),
  376. tr("Saturation"),
  377. tr("Color"),
  378. tr("Value"),
  379. ];
  380. context_raw.brush_blending = ui_combo(brush_blending_handle, brush_blending_combo, tr("Blending"));
  381. if (brush_blending_handle.changed) {
  382. make_material_parse_paint_material();
  383. }
  384. }
  385. if (context_raw.tool == workspace_tool_t.BRUSH || context_raw.tool == workspace_tool_t.FILL) {
  386. let paint_handle: ui_handle_t = ui_handle(__ID__);
  387. let texcoord_combo: string[] = [tr("UV Map"), tr("Triplanar"), tr("Project")];
  388. context_raw.brush_paint = ui_combo(paint_handle, texcoord_combo, tr("TexCoord"));
  389. if (paint_handle.changed) {
  390. make_material_parse_paint_material();
  391. }
  392. }
  393. if (context_raw.tool == workspace_tool_t.TEXT) {
  394. let h: ui_handle_t = ui_handle(__ID__);
  395. h.text = context_raw.text_tool_text;
  396. let w: i32 = ui._w;
  397. if (ui.text_selected_handle == h || ui.submit_text_handle == h) {
  398. ui._w *= 3;
  399. }
  400. context_raw.text_tool_text = ui_text_input(h, "", ui_align_t.LEFT, true, true);
  401. ui._w = w;
  402. if (h.changed) {
  403. let current: gpu_texture_t = _draw_current;
  404. draw_end();
  405. util_render_make_text_preview();
  406. util_render_make_decal_preview();
  407. draw_begin(current);
  408. }
  409. }
  410. if (context_raw.tool == workspace_tool_t.FILL) {
  411. let fill_mode_combo: string[] = [tr("Object"), tr("Face"), tr("Angle"), tr("UV Island")];
  412. ui_combo(context_raw.fill_type_handle, fill_mode_combo, tr("Fill Mode"));
  413. if (context_raw.fill_type_handle.changed) {
  414. if (context_raw.fill_type_handle.position == fill_type_t.FACE) {
  415. let current: gpu_texture_t = _draw_current;
  416. draw_end();
  417. // cache_uv_map();
  418. util_uv_cache_triangle_map();
  419. draw_begin(current);
  420. // wireframe_handle.selected = draw_wireframe = true;
  421. }
  422. make_material_parse_paint_material();
  423. make_material_parse_mesh_material();
  424. }
  425. }
  426. else {
  427. let _w: i32 = ui._w;
  428. let sc: f32 = ui_SCALE(ui);
  429. let touch_header: bool = (config_raw.touch_ui && config_raw.layout[layout_size_t.HEADER] == 1);
  430. if (touch_header) {
  431. ui._x -= 4 * sc;
  432. }
  433. ui._w = math_floor((touch_header ? 54 : 60) * sc);
  434. let xray_handle: ui_handle_t = ui_handle(__ID__);
  435. if (xray_handle.init) {
  436. xray_handle.selected = context_raw.xray;
  437. }
  438. context_raw.xray = ui_check(xray_handle, tr("X-Ray"));
  439. if (xray_handle.changed) {
  440. make_material_parse_paint_material();
  441. }
  442. let sym_x_handle: ui_handle_t = ui_handle(__ID__);
  443. if (sym_x_handle.init) {
  444. sym_x_handle.selected = false;
  445. }
  446. let sym_y_handle: ui_handle_t = ui_handle(__ID__);
  447. if (sym_y_handle.init) {
  448. sym_y_handle.selected = false;
  449. }
  450. let sym_z_handle: ui_handle_t = ui_handle(__ID__);
  451. if (sym_z_handle.init) {
  452. sym_z_handle.selected = false;
  453. }
  454. if (config_raw.layout[layout_size_t.HEADER] == 1) {
  455. if (config_raw.touch_ui) {
  456. ui._w = math_floor(19 * sc);
  457. context_raw.sym_x = ui_check(sym_x_handle, "");
  458. ui._x -= 4 * sc;
  459. context_raw.sym_y = ui_check(sym_y_handle, "");
  460. ui._x -= 4 * sc;
  461. context_raw.sym_z = ui_check(sym_z_handle, "");
  462. ui._x -= 4 * sc;
  463. ui._w = math_floor(40 * sc);
  464. let x: string = tr("X");
  465. let y: string = tr("Y");
  466. let z: string = tr("Z");
  467. ui_text(x + y + z);
  468. }
  469. else {
  470. ui._w = math_floor(56 * sc);
  471. ui_text(tr("Symmetry"));
  472. ui._w = math_floor(25 * sc);
  473. context_raw.sym_x = ui_check(sym_x_handle, tr("X"));
  474. context_raw.sym_y = ui_check(sym_y_handle, tr("Y"));
  475. context_raw.sym_z = ui_check(sym_z_handle, tr("Z"));
  476. }
  477. ui._w = _w;
  478. }
  479. else {
  480. // Popup
  481. ui._w = _w;
  482. context_raw.sym_x = ui_check(sym_x_handle, tr("Symmetry") + " " + tr("X"));
  483. context_raw.sym_y = ui_check(sym_y_handle, tr("Symmetry") + " " + tr("Y"));
  484. context_raw.sym_z = ui_check(sym_z_handle, tr("Symmetry") + " " + tr("Z"));
  485. }
  486. if (sym_x_handle.changed || sym_y_handle.changed || sym_z_handle.changed) {
  487. make_material_parse_paint_material();
  488. }
  489. }
  490. }
  491. }