Change img rectangle selection behavior

Add setting to return to old behavior
This commit is contained in:
Jannis 2022-08-04 16:40:12 +02:00
parent af97b8a302
commit 51a868eb34
3 changed files with 18 additions and 6 deletions

View File

@ -276,11 +276,12 @@ const Settings = {
}});
//Snapping
new Setting('edit_size', {category: 'snapping', value: 16, type: 'number'});
new Setting('shift_size', {category: 'snapping', value: 64, type: 'number'});
new Setting('ctrl_size', {category: 'snapping', value: 160, type: 'number'});
new Setting('edit_size', {category: 'snapping', value: 16, type: 'number'});
new Setting('shift_size', {category: 'snapping', value: 64, type: 'number'});
new Setting('ctrl_size', {category: 'snapping', value: 160, type: 'number'});
new Setting('ctrl_shift_size', {category: 'snapping', value: 640, type: 'number'});
new Setting('negative_size',{category: 'snapping', value: false});
new Setting('negative_size', {category: 'snapping', value: false});
new Setting('nearest_rectangle_select',{category: 'snapping', value: false});
//Paint
new Setting('sync_color', {category: 'paint', value: false});

View File

@ -63,8 +63,13 @@ const UVEditor = {
}
if (Toolbox.selected.id === 'copy_paste_tool') {
result.x = Math.round(mouse_coords[0]/pixel_size*1);
result.y = Math.round(mouse_coords[1]/pixel_size*1);
if (settings.nearest_rectangle_select.value) {
result.x = Math.round(mouse_coords[0]/pixel_size*1);
result.y = Math.round(mouse_coords[1]/pixel_size*1);
} else {
result.x = Math.floor(mouse_coords[0]/pixel_size*1 + 0.06);
result.y = Math.floor(mouse_coords[1]/pixel_size*1 + 0.06);
}
} else {
let offset = BarItems.slider_brush_size.get()%2 == 0 && Toolbox.selected.brush?.offset_even_radius ? 0.5 : 0;
result.x = mouse_coords[0]/pixel_size*1 + offset;
@ -177,6 +182,10 @@ const UVEditor = {
let m = UVEditor.inner_width / UVEditor.texture.width;
if (!Painter.selection.overlay) {
if (!settings.nearest_rectangle_select.value) {
if (x >= Painter.selection.start_x) x++;
if (y >= Painter.selection.start_y) y++;
}
if (x === Painter.current.x && y === Painter.current.y) return;
Painter.current.x = x = Math.clamp(x, 0, UVEditor.texture.img.naturalWidth);
Painter.current.y = y = Math.clamp(y, 0, UVEditor.texture.img.naturalHeight);

View File

@ -761,6 +761,8 @@
"settings.ctrl_shift_size.desc": "Resolution of the grid while holding control and shift",
"settings.negative_size": "Negative Size",
"settings.negative_size.desc": "Allow the resize tool to use negative sizes",
"settings.nearest_rectangle_select": "Rectangle Seletion: Nearest Edge",
"settings.nearest_rectangle_select.desc": "Snap rectangle selections to the nearest pixel edge, like in GIMP, instead of entire pixels.",
"settings.sync_color": "Sync Color",
"settings.sync_color.desc": "Synchronize the color between different Blockbench instances",