diff --git a/index.html b/index.html
index 97390a8..aa296f5 100644
--- a/index.html
+++ b/index.html
@@ -319,6 +319,10 @@
width: 100%;
margin-left: 10px;
}
+ .disabled-btn{
+ opacity : 0.65;
+ cursor : not-allowed;
+ }
@@ -558,7 +562,7 @@
width="300px" height="100px" />
-
+
@@ -569,7 +573,7 @@
width="100px" height="100px" />
-
+
diff --git a/index.js b/index.js
index 5435b15..a92a7ea 100644
--- a/index.js
+++ b/index.js
@@ -112,21 +112,8 @@ const eventHandler = async (event, descriptor) => {
require("photoshop").action.addNotificationListener(['set','move'], eventHandler);
-// require("photoshop").action.addNotificationListener(['historyStateChanged'], eventHandler);
-// const onSelect = (event, descriptor) => {
-// // console.log(`descriptor._target?.[0]._ref === "layer" : `,descriptor._target?.[0]._ref === "layer" )
-// // console.log(`descriptor._target?.[0]._name === "Mask -- Paint White to Mask -- temporary" : `,descriptor._target?.[0]._name === "Mask -- Paint White to Mask -- temporary" )
-// console.log(event,descriptor)
-// // if(descriptor._target?.[0]._ref === "layer" && descriptor._target?.[0]._name === "Mask -- Paint White to Mask -- temporary") {
-// // // -> The layer with name "Test Layer 1" was selected
-// // console.log(" onSelect event got triggered!")
-// // console.log("descriptor: ",descriptor)
-// // // console.log()
-// // }
-// }
-// require("photoshop").action.addNotificationListener(['all'], onSelect);
@@ -606,37 +593,44 @@ for (let rbModeElement of rbModeElements) {
}
})
}
+async function createTempInpaintMaskLayer(){
+ if(!g_b_mask_layer_exist){
+
+ //make new layer "Mask -- Paint White to Mask -- temporary"
+
+ const name = "Mask -- Paint White to Mask -- temporary"
+ g_inpaint_mask_layer = await util_layer.createNewLayerExe(name)
+
+ g_b_mask_layer_exist = true
+ const index = app.activeDocument.historyStates.length -1
+ g_inpaint_mask_layer_history_id = app.activeDocument.historyStates[index].id
+ console.log("g_inpaint_mask_layer_history_id: ",g_inpaint_mask_layer_history_id)
+
+ }
+}
+async function deleteTempInpaintMaskLayer(){
+
+ console.log("g_inpaint_mask_layer_history_id: ",g_inpaint_mask_layer_history_id)
+ const historyBrushTools = app.activeDocument.historyStates.filter(h => (h.id > g_inpaint_mask_layer_history_id) && (h.name === "Brush Tool"))
+ console.log(historyBrushTools)
+ if(historyBrushTools.length === 0 && g_b_mask_layer_exist){
+
+ await util_layer.deleteLayers([g_inpaint_mask_layer])
+
+ g_b_mask_layer_exist = false
+ }
+}
async function postModeSelection(){
//
try{
if(g_sd_mode === generationMode['Inpaint']){
//check if the we already have created a mask layer
- if(!g_b_mask_layer_exist){
-
- //make new layer "Mask -- Paint White to Mask -- temporary"
-
- const name = "Mask -- Paint White to Mask -- temporary"
- g_inpaint_mask_layer = await util_layer.createNewLayerExe(name)
-
- g_b_mask_layer_exist = true
- const index = app.activeDocument.historyStates.length -1
- g_inpaint_mask_layer_history_id = app.activeDocument.historyStates[index].id
- console.log("g_inpaint_mask_layer_history_id: ",g_inpaint_mask_layer_history_id)
-
- }
+ await createTempInpaintMaskLayer()
}
else{// if we switch from inpaint mode, delete the mask layer
// Find all history states after the creation of the inpaint mask and their name brush tool
- console.log("g_inpaint_mask_layer_history_id: ",g_inpaint_mask_layer_history_id)
- const historyBrushTools = app.activeDocument.historyStates.filter(h => (h.id > g_inpaint_mask_layer_history_id) && (h.name === "Brush Tool"))
- console.log(historyBrushTools)
- if(historyBrushTools.length === 0 && g_b_mask_layer_exist){
-
- await util_layer.deleteLayers([g_inpaint_mask_layer])
-
- g_b_mask_layer_exist = false
- }
+ await deleteTempInpaintMaskLayer()
}
}
catch(e){
diff --git a/utility/session.js b/utility/session.js
index 5131b22..3b374f5 100644
--- a/utility/session.js
+++ b/utility/session.js
@@ -87,10 +87,20 @@ class GenerationSession{
}
+ //delete the old selection area
+ g_selection = {}
this.isFirstGeneration = true // only before the first generation is requested should this be true
await util_layer.collapseFolderExe([this.outputGroup],false)// close the folder group
+
+ if(this.mode === generationMode['Inpaint'] && g_sd_mode === generationMode['Inpaint']){
+ //create "Mask -- Paint White to Mask -- temporary" layer if current session was inpiant and the selected session is inpaint
+ // the current inpaint session ended on inpaint
+ g_b_mask_layer_exist = false
+ await util_layer.deleteLayers([g_inpaint_mask_layer])
+ await createTempInpaintMaskLayer()
+ }
}catch(e){
console.warn(e)