mirror of
https://github.com/Doodle3D/Doodle3D-Core.git
synced 2024-12-22 11:03:48 +01:00
fix context menu
This commit is contained in:
parent
0360c677c7
commit
b1dd09b2ad
BIN
img/contextmenu/btnHole.png
Normal file
BIN
img/contextmenu/btnHole.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
img/contextmenu/btnSolid.png
Normal file
BIN
img/contextmenu/btnSolid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -148,8 +148,8 @@ function renderChildren(children) {
|
|||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, menus) {
|
function filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, menus) {
|
||||||
const showUnion = activeTool === d2Tools.TRANSFORM && allObjectsAreFilled && numSelectedObjects >= 2;
|
const showUnion = activeTool === d2Tools.TRANSFORM && numFilledObjects && numSelectedObjects >= 2;
|
||||||
const showIntersect = activeTool === d2Tools.TRANSFORM && numSelectedObjects >= 1;
|
const showIntersect = activeTool === d2Tools.TRANSFORM && numSelectedObjects >= 1;
|
||||||
return {
|
return {
|
||||||
...menus,
|
...menus,
|
||||||
@ -166,9 +166,11 @@ function filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, menus)
|
|||||||
|
|
||||||
case contextTools.DUPLICATE:
|
case contextTools.DUPLICATE:
|
||||||
case contextTools.DELETE:
|
case contextTools.DELETE:
|
||||||
case contextTools.FILL_TOGGLE:
|
|
||||||
return numSelectedObjects > 0;
|
return numSelectedObjects > 0;
|
||||||
|
|
||||||
|
case contextTools.FILL_TOGGLE:
|
||||||
|
return numSelectedObjects > 0 && numSolidObjects === numSelectedObjects;
|
||||||
|
|
||||||
case contextTools.ALIGN:
|
case contextTools.ALIGN:
|
||||||
return numSelectedObjects > 1;
|
return numSelectedObjects > 1;
|
||||||
|
|
||||||
@ -183,11 +185,14 @@ function filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, menus)
|
|||||||
case contextTools.BRUSH_SIZE:
|
case contextTools.BRUSH_SIZE:
|
||||||
return activeTool === d2Tools.BRUSH;
|
return activeTool === d2Tools.BRUSH;
|
||||||
|
|
||||||
|
case contextTools.HOLE_TOGGLE:
|
||||||
|
return numSelectedObjects > 0 && numFilledObjects === numSelectedObjects;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).map(child => {
|
}).map(child => {
|
||||||
return filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, child);
|
return filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, child);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -206,13 +211,14 @@ function nestChildren(menus, target) {
|
|||||||
|
|
||||||
const getMenus = createSelector([
|
const getMenus = createSelector([
|
||||||
state => state.sketcher.present.menus,
|
state => state.sketcher.present.menus,
|
||||||
|
state => state.sketcher.present.d2.tool,
|
||||||
state => state.sketcher.present.selection.objects.length,
|
state => state.sketcher.present.selection.objects.length,
|
||||||
state => state.sketcher.present.selection.objects.every(({ id }) => state.sketcher.present.objectsById[id].fill),
|
state => state.sketcher.present.selection.objects.filter(({ id }) => state.sketcher.present.objectsById[id].fill).length,
|
||||||
state => state.sketcher.present.d2.tool
|
state => state.sketcher.present.selection.objects.filter(({ id }) => state.sketcher.present.objectsById[id].solid).length
|
||||||
], (menus, numSelectedObjects, allObjectsAreFilled, activeTool) => ({
|
], (menus, activeTool, numSelectedObjects, numFilledObjects, numSolidObjects) => ({
|
||||||
toolbar2d: filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, nestChildren(menus, menus[TOOLBAR2D])),
|
toolbar2d: filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, nestChildren(menus, menus[TOOLBAR2D])),
|
||||||
toolbar3d: filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, nestChildren(menus, menus[TOOLBAR3D])),
|
toolbar3d: filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, nestChildren(menus, menus[TOOLBAR3D])),
|
||||||
context: filterMenus(numSelectedObjects, allObjectsAreFilled, activeTool, nestChildren(menus, menus[CONTEXT]))
|
context: filterMenus(activeTool, numSelectedObjects, numFilledObjects, numSolidObjects, nestChildren(menus, menus[CONTEXT]))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const style = document.createElement('style');
|
const style = document.createElement('style');
|
||||||
@ -404,13 +410,13 @@ style.innerHTML = `
|
|||||||
height: 41px;
|
height: 41px;
|
||||||
}
|
}
|
||||||
#hole-toggle-solid, #hole-toggle-solid-menu {
|
#hole-toggle-solid, #hole-toggle-solid-menu {
|
||||||
background-image: url('../img/contextmenu/btnShapeFill.png');
|
background-image: url('../img/contextmenu/btnSolid.png');
|
||||||
background-size: 33px auto;
|
background-size: 33px auto;
|
||||||
width: 33px;
|
width: 33px;
|
||||||
height: 41px;
|
height: 41px;
|
||||||
}
|
}
|
||||||
#hole-toggle-hole, #hole-toggle-hole-menu {
|
#hole-toggle-hole, #hole-toggle-hole-menu {
|
||||||
background-image: url('../img/contextmenu/btnShapeOutline.png');
|
background-image: url('../img/contextmenu/btnHole.png');
|
||||||
background-size: 33px auto;
|
background-size: 33px auto;
|
||||||
width: 33px;
|
width: 33px;
|
||||||
height: 41px;
|
height: 41px;
|
||||||
|
@ -114,7 +114,8 @@ export default function (state, action) {
|
|||||||
|
|
||||||
return update(state, {
|
return update(state, {
|
||||||
objectsById: state.selection.objects.reduce((updateObject, { id }) => {
|
objectsById: state.selection.objects.reduce((updateObject, { id }) => {
|
||||||
updateObject[id] = { solid: { $set: solid } };
|
const { fill } = state.objectsById[id];
|
||||||
|
if (fill) updateObject[id] = { solid: { $set: solid } };
|
||||||
return updateObject;
|
return updateObject;
|
||||||
}, {})
|
}, {})
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user