mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-01-26 19:09:45 +00:00
two options for Forge canvas toolbar (#2613)
This commit is contained in:
@@ -5,6 +5,16 @@
|
|||||||
overflow: hidden;
|
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 {
|
.forge-image-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: calc(100% - 6px);
|
height: calc(100% - 6px);
|
||||||
@@ -48,6 +58,16 @@
|
|||||||
left: 0;
|
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 {
|
.forge-toolbar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
@@ -59,7 +79,7 @@
|
|||||||
transition: opacity 0.3s ease;
|
transition: opacity 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.forge-toolbar .forge-btn {
|
.forge-toolbar .forge-btn, .forge-toolbar-static .forge-btn {
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
border: none;
|
border: none;
|
||||||
background-color: #4a4a4a;
|
background-color: #4a4a4a;
|
||||||
@@ -69,11 +89,11 @@
|
|||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.forge-toolbar .forge-btn:hover {
|
.forge-toolbar .forge-btn, .forge-toolbar-static .forge-btn:hover {
|
||||||
background-color: #5e5e5e;
|
background-color: #5e5e5e;
|
||||||
}
|
}
|
||||||
|
|
||||||
.forge-toolbar .forge-btn:active {
|
.forge-toolbar .forge-btn, .forge-toolbar-static .forge-btn:active {
|
||||||
background-color: #3e3e3e;
|
background-color: #3e3e3e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,4 +176,4 @@
|
|||||||
width: 30%;
|
width: 30%;
|
||||||
height: 30%;
|
height: 30%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ from io import BytesIO
|
|||||||
from gradio.context import Context
|
from gradio.context import Context
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
from modules.shared import opts
|
||||||
|
|
||||||
canvas_js_root_path = os.path.dirname(__file__)
|
canvas_js_root_path = os.path.dirname(__file__)
|
||||||
|
|
||||||
@@ -136,7 +137,15 @@ class ForgeCanvas:
|
|||||||
elem_classes=None
|
elem_classes=None
|
||||||
):
|
):
|
||||||
self.uuid = 'uuid_' + uuid.uuid4().hex
|
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.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'])
|
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}, '
|
Context.root_block.load(None, js=f'async ()=>{{new ForgeCanvas("{self.uuid}", {no_upload}, {no_scribbles}, {contrast_scribbles}, {height}, '
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
def register(options_templates, options_section, OptionInfo):
|
def register(options_templates, options_section, OptionInfo):
|
||||||
options_templates.update(options_section((None, "Forge Hidden options"), {
|
options_templates.update(options_section((None, "Forge Hidden options"), {
|
||||||
"forge_unet_storage_dtype": OptionInfo('Automatic'),
|
"forge_unet_storage_dtype": OptionInfo('Automatic'),
|
||||||
@@ -8,3 +7,7 @@ def register(options_templates, options_section, OptionInfo):
|
|||||||
"forge_preset": OptionInfo('sd'),
|
"forge_preset": OptionInfo('sd'),
|
||||||
"forge_additional_modules": OptionInfo([]),
|
"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(),
|
||||||
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user