ui_header_ext.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. let _ui_header_draw_tool_properties_h: ui_handle_t;
  2. function ui_header_draw_tool_properties() {
  3. if (context_raw.tool == tool_type_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 == tool_type_t.PICKER || context_raw.tool == tool_type_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 () {
  103. ui_fill(0, 0, ui._w / UI_SCALE(), 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(), 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 == tool_type_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("Curvature"),
  162. tr("Normal"),
  163. tr("Object Normal"),
  164. tr("Height"),
  165. tr("Derivative"),
  166. tr("Position"),
  167. tr("TexCoord"),
  168. tr("Material ID"),
  169. tr("Object ID"),
  170. tr("Vertex Color"),
  171. ];
  172. if (gpu_raytrace_supported()) {
  173. array_push(bakes, tr("AO"));
  174. array_push(bakes, tr("Lightmap"));
  175. array_push(bakes, tr("Bent Normal"));
  176. array_push(bakes, tr("Thickness"));
  177. }
  178. context_raw.bake_type = ui_combo(bake_handle, bakes, tr("Bake"));
  179. if (bake_handle.changed && ui_menu_show) {
  180. ui_menu_nested = true; // Update menu height
  181. }
  182. if (rt_bake) {
  183. let samples_handle: ui_handle_t = ui_handle(__ID__);
  184. if (samples_handle.init) {
  185. samples_handle.value = context_raw.bake_samples;
  186. }
  187. context_raw.bake_samples = math_floor(ui_slider(samples_handle, tr("Samples"), 1, 512, true, 1));
  188. }
  189. if (context_raw.bake_type == bake_type_t.NORMAL_OBJECT ||
  190. context_raw.bake_type == bake_type_t.POSITION ||
  191. context_raw.bake_type == bake_type_t.BENT_NORMAL
  192. ) {
  193. let bake_up_axis_handle: ui_handle_t = ui_handle(__ID__);
  194. if (bake_up_axis_handle.init) {
  195. bake_up_axis_handle.position = context_raw.bake_up_axis;
  196. }
  197. let bake_up_axis_combo: string[] = [tr("Z"), tr("Y")];
  198. context_raw.bake_up_axis = ui_combo(bake_up_axis_handle, bake_up_axis_combo, tr("Up Axis"), true);
  199. }
  200. if (context_raw.bake_type == bake_type_t.AO || context_raw.bake_type == bake_type_t.CURVATURE) {
  201. let bake_axis_handle: ui_handle_t = ui_handle(__ID__);
  202. if (bake_axis_handle.init) {
  203. bake_axis_handle.position = context_raw.bake_axis;
  204. }
  205. let bake_axis_combo: string[] = [tr("XYZ"), tr("X"), tr("Y"), tr("Z"), tr("-X"), tr("-Y"), tr("-Z")];
  206. context_raw.bake_axis = ui_combo(bake_axis_handle, bake_axis_combo, tr("Axis"), true);
  207. }
  208. if (context_raw.bake_type == bake_type_t.AO) {
  209. let strength_handle: ui_handle_t = ui_handle(__ID__);
  210. if (strength_handle.init) {
  211. strength_handle.value = context_raw.bake_ao_strength;
  212. }
  213. context_raw.bake_ao_strength = ui_slider(strength_handle, tr("Strength"), 0.0, 2.0, true);
  214. let radius_handle: ui_handle_t = ui_handle(__ID__);
  215. if (radius_handle.init) {
  216. radius_handle.value = context_raw.bake_ao_radius;
  217. }
  218. context_raw.bake_ao_radius = ui_slider(radius_handle, tr("Radius"), 0.0, 2.0, true);
  219. let offset_handle: ui_handle_t = ui_handle(__ID__);
  220. if (offset_handle.init) {
  221. offset_handle.value = context_raw.bake_ao_offset;
  222. }
  223. context_raw.bake_ao_offset = ui_slider(offset_handle, tr("Offset"), 0.0, 2.0, true);
  224. }
  225. if (rt_bake) {
  226. let progress: f32 = render_path_raytrace_bake_current_sample / context_raw.bake_samples;
  227. if (progress > 1.0) progress = 1.0;
  228. // Progress bar
  229. draw_set_color(ui.ops.theme.SEPARATOR_COL);
  230. ui_draw_rect(true, ui._x + 1, ui._y, ui._w - 2, UI_ELEMENT_H());
  231. draw_set_color(ui.ops.theme.HIGHLIGHT_COL);
  232. ui_draw_rect(true, ui._x + 1, ui._y, (ui._w - 2) * progress, UI_ELEMENT_H());
  233. draw_set_color(0xffffffff);
  234. ui_text(tr("Samples") + ": " + render_path_raytrace_bake_current_sample);
  235. ui_text(tr("Rays/pixel") + ": " + render_path_raytrace_bake_rays_pix);
  236. ui_text(tr("Rays/second") + ": " + render_path_raytrace_bake_rays_sec);
  237. }
  238. if (context_raw.bake_type == bake_type_t.CURVATURE) {
  239. let strength_handle: ui_handle_t = ui_handle(__ID__);
  240. if (strength_handle.init) {
  241. strength_handle.value = context_raw.bake_curv_strength;
  242. }
  243. context_raw.bake_curv_strength = ui_slider(strength_handle, tr("Strength"), 0.0, 2.0, true);
  244. let radius_handle: ui_handle_t = ui_handle(__ID__);
  245. if (radius_handle.init) {
  246. radius_handle.value = context_raw.bake_curv_radius;
  247. }
  248. context_raw.bake_curv_radius = ui_slider(radius_handle, tr("Radius"), 0.0, 2.0, true);
  249. let offset_handle: ui_handle_t = ui_handle(__ID__);
  250. if (offset_handle.init) {
  251. offset_handle.value = context_raw.bake_curv_offset;
  252. }
  253. context_raw.bake_curv_offset = ui_slider(offset_handle, tr("Offset"), -2.0, 2.0, true);
  254. let smooth_handle: ui_handle_t = ui_handle(__ID__);
  255. if (smooth_handle.init) {
  256. smooth_handle.value = context_raw.bake_curv_smooth;
  257. }
  258. context_raw.bake_curv_smooth = math_floor(ui_slider(smooth_handle, tr("Smooth"), 0, 5, false, 1));
  259. }
  260. 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) {
  261. let ar: string[] = [];
  262. for (let i: i32 = 0; i < project_paint_objects.length; ++i) {
  263. let p: mesh_object_t = project_paint_objects[i];
  264. array_push(ar, p.base.name);
  265. }
  266. let poly_handle: ui_handle_t = ui_handle(__ID__);
  267. if (poly_handle.init) {
  268. poly_handle.position = context_raw.bake_high_poly;
  269. }
  270. context_raw.bake_high_poly = ui_combo(poly_handle, ar, tr("High Poly"));
  271. }
  272. if (ui.changed) {
  273. make_material_parse_paint_material();
  274. }
  275. }
  276. else if (context_raw.tool == tool_type_t.BRUSH ||
  277. context_raw.tool == tool_type_t.ERASER ||
  278. context_raw.tool == tool_type_t.FILL ||
  279. context_raw.tool == tool_type_t.DECAL ||
  280. context_raw.tool == tool_type_t.TEXT ||
  281. context_raw.tool == tool_type_t.CLONE ||
  282. context_raw.tool == tool_type_t.BLUR ||
  283. context_raw.tool == tool_type_t.SMUDGE ||
  284. context_raw.tool == tool_type_t.PARTICLE) {
  285. let decal: bool = context_is_decal();
  286. let decal_mask: bool = context_is_decal_mask();
  287. if (context_raw.tool != tool_type_t.FILL) {
  288. if (decal_mask) {
  289. context_raw.brush_decal_mask_radius = ui_slider(context_raw.brush_decal_mask_radius_handle, tr("Radius"), 0.01, 2.0, true);
  290. if (ui.is_hovered) {
  291. let vars: map_t<string, string> = map_create();
  292. map_set(vars, "brush_radius", map_get(config_keymap, "brush_radius"));
  293. map_set(vars, "brush_radius_decrease", map_get(config_keymap, "brush_radius_decrease"));
  294. map_set(vars, "brush_radius_increase", map_get(config_keymap, "brush_radius_increase"));
  295. 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));
  296. }
  297. }
  298. else {
  299. context_raw.brush_radius = ui_slider(context_raw.brush_radius_handle, tr("Radius"), 0.01, 2.0, true);
  300. if (ui.is_hovered) {
  301. let vars: map_t<string, string> = map_create();
  302. map_set(vars, "brush_radius", map_get(config_keymap, "brush_radius"));
  303. map_set(vars, "brush_radius_decrease", map_get(config_keymap, "brush_radius_decrease"));
  304. map_set(vars, "brush_radius_increase", map_get(config_keymap, "brush_radius_increase"));
  305. 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));
  306. }
  307. }
  308. }
  309. if (context_raw.tool == tool_type_t.DECAL || context_raw.tool == tool_type_t.TEXT) {
  310. context_raw.brush_scale_x = ui_slider(context_raw.brush_scale_x_handle, tr("Scale X"), 0.01, 2.0, true);
  311. }
  312. if (context_raw.tool == tool_type_t.BRUSH ||
  313. context_raw.tool == tool_type_t.FILL ||
  314. context_raw.tool == tool_type_t.DECAL ||
  315. context_raw.tool == tool_type_t.TEXT) {
  316. let brush_scale_handle: ui_handle_t = ui_handle(__ID__);
  317. if (brush_scale_handle.init) {
  318. brush_scale_handle.value = context_raw.brush_scale;
  319. }
  320. context_raw.brush_scale = ui_slider(brush_scale_handle, tr("UV Scale"), 0.01, 5.0, true);
  321. if (brush_scale_handle.changed) {
  322. if (context_raw.tool == tool_type_t.DECAL || context_raw.tool == tool_type_t.TEXT) {
  323. let current: gpu_texture_t = _draw_current;
  324. draw_end();
  325. util_render_make_decal_preview();
  326. draw_begin(current);
  327. }
  328. }
  329. context_raw.brush_angle = ui_slider(context_raw.brush_angle_handle, tr("Angle"), 0.0, 360.0, true, 1);
  330. if (ui.is_hovered) {
  331. let vars: map_t<string, string> = map_create();
  332. map_set(vars, "brush_angle", map_get(config_keymap, "brush_angle"));
  333. 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));
  334. }
  335. if (context_raw.brush_angle_handle.changed) {
  336. make_material_parse_paint_material();
  337. }
  338. }
  339. context_raw.brush_opacity = ui_slider(context_raw.brush_opacity_handle, tr("Opacity"), 0.0, 1.0, true);
  340. if (ui.is_hovered) {
  341. let vars: map_t<string, string> = map_create();
  342. map_set(vars, "brush_opacity", map_get(config_keymap, "brush_opacity"));
  343. 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));
  344. }
  345. if (context_raw.tool == tool_type_t.BRUSH || context_raw.tool == tool_type_t.ERASER || context_raw.tool == tool_type_t.CLONE || decal_mask) {
  346. let h: ui_handle_t = ui_handle(__ID__);
  347. if (h.init) {
  348. h.value = context_raw.brush_hardness;
  349. }
  350. context_raw.brush_hardness = ui_slider(h, tr("Hardness"), 0.0, 1.0, true);
  351. }
  352. if (context_raw.tool != tool_type_t.ERASER) {
  353. let brush_blending_handle: ui_handle_t = ui_handle(__ID__);
  354. if (brush_blending_handle.init) {
  355. brush_blending_handle.value = context_raw.brush_blending;
  356. }
  357. let brush_blending_combo: string[] = [
  358. tr("Mix"),
  359. tr("Darken"),
  360. tr("Multiply"),
  361. tr("Burn"),
  362. tr("Lighten"),
  363. tr("Screen"),
  364. tr("Dodge"),
  365. tr("Add"),
  366. tr("Overlay"),
  367. tr("Soft Light"),
  368. tr("Linear Light"),
  369. tr("Difference"),
  370. tr("Subtract"),
  371. tr("Divide"),
  372. tr("Hue"),
  373. tr("Saturation"),
  374. tr("Color"),
  375. tr("Value"),
  376. ];
  377. context_raw.brush_blending = ui_combo(brush_blending_handle, brush_blending_combo, tr("Blending"));
  378. if (brush_blending_handle.changed) {
  379. make_material_parse_paint_material();
  380. }
  381. }
  382. if (context_raw.tool == tool_type_t.BRUSH || context_raw.tool == tool_type_t.FILL) {
  383. let paint_handle: ui_handle_t = ui_handle(__ID__);
  384. let texcoord_combo: string[] = [tr("UV Map"), tr("Triplanar"), tr("Project")];
  385. context_raw.brush_paint = ui_combo(paint_handle, texcoord_combo, tr("TexCoord"));
  386. if (paint_handle.changed) {
  387. make_material_parse_paint_material();
  388. }
  389. }
  390. if (context_raw.tool == tool_type_t.TEXT) {
  391. let h: ui_handle_t = ui_handle(__ID__);
  392. h.text = context_raw.text_tool_text;
  393. let w: i32 = ui._w;
  394. if (ui.text_selected_handle == h || ui.submit_text_handle == h) {
  395. ui._w *= 3;
  396. }
  397. context_raw.text_tool_text = ui_text_input(h, "", ui_align_t.LEFT, true, true);
  398. ui._w = w;
  399. if (h.changed) {
  400. let current: gpu_texture_t = _draw_current;
  401. draw_end();
  402. util_render_make_text_preview();
  403. util_render_make_decal_preview();
  404. draw_begin(current);
  405. }
  406. }
  407. if (context_raw.tool == tool_type_t.FILL) {
  408. let fill_mode_combo: string[] = [tr("Object"), tr("Face"), tr("Angle"), tr("UV Island")];
  409. ui_combo(context_raw.fill_type_handle, fill_mode_combo, tr("Fill Mode"));
  410. if (context_raw.fill_type_handle.changed) {
  411. if (context_raw.fill_type_handle.position == fill_type_t.FACE) {
  412. let current: gpu_texture_t = _draw_current;
  413. draw_end();
  414. // cache_uv_map();
  415. util_uv_cache_triangle_map();
  416. draw_begin(current);
  417. // wireframe_handle.selected = draw_wireframe = true;
  418. }
  419. make_material_parse_paint_material();
  420. make_material_parse_mesh_material();
  421. }
  422. }
  423. else {
  424. let _w: i32 = ui._w;
  425. let sc: f32 = UI_SCALE();
  426. let touch_header: bool = (config_raw.touch_ui && config_raw.layout[layout_size_t.HEADER] == 1);
  427. if (touch_header) {
  428. ui._x -= 4 * sc;
  429. }
  430. ui._w = math_floor((touch_header ? 54 : 60) * sc);
  431. let xray_handle: ui_handle_t = ui_handle(__ID__);
  432. if (xray_handle.init) {
  433. xray_handle.selected = context_raw.xray;
  434. }
  435. context_raw.xray = ui_check(xray_handle, tr("X-Ray"));
  436. if (xray_handle.changed) {
  437. make_material_parse_paint_material();
  438. }
  439. let sym_x_handle: ui_handle_t = ui_handle(__ID__);
  440. if (sym_x_handle.init) {
  441. sym_x_handle.selected = false;
  442. }
  443. let sym_y_handle: ui_handle_t = ui_handle(__ID__);
  444. if (sym_y_handle.init) {
  445. sym_y_handle.selected = false;
  446. }
  447. let sym_z_handle: ui_handle_t = ui_handle(__ID__);
  448. if (sym_z_handle.init) {
  449. sym_z_handle.selected = false;
  450. }
  451. if (config_raw.layout[layout_size_t.HEADER] == 1) {
  452. if (config_raw.touch_ui) {
  453. ui._w = math_floor(19 * sc);
  454. context_raw.sym_x = ui_check(sym_x_handle, "");
  455. ui._x -= 4 * sc;
  456. context_raw.sym_y = ui_check(sym_y_handle, "");
  457. ui._x -= 4 * sc;
  458. context_raw.sym_z = ui_check(sym_z_handle, "");
  459. ui._x -= 4 * sc;
  460. ui._w = math_floor(40 * sc);
  461. let x: string = tr("X");
  462. let y: string = tr("Y");
  463. let z: string = tr("Z");
  464. ui_text(x + y + z);
  465. }
  466. else {
  467. ui._w = math_floor(56 * sc);
  468. ui_text(tr("Symmetry"));
  469. ui._w = math_floor(25 * sc);
  470. context_raw.sym_x = ui_check(sym_x_handle, tr("X"));
  471. context_raw.sym_y = ui_check(sym_y_handle, tr("Y"));
  472. context_raw.sym_z = ui_check(sym_z_handle, tr("Z"));
  473. }
  474. ui._w = _w;
  475. }
  476. else {
  477. // Popup
  478. ui._w = _w;
  479. context_raw.sym_x = ui_check(sym_x_handle, tr("Symmetry") + " " + tr("X"));
  480. context_raw.sym_y = ui_check(sym_y_handle, tr("Symmetry") + " " + tr("Y"));
  481. context_raw.sym_z = ui_check(sym_z_handle, tr("Symmetry") + " " + tr("Z"));
  482. }
  483. if (sym_x_handle.changed || sym_y_handle.changed || sym_z_handle.changed) {
  484. make_material_parse_paint_material();
  485. }
  486. }
  487. }
  488. if (context_raw.tool == tool_type_t.GIZMO) {
  489. if (!sim_running && ui_button("Play")) {
  490. sim_play();
  491. context_raw.selected_object = scene_camera.base;
  492. }
  493. if (sim_running && ui_button("Stop")) {
  494. sim_stop();
  495. }
  496. let h_record: ui_handle_t = ui_handle(__ID__);
  497. sim_record = ui_check(h_record, tr("Record"));
  498. }
  499. }