diff --git a/modules_forge/forge_canvas/canvas.css b/modules_forge/forge_canvas/canvas.css index bc32583d..7c461eec 100644 --- a/modules_forge/forge_canvas/canvas.css +++ b/modules_forge/forge_canvas/canvas.css @@ -5,6 +5,16 @@ overflow: hidden; } +.forge-image-container-plain { + width: 100%; + height: calc(100% - 6px); + position: relative; + overflow: hidden; + background-color: #202020; + background-size: 20px 20px; + background-position: 0 0, 10px 10px; +} + .forge-image-container { width: 100%; height: calc(100% - 6px); @@ -48,6 +58,16 @@ left: 0; } +.forge-toolbar-static { + position: absolute; + top: 0px; + left: 0px; + z-index: 10 !important; + background: rgba(47, 47, 47, 0.8); + padding: 6px 10px; + opacity: 1.0 !important; +} + .forge-toolbar { position: absolute; top: 0px; @@ -59,7 +79,7 @@ transition: opacity 0.3s ease; } -.forge-toolbar .forge-btn { +.forge-toolbar .forge-btn, .forge-toolbar-static .forge-btn { padding: 2px 6px; border: none; background-color: #4a4a4a; @@ -69,11 +89,11 @@ transition: background-color 0.3s ease; } -.forge-toolbar .forge-btn:hover { +.forge-toolbar .forge-btn, .forge-toolbar-static .forge-btn:hover { background-color: #5e5e5e; } -.forge-toolbar .forge-btn:active { +.forge-toolbar .forge-btn, .forge-toolbar-static .forge-btn:active { background-color: #3e3e3e; } @@ -156,4 +176,4 @@ width: 30%; height: 30%; transform: translate(-50%, -50%); -} +} \ No newline at end of file diff --git a/modules_forge/forge_canvas/canvas.py b/modules_forge/forge_canvas/canvas.py index a343f27e..88649312 100644 --- a/modules_forge/forge_canvas/canvas.py +++ b/modules_forge/forge_canvas/canvas.py @@ -32,6 +32,7 @@ from io import BytesIO from gradio.context import Context from functools import wraps +from modules.shared import opts canvas_js_root_path = os.path.dirname(__file__) @@ -136,7 +137,15 @@ class ForgeCanvas: elem_classes=None ): self.uuid = 'uuid_' + uuid.uuid4().hex - self.block = gr.HTML(canvas_html.replace('forge_mixin', self.uuid), visible=visible, elem_id=elem_id, elem_classes=elem_classes) + + canvas_html_uuid = canvas_html.replace('forge_mixin', self.uuid) + + if opts.forge_canvas_plain: + canvas_html_uuid = canvas_html_uuid.replace('class="forge-image-container"', 'class="forge-image-container-plain"').replace('stroke="white"', 'stroke=#444') + if opts.forge_canvas_toolbar_always: + canvas_html_uuid = canvas_html_uuid.replace('class="forge-toolbar"', 'class="forge-toolbar-static"') + + self.block = gr.HTML(canvas_html_uuid, visible=visible, elem_id=elem_id, elem_classes=elem_classes) self.foreground = LogicalImage(visible=DEBUG_MODE, label='foreground', numpy=numpy, elem_id=self.uuid, elem_classes=['logical_image_foreground']) self.background = LogicalImage(visible=DEBUG_MODE, label='background', numpy=numpy, value=initial_image, elem_id=self.uuid, elem_classes=['logical_image_background']) Context.root_block.load(None, js=f'async ()=>{{new ForgeCanvas("{self.uuid}", {no_upload}, {no_scribbles}, {contrast_scribbles}, {height}, ' diff --git a/modules_forge/shared_options.py b/modules_forge/shared_options.py index e7ae3578..51a33ae7 100644 --- a/modules_forge/shared_options.py +++ b/modules_forge/shared_options.py @@ -1,4 +1,3 @@ - def register(options_templates, options_section, OptionInfo): options_templates.update(options_section((None, "Forge Hidden options"), { "forge_unet_storage_dtype": OptionInfo('Automatic'), @@ -8,3 +7,7 @@ def register(options_templates, options_section, OptionInfo): "forge_preset": OptionInfo('sd'), "forge_additional_modules": OptionInfo([]), })) + options_templates.update(options_section(('ui_alternatives', "UI alternatives", "ui"), { + "forge_canvas_plain": OptionInfo(False, "ForgeCanvas: use plain background").needs_reload_ui(), + "forge_canvas_toolbar_always": OptionInfo(False, "ForgeCanvas: toolbar always visible").needs_reload_ui(), + }))