Skip to content

Commit

Permalink
Merge pull request #295 from Metachs/select-overhaul
Browse files Browse the repository at this point in the history
Select tool overhaul
  • Loading branch information
zero01101 authored Aug 31, 2024
2 parents 42dfd01 + a24bc7e commit bf9e6d0
Show file tree
Hide file tree
Showing 9 changed files with 397 additions and 119 deletions.
6 changes: 6 additions & 0 deletions css/icons.css
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,9 @@
-webkit-mask-image: url("../res/icons/squircle.svg");
mask-image: url("../res/icons/squircle.svg");
}

.ui.inline-icon.icon-file-plus::after,
.ui.icon > .icon-file-plus {
-webkit-mask-image: url("../res/icons/file-plus.svg");
mask-image: url("../res/icons/file-plus.svg");
}
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
<br />
<span id="version">
<a href="https://github.com/zero01101/openOutpaint" target="_blank">
v20240427.001
v20240824.001
</a>
<br />
<a
Expand Down Expand Up @@ -545,7 +545,7 @@
type="text/javascript"></script>
<script src="js/lib/events.js?v=2ab7933" type="text/javascript"></script>
<script src="js/lib/db.js?v=434363b" type="text/javascript"></script>
<script src="js/lib/input.js?v=769485c" type="text/javascript"></script>
<script src="js/lib/input.js?v=f99493d" type="text/javascript"></script>
<script src="js/lib/layers.js?v=26b7436" type="text/javascript"></script>
<script src="js/lib/commands.js?v=ad60afc" type="text/javascript"></script>

Expand Down Expand Up @@ -576,7 +576,7 @@
src="js/ui/tool/generic.js?v=3e678e0"
type="text/javascript"></script>

<script src="js/ui/tool/dream.js?v=56c7c50" type="text/javascript"></script>
<script src="js/ui/tool/dream.js?v=9ae0612" type="text/javascript"></script>
<script
src="js/ui/tool/maskbrush.js?v=e9bd0eb"
type="text/javascript"></script>
Expand Down
3 changes: 2 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ async function upscaleAndDownload(
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((data) => {
.then(async (data) => {
console.log(data);
var link = document.createElement("a");
link.download =
Expand All @@ -1554,6 +1554,7 @@ async function upscaleAndDownload(
console.log("Add upscaled to resource");
const img = new Image();
img.src = link.href;
await img.decode();
tools.stamp.state.addResource(guid() + " (upscaled)", img);
}
if (download == true) {
Expand Down
20 changes: 20 additions & 0 deletions js/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,27 @@ const commands = makeReadOnly(
_history: [],
/** The types of commands we can run (private) */
_types: {},

/** @type {Observer<{n: int, cancel: function}>} */
get onundo() { return this._onundo; },
_onundo: new Observer(),

/** @type {Observer<{n: int, cancel: function}>} */
get onredo() { return this._onredo; },
_onredo: new Observer(),

/**
* Undoes the last commands in the history
*
* @param {number} [n] Number of actions to undo
*/
async undo(n = 1) {
var cancelled = false;
await this._onundo.emit({
n:n,
cancel: ()=>{cancelled=true;},
});
if (cancelled) return;
for (var i = 0; i < n && this.current > -1; i++) {
try {
await this._history[this._current--].undo();
Expand All @@ -45,6 +59,12 @@ const commands = makeReadOnly(
* @param {number} [n] Number of actions to redo
*/
async redo(n = 1) {
let cancelled = false;
await this._onredo.emit({
n:n,
cancel: ()=>{cancelled=true;},
});
if (cancelled) return;
for (var i = 0; i < n && this.current + 1 < this._history.length; i++) {
try {
await this._history[++this._current].redo();
Expand Down
3 changes: 3 additions & 0 deletions js/lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,9 @@ window.onkeyup = (evn) => {
});
}

if (keyboard.keys[evn.code]._hold_to)
clearTimeout(keyboard.keys[evn.code]._hold_to);

keyboard.keys[evn.code] = {
pressed: false,
held: false,
Expand Down
4 changes: 3 additions & 1 deletion js/ui/tool/dream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3339,6 +3339,7 @@ function addControlNetToAlwaysOnScripts(state, initCanvas, maskCanvas) {
//img2img?
state.alwayson_scripts.controlnet.args = [
{
enabled: true,
module: extensions.selectedControlNetModule,
model: extensions.selectedControlNetModel,
control_mode: document.getElementById("controlNetMode-select").value,
Expand All @@ -3351,10 +3352,11 @@ function addControlNetToAlwaysOnScripts(state, initCanvas, maskCanvas) {
} else {
state.alwayson_scripts.controlnet.args = [
{
enabled: true,
module: extensions.selectedControlNetModule,
model: extensions.selectedControlNetModel,
control_mode: document.getElementById("controlNetMode-select").value,
input_image: initimg, //initCanvas.toDataURL(),
image: initimg, //initCanvas.toDataURL(),
mask: maskimg, //maskCanvas.toDataURL(),
processor_res: 64,
resize_mode: document.getElementById("controlNetResize-select").value,
Expand Down
Loading

0 comments on commit bf9e6d0

Please sign in to comment.