paint: add set source button to clone tool

This commit is contained in:
luboslenco
2026-08-12 12:55:24 +02:00
parent cd6fc93995
commit 0977f045b0
3 changed files with 23 additions and 4 deletions
+1
View File
@@ -44,6 +44,7 @@ void context_init() {
g_context->clone_start_y = -1.0;
g_context->clone_delta_x = 0.0;
g_context->clone_delta_y = 0.0;
g_context->clone_set_source = false;
g_context->show_compass = true;
g_context->last_paint_vec_x = -1.0;
g_context->last_paint_vec_y = -1.0;
+6
View File
@@ -478,6 +478,12 @@ void ui_header_draw_tool_properties() {
}
}
if (g_context->tool == TOOL_TYPE_CLONE) {
if (ui_button(g_context->clone_set_source ? tr("Setting Source") : tr("Set Source"), UI_ALIGN_CENTER, "")) {
g_context->clone_set_source = !g_context->clone_set_source;
}
}
if (g_context->tool == TOOL_TYPE_BLUR) {
string_array_t *blur_type_combo = any_array_create_from_raw(
(void *[]){
+16 -4
View File
@@ -1,14 +1,19 @@
#include "../global.h"
static bool util_brush_clone_source_down = false;
void util_brush_update() {
bool paint_down = operator_shortcut(any_map_get(g_keymap, "action_paint"), SHORTCUT_TYPE_DOWN);
bool set_clone_source =
g_context->tool == TOOL_TYPE_CLONE &&
operator_shortcut(string("%s+%s", any_map_get(g_keymap, "set_clone_source"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN);
(operator_shortcut(string("%s+%s", any_map_get(g_keymap, "set_clone_source"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN) ||
(g_context->clone_set_source && (paint_down || pen_down("tip"))));
bool decal_mask = context_is_decal_mask_paint();
bool down = operator_shortcut(any_map_get(g_keymap, "action_paint"), SHORTCUT_TYPE_DOWN) || decal_mask || set_clone_source ||
bool down = paint_down || decal_mask || set_clone_source ||
operator_shortcut(string("%s+%s", any_map_get(g_keymap, "brush_ruler"), any_map_get(g_keymap, "action_paint")), SHORTCUT_TYPE_DOWN) ||
(pen_down("tip") && !keyboard_down("alt"));
@@ -42,8 +47,9 @@ void util_brush_update() {
if (mx < ww && mx > sys_x() && my < sys_h() && my > sys_y()) {
if (set_clone_source) {
g_context->clone_start_x = mx;
g_context->clone_start_y = my;
g_context->clone_start_x = mx;
g_context->clone_start_y = my;
util_brush_clone_source_down = true;
}
else {
if (g_context->brush_time == 0 && !base_is_dragging && !base_is_resizing && g_ui->combo_selected_handle == NULL) { // Paint started
@@ -83,4 +89,10 @@ void util_brush_update() {
sys_notify_on_next_frame(&ui_base_update_ui_on_next_frame, NULL);
}
}
if (util_brush_clone_source_down && !paint_down && !pen_down("tip")) {
util_brush_clone_source_down = false;
g_context->clone_set_source = false;
ui_header_handle->redraws = 2;
}
}