Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
0995e879
Commit
0995e879
authored
Oct 27, 2022
by
Florian Horn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added save button and shortcut (s) to Modal View
parent
737eb28f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
5 deletions
+50
-5
imageviewer.js
javascript/imageviewer.js
+29
-0
ui.py
modules/ui.py
+5
-3
style.css
style.css
+16
-2
No files found.
javascript/imageviewer.js
View file @
0995e879
...
@@ -81,6 +81,25 @@ function modalImageSwitch(offset) {
...
@@ -81,6 +81,25 @@ function modalImageSwitch(offset) {
}
}
}
}
function
saveImage
(){
const
tabTxt2Img
=
gradioApp
().
getElementById
(
"tab_txt2img"
)
const
tabImg2Img
=
gradioApp
().
getElementById
(
"tab_img2img"
)
const
saveTxt2Img
=
"save_txt2img"
const
saveImg2Img
=
"save_img2img"
if
(
tabTxt2Img
.
style
[
"display"
]
!=
"none"
)
{
gradioApp
().
getElementById
(
saveTxt2Img
).
click
()
}
else
if
(
tabImg2Img
.
style
[
"display"
]
!=
"none"
)
{
gradioApp
().
getElementById
(
saveImg2Img
).
click
()
}
else
{
console
.
error
(
"missing implementation for saving modal of this type"
)
}
}
function
modalSaveImage
(
event
)
{
saveImage
()
event
.
stopPropagation
()
}
function
modalNextImage
(
event
)
{
function
modalNextImage
(
event
)
{
modalImageSwitch
(
1
)
modalImageSwitch
(
1
)
event
.
stopPropagation
()
event
.
stopPropagation
()
...
@@ -93,6 +112,9 @@ function modalPrevImage(event) {
...
@@ -93,6 +112,9 @@ function modalPrevImage(event) {
function
modalKeyHandler
(
event
)
{
function
modalKeyHandler
(
event
)
{
switch
(
event
.
key
)
{
switch
(
event
.
key
)
{
case
"s"
:
saveImage
()
break
;
case
"ArrowLeft"
:
case
"ArrowLeft"
:
modalPrevImage
(
event
)
modalPrevImage
(
event
)
break
;
break
;
...
@@ -198,6 +220,13 @@ document.addEventListener("DOMContentLoaded", function() {
...
@@ -198,6 +220,13 @@ document.addEventListener("DOMContentLoaded", function() {
modalTileImage
.
title
=
"Preview tiling"
;
modalTileImage
.
title
=
"Preview tiling"
;
modalControls
.
appendChild
(
modalTileImage
)
modalControls
.
appendChild
(
modalTileImage
)
const
modalSave
=
document
.
createElement
(
"span"
)
modalSave
.
className
=
"modalSave cursor"
modalSave
.
innerHTML
=
"🖫"
modalSave
.
addEventListener
(
"click"
,
modalSaveImage
,
true
)
modalSave
.
title
=
"Save Image(s)"
modalControls
.
appendChild
(
modalSave
)
const
modalClose
=
document
.
createElement
(
'span'
)
const
modalClose
=
document
.
createElement
(
'span'
)
modalClose
.
className
=
'modalClose cursor'
;
modalClose
.
className
=
'modalClose cursor'
;
modalClose
.
innerHTML
=
'×'
modalClose
.
innerHTML
=
'×'
...
...
modules/ui.py
View file @
0995e879
...
@@ -630,7 +630,7 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -630,7 +630,7 @@ def create_ui(wrap_gradio_gpu_call):
import
modules.img2img
import
modules.img2img
import
modules.txt2img
import
modules.txt2img
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
False
)
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
txt2img_paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
False
)
dummy_component
=
gr
.
Label
(
visible
=
False
)
dummy_component
=
gr
.
Label
(
visible
=
False
)
...
@@ -683,7 +683,8 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -683,7 +683,8 @@ def create_ui(wrap_gradio_gpu_call):
with
gr
.
Column
():
with
gr
.
Column
():
with
gr
.
Row
():
with
gr
.
Row
():
save
=
gr
.
Button
(
'Save'
)
saveButtonId
=
'save_txt2img'
save
=
gr
.
Button
(
'Save'
,
elem_id
=
saveButtonId
)
send_to_img2img
=
gr
.
Button
(
'Send to img2img'
)
send_to_img2img
=
gr
.
Button
(
'Send to img2img'
)
send_to_inpaint
=
gr
.
Button
(
'Send to inpaint'
)
send_to_inpaint
=
gr
.
Button
(
'Send to inpaint'
)
send_to_extras
=
gr
.
Button
(
'Send to extras'
)
send_to_extras
=
gr
.
Button
(
'Send to extras'
)
...
@@ -901,7 +902,8 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -901,7 +902,8 @@ def create_ui(wrap_gradio_gpu_call):
with
gr
.
Column
():
with
gr
.
Column
():
with
gr
.
Row
():
with
gr
.
Row
():
save
=
gr
.
Button
(
'Save'
)
saveButtonId
=
'save_img2img'
save
=
gr
.
Button
(
'Save'
,
elem_id
=
saveButtonId
)
img2img_send_to_img2img
=
gr
.
Button
(
'Send to img2img'
)
img2img_send_to_img2img
=
gr
.
Button
(
'Send to img2img'
)
img2img_send_to_inpaint
=
gr
.
Button
(
'Send to inpaint'
)
img2img_send_to_inpaint
=
gr
.
Button
(
'Send to inpaint'
)
img2img_send_to_extras
=
gr
.
Button
(
'Send to extras'
)
img2img_send_to_extras
=
gr
.
Button
(
'Send to extras'
)
...
...
style.css
View file @
0995e879
...
@@ -314,8 +314,8 @@ input[type="range"]{
...
@@ -314,8 +314,8 @@ input[type="range"]{
.modalControls
{
.modalControls
{
display
:
grid
;
display
:
grid
;
grid-template-columns
:
32px
auto
1
fr
32px
;
grid-template-columns
:
32px
auto
32px
1
fr
32px
;
grid-template-areas
:
"zoom tile space close"
;
grid-template-areas
:
"zoom tile s
ave s
pace close"
;
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
0
;
left
:
0
;
left
:
0
;
...
@@ -333,6 +333,10 @@ input[type="range"]{
...
@@ -333,6 +333,10 @@ input[type="range"]{
grid-area
:
zoom
;
grid-area
:
zoom
;
}
}
.modalSave
{
grid-area
:
save
;
}
.modalTileImage
{
.modalTileImage
{
grid-area
:
tile
;
grid-area
:
tile
;
}
}
...
@@ -346,8 +350,18 @@ input[type="range"]{
...
@@ -346,8 +350,18 @@ input[type="range"]{
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.modalSave
{
color
:
white
;
font-size
:
30px
;
margin-top
:
6px
;
font-weight
:
bold
;
cursor
:
pointer
;
}
.modalClose
:hover
,
.modalClose
:hover
,
.modalClose
:focus
,
.modalClose
:focus
,
.modalSave
:hover
,
.modalSave
:focus
,
.modalZoom
:hover
,
.modalZoom
:hover
,
.modalZoom
:focus
{
.modalZoom
:focus
{
color
:
#999
;
color
:
#999
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment