Change "Filter" menu to "Tools"

Add separator lines to preview angles menu
This commit is contained in:
JannisX11 2021-11-20 16:17:13 +01:00
parent 03f1f7e65e
commit 53c3fa5535
9 changed files with 46 additions and 10 deletions

View File

@ -518,6 +518,10 @@
margin-left: 6px;
pointer-events: none;
}
.contextMenu li.enabled {
padding-left: 29px;
border-left: 5px solid var(--color-accent);
}
.contextMenu li.focused, .contextMenu li.parent.opened {
background-color: var(--color-accent);
}

View File

@ -290,11 +290,11 @@ const Blockbench = {
console.warn('Blockbench.addMenuEntry is deprecated. Please use Actions instead.')
let id = name.replace(/\s/g, '').toLowerCase();
var action = new Action(id, {icon: icon, name: name, click: click})
MenuBar.addAction(action, 'filter')
MenuBar.addAction(action, 'tools')
},
removeMenuEntry(name) {
let id = name.replace(/\s/g, '').toLowerCase();
MenuBar.removeAction('filter.'+id);
MenuBar.removeAction('tools.'+id);
},
openLink(link) {
if (isApp) {

View File

@ -390,7 +390,7 @@ class Tool extends Action {
if (BARS.condition(this.condition, this)) {
this.select()
return true;
} else if (event.type.includes('key') && this.modes) {
} else if (this.modes) {
for (var i = 0; i < this.modes.length; i++) {
var mode = Modes.options[this.modes[i]]
if (mode && Condition(mode.condition)) {
@ -1470,7 +1470,7 @@ const BARS = {
new Action('swap_tools', {
icon: 'swap_horiz',
category: 'tools',
condition: {modes: ['edit', 'paint', 'display']},
condition: {modes: ['edit', 'paint', 'display'], project: true},
keybind: new Keybind({key: 32}),
click: function () {
if (BarItems[Toolbox.selected.alt_tool] && Condition(BarItems[Toolbox.selected.alt_tool].condition)) {

View File

@ -683,10 +683,34 @@ const MenuBar = {
condition: {modes: ['display']}
})
new BarMenu('filter', [
new BarMenu('tools', [
{id: 'main_tools', icon: 'construction', name: 'Toolbox', condition: () => Project, children() {
let tools = Toolbox.children.filter(tool => tool instanceof Tool);
tools.forEach(tool => {
let old_condition = tool.condition;
tool.condition = () => {
tool.condition = old_condition;
return true;
}
})
let modes = Object.keys(Modes.options);
tools.sort((a, b) => modes.indexOf(a.modes[0]) - modes.indexOf(b.modes[0]))
let mode = tools[0].modes[0];
for (let i = 0; i < tools.length; i++) {
if (tools[i].modes[0] !== mode) {
mode = tools[i].modes[0];
tools.splice(i, 0, '_');
i++;
}
}
return tools;
}},
'swap_tools',
'_',
'convert_to_mesh',
'remove_blank_faces',
])
MenuBar.menus.filter = MenuBar.menus.tools;
new BarMenu('animation', [
'copy',

View File

@ -1533,9 +1533,18 @@ class Preview {
]
let presets = localStorage.getItem('camera_presets')
presets = (presets && autoParseJSON(presets, false)) || [];
let all_presets = [...DefaultCameraPresets, ...presets];
let all_presets = [
DefaultCameraPresets[0], '_',
...DefaultCameraPresets.slice(1, 7), '_',
...DefaultCameraPresets.slice(7, 11), '_',
...DefaultCameraPresets.slice(11), '_',
...presets
];
all_presets.forEach(preset => {
if (typeof preset == 'string') {
children.push('_'); return;
}
let icon = typeof preset.locked_angle ? 'videocam' : (preset.locked_angle == preview.angle ? 'radio_button_checked' : 'radio_button_unchecked');
children.push({
name: preset.name,

View File

@ -1736,7 +1736,6 @@ BARS.defineActions(function() {
new Action('remove_blank_faces', {
icon: 'cancel_presentation',
category: 'filter',
condition: () => !Format.box_uv,
click: function () {
let elements = Outliner.selected.filter(el => el.faces);

View File

@ -40,6 +40,7 @@ const Condition = function(condition, context) {
if (condition.formats instanceof Array && condition.formats.includes(Format.id) === false) return false;
if (condition.tools instanceof Array && window.Toolbox && condition.tools.includes(Toolbox.selected.id) === false) return false;
if (condition.features instanceof Array && Format && condition.features.find(feature => !Format[feature])) return false;
if (condition.project && !Project) return false;
if (condition.method instanceof Function) {
return !!condition.method(context);

File diff suppressed because one or more lines are too long

View File

@ -725,7 +725,6 @@
"category.transform": "Transform",
"category.color": "Color",
"category.paint": "Paint",
"category.filter": "Filter",
"category.view": "View",
"category.display": "Display Settings",
"category.animation": "Animation",
@ -1275,7 +1274,7 @@
"menu.file": "File",
"menu.edit": "Edit",
"menu.transform": "Transform",
"menu.filter": "Filter",
"menu.tools": "Tools",
"menu.display": "Display",
"menu.animation": "Animation",
"menu.view": "View",