From 473c47506ce0c1412ded3fb0204432e0d68b295f Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 27 Apr 2024 13:49:09 -0400 Subject: [PATCH] add style apply/save --- CHANGELOG.md | 1 + extensions-builtin/sdnext-modernui | 2 +- javascript/extraNetworks.js | 1 + modules/ui_extra_networks.py | 4 +++- modules/ui_sections.py | 6 ++++-- modules/ui_symbols.py | 2 ++ 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 241685db4..785b05b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ it is time to give credit to original [author](https://github.com/auTOMATIC1111) **Standard* (built-in themes), **Modern** (experimental nextgen ui), **None** (used for Gradio and Huggingface 3rd party themes) Specifying a theme type updates list of available themes For example, *Gradio* themes will not appear as available if theme type is set to *Standard* + - Minor tweaks to styles: refresh/apply/save - See details in [WiKi](https://github.com/vladmandic/automatic/wiki/Themes) - **API**: - Add API endpoint `/sdapi/v1/control` and CLI util `cli/simple-control.py` diff --git a/extensions-builtin/sdnext-modernui b/extensions-builtin/sdnext-modernui index 6b8890131..a579e3380 160000 --- a/extensions-builtin/sdnext-modernui +++ b/extensions-builtin/sdnext-modernui @@ -1 +1 @@ -Subproject commit 6b8890131a1fe8eb5111ff2ba021c9ae7c808a3e +Subproject commit a579e3380439c3bfd5703fced0a5da5cf235feb2 diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index 96ac263a4..45ab26c45 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -308,6 +308,7 @@ function quickApplyStyle() { } function quickSaveStyle() { + console.log('HERE'); const tabname = getENActiveTab(); const btnSave = gradioApp().getElementById(`${tabname}_extra_quicksave`); if (btnSave) btnSave.click(); diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index eb293283e..7183b11e9 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -284,7 +284,7 @@ class ExtraNetworksPage: r = random.randint(100, 255) g = random.randint(100, 255) b = random.randint(100, 255) - return '#{:02x}{:02x}{:02x}'.format(r, g, b) + return '#{:02x}{:02x}{:02x}'.format(r, g, b) # pylint: disable=consider-using-f-string try: args = { @@ -883,6 +883,8 @@ def create_ui(container, button_parent, tabname, skip_indexing = False): return res def ui_quicksave_click(name): + if name is None: + return from modules import generation_parameters_copypaste fn = os.path.join(paths.data_path, "params.txt") if os.path.exists(fn): diff --git a/modules/ui_sections.py b/modules/ui_sections.py index 44e44b5f2..844cf468d 100644 --- a/modules/ui_sections.py +++ b/modules/ui_sections.py @@ -48,10 +48,12 @@ def create_toprow(is_img2img: bool = False, id_part: str = None): with gr.Row(elem_id=f"{id_part}_styles_row"): styles = gr.Dropdown(label="Styles", elem_id=f"{id_part}_styles", choices=[style.name for style in shared.prompt_styles.styles.values()], value=[], multiselect=True) _styles_btn_refresh = ui_common.create_refresh_button(styles, shared.prompt_styles.reload, lambda: {"choices": [style.name for style in shared.prompt_styles.styles.values()]}, f"{id_part}_styles_refresh") - styles_btn_select = gr.Button('Select', elem_id=f"{id_part}_styles_select", visible=False) + styles_btn_select = ToolButton('Select', elem_id=f"{id_part}_styles_select", visible=False) + styles_btn_apply = ToolButton(ui_symbols.style_apply, elem_id=f"{id_part}_styles_apply", visible=True) + styles_btn_save = ToolButton(ui_symbols.style_save, elem_id=f"{id_part}_styles_save", visible=True) styles_btn_select.click(_js="applyStyles", fn=parse_style, inputs=[styles], outputs=[styles]) - styles_btn_apply = ToolButton(ui_symbols.apply, elem_id=f"{id_part}_extra_apply", visible=False) styles_btn_apply.click(fn=apply_styles, inputs=[prompt, negative_prompt, styles], outputs=[prompt, negative_prompt, styles]) + styles_btn_save.click(fn=lambda: None, _js='() => quickSaveStyle()', inputs=[], outputs=[]) return prompt, styles, negative_prompt, submit, button_paste, button_extra, token_counter, token_button, negative_token_counter, negative_token_button diff --git a/modules/ui_symbols.py b/modules/ui_symbols.py index ff59973a6..7a999bad2 100644 --- a/modules/ui_symbols.py +++ b/modules/ui_symbols.py @@ -37,6 +37,8 @@ sort_num_asc = '\uf162' sort_num_dsc = '\uf163' sort_time_asc = '\uf0de' sort_time_dsc = '\uf0dd' +style_apply = '↶' +style_save = '↷' """ refresh = '🔄' close = '🛗'