anki/ts/editor/editor-toolbar/ImageOcclusionButton.svelte
Mani be1f889211
fixes: remove unfinished shapes, remove selectable and make shapes remain inside canvas (#2809)
* remove unfinished polygon and remove selectable for shapes in polygon mode

* make group and polygon position remain inside canvas area

* click through transparent area in grouped object

* add some shortcuts for basic usages

* tools button icon in center & switch mode border

* fix load svg image

* basic rtl support, panzoom have issues in rtl mode

* better zoom option both in ltr and rtl

* handle zoom event in mask editor

* add h button to handle toggle mask

* add more mime type

* use capital M (shift+m) for toggle mask

* allow io shortcuts in mask editor only

* make other shapes also remain in canvas bound area

* better zoom implementation, zoom from center
add zoom to resize event listener

* add a border to corner to handle blend of control

* add refresh button to go to  selection menu

* add tooltip to shortcuts and also add shortcut for other tools

* make opacity remain in same state when toggled on

* opacity for group/ungroup objects

* update shortcuts implementation
2023-11-24 14:06:40 +10:00

67 lines
2.1 KiB
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "@tslib/ftl";
import ButtonGroup from "components/ButtonGroup.svelte";
import DynamicallySlottable from "components/DynamicallySlottable.svelte";
import IconButton from "components/IconButton.svelte";
import { ioImageLoadedStore, ioMaskEditorVisible } from "image-occlusion/store";
import ButtonGroupItem, {
createProps,
setSlotHostContext,
updatePropsList,
} from "../../components/ButtonGroupItem.svelte";
import { mdiTableRefresh, mdiViewDashboard } from "./icons";
export let api = {};
</script>
<ButtonGroup>
<DynamicallySlottable
slotHost={ButtonGroupItem}
{createProps}
{updatePropsList}
{setSlotHostContext}
{api}
>
<ButtonGroupItem>
<IconButton
id="io-mask-btn"
class={$ioMaskEditorVisible ? "active-io-btn" : ""}
on:click={() => {
$ioMaskEditorVisible = !$ioMaskEditorVisible;
}}
tooltip={tr.editingImageOcclusionToggleMaskEditor()}
>
{@html mdiViewDashboard}
</IconButton>
</ButtonGroupItem>
<ButtonGroupItem>
<IconButton
id="io-reset-btn"
disabled={!$ioImageLoadedStore}
on:click={() => {
if (confirm(tr.editingImageOcclusionConfirmReset())) {
globalThis.resetIOImageLoaded();
} else {
return;
}
}}
tooltip={tr.editingImageOcclusionReset()}
>
{@html mdiTableRefresh}
</IconButton>
</ButtonGroupItem>
</DynamicallySlottable>
</ButtonGroup>
<style>
:global(.active-io-btn) {
background: var(--button-primary-bg) !important;
color: white !important;
}
</style>