Skip to content

Commit

Permalink
fix re-layout on session load
Browse files Browse the repository at this point in the history
  • Loading branch information
tlr committed Dec 21, 2024
1 parent c0349cc commit bfb1280
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 57 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="MIDI router with scripting and a node based interface">
<title>Mididash</title>
<script type="module" crossorigin src="/assets/index-D1R_QktQ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CLFkdzB_.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="MIDI router with Lua scripting and a node based interface">
<title>Mididash</title>
<script type="module" crossorigin src="/assets/index-C1c2PsZC.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BXVyj4tC.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
2 changes: 1 addition & 1 deletion site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="MIDI router with scripting and a node based interface">
<meta name="description" content="MIDI router with Lua scripting and a node based interface">
<title>Mididash</title>
</head>
<body>
Expand Down
46 changes: 23 additions & 23 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
[package]
name = "mididash"
version = "0.1.7"
description = "A new midi router"
name = "Mididash"
version = "0.1.8"
description = "Midi router with Lua scripting and a node based interface"
authors = ["tilr"]
edition = "2021"
readme = "../README.md"
homepage = "mididash.com"
repository = "https://github.com/tiagolr/mididash"
license = "../LICENSE"
keywords = ["audio", "cross-platform", "router", "midi", "midi-events", "tauri", "audio-midi", "midi-router"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Mididash",
"version": "0.1.7",
"version": "0.1.8",
"identifier": "com.mididash.app",
"build": {
"beforeDevCommand": "npm run dev",
Expand Down
1 change: 1 addition & 0 deletions src/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default {
</div>
<div
class="nav-button"
:style="$store.app.settings.hubPaused && 'background: #f008'"
:title="$store.app.settings.hubPaused ? 'Start MIDI processing' : 'Pause MIDI processing'"
@click="$store.app.toggleHubPaused"
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/graph/GraphView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default {
},
async onProjectNew () {
await this.$nextTick()
if (!this.$store.app.settings.projectPath) { // if its a new project not an opened one
if (!this.$store.app.preferences.lastSave) { // if its a new project not an opened one
this.$store.graph.layoutNodes()
}
this.zoomNodes()
Expand Down Expand Up @@ -234,7 +234,7 @@ export default {
const pan = this.$refs.screen.getPan()
const x = (event.clientX - rect.left - pan.x) / zoom
const y = (event.clientY - rect.top - pan.y) / zoom
this.$store.graph.createDeviceAt(x, y, device)
this.$store.graph.createDeviceAt(x, y, true, device)
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/stores/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default defineStore('app', {
try {
await this.getSettings() // make sure settings are up to date
const project = await invoke('get_project').then(camelCase)
this.preferences = project.preferences
this.preferences = camelCase(project.preferences) || {}

project.devices.forEach(device => {
if (typeof device.name === 'string') {
Expand Down Expand Up @@ -225,6 +225,7 @@ export default defineStore('app', {
* Saves current session to config file
*/
async saveCurrentProject() {
this.preferences.lastSave = (new Date()).toISOString()
await invoke('save_current_project', { project: snakeCase({
version: this.version,
preferences: this.preferences,
Expand Down
17 changes: 10 additions & 7 deletions src/stores/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default defineStore('graph', {
this.fitNode(id)
},

async createDeviceAt(x, y, opts = { class: 'Unknown' }) {
async createDeviceAt(x, y, centerDevice, opts = { class: 'Unknown' }) {
const makeUniqueId = classname => {
const nodes = this.nodes.filter(n => n.class === classname)
let i = nodes.length + 1
Expand All @@ -165,11 +165,13 @@ export default defineStore('graph', {
device = this.addNewDevice(device)

// center new device on mouse position
setTimeout(() => {
device = this.nodes.at(-1)
device.x -= device.width / 2
device.y -= 16
}, 0);
if (centerDevice) {
setTimeout(() => {
device = this.nodes.at(-1)
device.x -= device.width / 2
device.y -= 16
}, 0);
}

// this needs to go some place better
if (opts.class === 'trigger') {
Expand All @@ -187,6 +189,7 @@ export default defineStore('graph', {
device.minimized = true
}

// probably the same
if (opts.class === 'script') {
device.outPorts = opts.outPorts.map(id => ({ id, name: id }))
device.name = opts.name // template name
Expand All @@ -211,7 +214,7 @@ export default defineStore('graph', {
const outputs = this.edges.filter(e => e.to === device.id)
try {
await this.removeDevice(device.id) // remove old device
const newdevice = await this.createDeviceAt(device.x, device.y, { id, class: device.class }) // create new device
const newdevice = await this.createDeviceAt(device.x, device.y, false, { id, class: device.class }) // create new device
this.setDeviceName(newdevice.id, newname)
for (let input of inputs) { // reconnect new device
input.from = newdevice.id
Expand Down

0 comments on commit bfb1280

Please sign in to comment.