void gKeyboard::__cb_addColumn(int width) { int colx; int colxw; int gap = 16; if (columns.size() == 0) { colx = x() - xposition(); // mind the offset with xposition() colxw = colx + width; } else { gColumn *prev = columns.back(); colx = prev->x()+prev->w() + gap; colxw = colx + width; } /* add gColumn to gKeyboard and to columns vector */ gColumn *gc = new gColumn(colx, y(), width, 2000, indexColumn, this); add(gc); columns.push_back(gc); indexColumn++; /* move addColumn button */ addColumnBtn->position(colxw + gap, y()); redraw(); gu_log("[gKeyboard::__cb_addColumn] new column added (index=%d, w=%d), total count=%d, addColumn(x)=%d\n", gc->getIndex(), width, columns.size(), addColumnBtn->x()); /* recompute col indexes */ refreshColIndexes(); }
int Patch::read(const string &file) { jRoot = json_load_file(file.c_str(), 0, &jError); if (!jRoot) { gu_log("[Patch::read] unable to read patch file! Error on line %d: %s\n", jError.line, jError.text); return PATCH_UNREADABLE; } if (!checkObject(jRoot, "root element")) return PATCH_INVALID; init(); /* TODO json_decref also when PATCH_INVALID */ if (!readCommons(jRoot)) return setInvalid(); if (!readColumns(jRoot)) return setInvalid(); if (!readChannels(jRoot)) return setInvalid(); #ifdef WITH_VST if (!readPlugins(jRoot, &masterInPlugins, PATCH_KEY_MASTER_IN_PLUGINS)) return setInvalid(); if (!readPlugins(jRoot, &masterOutPlugins, PATCH_KEY_MASTER_OUT_PLUGINS)) return setInvalid(); #endif json_decref(jRoot); sanitize(); return PATCH_READ_OK; }
geChannel *gKeyboard::addChannel(int colIndex, Channel *ch, bool build) { gColumn *col = getColumnByIndex(colIndex); /* no column with index 'colIndex' found? Just create it and set its index to 'colIndex'. */ if (!col) { __cb_addColumn(); col = columns.back(); col->setIndex(colIndex); gu_log("[gKeyboard::addChannel] created new column with index=%d\n", colIndex); } gu_log("[gKeyboard::addChannel] add to column with index = %d\n", col->getIndex()); return col->addChannel(ch); }
int Patch::write(const string &file) { jRoot = json_object(); writeCommons(jRoot); writeColumns(jRoot, &columns); writeChannels(jRoot, &channels); #ifdef WITH_VST writePlugins(jRoot, &masterInPlugins, PATCH_KEY_MASTER_IN_PLUGINS); writePlugins(jRoot, &masterOutPlugins, PATCH_KEY_MASTER_OUT_PLUGINS); #endif if (json_dump_file(jRoot, file.c_str(), JSON_COMPACT) != 0) { gu_log("[Patch::write] unable to write patch file!\n"); return 0; } return 1; }
gdPluginWindowGUI::gdPluginWindowGUI(Plugin *pPlugin) : gWindow(450, 300), pPlugin(pPlugin) { show(); #ifndef __APPLE__ Fl::check(); #endif gu_log("[gdPluginWindowGUI] opening GUI, this=%p, xid=%p\n", (void*) this, (void*) fl_xid(this)); #if defined(__APPLE__) void *cocoaWindow = (void*) fl_xid(this); cocoa_setWindowSize(cocoaWindow, pPlugin->getEditorW(), pPlugin->getEditorH()); pPlugin->showEditor(cocoa_getViewFromWindow(cocoaWindow)); #else pPlugin->showEditor((void*) fl_xid(this)); #endif int pluginW = pPlugin->getEditorW(); int pluginH = pPlugin->getEditorH(); resize((Fl::w() - pluginW) / 2, (Fl::h() - pluginH) / 2, pluginW, pluginH); Fl::add_timeout(GUI_PLUGIN_RATE, cb_refresh, (void*) this); copy_label(pPlugin->getName().toRawUTF8()); }
void gdPluginWindowGUI::__cb_close() { Fl::remove_timeout(cb_refresh); pPlugin->closeEditor(); gu_log("[gdPluginWindowGUI::__cb_close] GUI closed, this=%p\n", (void*) this); }