diff --git a/paint/sources/base.c b/paint/sources/base.c index 90a211be..54933e84 100644 --- a/paint/sources/base.c +++ b/paint/sources/base.c @@ -582,9 +582,8 @@ void base_render(void *_) { if (context_raw->frame == 2) { make_material_parse_mesh_material(); make_material_parse_paint_material(true); - context_raw->ddirty = 0; - - // Mouse coords not updated during drag + context_raw->ddirty = 0; + context_raw->camera_pivot = config_raw->camera_pivot; context_raw->camera_controls = config_raw->camera_controls; } else if (context_raw->frame == 3) { @@ -1806,6 +1805,7 @@ void ui_base_render(void *_) { draw_image(img, base_view3d_w() / 2.0 - img->width / 2.0, base_h() / 2.0 - img->height / 2.0); draw_end(); } + ui_begin(ui); ui_toolbar_render_ui(); ui_menubar_render_ui(); diff --git a/paint/sources/box_preferences.c b/paint/sources/box_preferences.c index dee4fe21..02bf5dcc 100644 --- a/paint/sources/box_preferences.c +++ b/paint/sources/box_preferences.c @@ -338,6 +338,16 @@ void box_preferences_usage_tab() { ui_tooltip(tr("Dilate painted textures to prevent seams")); } + ui_handle_t *h_camera_pivot = ui_handle(__ID__); + h_camera_pivot->i = config_raw->camera_pivot; + string_t_array_t *camera_pivot_combo = any_array_create_from_raw( + (void *[]){ + tr("Cursor"), + tr("Center"), + }, + 2); + config_raw->camera_pivot = ui_combo(h_camera_pivot, camera_pivot_combo, tr("Default Camera Pivot"), true, UI_ALIGN_LEFT, true); + ui_handle_t *h_camera_controls = ui_handle(__ID__); h_camera_controls->i = config_raw->camera_controls; string_t_array_t *camera_controls_combo = any_array_create_from_raw( diff --git a/paint/sources/config.c b/paint/sources/config.c index 985264fe..7961bba3 100644 --- a/paint/sources/config.c +++ b/paint/sources/config.c @@ -92,6 +92,7 @@ void config_save() { else { json_encode_null("layout_tabs"); } + json_encode_i32("camera_pivot", config_raw->camera_pivot); json_encode_i32("camera_controls", config_raw->camera_controls); json_encode_string("server", config_raw->server); json_encode_i32("viewport_mode", config_raw->viewport_mode); @@ -207,6 +208,7 @@ void config_init() { config_raw->zoom_direction = ZOOM_DIRECTION_VERTICAL; config_raw->displace_strength = 0.0; config_raw->wrap_mouse = false; + config_raw->camera_pivot = CAMERA_PIVOT_CURSOR; config_raw->camera_controls = CAMERA_CONTROLS_ORBIT; config_raw->layer_res = TEXTURE_RES_RES2048; #if defined(IRON_ANDROID) || defined(IRON_IOS) diff --git a/paint/sources/context.c b/paint/sources/context.c index 2f84595d..0f9b1c70 100644 --- a/paint/sources/context.c +++ b/paint/sources/context.c @@ -56,6 +56,7 @@ context_t *context_create() { c->fov_handle = ui_handle_create(); c->texture_export_path = ""; c->last_status_position = 0; + c->camera_pivot = CAMERA_PIVOT_CURSOR; c->camera_controls = CAMERA_CONTROLS_ORBIT; c->pen_painting_only = false; // Reject painting with finger when using pen c->layer_preview_dirty = true; diff --git a/paint/sources/enums.h b/paint/sources/enums.h index 2ae28644..37ea89da 100644 --- a/paint/sources/enums.h +++ b/paint/sources/enums.h @@ -111,10 +111,10 @@ typedef enum { } export_destination_t; typedef enum { - PLAYER_TARGET_WEB = 0, + PLAYER_TARGET_WEB = 0, PLAYER_TARGET_WINDOWS = 1, - PLAYER_TARGET_LINUX = 2, - PLAYER_TARGET_MACOS = 3, + PLAYER_TARGET_LINUX = 2, + PLAYER_TARGET_MACOS = 3, } player_target_t; typedef enum { @@ -167,6 +167,11 @@ typedef enum { CAMERA_CONTROLS_FLY = 2, } camera_controls_t; +typedef enum { + CAMERA_PIVOT_CURSOR = 0, + CAMERA_PIVOT_CAMERA_CENTER = 1, +} camera_pivot_t; + typedef enum { CAMERA_TYPE_PERSPECTIVE = 0, CAMERA_TYPE_ORTHOGRAPHIC = 1, diff --git a/paint/sources/make_paint.c b/paint/sources/make_paint.c index 7eb8a476..e4c51b6d 100644 --- a/paint/sources/make_paint.c +++ b/paint/sources/make_paint.c @@ -503,7 +503,7 @@ node_shader_context_t *make_paint_run(material_t *data, material_context_t *matc } else { node_shader_write_frag(kong, string("output[0] = float4(%s, str + sample_undo.a * (1.0 - str));", - make_material_blend_mode(kong, context_raw->brush_blending, "sample_undo.rgb", "basecol", "opacity"))); + make_material_blend_mode(kong, context_raw->brush_blending, "sample_undo.rgb", "basecol", "str"))); } } node_shader_write_frag(kong, "output[1] = float4(nortan, matid);"); diff --git a/paint/sources/types.h b/paint/sources/types.h index afafe24c..ace9a332 100644 --- a/paint/sources/types.h +++ b/paint/sources/types.h @@ -113,7 +113,8 @@ typedef struct config { bool splash_screen; struct i32_array *layout; // Sizes struct i32_array *layout_tabs; // Active tabs - i32 camera_controls; // Orbit, rotate + i32 camera_pivot; // Cursor, camera center + i32 camera_controls; // Orbit, rotate, fly char *server; i32 viewport_mode; i32 pathtrace_mode; @@ -260,6 +261,7 @@ typedef struct context { struct ui_handle *fov_handle; char *texture_export_path; i32 last_status_position; + camera_pivot_t camera_pivot; camera_controls_t camera_controls; bool pen_painting_only; struct slot_material *material; diff --git a/paint/sources/ui_header.c b/paint/sources/ui_header.c index 2ecd6e47..0e12826d 100644 --- a/paint/sources/ui_header.c +++ b/paint/sources/ui_header.c @@ -25,6 +25,10 @@ void ui_header_render_ui() { i32 nodesw = (ui_nodes_show || ui_view2d_show) ? config_raw->layout->buffer[LAYOUT_SIZE_NODES_W] : 0; i32 ww = iron_window_width() - ui_toolbar_w(true) - config_raw->layout->buffer[LAYOUT_SIZE_SIDEBAR_W] - nodesw; + if (ui->is_typing) { + ui_header_handle->redraws = 2; + } + if (ui_window(ui_header_handle, base_x(), ui_header_h, ww, ui_header_h, false)) { ui->_y += 2; ui_header_draw_tool_properties(); diff --git a/paint/sources/ui_menubar.c b/paint/sources/ui_menubar.c index ddded2fe..1771e2a2 100644 --- a/paint/sources/ui_menubar.c +++ b/paint/sources/ui_menubar.c @@ -761,10 +761,10 @@ void ui_menubar_draw_category_items() { ui_handle_t *h = ui_handle(__ID__); string_t_array_t *pivot_center_items = any_array_create_from_raw( (void *[]){ - tr("Camera Center"), // tr("Paint Stroke") + tr("Cursor"), tr("Center"), }, - 1); - ui_inline_radio(h, pivot_center_items, UI_ALIGN_LEFT); + 2); + context_raw->camera_pivot = ui_inline_radio(h, pivot_center_items, UI_ALIGN_LEFT); ui_menu_separator(); ui_menu_align();