Add action to cycle between tabs

Make Center View on Selection work in display mode, closes #1117
This commit is contained in:
JannisX11 2022-04-24 17:26:47 +02:00
parent 9334e9649e
commit 70e27ad555
3 changed files with 27 additions and 3 deletions

View File

@ -876,4 +876,20 @@ BARS.defineActions(function() {
dialog.show()
}
})
new Action('switch_tabs', {
icon: 'swap_horiz',
category: 'file',
keybind: new Keybind({key: 9, ctrl: true, shift: null}),
condition: () => ModelProject.all.length > 1,
click(event) {
let index = ModelProject.all.indexOf(Project);
let target;
if (event && event.shiftKey) {
target = ModelProject.all[index-1] || ModelProject.all.last();
} else {
target = ModelProject.all[index+1] || ModelProject.all[0];
}
if (target) target.select();
}
})
})

View File

@ -2110,15 +2110,21 @@ BARS.defineActions(function() {
new Action('focus_on_selection', {
icon: 'center_focus_weak',
category: 'view',
condition: () => !Modes.display,
click: function () {
if (!Project) return;
if (Prop.active_panel == 'uv') {
UVEditor.focusOnSelection()
} else {
let preview = quad_previews.current;
let center = new THREE.Vector3().fromArray(getSelectionCenter());
center.add(scene.position);
if (!preview.controls.enabled) return;
let center = new THREE.Vector3();
if (!Modes.display) {
center.fromArray(getSelectionCenter());
center.add(scene.position);
} else {
Transformer.getWorldPosition(center)
}
let difference = new THREE.Vector3().copy(preview.controls.target).sub(center);
difference.divideScalar(6)

View File

@ -896,6 +896,8 @@
"action.convert_project.desc": "Converts the current project to a project for another model format",
"action.close_project": "Close Project",
"action.close_project.desc": "Closes the currently open project",
"action.switch_tabs": "Switch Tabs",
"action.switch_tabs.desc": "Cycle between opened tabs. Hold shift to cycle in the opposite direction.",
"action.import_obj": "Import OBJ Model",
"action.import_obj.desc": "Imports objects from an OBJ model as meshes",
"action.import_java_block_model": "Add Java Block/Item Model",