feat: buffer/latency control + non-selectable node text
Buffer Control:
- GET /api/quantum - reads current graph quantum via pw-metadata
- POST /api/quantum {quantum:N} - sets quantum via pw-metadata
- Toolbar dropdown with presets: 32, 64, 128, 256, 512, 1024, 2048, 4096
- Loads current quantum on startup
Text Selection Fix:
- Added user-select: none to wrap and canvas CSS
- Node text no longer gets selected when dragging
This commit is contained in:
@@ -603,6 +603,42 @@ void WebServer::setupRoutes() {
|
||||
}
|
||||
res.set_header("Access-Control-Allow-Origin", "*");
|
||||
});
|
||||
|
||||
m_http.Options("/api/quantum", cors_handler);
|
||||
|
||||
// Get current quantum: GET /api/quantum
|
||||
m_http.Get("/api/quantum", [](const httplib::Request &, httplib::Response &res) {
|
||||
int quantum = 0;
|
||||
FILE *fp = popen("pw-metadata 0 default.clock.quantum 2>/dev/null | grep -oP \"value:'\\K[0-9]+\"", "r");
|
||||
if (fp) {
|
||||
char buf[32] = {};
|
||||
if (fgets(buf, sizeof(buf), fp))
|
||||
quantum = atoi(buf);
|
||||
pclose(fp);
|
||||
}
|
||||
char out[64];
|
||||
snprintf(out, sizeof(out), "{\"quantum\":%d}", quantum);
|
||||
res.set_content(out, "application/json");
|
||||
res.set_header("Access-Control-Allow-Origin", "*");
|
||||
});
|
||||
|
||||
// Set quantum: POST /api/quantum {"quantum":256}
|
||||
m_http.Post("/api/quantum", [](const httplib::Request &req, httplib::Response &res) {
|
||||
int quantum = 0;
|
||||
if (sscanf(req.body.c_str(), "{\"quantum\":%d}", &quantum) == 1 && quantum > 0) {
|
||||
char cmd[128];
|
||||
snprintf(cmd, sizeof(cmd), "pw-metadata 0 default.clock.quantum %d 2>/dev/null", quantum);
|
||||
int ret = system(cmd);
|
||||
(void)ret;
|
||||
char out[64];
|
||||
snprintf(out, sizeof(out), "{\"ok\":true,\"quantum\":%d}", quantum);
|
||||
res.set_content(out, "application/json");
|
||||
} else {
|
||||
res.status = 400;
|
||||
res.set_content("{\"error\":\"invalid json\"}", "application/json");
|
||||
}
|
||||
res.set_header("Access-Control-Allow-Origin", "*");
|
||||
});
|
||||
}
|
||||
|
||||
// end of web_server.cpp
|
||||
|
||||
Reference in New Issue
Block a user