diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2023-04-15 21:56:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-15 21:56:23 -0400 |
| commit | c94ed73b4e859d64e8419f87dcaa1b44c4577408 (patch) | |
| tree | 06390f4eada8f152003cd9c7fc32d6db960a6e2a /electron/src | |
| parent | 6504c72fb73927151c10edcd5e891af53b36826c (diff) | |
| parent | ec55bc58b2427b1bb4db199f7b29fd4dab28516f (diff) | |
Merge pull request #2189 from inkstitch/jooshkins/addzoomtosim
Add zoom to page and zoom to selection to simulator
Diffstat (limited to 'electron/src')
| -rw-r--r-- | electron/src/renderer/assets/js/simulator.js | 16 | ||||
| -rw-r--r-- | electron/src/renderer/components/Simulator.vue | 33 | ||||
| -rw-r--r-- | electron/src/renderer/main.js | 8 |
3 files changed, 54 insertions, 3 deletions
diff --git a/electron/src/renderer/assets/js/simulator.js b/electron/src/renderer/assets/js/simulator.js index bb290838..186e3e30 100644 --- a/electron/src/renderer/assets/js/simulator.js +++ b/electron/src/renderer/assets/js/simulator.js @@ -511,7 +511,7 @@ export default { }, generatePage () { this.$refs.simulator.style.backgroundColor = this.page_specs.deskcolor - this.svg.rect(this.page_specs.width, this.page_specs.height) + let page = this.svg.rect(this.page_specs.width, this.page_specs.height) .move(-this.stitchPlan.bounding_box[0],-this.stitchPlan.bounding_box[1]) .fill(this.page_specs.pagecolor) .stroke({width: 1, color: 'black'}) @@ -520,6 +520,18 @@ export default { add.blend(add.$source, blur) }) .back() + this.page_specs["bbox"] = page.bbox() + }, + zoomDesign () { + let [minx, miny, maxx, maxy] = this.stitchPlan.bounding_box + let designWidth = maxx - minx + let designHeight = maxy - miny + this.svg.viewbox(0, 0, designWidth, designHeight); + this.resizeCursor() + }, + zoomPage () { + this.svg.viewbox(this.page_specs.bbox.x, this.page_specs.bbox.y - 50, this.page_specs.bbox.width + 100, this.page_specs.bbox.height + 100) + this.resizeCursor() } }, created: function () { @@ -607,6 +619,8 @@ export default { Mousetrap.bind("space", this.toggleAnimation) Mousetrap.bind("+", this.animationForwardOneStitch) Mousetrap.bind("-", this.animationBackwardOneStitch) + Mousetrap.bind("]", this.zoomDesign) + Mousetrap.bind("[", this.zoomPage) this.svg.on('zoom', this.resizeCursor) this.resizeCursor() diff --git a/electron/src/renderer/components/Simulator.vue b/electron/src/renderer/components/Simulator.vue index 22b25446..bbcb5138 100644 --- a/electron/src/renderer/components/Simulator.vue +++ b/electron/src/renderer/components/Simulator.vue @@ -140,6 +140,28 @@ </p> </div> </div> + <div> + <p> + <font-awesome-icon icon="search-minus" class="fa-button"/> + </p> + <p> + <translate>Zoom page</translate> + </p> + <p> + <translate>[ Left square bracket</translate> + </p> + </div> + <div> + <p> + <font-awesome-icon icon="search-plus" class="fa-button"/> + </p> + <p> + <translate>Zoom design</translate> + </p> + <p> + <translate>] Right square bracket</translate> + </p> + </div> </div> </collapse-transition> </div> @@ -191,6 +213,17 @@ <font-awesome-icon icon="horse" size="2x" class="fa-button fa-fast"/> </button> </fieldset> + <fieldset class="view"> + <legend> + <translate>View</translate> + </legend> + <button v-on:click="zoomPage" :title="$gettext('Zoom page ([)')"> + <font-awesome-icon icon="search-minus" size="2x" class="fa-button"/> + </button> + <button v-on:click="zoomDesign" :title="$gettext('Zoom design (])')"> + <font-awesome-icon icon="search-plus" size="2x" class="fa-button"/> + </button> + </fieldset> <fieldset class="command"> <legend> <translate>Command</translate> diff --git a/electron/src/renderer/main.js b/electron/src/renderer/main.js index 1afbca3a..ea422538 100644 --- a/electron/src/renderer/main.js +++ b/electron/src/renderer/main.js @@ -37,7 +37,9 @@ import { faSpinner, faStepBackward, faStepForward, - faStop + faStop, + faSearchPlus, + faSearchMinus } from '@fortawesome/free-solid-svg-icons' import {FontAwesomeIcon, FontAwesomeLayers} from '@fortawesome/vue-fontawesome' import Transitions from 'vue2-transitions' @@ -74,7 +76,9 @@ library.add( faSpinner, faStepBackward, faStepForward, - faStop + faStop, + faSearchPlus, + faSearchMinus ) Vue.component('font-awesome-icon', FontAwesomeIcon) |
