mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-04-06 17:31:09 +08:00
Change mac icon
Fix text pasting not working on mobile Combine brightness+contrast, saturation+hue dialogs Fix issue with UV editor scaling Add ctrl key to move floating panels without snapping
This commit is contained in:
parent
ec5bb874a8
commit
e1c9d555c1
BIN
build/icon.icns
BIN
build/icon.icns
Binary file not shown.
@ -449,8 +449,8 @@ function setupInterface() {
|
||||
}
|
||||
])
|
||||
|
||||
$(document).on('contextmenu', function(event) {
|
||||
if (!$(event.target).hasClass('allow_default_menu')) {
|
||||
document.addEventListener('contextmenu', (event) => {
|
||||
if (!$(event.target).hasClass('allow_default_menu') && event instanceof PointerEvent == false) {
|
||||
if (event.target.nodeName === 'INPUT' && $(event.target).is(':focus')) {
|
||||
Interface.text_edit_menu.open(event, event.target)
|
||||
}
|
||||
|
@ -760,10 +760,8 @@ const MenuBar = {
|
||||
condition: {modes: ['edit']}
|
||||
})
|
||||
new BarMenu('texture', [
|
||||
'adjust_brightness',
|
||||
'adjust_contrast',
|
||||
'adjust_saturation',
|
||||
'adjust_hue',
|
||||
'adjust_brightness_contrast',
|
||||
'adjust_saturation_hue',
|
||||
'invert_colors',
|
||||
'adjust_curves',
|
||||
'_',
|
||||
|
@ -181,7 +181,8 @@ class Panel {
|
||||
let threshold_y = 64;
|
||||
target_slot = null; target_panel = null; target_before = false;
|
||||
|
||||
if (e2.clientX < Math.max(Interface.left_bar_width, threshold)) {
|
||||
if (e2.ctrlOrCmd) {
|
||||
} else if (e2.clientX < Math.max(Interface.left_bar_width, threshold)) {
|
||||
|
||||
let y = Interface.work_screen.offsetTop;
|
||||
target_slot = 'left_bar';
|
||||
@ -342,12 +343,12 @@ class Panel {
|
||||
];
|
||||
let resize = (e1, direction_x, direction_y) => {
|
||||
let position_before = this.position_data.float_position.slice();
|
||||
let size_before = this.position_data.float_size.slice();
|
||||
let size_before = [this.width, this.height];
|
||||
let started = false;
|
||||
|
||||
let drag = e2 => {
|
||||
convertTouchEvent(e2);
|
||||
if (!started && (Math.pow(e2.clientX - e1.clientX, 2) + Math.pow(e2.clientX - e1.clientX, 2)) > 15) {
|
||||
if (!started && (Math.pow(e2.clientX - e1.clientX, 2) + Math.pow(e2.clientY - e1.clientY, 2)) > 12) {
|
||||
started = true;
|
||||
}
|
||||
if (!started) return;
|
||||
|
@ -290,8 +290,9 @@ class OutlinerNode {
|
||||
let zero_based = this.name.match(/[^\d]0$/) !== null;
|
||||
var name = this.name.replace(/\d+$/, '').replace(/\s+/g, '_');
|
||||
function check(n) {
|
||||
let n_lower = n.toLowerCase();
|
||||
for (var i = 0; i < others.length; i++) {
|
||||
if (others[i] !== scope && others[i].name.toLowerCase() == n.toLowerCase()) return false;
|
||||
if (others[i] !== scope && others[i].name.toLowerCase() === n_lower) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ BARS.defineActions(function() {
|
||||
Undo.finishEdit('Invert colors')
|
||||
}
|
||||
})
|
||||
new Action('adjust_brightness', {
|
||||
new Action('adjust_brightness_contrast', {
|
||||
icon: 'brightness_high',
|
||||
category: 'textures',
|
||||
condition: {modes: ['paint'], method: () => Texture.all.length},
|
||||
@ -41,13 +41,14 @@ BARS.defineActions(function() {
|
||||
Undo.initEdit({textures, bitmap: true});
|
||||
|
||||
new Dialog({
|
||||
id: 'adjust_brightness',
|
||||
name: 'action.adjust_brightness',
|
||||
id: 'adjust_brightness_contrast',
|
||||
name: 'action.adjust_brightness_contrast',
|
||||
darken: false,
|
||||
component: {
|
||||
data() {return {
|
||||
show_preview,
|
||||
brightness: 100,
|
||||
contrast: 100,
|
||||
textures
|
||||
}},
|
||||
methods: {
|
||||
@ -55,7 +56,7 @@ BARS.defineActions(function() {
|
||||
textures.forEach((texture, i) => {
|
||||
texture.edit((canvas) => {
|
||||
let ctx = canvas.getContext('2d');
|
||||
ctx.filter = `brightness(${this.brightness / 100})`;
|
||||
ctx.filter = `brightness(${this.brightness / 100}) contrast(${this.contrast / 100})`;
|
||||
ctx.drawImage(original_imgs[i], 0, 0);
|
||||
}, {no_undo: true, use_cache: true});
|
||||
})
|
||||
@ -74,59 +75,6 @@ BARS.defineActions(function() {
|
||||
<input type="range" class="tool" min="0" max="200" step="1" v-model="brightness" @input="change()">
|
||||
<input lang="en" type="number" class="tool" min="0" max="200" step="1" v-model.number="brightness" @input="change()">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
onConfirm() {
|
||||
Undo.finishEdit('Invert colors');
|
||||
},
|
||||
onCancel() {
|
||||
Undo.cancelEdit();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
new Action('adjust_contrast', {
|
||||
icon: 'brightness_6',
|
||||
category: 'textures',
|
||||
condition: {modes: ['paint'], method: () => Texture.all.length},
|
||||
click() {
|
||||
let textures = getTextures();
|
||||
let original_imgs = textures.map(tex => {
|
||||
return tex.img.cloneNode();
|
||||
})
|
||||
Undo.initEdit({textures, bitmap: true});
|
||||
|
||||
new Dialog({
|
||||
id: 'adjust_contrast',
|
||||
name: 'action.adjust_contrast',
|
||||
darken: false,
|
||||
component: {
|
||||
data() {return {
|
||||
show_preview,
|
||||
contrast: 100,
|
||||
textures
|
||||
}},
|
||||
methods: {
|
||||
change() {
|
||||
textures.forEach((texture, i) => {
|
||||
texture.edit((canvas) => {
|
||||
let ctx = canvas.getContext('2d');
|
||||
ctx.filter = `contrast(${this.contrast / 100})`;
|
||||
ctx.drawImage(original_imgs[i], 0, 0);
|
||||
}, {no_undo: true, use_cache: true});
|
||||
})
|
||||
},
|
||||
togglePreview() {
|
||||
this.show_preview = show_preview = !this.show_preview;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div>
|
||||
<div class="texture_adjust_previews checkerboard" :class="{folded: !show_preview}">
|
||||
<img v-for="texture in textures" :src="texture.source" />
|
||||
</div>
|
||||
<div class="tool texture_adjust_preview_toggle" @click="togglePreview()"><i class="material-icons">{{ show_preview ? 'expand_more' : 'expand_less' }}</i></div>
|
||||
<div class="bar slider_input_combo">
|
||||
<input type="range" class="tool" min="0" max="200" step="1" v-model="contrast" @input="change()">
|
||||
<input lang="en" type="number" class="tool" min="0" max="200" step="1" v-model.number="contrast" @input="change()">
|
||||
@ -135,7 +83,7 @@ BARS.defineActions(function() {
|
||||
`
|
||||
},
|
||||
onConfirm() {
|
||||
Undo.finishEdit('Invert colors');
|
||||
Undo.finishEdit('Adjust brightness and contrast');
|
||||
},
|
||||
onCancel() {
|
||||
Undo.cancelEdit();
|
||||
@ -143,7 +91,7 @@ BARS.defineActions(function() {
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
new Action('adjust_saturation', {
|
||||
new Action('adjust_saturation_hue', {
|
||||
icon: 'fa-tint',
|
||||
category: 'textures',
|
||||
condition: {modes: ['paint'], method: () => Texture.all.length},
|
||||
@ -162,6 +110,7 @@ BARS.defineActions(function() {
|
||||
data() {return {
|
||||
show_preview,
|
||||
saturation: 100,
|
||||
hue: 0,
|
||||
textures
|
||||
}},
|
||||
methods: {
|
||||
@ -169,7 +118,7 @@ BARS.defineActions(function() {
|
||||
textures.forEach((texture, i) => {
|
||||
texture.edit((canvas) => {
|
||||
let ctx = canvas.getContext('2d');
|
||||
ctx.filter = `saturate(${this.saturation / 100})`;
|
||||
ctx.filter = `saturate(${this.saturation / 100}) hue-rotate(${this.hue}deg)`;
|
||||
ctx.drawImage(original_imgs[i], 0, 0);
|
||||
}, {no_undo: true, use_cache: true});
|
||||
})
|
||||
@ -188,59 +137,6 @@ BARS.defineActions(function() {
|
||||
<input type="range" class="tool" min="0" max="200" step="1" v-model="saturation" @input="change()">
|
||||
<input lang="en" type="number" class="tool" min="0" max="200" step="1" v-model.number="saturation" @input="change()">
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
onConfirm() {
|
||||
Undo.finishEdit('Invert colors');
|
||||
},
|
||||
onCancel() {
|
||||
Undo.cancelEdit();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
})
|
||||
new Action('adjust_hue', {
|
||||
icon: 'fa-swatchbook',
|
||||
category: 'textures',
|
||||
condition: {modes: ['paint'], method: () => Texture.all.length},
|
||||
click() {
|
||||
let textures = getTextures();
|
||||
let original_imgs = textures.map(tex => {
|
||||
return tex.img.cloneNode();
|
||||
})
|
||||
Undo.initEdit({textures, bitmap: true});
|
||||
|
||||
new Dialog({
|
||||
id: 'adjust_hue',
|
||||
name: 'action.adjust_hue',
|
||||
darken: false,
|
||||
component: {
|
||||
data() {return {
|
||||
show_preview,
|
||||
hue: 0,
|
||||
textures
|
||||
}},
|
||||
methods: {
|
||||
change() {
|
||||
textures.forEach((texture, i) => {
|
||||
texture.edit((canvas) => {
|
||||
let ctx = canvas.getContext('2d');
|
||||
ctx.filter = `hue-rotate(${this.hue}deg)`;
|
||||
ctx.drawImage(original_imgs[i], 0, 0);
|
||||
}, {no_undo: true, use_cache: true});
|
||||
})
|
||||
},
|
||||
togglePreview() {
|
||||
this.show_preview = show_preview = !this.show_preview;
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div>
|
||||
<div class="texture_adjust_previews checkerboard" :class="{folded: !show_preview}">
|
||||
<img v-for="texture in textures" :src="texture.source" />
|
||||
</div>
|
||||
<div class="tool texture_adjust_preview_toggle" @click="togglePreview()"><i class="material-icons">{{ show_preview ? 'expand_more' : 'expand_less' }}</i></div>
|
||||
<div class="bar slider_input_combo">
|
||||
<input type="range" class="tool" min="-180" max="180" step="1" v-model="hue" @input="change()">
|
||||
<input lang="en" type="number" class="tool" min="-180" max="180" step="1" v-model.number="hue" @input="change()">
|
||||
@ -249,7 +145,7 @@ BARS.defineActions(function() {
|
||||
`
|
||||
},
|
||||
onConfirm() {
|
||||
Undo.finishEdit('Invert colors');
|
||||
Undo.finishEdit('Adjust saturation and hue');
|
||||
},
|
||||
onCancel() {
|
||||
Undo.cancelEdit();
|
||||
@ -373,7 +269,6 @@ BARS.defineActions(function() {
|
||||
curves[key] = new THREE.SplineCurve(vectors);
|
||||
}
|
||||
}
|
||||
console.log(curves)
|
||||
|
||||
textures.forEach((texture, i) => {
|
||||
texture.edit((canvas) => {
|
||||
@ -411,6 +306,8 @@ BARS.defineActions(function() {
|
||||
},
|
||||
dragPoint(point, e1) {
|
||||
let scope = this;
|
||||
let {points} = this.graphs[this.graph];
|
||||
if (point == points[0] || point == points.last()) return;
|
||||
let original_point = point.slice();
|
||||
|
||||
function drag(e2) {
|
||||
|
@ -1736,7 +1736,7 @@ Interface.definePanels(function() {
|
||||
inner_width() {
|
||||
let axis = this.project_resolution[0] / this.project_resolution[1] < this.width / this.height;
|
||||
if (axis) {
|
||||
return this.height * this.zoom * (this.project_resolution[1] / this.project_resolution[0]);
|
||||
return this.height * this.zoom * (this.project_resolution[0] / this.project_resolution[1]);
|
||||
} else {
|
||||
return this.width * this.zoom;
|
||||
}
|
||||
@ -1746,7 +1746,7 @@ Interface.definePanels(function() {
|
||||
if (axis) {
|
||||
return this.height * this.zoom;
|
||||
} else {
|
||||
return this.width * this.zoom * (this.project_resolution[1] / this.project_resolution[0]);
|
||||
return this.width * this.zoom * (this.project_resolution[0] / this.project_resolution[1]);
|
||||
}
|
||||
},
|
||||
mappable_elements() {
|
||||
@ -1800,11 +1800,14 @@ Interface.definePanels(function() {
|
||||
slider.setWidth(slider_bar_width / (Project.box_uv?2:4)-1);
|
||||
}
|
||||
if (this.$refs.viewport && this.zoom == 1 && ((!this.$refs.viewport.scrollLeft && !this.$refs.viewport.scrollTop) || this.centered_view)) {
|
||||
this.$refs.viewport.scrollLeft = this.width/2;
|
||||
this.$refs.viewport.scrollTop = this.height/2;
|
||||
this.centered_view = true;
|
||||
this.centerView();
|
||||
}
|
||||
},
|
||||
centerView() {
|
||||
this.$refs.viewport.scrollLeft = this.width/2;
|
||||
this.$refs.viewport.scrollTop = this.height/2;
|
||||
this.centered_view = true;
|
||||
},
|
||||
setMode(mode) {
|
||||
this.mode = mode;
|
||||
},
|
||||
@ -1858,8 +1861,8 @@ Interface.definePanels(function() {
|
||||
let original_margin = this.getFrameMargin();
|
||||
var n = (event.deltaY < 0) ? 0.1 : -0.1;
|
||||
n *= this.zoom
|
||||
let min = Math.min(1, this.inner_width/this.inner_height)
|
||||
var number = Math.clamp(this.zoom + n, min, this.max_zoom)
|
||||
var number = Math.clamp(this.zoom + n, 0.5, this.max_zoom)
|
||||
if (number > 1 && number < 1.1) number = 1;
|
||||
let old_zoom = this.zoom;
|
||||
|
||||
this.zoom = number;
|
||||
@ -1877,7 +1880,10 @@ Interface.definePanels(function() {
|
||||
|
||||
viewport.scrollLeft += ((viewport.scrollLeft + offsetX) * zoom_diff) / old_zoom + margin[0] - original_margin[0];
|
||||
viewport.scrollTop += ((viewport.scrollTop + offsetY) * zoom_diff) / old_zoom + margin[1] - original_margin[1];
|
||||
|
||||
|
||||
if (this.zoom == 1) {
|
||||
this.centerView();
|
||||
}
|
||||
this.updateMouseCoords(event)
|
||||
if (Painter.selection.overlay) UVEditor.updatePastingOverlay()
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
12
lang/en.json
12
lang/en.json
@ -1113,14 +1113,10 @@
|
||||
"action.merge_meshes": "Merge Meshes",
|
||||
"action.merge_meshes.desc": "Merge multiple meshes into one",
|
||||
|
||||
"action.adjust_brightness": "Adjust Brightness...",
|
||||
"action.adjust_brightness.desc": "Adjust the brightness of the selected texture",
|
||||
"action.adjust_contrast": "Adjust Contrast...",
|
||||
"action.adjust_contrast.desc": "Adjust the contrast of the selected texture",
|
||||
"action.adjust_saturation": "Adjust Saturation...",
|
||||
"action.adjust_saturation.desc": "Adjust the saturation of the selected texture",
|
||||
"action.adjust_hue": "Adjust Hue...",
|
||||
"action.adjust_hu.desce": "Adjust Hue",
|
||||
"action.adjust_brightness_contrast": "Adjust Brightness & Contrast...",
|
||||
"action.adjust_brightness_contrast.desc": "Adjust the brightness and contrast of the selected texture",
|
||||
"action.adjust_saturation_hue": "Adjust Saturation & Hue...",
|
||||
"action.adjust_saturation_hue.desc": "Adjust the saturation and hue of the selected texture",
|
||||
"action.invert_colors": "Invert Colors",
|
||||
"action.invert_colors.desc": "Invert all colors of the selected texture",
|
||||
"action.adjust_curves": "Adjust Curves...",
|
||||
|
Loading…
x
Reference in New Issue
Block a user