Skip to content

Commit

Permalink
Fix context menus appearing in web app
Browse files Browse the repository at this point in the history
Add back "3D Preview" navigation button on mobile
Fix Canvas Unselect not working on touch screens
Fix #1216 Relative auto UV can go out of bounds
  • Loading branch information
JannisX11 committed Mar 30, 2022
1 parent cca7221 commit d3cd512
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
6 changes: 3 additions & 3 deletions js/interface/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,14 @@ function setupInterface() {
}
])

document.addEventListener('contextmenu', (event) => {
if (!$(event.target).hasClass('allow_default_menu') && event instanceof PointerEvent == false) {
document.oncontextmenu = function (event) {
if (!$(event.target).hasClass('allow_default_menu') && event instanceof TouchEvent == false) {
if (event.target.nodeName === 'INPUT' && $(event.target).is(':focus')) {
Interface.text_edit_menu.open(event, event.target)
}
return false;
}
})
}

//Scrolling
$('input[type="range"]').on('mousewheel', function () {
Expand Down
3 changes: 3 additions & 0 deletions js/interface/panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,9 @@ function setupMobilePanelSelector() {
},
template: `
<div id="panel_selector_bar">
<div class="panel_selector" :class="{selected: selected == null}" @click="select(null)">
<div class="icon_wrapper"><i class="material-icons icon">3d_rotation</i></div>
</div>
<div class="panel_selector" :class="{selected: selected == panel.id}" v-for="panel in panels()" v-if="Condition(panel.condition)" @click="select(panel)">
<div class="icon_wrapper" v-html="getIconNode(panel.icon).outerHTML"></div>
</div>
Expand Down
35 changes: 22 additions & 13 deletions js/outliner/cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,6 @@ class Cube extends OutlinerElement {
var ph = Project.texture_height;
if (scope.autouv === 2) {
//Relative UV
function gt(n) {
return (n+16)%16
}
var all_faces = ['north', 'south', 'west', 'east', 'up', 'down']
all_faces.forEach(function(side) {
var uv = scope.faces[side].uv.slice()
Expand Down Expand Up @@ -573,14 +570,28 @@ class Cube extends OutlinerElement {
];
break;
}
//var texture = scope.faces[side]
//var fr_u = 16 / Project.texture_width;
//var fr_v = 16 / Project.texture_height;
//uv.forEach(function(s, uvi) {
// s *= (uvi%2 ? fr_v : fr_u);
// uv[uvi] = limitNumber(s, 0, 16)
//})
scope.faces[side].uv = uv
// Clamp to UV map boundaries
if (Math.max(uv[0], uv[2]) > Project.texture_width) {
let offset = Math.max(uv[0], uv[2]) - Project.texture_width;
uv[0] -= offset;
uv[2] -= offset;
}
if (Math.min(uv[0], uv[2]) < 0) {
let offset = Math.min(uv[0], uv[2]);
uv[0] = Math.clamp(uv[0] - offset, 0, Project.texture_width);
uv[2] = Math.clamp(uv[2] - offset, 0, Project.texture_width);
}
if (Math.max(uv[1], uv[3]) > Project.texture_height) {
let offset = Math.max(uv[1], uv[3]) - Project.texture_height;
uv[1] -= offset;
uv[3] -= offset;
}
if (Math.min(uv[1], uv[3]) < 0) {
let offset = Math.min(uv[1], uv[3]);
uv[1] = Math.clamp(uv[1] - offset, 0, Project.texture_height);
uv[3] = Math.clamp(uv[3] - offset, 0, Project.texture_height);
}
scope.faces[side].uv = uv;
})
Canvas.updateUV(scope)
} else if (scope.autouv === 1) {
Expand All @@ -594,8 +605,6 @@ class Cube extends OutlinerElement {
if (rot === 90 || rot === 270) {
size.reverse()
}
//size[0] *= 16/Project.texture_width;
//size[1] *= 16/Project.texture_height;
//Limit Input to 16
size[0] = Math.clamp(size[0], -Project.texture_width, Project.texture_width)
size[1] = Math.clamp(size[1], -Project.texture_height, Project.texture_height)
Expand Down
8 changes: 7 additions & 1 deletion js/preview/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,13 @@ class Preview {
}
mouseup(event) {
this.showContextMenu(event);
if (settings.canvas_unselect.value && (event.which === 1 || event.which === 3) && this.controls.hasMoved === false && !this.selection.activated && !Transformer.dragging && !this.selection.click_target) {
if (settings.canvas_unselect.value &&
(event.which === 1 || event.which === 3 || event instanceof TouchEvent) &&
!this.controls.hasMoved &&
!this.selection.activated &&
!Transformer.dragging &&
!this.selection.click_target
) {
unselectAll();
}
delete this.selection.click_target;
Expand Down

0 comments on commit d3cd512

Please sign in to comment.