Skip to content

Commit

Permalink
adjusting the ui of the spine preview
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxHuang committed Jan 24, 2025
1 parent 8de922e commit 66ba98b
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions editor/inspector/assets/spine-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ exports.template = /* html */`
</ui-checkbox>
</div>
</ui-prop>
<ui-prop class="time-scale-prop">
<ui-label slot="label" value="i18n:ENGINE.inspector.spine.timeScale"></ui-label>
<div slot="content">
<ui-slider class="timeScale" value="1"></ui-slider>
<ui-button class="reset-timeScale">
<ui-icon value="reset"></ui-icon>
</ui-button>
</div>
</ui-prop>
<ui-prop hidden>
<ui-label slot="label" value="Track"></ui-label>
<ui-radio-group slot="content" class="track-group"></ui-radio-group>
</ui-prop>
</div>
<inspector-resize-preview></inspector-resize-preview>
<div class="buttons-group">
Expand All @@ -70,10 +84,6 @@ exports.template = /* html */`
<ui-icon value="forward"></ui-icon>
</ui-button>
</div>
<ui-prop>
<ui-label slot="label" value="i18n:ENGINE.inspector.spine.timeScale"></ui-label>
<ui-slider slot="content" class="timeScale" value="1"></ui-slider>
</ui-prop>
</div>
<ui-scale-plate class="duration"></ui-scale-plate>
</div>
Expand Down Expand Up @@ -101,6 +111,14 @@ exports.style = /* css */`
& > .attribute {
padding-bottom: 4px;
& > .time-scale-prop [slot="content"] {
display: flex;
& > .timeScale {
flex: 1;
}
}
}
& > .duration[disabled] {
Expand Down Expand Up @@ -141,7 +159,9 @@ exports.$ = {

...Object.fromEntries(Properties.map((key) => [key, `.${key}`])),

resetTimeScale: '.reset-timeScale',
buttonsGroup: '.buttons-group',
trackGroup: '.track-group',
};

const Elements = {
Expand All @@ -160,6 +180,18 @@ const Elements = {
},
},
spine: {
updateTrackGroup(trackGroupElement, index, total) {
trackGroupElement.innerHTML = '';
trackGroupElement.setAttribute('value', index);
for (let i = 0; i < total; i++) {
const item = document.createElement('ui-radio-button');
item.setAttribute('value', i.toString());
trackGroupElement.appendChild(item);
const label = document.createElement('ui-label');
label.setAttribute('value', i.toString());
item.appendChild(label);
}
},
updateEnum($selectPro, info, cb) {
$selectPro.innerHTML = '';
for (const key in info.list) {
Expand Down Expand Up @@ -187,6 +219,13 @@ const Elements = {
panel.$.duration.addEventListener('confirm', (event) => {
panel.preview.callPreviewFunction('setCurrentTime', Number(event.target.value));
});
panel.$.resetTimeScale.addEventListener('click', (event) => {
panel.$.timeScale.setAttribute('value', 1 + '');
panel.preview.callPreviewFunction('setProperties', 'timeScale', 1);
});
panel.$.trackGroup.addEventListener('change', (event) => {
panel.preview.callPreviewFunction('setTrackIndex', Number(event.target.value));
});

panel.spinUpdate = Elements.spine.update.bind(panel);
},
Expand All @@ -201,6 +240,7 @@ const Elements = {
if (!info) { return; }

Elements.control.updateState(panel);
Elements.spine.updateTrackGroup(panel.$.trackGroup, info.trackIndex, info.trackTotals);
Elements.spine.updateEnum(panel.$.skin, info.skin);
Elements.spine.updateEnum(panel.$.animation, info.animation, (value) => {
panel.animationIndex = value;
Expand Down

0 comments on commit 66ba98b

Please sign in to comment.