From 89a6476bac26df4257931ffcecbe86b29d47ebdd Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 11 Mar 2026 15:24:56 +0100 Subject: [PATCH] paint: implement workspace radio --- paint/sources/base.c | 36 ++++++++++++++++++++++++++++++++++++ paint/sources/enums.h | 14 ++++++++------ paint/sources/functions.h | 5 ++++- paint/sources/ui_sidebar.c | 28 ++++++++++++++++++---------- paint/sources/ui_view2d.c | 11 ++++++++++- 5 files changed, 76 insertions(+), 18 deletions(-) diff --git a/paint/sources/base.c b/paint/sources/base.c index 21e38a48..5062e957 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -104,6 +104,13 @@ void base_init() { args_run(); + if (config_raw->workspace != WORKSPACE_PAINT_3D) { + base_update_workspace(); + } + if (config_raw->workflow != WORKFLOW_PBR) { + base_update_workflow(); + } + bool has_projects = config_raw->recent_projects->length > 0; if (config_raw->splash_screen && has_projects) { box_projects_show(); @@ -2100,7 +2107,36 @@ void ui_base_set_viewport_col(i32 col) { } void base_update_workspace() { + if (config_raw->workspace == WORKSPACE_PAINT_3D || config_raw->workspace == WORKSPACE_SCULPT) { + base_view3d_show = true; + ui_menubar_tab->i = 0; + ui_view2d_show = false; + ui_nodes_show = false; + ui_sidebar_show(true); + } + else if (config_raw->workspace == WORKSPACE_PAINT_2D) { + base_view3d_show = false; + ui_menubar_tab->i = -1; + ui_view2d_show = true; + ui_nodes_show = false; + ui_sidebar_show(true); + } + else if (config_raw->workspace == WORKSPACE_NODES) { + base_view3d_show = false; + ui_menubar_tab->i = -1; + ui_view2d_show = false; + ui_nodes_show = true; + ui_sidebar_show(false); + } + else if (config_raw->workspace == WORKSPACE_SCRIPT) { + base_view3d_show = false; + ui_menubar_tab->i = -1; + ui_view2d_show = false; + ui_nodes_show = false; + ui_sidebar_show(false); + } + base_resize(); } void base_update_workflow() { diff --git a/paint/sources/enums.h b/paint/sources/enums.h index 321a6eaa..dc9ac2d2 100644 --- a/paint/sources/enums.h +++ b/paint/sources/enums.h @@ -72,7 +72,9 @@ typedef enum { typedef enum { WORKSPACE_PAINT_3D = 0, WORKSPACE_PAINT_2D = 1, - WORKSPACE_SCULPT = 2, + WORKSPACE_NODES = 2, + WORKSPACE_SCRIPT = 3, + WORKSPACE_SCULPT = 4, } workspace_t; typedef enum { @@ -218,11 +220,11 @@ typedef enum { typedef enum { PAINT_TEX_BASE = 0, - PAINT_TEX_NORMAL = 1, - PAINT_TEX_OCCLUSION = 2, - PAINT_TEX_ROUGHNESS = 3, - PAINT_TEX_METALLIC = 4, - PAINT_TEX_OPACITY = 5, + PAINT_TEX_OPACITY = 1, + PAINT_TEX_NORMAL = 2, + PAINT_TEX_OCCLUSION = 3, + PAINT_TEX_ROUGHNESS = 4, + PAINT_TEX_METALLIC = 5, PAINT_TEX_HEIGHT = 6, } paint_tex_t; diff --git a/paint/sources/functions.h b/paint/sources/functions.h index c3f2f60f..deac056f 100644 --- a/paint/sources/functions.h +++ b/paint/sources/functions.h @@ -1,9 +1,9 @@ #pragma once -#include #include "enums.h" #include "types.h" +#include f32 ui_MENUBAR_H(ui_t *ui); f32 ui_nodes_INPUT_Y(ui_node_canvas_t *canvas, ui_node_t *node, i32 pos); @@ -177,6 +177,8 @@ void base_on_resize(); void base_save_window_rect(); void base_resize(); void base_update(void *_); +void base_update_workspace(); +void base_update_workflow(); void base_material_dropped(); void base_handle_drop_paths(); rect_t *base_get_drag_background(); @@ -742,6 +744,7 @@ raw_mesh_t *geom_make_plane(f32 size_x, f32 size_y, i32 verts_x raw_mesh_t *geom_make_uv_sphere(f32 radius, i32 width_segments, i32 height_segments, bool stretch_uv, f32 uv_scale); node_shader_context_t *make_mesh_run(material_t *data, i32 layer_pass); void ui_sidebar_render_ui(); +void ui_sidebar_show(bool b); void console_draw_toast(char *s); void console_toast(char *s); void console_draw_progress(void *_); diff --git a/paint/sources/ui_sidebar.c b/paint/sources/ui_sidebar.c index 3fb47676..2f058109 100644 --- a/paint/sources/ui_sidebar.c +++ b/paint/sources/ui_sidebar.c @@ -17,9 +17,7 @@ void ui_sidebar_render_ui() { ui->ops->theme->TEXT_COL = ui->ops->theme->HOVER_COL; if (ui_button("<", UI_ALIGN_CENTER, "")) { - config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = context_raw->maximized_sidebar_width != 0 - ? context_raw->maximized_sidebar_width - : math_floor(ui_sidebar_default_w * config_raw->window_scale); + ui_sidebar_show(true); } ui->ops->theme->BUTTON_H = _BUTTON_H; ui->ops->theme->BUTTON_COL = _BUTTON_COL; @@ -33,14 +31,14 @@ void ui_sidebar_render_ui() { i32 expand_button_offset = config_raw->touch_ui ? math_floor(UI_ELEMENT_H() + UI_ELEMENT_OFFSET()) : 0; ui_sidebar_tabx = iron_window_width() - config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W]; - i32 _SCROLL_W = ui->ops->theme->SCROLL_W; + i32 _SCROLL_W = ui->ops->theme->SCROLL_W; if (mini) { ui->ops->theme->SCROLL_W = ui->ops->theme->SCROLL_MINI_W; } i32 sidebar_y = 0; - #ifdef IRON_IOS +#ifdef IRON_IOS if (config_is_iphone()) { sidebar_y += UI_ELEMENT_H() + UI_ELEMENT_OFFSET(); ui_end(); @@ -50,7 +48,7 @@ void ui_sidebar_render_ui() { draw_end(); ui_begin(ui); } - #endif +#endif if (ui_window(ui_base_hwnds->buffer[TAB_AREA_SIDEBAR0], ui_sidebar_tabx, sidebar_y, config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W], config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_H0] - sidebar_y, false)) { @@ -65,10 +63,7 @@ void ui_sidebar_render_ui() { if (!config_raw->touch_ui && !mini) { if (ui_tab(ui_base_htabs->buffer[TAB_AREA_SIDEBAR0], ">", false, -2, false)) { - ui_base_htabs->buffer[TAB_AREA_SIDEBAR0]->i = ui_sidebar_last_tab; - config_raw->layout_tabs->buffer[TAB_AREA_SIDEBAR0] = ui_sidebar_last_tab; - context_raw->maximized_sidebar_width = config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W]; - config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = 0; + ui_sidebar_show(false); } } } @@ -102,3 +97,16 @@ void ui_sidebar_render_ui() { } } } + +void ui_sidebar_show(bool b) { + if (b) { + config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = + context_raw->maximized_sidebar_width != 0 ? context_raw->maximized_sidebar_width : math_floor(ui_sidebar_default_w * config_raw->window_scale); + } + else { + ui_base_htabs->buffer[TAB_AREA_SIDEBAR0]->i = ui_sidebar_last_tab; + config_raw->layout_tabs->buffer[TAB_AREA_SIDEBAR0] = ui_sidebar_last_tab; + context_raw->maximized_sidebar_width = config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W]; + config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] = 0; + } +} diff --git a/paint/sources/ui_view2d.c b/paint/sources/ui_view2d.c index 0e364b48..57e4b5ac 100644 --- a/paint/sources/ui_view2d.c +++ b/paint/sources/ui_view2d.c @@ -323,14 +323,23 @@ void ui_view2d_render(void *_) { string_t_array_t *tex_type_combo = any_array_create_from_raw( (void *[]){ tr("Base Color", NULL), + tr("Opacity", NULL), tr("Normal Map", NULL), tr("Occlusion", NULL), tr("Roughness", NULL), tr("Metallic", NULL), - tr("Opacity", NULL), tr("Height", NULL), }, 7); + + if (config_raw->workflow == WORKFLOW_BASE) { + array_splice(tex_type_combo, 6, 1); + array_splice(tex_type_combo, 5, 1); + array_splice(tex_type_combo, 4, 1); + array_splice(tex_type_combo, 3, 1); + array_splice(tex_type_combo, 2, 1); + } + ui_view2d_tex_type = ui_combo(h_tex_type, tex_type_combo, tr("Texture", NULL), false, UI_ALIGN_LEFT, true); ui->_x += ew + 3; ui->_y = 2 + start_y;