added option visibleChildWidgets to INPUT.choose (#2215)

This commit is contained in:
ArnoldSmith86 2024-08-18 16:41:50 +02:00 committed by GitHub
parent 95cc48ed7d
commit b455f4cc53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 9 deletions

View File

@ -1755,7 +1755,7 @@ input:invalid+span::after, .inputError::before {
z-index: 2;
}
.inputchoose .widget {
.inputchoose .inputchooseWidgetWrapper > .widget {
position: relative !important;
transform-origin: top left !important;
z-index: 1 !important;

View File

@ -309,7 +309,7 @@ export function formField(field, dom, id) {
propertyOverride.activeFace = face;
const widgetContainer = div(input, 'inputchooseWidgetWrapper');
const widgetClone = widget.renderReadonlyCopy(propertyOverride, $('body'));
const widgetClone = widget.renderReadonlyCopy(propertyOverride, $('body'), field.visibleChildWidgets);
const widgetDOM = widgetClone.domElement;
widgetClone.state.scale = scale * (field.scale || 1);
widgetClone.domElement.style.cssText = mapAssetURLs(widgetClone.css());

View File

@ -1081,6 +1081,7 @@ function jeAddCommands() {
jeAddFieldCommand('faces', 'choose', null);
jeAddFieldCommand('scale', 'choose', 1);
jeAddFieldCommand('propertyOverride', 'choose', {});
jeAddFieldCommand('visibleChildWidgets', 'choose', false);
jeAddEnumCommands('^[a-z]+ ↦ type', widgetTypes.slice(1));
jeAddEnumCommands('^.*\\([A-Z]+\\) ↦ value', [ '${}' ]);

View File

@ -2374,12 +2374,14 @@ export class Widget extends StateManaged {
return readOnlyProperties;
}
renderReadonlyCopyRaw(state, target) {
renderReadonlyCopyRaw(state, target, isChild=false) {
delete state.id;
state.x = 0;
state.y = 0;
state.rotation = 0;
state.scale = 1;
if(!isChild) {
state.x = 0;
state.y = 0;
state.rotation = 0;
state.scale = 1;
}
state.parent = null;
state.owner = null;
state.linkedToSeat = null;
@ -2392,8 +2394,15 @@ export class Widget extends StateManaged {
return this;
}
renderReadonlyCopy(propertyOverride, target) {
return new this.constructor(generateUniqueWidgetID()).renderReadonlyCopyRaw(Object.assign({}, this.state, propertyOverride), target);
renderReadonlyCopy(propertyOverride, target, includeChildren=false, isChild=false) {
const newID = generateUniqueWidgetID();
const newWidget = new this.constructor(newID);
newWidget.renderReadonlyCopyRaw(Object.assign({}, this.state, propertyOverride), target, isChild);
if(includeChildren)
for(const child of widgetFilter(w=>w.get('parent') == this.id))
if(this.get('type') != 'holder' || !compareDropTarget(child, this) || includeChildren == 'all')
child.renderReadonlyCopy({}, newWidget.domElement, includeChildren, true);
return newWidget;
}
requiresHiddenCursor() {