Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
1233bec1
Commit
1233bec1
authored
Oct 29, 2022
by
AUTOMATIC1111
Committed by
GitHub
Oct 29, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3798 from aurror/modal-save-button-and-shortcut
added save image button and a hotkey to Modal Image View
parents
02b54786
76086f66
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
4 deletions
+55
-4
javascript/imageviewer.js
javascript/imageviewer.js
+39
-0
modules/ui.py
modules/ui.py
+0
-2
style.css
style.css
+16
-2
No files found.
javascript/imageviewer.js
View file @
1233bec1
...
@@ -13,6 +13,15 @@ function showModal(event) {
...
@@ -13,6 +13,15 @@ function showModal(event) {
}
}
lb
.
style
.
display
=
"
block
"
;
lb
.
style
.
display
=
"
block
"
;
lb
.
focus
()
lb
.
focus
()
const
tabTxt2Img
=
gradioApp
().
getElementById
(
"
tab_txt2img
"
)
const
tabImg2Img
=
gradioApp
().
getElementById
(
"
tab_img2img
"
)
// show the save button in modal only on txt2img or img2img tabs
if
(
tabTxt2Img
.
style
.
display
!=
"
none
"
||
tabImg2Img
.
style
.
display
!=
"
none
"
)
{
gradioApp
().
getElementById
(
"
modal_save
"
).
style
.
display
=
"
inline
"
}
else
{
gradioApp
().
getElementById
(
"
modal_save
"
).
style
.
display
=
"
none
"
}
event
.
stopPropagation
()
event
.
stopPropagation
()
}
}
...
@@ -81,6 +90,25 @@ function modalImageSwitch(offset) {
...
@@ -81,6 +90,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 +121,9 @@ function modalPrevImage(event) {
...
@@ -93,6 +121,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 +229,14 @@ document.addEventListener("DOMContentLoaded", function() {
...
@@ -198,6 +229,14 @@ 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
.
id
=
"
modal_save
"
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 @
1233bec1
...
@@ -715,8 +715,6 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -715,8 +715,6 @@ def create_ui(wrap_gradio_gpu_call):
with
gr
.
Group
():
with
gr
.
Group
():
custom_inputs
=
modules
.
scripts
.
scripts_txt2img
.
setup_ui
(
is_img2img
=
False
)
custom_inputs
=
modules
.
scripts
.
scripts_txt2img
.
setup_ui
(
is_img2img
=
False
)
txt2img_gallery
,
generation_info
,
html_info
=
create_output_panel
(
"txt2img"
,
opts
.
outdir_txt2img_samples
)
txt2img_gallery
,
generation_info
,
html_info
=
create_output_panel
(
"txt2img"
,
opts
.
outdir_txt2img_samples
)
connect_reuse_seed
(
seed
,
reuse_seed
,
generation_info
,
dummy_component
,
is_subseed
=
False
)
connect_reuse_seed
(
seed
,
reuse_seed
,
generation_info
,
dummy_component
,
is_subseed
=
False
)
...
...
style.css
View file @
1233bec1
...
@@ -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
32px
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
:
28px
;
margin-top
:
8px
;
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