void VstPlugin::saveSettings( QDomDocument & _doc, QDomElement & _this ) { if( pluginWidget() != NULL ) { _this.setAttribute( "guivisible", pluginWidget()->isVisible() ); } // try to save all settings in a chunk QByteArray chunk = saveChunk(); if( !chunk.isEmpty() ) { _this.setAttribute( "chunk", QString( chunk.toBase64() ) ); } else { // plugin doesn't seem to support chunks, therefore save // individual parameters const QMap<QString, QString> & dump = parameterDump(); _this.setAttribute( "numparams", dump.size() ); for( QMap<QString, QString>::const_iterator it = dump.begin(); it != dump.end(); ++it ) { _this.setAttribute( it.key(), it.value() ); } } _this.setAttribute( "program", currentProgram() ); }
void VstPlugin::hideEditor() { QWidget * w = pluginWidget(); if( w ) { w->hide(); } }
void VstPlugin::hideUI() { if ( m_embedMethod == "none" ) { RemotePlugin::hideUI(); } else if ( pluginWidget() != nullptr ) { toggleEditorVisibility( false ); } }
void VstPlugin::toggleUI() { if ( m_embedMethod == "none" ) { RemotePlugin::toggleUI(); } else if (pluginWidget()) { toggleEditorVisibility(); } }
bool HTMLPlugInElement::isKeyboardFocusable(KeyboardEvent*) const { // FIXME: Why is this check needed? if (!document().page()) return false; Widget* widget = pluginWidget(); if (!widget || !widget->isPluginViewBase()) return false; return toPluginViewBase(widget)->supportsKeyboardFocus(); }
bool HTMLPlugInElement::isKeyboardFocusable(KeyboardEvent*) const { // FIXME: Why is this check needed? if (!document().page()) return false; Widget* widget = pluginWidget(); if (!is<PluginViewBase>(widget)) return false; return downcast<PluginViewBase>(*widget).supportsKeyboardFocus(); }
PassRefPtr<JSC::Bindings::Instance> HTMLPlugInElement::getInstance() { Frame* frame = document().frame(); if (!frame) return 0; // If the host dynamically turns off JavaScript (or Java) we will still return // the cached allocated Bindings::Instance. Not supporting this edge-case is OK. if (m_instance) return m_instance; if (Widget* widget = pluginWidget()) m_instance = frame->script().createScriptInstanceForWidget(widget); return m_instance; }
bool HTMLPlugInElement::isUserObservable() const { // No widget - can't be anything to see or hear here. Widget* widget = pluginWidget(PluginLoadingPolicy::DoNotLoad); if (!is<PluginViewBase>(widget)) return false; PluginViewBase& pluginView = downcast<PluginViewBase>(*widget); // If audio is playing (or might be) then the plugin is detectable. if (pluginView.audioHardwareActivity() != AudioHardwareActivityType::IsInactive) return true; // If the plugin is visible and not vanishingly small in either dimension it is detectable. return pluginView.isVisible() && pluginView.width() > 2 && pluginView.height() > 2; }
void HTMLPlugInImageElement::checkSizeChangeForSnapshotting() { if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized || documentHadRecentUserGesture(document())) return; m_needsCheckForSizeChange = false; LayoutRect contentBoxRect = toRenderBox(renderer())->contentBoxRect(); int contentWidth = contentBoxRect.width(); int contentHeight = contentBoxRect.height(); if (contentWidth <= sizingTinyDimensionThreshold || contentHeight <= sizingTinyDimensionThreshold) return; LOG(Plugins, "%p Plug-in originally avoided snapshotting because it was sized %dx%d. Now it is %dx%d. Tell it to snapshot.\n", this, m_sizeWhenSnapshotted.width(), m_sizeWhenSnapshotted.height(), contentWidth, contentHeight); setDisplayState(WaitingForSnapshot); m_snapshotDecision = Snapshotted; Widget* widget = pluginWidget(); if (widget && widget->isPluginViewBase()) toPluginViewBase(widget)->beginSnapshottingRunningPlugin(); }
void VstPlugin::loadSettings( const QDomElement & _this ) { if( pluginWidget() != NULL ) { if( _this.attribute( "guivisible" ).toInt() ) { showEditor( NULL, false ); } else { hideEditor(); } } const int num_params = _this.attribute( "numparams" ).toInt(); // if it exists try to load settings chunk if( _this.hasAttribute( "chunk" ) ) { loadChunk( QByteArray::fromBase64( _this.attribute( "chunk" ).toUtf8() ) ); } else if( num_params > 0 ) { // no chunk, restore individual parameters QMap<QString, QString> dump; for( int i = 0; i < num_params; ++i ) { const QString key = "param" + QString::number( i ); dump[key] = _this.attribute( key ); } setParameterDump( dump ); } if( _this.hasAttribute( "program" ) ) { setProgram( _this.attribute( "program" ).toInt() ); } }
SharedPersistent<v8::Object>* HTMLPlugInElement::pluginWrapper() { LocalFrame* frame = document().frame(); if (!frame) return 0; // If the host dynamically turns off JavaScript (or Java) we will still // return the cached allocated Bindings::Instance. Not supporting this // edge-case is OK. if (!m_pluginWrapper) { Widget* plugin; if (m_persistedPluginWidget) plugin = m_persistedPluginWidget.get(); else plugin = pluginWidget(); if (plugin) m_pluginWrapper = frame->script().createPluginWrapper(plugin); } return m_pluginWrapper.get(); }
void VstPlugin::showEditor( QWidget * _parent, bool isEffect ) { QWidget * w = pluginWidget(); if( w ) { #ifdef LMMS_BUILD_WIN32 // hide sw, plugin window wrapper on win32 // this is obtained from pluginWidget() if( isEffect ) { w->setWindowFlags( Qt::FramelessWindowHint ); w->setAttribute( Qt::WA_TranslucentBackground ); } else { w->setWindowFlags( Qt::WindowCloseButtonHint ); } #endif w->show(); return; } #ifdef LMMS_BUILD_LINUX if( m_pluginWindowID == 0 ) { return; } m_pluginWidget = new QWidget( _parent ); m_pluginWidget->setFixedSize( m_pluginGeometry ); m_pluginWidget->setWindowTitle( name() ); if( _parent == NULL ) { vstSubWin * sw = new vstSubWin( gui->mainWindow()->workspace() ); if( isEffect ) { sw->setAttribute( Qt::WA_TranslucentBackground ); sw->setWindowFlags( Qt::FramelessWindowHint ); sw->setWidget( m_pluginWidget ); #if QT_VERSION < 0x050000 QX11EmbedContainer * xe = new QX11EmbedContainer( sw ); xe->embedClient( m_pluginWindowID ); xe->setFixedSize( m_pluginGeometry ); xe->show(); #endif } else { sw->setWindowFlags( Qt::WindowCloseButtonHint ); sw->setWidget( m_pluginWidget ); #if QT_VERSION < 0x050000 QX11EmbedContainer * xe = new QX11EmbedContainer( sw ); xe->embedClient( m_pluginWindowID ); xe->setFixedSize( m_pluginGeometry ); xe->move( 4, 24 ); xe->show(); #endif } } #endif if( m_pluginWidget ) { m_pluginWidget->show(); } }
bool HTMLPlugInElement::canProcessDrag() const { return pluginWidget() && pluginWidget()->isPluginView() && toPluginView(pluginWidget())->canProcessDrag(); }
bool HTMLPlugInElement::isKeyboardFocusable() const { if (!document().isActive()) return false; return pluginWidget() && pluginWidget()->isPluginView() && toPluginView(pluginWidget())->supportsKeyboardFocus(); }