Skip to content

Commit

Permalink
Change mac icon
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JannisX11 committed Mar 11, 2022
1 parent ec5bb87 commit e1c9d55
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 142 deletions.
Binary file modified build/icon.icns
Binary file not shown.
4 changes: 2 additions & 2 deletions js/interface/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 2 additions & 4 deletions js/interface/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
'_',
Expand Down
7 changes: 4 additions & 3 deletions js/interface/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion js/outliner/outliner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
127 changes: 12 additions & 115 deletions js/texturing/edit_texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -41,21 +41,22 @@ 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: {
change() {
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});
})
Expand All @@ -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()">
Expand All @@ -135,15 +83,15 @@ BARS.defineActions(function() {
`
},
onConfirm() {
Undo.finishEdit('Invert colors');
Undo.finishEdit('Adjust brightness and contrast');
},
onCancel() {
Undo.cancelEdit();
}
}).show();
}
})
new Action('adjust_saturation', {
new Action('adjust_saturation_hue', {
icon: 'fa-tint',
category: 'textures',
condition: {modes: ['paint'], method: () => Texture.all.length},
Expand All @@ -162,14 +110,15 @@ BARS.defineActions(function() {
data() {return {
show_preview,
saturation: 100,
hue: 0,
textures
}},
methods: {
change() {
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});
})
Expand All @@ -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()">
Expand All @@ -249,7 +145,7 @@ BARS.defineActions(function() {
`
},
onConfirm() {
Undo.finishEdit('Invert colors');
Undo.finishEdit('Adjust saturation and hue');
},
onCancel() {
Undo.cancelEdit();
Expand Down Expand Up @@ -373,7 +269,6 @@ BARS.defineActions(function() {
curves[key] = new THREE.SplineCurve(vectors);
}
}
console.log(curves)

textures.forEach((texture, i) => {
texture.edit((canvas) => {
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 14 additions & 8 deletions js/texturing/uv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
},
Expand Down Expand Up @@ -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;
Expand All @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion js/webpack/bundle.js

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
Expand Down

0 comments on commit e1c9d55

Please sign in to comment.