ui_header.ts 22 KB

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