|
@@ -1,6 +1,6 @@
|
|
|
<script>
|
|
|
import { appWindow } from "@tauri-apps/api/window";
|
|
|
- import { open as openDialog } from '@tauri-apps/api/dialog'
|
|
|
+ import { open as openDialog } from "@tauri-apps/api/dialog";
|
|
|
import { open } from "@tauri-apps/api/shell";
|
|
|
|
|
|
const {
|
|
@@ -12,6 +12,7 @@
|
|
|
unminimize,
|
|
|
show,
|
|
|
hide,
|
|
|
+ setTransparent,
|
|
|
setDecorations,
|
|
|
setAlwaysOnTop,
|
|
|
setWidth,
|
|
@@ -23,30 +24,29 @@
|
|
|
setY,
|
|
|
// setPosition,
|
|
|
setFullscreen,
|
|
|
- setIcon
|
|
|
- } = appWindow
|
|
|
-
|
|
|
- export let onMessage;
|
|
|
- let pathValue = "https://tauri.studio";
|
|
|
- let openWith = "";
|
|
|
- let resizable = true
|
|
|
- let maximized = false
|
|
|
- let decorations = false
|
|
|
- let alwaysOnTop = false
|
|
|
- let fullscreen = false
|
|
|
- let width = 600
|
|
|
- let height = 600
|
|
|
- let minWidth = 600
|
|
|
- let minHeight = 600
|
|
|
- let maxWidth = null
|
|
|
- let maxHeight = null
|
|
|
- let x = 300
|
|
|
- let y = 300
|
|
|
-
|
|
|
- let windowTitle = 'Awesome Tauri Example!';
|
|
|
+ setIcon,
|
|
|
+ } = appWindow;
|
|
|
+
|
|
|
+ let urlValue = "https://tauri.studio";
|
|
|
+ let resizable = true;
|
|
|
+ let maximized = false;
|
|
|
+ let transparent = false;
|
|
|
+ let decorations = true;
|
|
|
+ let alwaysOnTop = false;
|
|
|
+ let fullscreen = false;
|
|
|
+ let width = 900;
|
|
|
+ let height = 700;
|
|
|
+ let minWidth = 600;
|
|
|
+ let minHeight = 600;
|
|
|
+ let maxWidth = null;
|
|
|
+ let maxHeight = null;
|
|
|
+ let x = 100;
|
|
|
+ let y = 100;
|
|
|
+
|
|
|
+ let windowTitle = "Awesome Tauri Example!";
|
|
|
|
|
|
function openUrl() {
|
|
|
- open(pathValue, !!openWith ? openWith : undefined).catch(onMessage);
|
|
|
+ open(urlValue);
|
|
|
}
|
|
|
|
|
|
function setTitle_() {
|
|
@@ -54,65 +54,44 @@
|
|
|
}
|
|
|
|
|
|
function hide_() {
|
|
|
- hide()
|
|
|
- setTimeout(show, 2000)
|
|
|
+ hide();
|
|
|
+ setTimeout(show, 2000);
|
|
|
}
|
|
|
|
|
|
function minimize_() {
|
|
|
- minimize()
|
|
|
- setTimeout(unminimize, 2000)
|
|
|
+ minimize();
|
|
|
+ setTimeout(unminimize, 2000);
|
|
|
}
|
|
|
|
|
|
function getIcon() {
|
|
|
openDialog({
|
|
|
- multiple: false
|
|
|
- }).then(setIcon)
|
|
|
+ multiple: false,
|
|
|
+ }).then(setIcon);
|
|
|
}
|
|
|
|
|
|
- $: setResizable(resizable)
|
|
|
- $: maximized ? maximize() : unmaximize()
|
|
|
- $: setDecorations(decorations)
|
|
|
- $: setAlwaysOnTop(alwaysOnTop)
|
|
|
- $: setFullscreen(fullscreen)
|
|
|
-
|
|
|
- $: setWidth(width)
|
|
|
- $: setHeight(height)
|
|
|
- $: minWidth && minHeight && setMinSize(minWidth, minHeight)
|
|
|
- $: maxWidth && maxHeight && setMaxSize(maxWidth, maxHeight)
|
|
|
- $: setX(x)
|
|
|
- $: setY(y)
|
|
|
+ $: setResizable(resizable);
|
|
|
+ $: maximized ? maximize() : unmaximize();
|
|
|
+ //$: setTransparent(transparent)
|
|
|
+ $: setDecorations(decorations);
|
|
|
+ $: setAlwaysOnTop(alwaysOnTop);
|
|
|
+ $: setFullscreen(fullscreen);
|
|
|
+
|
|
|
+ $: setWidth(width);
|
|
|
+ $: setHeight(height);
|
|
|
+ $: minWidth && minHeight && setMinSize(minWidth, minHeight);
|
|
|
+ $: maxWidth && maxHeight && setMaxSize(maxWidth, maxHeight);
|
|
|
+ $: setX(x);
|
|
|
+ $: setY(y);
|
|
|
</script>
|
|
|
|
|
|
-<style>
|
|
|
- .flex {
|
|
|
- display: flex;
|
|
|
- }
|
|
|
-
|
|
|
- .flex-row {
|
|
|
- flex-direction: row;
|
|
|
- }
|
|
|
-
|
|
|
- .flex-column {
|
|
|
- flex-direction: column;
|
|
|
- }
|
|
|
-
|
|
|
- .grow {
|
|
|
- flex-grow: 1;
|
|
|
- }
|
|
|
-
|
|
|
- .window-controls input {
|
|
|
- width: 50px;
|
|
|
- }
|
|
|
-</style>
|
|
|
-
|
|
|
-<div class="flex flex-column">
|
|
|
+<div class="flex col">
|
|
|
<div>
|
|
|
<label>
|
|
|
- <input type="checkbox" bind:checked={resizable}>
|
|
|
+ <input type="checkbox" bind:checked={resizable} />
|
|
|
Resizable
|
|
|
</label>
|
|
|
<label>
|
|
|
- <input type="checkbox" bind:checked={maximized}>
|
|
|
+ <input type="checkbox" bind:checked={maximized} />
|
|
|
Maximize
|
|
|
</label>
|
|
|
<button title="Unminimizes after 2 seconds" on:click={minimize_}>
|
|
@@ -122,64 +101,66 @@
|
|
|
Hide
|
|
|
</button>
|
|
|
<label>
|
|
|
- <input type="checkbox" bind:checked={decorations}>
|
|
|
+ <input type="checkbox" bind:checked={transparent} />
|
|
|
+ Transparent
|
|
|
+ </label>
|
|
|
+ <label>
|
|
|
+ <input type="checkbox" bind:checked={decorations} />
|
|
|
Has decorations
|
|
|
</label>
|
|
|
<label>
|
|
|
- <input type="checkbox" bind:checked={alwaysOnTop}>
|
|
|
+ <input type="checkbox" bind:checked={alwaysOnTop} />
|
|
|
Always on top
|
|
|
</label>
|
|
|
<label>
|
|
|
- <input type="checkbox" bind:checked={fullscreen}>
|
|
|
+ <input type="checkbox" bind:checked={fullscreen} />
|
|
|
Fullscreen
|
|
|
</label>
|
|
|
- <button on:click={getIcon}>
|
|
|
- Change icon
|
|
|
- </button>
|
|
|
+ <button on:click={getIcon}> Change icon </button>
|
|
|
</div>
|
|
|
<div>
|
|
|
<div class="window-controls flex flex-row">
|
|
|
- <div class="flex flex-column grow">
|
|
|
+ <div class="flex col grow">
|
|
|
<div>
|
|
|
X
|
|
|
- <input type="number" bind:value={x} min="0">
|
|
|
+ <input type="number" bind:value={x} min="0" />
|
|
|
</div>
|
|
|
<div>
|
|
|
Y
|
|
|
- <input type="number" bind:value={y} min="0">
|
|
|
+ <input type="number" bind:value={y} min="0" />
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="flex flex-column grow">
|
|
|
+ <div class="flex col grow">
|
|
|
<div>
|
|
|
Width
|
|
|
- <input type="number" bind:value={width} min="400">
|
|
|
+ <input type="number" bind:value={width} min="400" />
|
|
|
</div>
|
|
|
<div>
|
|
|
Height
|
|
|
- <input type="number" bind:value={height} min="400">
|
|
|
+ <input type="number" bind:value={height} min="400" />
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="flex flex-column grow">
|
|
|
+ <div class="flex col grow">
|
|
|
<div>
|
|
|
Min width
|
|
|
- <input type="number" bind:value={minWidth}>
|
|
|
+ <input type="number" bind:value={minWidth} />
|
|
|
</div>
|
|
|
<div>
|
|
|
Min height
|
|
|
- <input type="number" bind:value={minHeight}>
|
|
|
+ <input type="number" bind:value={minHeight} />
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div class="flex flex-column grow">
|
|
|
+ <div class="flex col grow">
|
|
|
<div>
|
|
|
Max width
|
|
|
- <input type="number" bind:value={maxWidth} min="400">
|
|
|
+ <input type="number" bind:value={maxWidth} min="400" />
|
|
|
</div>
|
|
|
<div>
|
|
|
Max height
|
|
|
- <input type="number" bind:value={maxHeight} min="400">
|
|
|
+ <input type="number" bind:value={maxHeight} min="400" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -190,15 +171,20 @@
|
|
|
<button class="button" type="submit">Set title</button>
|
|
|
</form>
|
|
|
<form style="margin-top: 24px" on:submit|preventDefault={openUrl}>
|
|
|
- <div>
|
|
|
- <label for="path">Path or URL:</label>
|
|
|
- <input id="path" bind:value={pathValue} />
|
|
|
- </div>
|
|
|
- <div>
|
|
|
- <label for="openWith">Open With (Optional):</label>
|
|
|
- <input id="openWith" bind:value={openWith} />
|
|
|
- </div>
|
|
|
- <button class="button" id="open-path">
|
|
|
- Open Path or Url
|
|
|
- </button>
|
|
|
-</form>
|
|
|
+ <input id="url" bind:value={urlValue} />
|
|
|
+ <button class="button" id="open-url"> Open URL </button>
|
|
|
+</form>
|
|
|
+
|
|
|
+<style>
|
|
|
+ .flex-row {
|
|
|
+ flex-direction: row;
|
|
|
+ }
|
|
|
+
|
|
|
+ .grow {
|
|
|
+ flex-grow: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .window-controls input {
|
|
|
+ width: 50px;
|
|
|
+ }
|
|
|
+</style>
|