Added 'Show buttons on hover only' setting for preview buttons

This commit is contained in:
EtSL33py
2024-09-23 20:19:38 +03:00
parent b0913a73e4
commit 6fa3b357c3
3 changed files with 21 additions and 3 deletions

View File

@@ -190,6 +190,7 @@ def ui_rules():
Rule("model-show-copy-button", True, bool),
Rule("model-show-load-workflow-button", True, bool),
Rule("model-info-button-on-left", False, bool),
Rule("model-buttons-only-on-hover", False, bool),
Rule("model-add-embedding-extension", False, bool),
Rule("model-add-drag-strict-on-field", False, bool),

View File

@@ -492,7 +492,6 @@
.model-manager .comfy-grid .model-preview-top-right,
.model-manager .comfy-grid .model-preview-top-left {
position: absolute;
display: flex;
flex-direction: column;
gap: 8px;
top: 8px;
@@ -506,6 +505,15 @@
left: 8px;
}
.model-manager .item .model-buttons-hidden {
display: none;
}
.model-manager .item:hover .model-buttons-hidden,
.model-manager .comfy-grid .model-buttons-visible {
display: flex;
}
.model-manager .comfy-grid .model-button {
opacity: 0.65;
}

View File

@@ -2044,6 +2044,8 @@ class ModelGrid {
Math.round(settingsElements['model-preview-thumbnail-width'].value / 0.75);
const previewThumbnailHeight =
Math.round(settingsElements['model-preview-thumbnail-height'].value / 0.75);
const buttonsOnlyOnHover =
settingsElements['model-buttons-only-on-hover'].checked;
if (models.length > 0) {
const $overlay = IS_FIREFOX
@@ -2085,6 +2087,8 @@ class ModelGrid {
draggable: true,
});
});
const forHiddingButtonsClass = buttonsOnlyOnHover
? 'model-buttons-hidden' : 'model-buttons-visible';
return models.map((item) => {
const previewInfo = item.preview;
@@ -2182,14 +2186,14 @@ class ModelGrid {
strictDragToAdd,
),
$el(
'div.model-preview-top-right',
'div.model-preview-top-right.' + forHiddingButtonsClass,
{
draggable: false,
},
modelInfoButtonOnLeft ? infoButtons : actionButtons,
),
$el(
'div.model-preview-top-left',
'div.model-preview-top-left.' + forHiddingButtonsClass,
{
draggable: false,
},
@@ -4372,6 +4376,7 @@ class SettingsView {
/** @type {HTMLInputElement} */ 'model-show-copy-button': null,
/** @type {HTMLInputElement} */ 'model-show-load-workflow-button': null,
/** @type {HTMLInputElement} */ 'model-info-button-on-left': null,
/** @type {HTMLInputElement} */ 'model-buttons-only-on-hover': null,
/** @type {HTMLInputElement} */ 'model-add-embedding-extension': null,
/** @type {HTMLInputElement} */ 'model-add-drag-strict-on-field': null,
@@ -4690,6 +4695,10 @@ class SettingsView {
$: (el) => (settings['model-info-button-on-left'] = el),
textContent: '"Model Info" button on left',
}),
$checkbox({
$: (el) => (settings['model-buttons-only-on-hover'] = el),
textContent: 'Show buttons on hover only',
}),
$el('h2', ['Node Graph']),
$checkbox({
$: (el) => (settings['model-add-embedding-extension'] = el),