Ejemplo n.º 1
0
void EditToolBar::ForAllButtons(int Action)
{
   AudacityProject *p;
   CommandManager* cm = nullptr;

   if( Action & ETBActEnableDisable ){
      p = GetActiveProject();
      if (!p) return;
      cm = p->GetCommandManager();
      if (!cm) return;
#ifdef OPTION_SYNC_LOCK_BUTTON
      bool bSyncLockTracks;
      gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false);

      if (bSyncLockTracks)
         mButtons[ETBSyncLockID]->PushDown();
      else
         mButtons[ETBSyncLockID]->PopUp();
#endif
   }


   for (const auto &entry : EditToolbarButtonList) {
#if wxUSE_TOOLTIPS
      if( Action & ETBActTooltips ){
         TranslatedInternalString command{
            entry.commandName, wxGetTranslation(entry.untranslatedLabel) };
         ToolBar::SetButtonToolTip( *mButtons[entry.tool], &command, 1u );
      }
#endif
      if (cm) {
         mButtons[entry.tool]->SetEnabled(cm->GetEnabled(entry.commandName));
      }
   }
}
//==============================================================================
HostFilterComponent::~HostFilterComponent()
{
     DBG ("HostFilterComponent::~HostFilterComponent");

    knownPluginList.removeChangeListener (this);

    // register as listener to transport
    getFilter()->getTransport()->removeChangeListener (this);

    // deregister ouselves from the plugin (in this case the host)
    getFilter()->removeChangeListener (this);
    // getFilter()->removeListenerToParameters (this);

    // save toolbar layout
    Config::getInstance()->toolbarSet = toolbar->toString ();

    // close and free editor window
    closePluginEditorWindows ();

    // clear all childrens and objects
    deleteAndZero (navigator);
    deleteAndZero (toolbar);
    deleteAndZero (factory);
    deleteAndZero (main);
    deleteAndZero (browser);
    deleteAndZero (verticalDividerBar);
    deleteAndZero (horizontalDividerBar);
    deleteAndZero (tooltipWindow);
    deleteAndZero (resizer);

    // clear command manager commands... save keymappings before this point !
    CommandManager* commandManager = CommandManager::getInstance();
    commandManager->setFirstCommandTarget (0);
    commandManager->clearCommands ();
}
Ejemplo n.º 3
0
/**
 * Represents a BIOSManager.
 */
BIOSManager::BIOSManager(){
	CommandManager<int>* cmdManager = new CommandManager<int>();

	this->fileName = "BIOS Infos.txt";

	this->inFileName = "---BIOS INFOs---";

	this->onDifferenceName = "BIOSes";

	this->numberOfInfos = 6;

	this->numberOfCommands = 6;

    this->numberOfDevicesCommand = new Command();
	this->checkCommand = new Command();

	numberOfDevicesCommand->setCommand("dmidecode --type BIOS | grep -i 'BIOS Information' | wc -l");
	numberOfDevicesCommand->setFilter("");

	this->numberOfDevices = cmdManager->getInfoFromCommand(this->numberOfDevicesCommand);

	this->devices = new HWDevice*[this->numberOfDevices];
	this->commands = new Command*[this->numberOfCommands];

	this->deviceCreator = new BiosCreator();

}
Ejemplo n.º 4
0
void Commands::PasteKeywordsCommandResult::afterExecCallback(const Commands::ICommandManager *commandManagerInterface) const {
    CommandManager *commandManager = (CommandManager*)commandManagerInterface;
    Models::ArtItemsModel *artItemsModel = commandManager->getArtItemsModel();
    artItemsModel->updateItems(m_IndicesToUpdate,
                               QVector<int>() <<
                               Models::ArtItemsModel::IsModifiedRole <<
                               Models::ArtItemsModel::KeywordsCountRole);
}
Ejemplo n.º 5
0
bool ExecMenuCommand::Apply(CommandExecutionContext context)
{
   CommandManager *cmdManager = context.GetProject()->GetCommandManager();

   wxString cmdName = GetString(wxT("CommandName"));
   auto cmdFlags = AlwaysEnabledFlag; // TODO ?
   auto cmdMask = AlwaysEnabledFlag;
   return cmdManager->HandleTextualCommand(cmdName, cmdFlags, cmdMask);
}
Ejemplo n.º 6
0
int _tmain(int argc, _TCHAR* argv[])
{
	shared_ptr<LightOnCommand> lightOncmd(new LightOnCommand());
	shared_ptr<LightOffCommand> lightOffcmd(new LightOffCommand());

	CommandManager cmdManager;
	cmdManager.addCommand(lightOncmd);
	cmdManager.addCommand(lightOffcmd);
	cmdManager.execute();
	return 0;
}
Ejemplo n.º 7
0
void ControlToolBar::EnablePauseCommand(bool bEnable)
{
   // Enable/disable the "P" key command. 
   // GetActiveProject() won't work for all callers, e.g., MakeButton(), because it hasn't finished initializing.
   AudacityProject* pProj = (AudacityProject*)GetParent(); 
   if (pProj)
   {
      CommandManager* pCmdMgr = pProj->GetCommandManager();
      if (pCmdMgr)
         pCmdMgr->Enable(wxT("Pause"), bEnable);
   }
}
/**
 * Hide and delete resource function pointer.
 * This function should notify its Items to hide as well.
 *
 * @param cmPtr pointer to menu native peer
 * @param onExit  true if this is called during VM exit.
 * 		  All native resource must be deleted in this case.
 * @return status of this call
 */
extern "C" MidpError
cmdmanager_hide_and_delete(MidpFrame* cmPtr, jboolean onExit) {
    CommandManager *cmdMgr = (CommandManager *)cmPtr->widgetPtr;

    if (onExit) {
	// Delete Command Manager and its children popup menus
	delete cmdMgr;
    } else {
	// Hide any popup menu
	cmdMgr->dismissMenu();
    }

    return KNI_OK;
}
Ejemplo n.º 9
0
Manager::Manager(int argc, const char * argv[]) {
    //gather the factories necessary for constructing commands
    FactoryManager* fm = new FactoryManager();
    
    //Parse and construct commands
    CommandManager* cm = new CommandManager(fm->getFactories());
    Parser* p = new Parser();
    myCommandsToExecute = cm->getCommandsToExecute(p->buildCommandMap(argc, argv));
    
    
    //Define input and outputPaths
    //these MUST be called after p->buildCommandMap
    myImageIn = p->getInputPath();
    myImageOut = p->getOutputPath();
};
Ejemplo n.º 10
0
void EditToolBar::OnButton(wxCommandEvent &event)
{
   int id = event.GetId()-first_ETB_ID;
   // Be sure the pop-up happens even if there are exceptions, except for buttons which toggle.
   auto cleanup = finally( [&] { mButtons[id]->InteractionOver();});

   AudacityProject *p = GetActiveProject();
   if (!p) return;
   CommandManager* cm = p->GetCommandManager();
   if (!cm) return;

   auto flags = GetMenuManager(*p).GetUpdateFlags(*p);
   const CommandContext context( *GetActiveProject() );
   cm->HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecified);
}
Ejemplo n.º 11
0
void LogTextControl::OnContextMenu(wxContextMenuEvent& event)
{
    SetFocus();

    CommandManager cm;
    wxMenu m;
    m.Append(wxID_COPY, cm.getPopupMenuItemText(_("&Copy"), wxID_COPY));
    m.AppendSeparator();
    m.Append(wxID_DELETE,
        cm.getPopupMenuItemText(_("Clear al&l"), wxID_DELETE));
    m.AppendSeparator();
    m.Append(wxID_SELECTALL,
        cm.getPopupMenuItemText(_("Select &all"), wxID_SELECTALL));

    PopupMenu(&m, calcContextMenuPosition(event.GetPosition(), this));
}
Ejemplo n.º 12
0
void TSelectionHandle::setSelection(TSelection *selection)
{
	if (getSelection() == selection)
		return;
	TSelection *oldSelection = getSelection();
	if (oldSelection) {
		oldSelection->selectNone();
		// disable selection related commands
		CommandManager *commandManager = CommandManager::instance();
		int i;
		for (i = 0; i < (int)m_enabledCommandIds.size(); i++)
			commandManager->setHandler(m_enabledCommandIds[i].c_str(), 0);
		m_enabledCommandIds.clear();
	}
	m_selectionStack.back() = selection;
	if (selection)
		selection->enableCommands();
	emit selectionSwitched(oldSelection, selection);
}
Ejemplo n.º 13
0
bool GetAllMenuCommands::Apply(CommandExecutionContext context)
{
   bool showStatus = GetBool(wxT("ShowStatus"));
   wxArrayString names;
   CommandManager *cmdManager = context.GetProject()->GetCommandManager();
   cmdManager->GetAllCommandNames(names, false);
   wxArrayString::iterator iter;
   for (iter = names.begin(); iter != names.end(); ++iter)
   {
      wxString name = *iter;
      wxString out = name;
      if (showStatus)
      {
         out += wxT("\t");
         out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled");
      }
      Status(out);
   }
   return true;
}
Ejemplo n.º 14
0
   // ModuleDispatch
   // is called by Audacity to initialize/terminmate the module,
   // and ask if it has anything for the menus.
   int ModuleDispatch(ModuleDispatchTypes type){
      switch (type){
         case AppInitialized:{
            wxASSERT(gBench == NULL);
            gBench = new NyqBench(NULL);
         }
         break;
         case AppQuiting: {
            wxASSERT(gBench != NULL);
            if (gBench) {
               delete gBench;
               gBench = NULL;
            }
         }
         break;
         case ProjectInitialized:
         case MenusRebuilt:  {
            AudacityProject *p = GetActiveProject();
            wxASSERT(p != NULL);
            CommandManager *c = p->GetCommandManager();
            wxASSERT(c != NULL);

            wxMenuBar * pBar = p->GetMenuBar();
            wxASSERT(pBar != NULL );
            wxMenu * pMenu = pBar->GetMenu( 2 );  // Menu 2 is the View Menu.
            wxASSERT( pMenu != NULL );

            c->SetToMenu( pMenu );
            c->AddSeparator();
            // c->BeginMenu(_("T&ools"));
            c->SetDefaultFlags(AudioIONotBusyFlag, AudioIONotBusyFlag);
            c->AddItem(wxT("NyqBench"),
                       _("&Nyquist Workbench..."),
                       new ModNyqBenchCommandFunctor());
         }
         break;
         default:
         break;
      }
      return 1;
   }
Ejemplo n.º 15
0
void ControlToolBar::RegenerateToolsTooltips()
{
#if wxUSE_TOOLTIPS
   for (long iWinID = ID_PLAY_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
   {
      wxWindow* pCtrl = this->FindWindow(iWinID);
      wxString strToolTip = pCtrl->GetLabel();
      AudacityProject* pProj = GetActiveProject();
      CommandManager* pCmdMgr = (pProj) ? pProj->GetCommandManager() : NULL;
      if (pCmdMgr)
      {
         wxString strKey(wxT(" ("));
         switch (iWinID)
         {
            case ID_PLAY_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Play"));
               strKey += _(") / Loop Play (");
               strKey += pCmdMgr->GetKeyFromName(wxT("PlayLooped"));
               break;
            case ID_RECORD_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Record"));
               strKey += _(") / Append Record (");
               strKey += pCmdMgr->GetKeyFromName(wxT("RecordAppend"));
               break;
            case ID_PAUSE_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Pause"));
               break;
            case ID_STOP_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Stop"));
               break;
            case ID_FF_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("SkipEnd"));
               break;
            case ID_REW_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("SkipStart"));
               break;
         }
         strKey += wxT(")");
         strToolTip += strKey;
      }
      pCtrl->SetToolTip(strToolTip);
   }
#endif
}
Ejemplo n.º 16
0
// This is the function that connects us to Audacity.
MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
{
   switch (type)
   {
   case AppInitialized:
      Registrar::Start();
      // Demand that all track panels be created using the TrackPanel2Factory.
      TrackPanel::FactoryFunction = TrackPanel2Factory;
      break;
   case AppQuiting:
      Registrar::Finish();
      break;
   case ProjectInitialized:
   case MenusRebuilt:
      {
         AudacityProject *p = GetActiveProject();
         if( p== NULL )
            return 0;

         wxMenuBar * pBar = p->GetMenuBar();
         wxMenu * pMenu = pBar->GetMenu( 7 );  // Menu 7 is the Analyze Menu.
         CommandManager * c = p->GetCommandManager();

         c->SetToMenu( pMenu );
         c->AddSeparator();
         // We add two new commands into the Analyze menu.
         c->AddItem( _T("Extra Dialog..."), _T("Experimental Extra Dialog for whatever you want."),
            ModTrackPanelFN( OnFuncShowAudioExplorer ) );
         //Second menu tweak no longer needed as we always make TrackPanel2's.
         //c->AddItem( _T("Replace TrackPanel..."), _T("Replace Current TrackPanel with TrackPanel2"),
         //   ModTrackPanelFN( OnFuncReplaceTrackPanel ) );
      }
      break;
   default:
      break;
   }

   return 1;
}
Ejemplo n.º 17
0
std::shared_ptr<Commands::ICommandResult> Commands::PasteKeywordsCommand::execute(const ICommandManager *commandManagerInterface) const {
    LOG_INFO << "Pasting" << m_KeywordsList.length() << "keywords to" << m_MetadataElements.size() << "item(s)";

    CommandManager *commandManager = (CommandManager*)commandManagerInterface;

    QVector<int> indicesToUpdate;
    std::vector<UndoRedo::ArtworkMetadataBackup> artworksBackups;
    QVector<Models::ArtworkMetadata*> itemsToSave;
    size_t size = m_MetadataElements.size();
    indicesToUpdate.reserve((int)size);
    artworksBackups.reserve(size);
    itemsToSave.reserve((int)size);

    for (size_t i = 0; i < size; ++i) {
        const Models::MetadataElement &element = m_MetadataElements.at(i);
        Models::ArtworkMetadata *metadata = element.getOrigin();

        indicesToUpdate.append(element.getOriginalIndex());
        artworksBackups.emplace_back(metadata);

        metadata->appendKeywords(m_KeywordsList);
        itemsToSave.append(metadata);
    }

    if (size > 0) {
        commandManager->submitForSpellCheck(itemsToSave);
        commandManager->submitForWarningsCheck(itemsToSave);
        commandManager->saveArtworksBackups(itemsToSave);

        std::unique_ptr<UndoRedo::IHistoryItem> modifyArtworksItem(new UndoRedo::ModifyArtworksHistoryItem(artworksBackups, indicesToUpdate,
                                                                                                           UndoRedo::PasteModificationType));
        commandManager->recordHistoryItem(modifyArtworksItem);
    } else {
        LOG_WARNING << "Pasted zero real words!";
    }

    std::shared_ptr<PasteKeywordsCommandResult> result(new PasteKeywordsCommandResult(indicesToUpdate));
    return result;
}
Ejemplo n.º 18
0
void ShortcutViewer::keyPressEvent(QKeyEvent *event)
{
	int key = event->key();
	if (key == Qt::Key_Control || key == Qt::Key_Shift || key == Qt::Key_Alt) {
		event->ignore();
		return;
	}
	Qt::KeyboardModifiers modifiers = event->modifiers();

	// Tasti che non possono essere utilizzati come shortcut
	if ((modifiers | (Qt::CTRL | Qt::SHIFT | Qt::ALT)) != (Qt::CTRL | Qt::SHIFT | Qt::ALT) || key == Qt::Key_Home || key == Qt::Key_End || key == Qt::Key_PageDown || key == Qt::Key_PageUp || key == Qt::Key_Escape || key == Qt::Key_Print || key == Qt::Key_Pause || key == Qt::Key_ScrollLock) {
		if (key != Qt::Key_Plus && key != Qt::Key_Minus && key != Qt::Key_Asterisk && key != Qt::Key_Slash) {
			event->ignore();
			return;
		} else
			modifiers = 0;
	}

	if (m_action) {
		CommandManager *cm = CommandManager::instance();
		QKeySequence keySequence(key + modifiers);
		std::string shortcutString = keySequence.toString().toStdString();
		QAction *oldAction = cm->getActionFromShortcut(keySequence.toString().toStdString());
		if (oldAction == m_action)
			return;
		if (oldAction) {
			QString msg = tr("%1 is already assigned to '%2'\nAssign to '%3'?").arg(keySequence.toString()).arg(oldAction->iconText()).arg(m_action->iconText());
			int ret = DVGui::MsgBox(msg, tr("Yes"), tr("No"), 1);
			activateWindow();
			if (ret == 2 || ret == 0)
				return;
		}
		CommandManager::instance()->setShortcut(m_action, shortcutString);
		emit shortcutChanged();
	}
	event->accept();
	update();
}
Ejemplo n.º 19
0
void TextControl::OnContextMenu(wxContextMenuEvent& event)
{
    SetFocus();

    CommandManager cm;
    wxMenu m;
    m.Append(wxID_UNDO, cm.getPopupMenuItemText(_("&Undo"), wxID_UNDO));
    m.Append(wxID_REDO, cm.getPopupMenuItemText(_("&Redo"), wxID_REDO));
    m.AppendSeparator();
    m.Append(wxID_CUT, cm.getPopupMenuItemText(_("Cu&t"), wxID_CUT));
    m.Append(wxID_COPY, cm.getPopupMenuItemText(_("&Copy"), wxID_COPY));
    m.Append(wxID_PASTE, cm.getPopupMenuItemText(_("&Paste"), wxID_PASTE));
    m.Append(wxID_DELETE, cm.getPopupMenuItemText(_("&Delete"), wxID_DELETE));
    m.AppendSeparator();
    m.Append(wxID_SELECTALL,
        cm.getPopupMenuItemText(_("Select &all"), wxID_SELECTALL));

    PopupMenu(&m, calcContextMenuPosition(event.GetPosition(), this));
}
Ejemplo n.º 20
0
void RowArea::contextMenuEvent(QContextMenuEvent *event)
{
	OnionSkinMask osMask = TApp::instance()->getCurrentOnionSkin()->getOnionSkinMask();

	QMenu *menu = new QMenu(this);
	QAction *setStartMarker = menu->addAction(tr("Set Start Marker"));
	connect(setStartMarker, SIGNAL(triggered()), SLOT(onSetStartMarker()));
	QAction *setStopMarker = menu->addAction(tr("Set Stop Marker"));
	connect(setStopMarker, SIGNAL(triggered()), SLOT(onSetStopMarker()));
	QAction *removeMarkers = menu->addAction(tr("Remove Markers"));
	connect(removeMarkers, SIGNAL(triggered()), SLOT(onRemoveMarkers()));

	//set both the from and to markers at the specified row
	QAction *previewThis = menu->addAction(tr("Preview This"));
	connect(previewThis, SIGNAL(triggered()), SLOT(onPreviewThis()));

	menu->addSeparator();

	if (Preferences::instance()->isOnionSkinEnabled())
	{
		OnioniSkinMaskGUI::addOnionSkinCommand(menu);
		menu->addSeparator();
	}

	CommandManager *cmdManager = CommandManager::instance();
	menu->addAction(cmdManager->getAction(MI_InsertSceneFrame));
	menu->addAction(cmdManager->getAction(MI_RemoveSceneFrame));
	menu->addAction(cmdManager->getAction(MI_InsertGlobalKeyframe));
	menu->addAction(cmdManager->getAction(MI_RemoveGlobalKeyframe));

	menu->addSeparator();
	menu->addAction(cmdManager->getAction(MI_ShiftTrace));
	menu->addAction(cmdManager->getAction(MI_EditShift));
	menu->addAction(cmdManager->getAction(MI_NoShift));
	menu->addAction(cmdManager->getAction(MI_ResetShift));

	menu->exec(event->globalPos());
}
Ejemplo n.º 21
0
   // ModuleDispatch
   // is called by Audacity to initialize/terminmate the module,
   // and ask if it has anything for the menus.
   int ModuleDispatch(ModuleDispatchTypes type){
      switch (type){
         case AppQuiting: {
            //It is perfectly OK for gBench to be NULL.
            //Can happen if the menu item was never invoked.
            //wxASSERT(gBench != NULL);
            if (gBench) {
               gBench->Destroy();
               gBench = NULL;
            }
         }
         break;
         case ProjectInitialized:
         case MenusRebuilt:  {
            AudacityProject *p = GetActiveProject();
            wxASSERT(p != NULL);
            CommandManager *c = p->GetCommandManager();
            wxASSERT(c != NULL);

            wxMenuBar * pBar = p->GetMenuBar();
            wxASSERT(pBar != NULL );
            wxMenu * pMenu = pBar->GetMenu( 9 );  // Menu 9 is the Tools Menu.
            wxASSERT( pMenu != NULL );

            c->SetCurrentMenu(pMenu);
            c->AddSeparator();
            c->SetDefaultFlags(AudioIONotBusyFlag, AudioIONotBusyFlag);
            c->AddItem(wxT("NyqBench"),
               _("&Nyquist Workbench..."),
               true,
               findme,
               static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench));

            c->ClearCurrentMenu();
         }
         break;
         default:
         break;
      }
      return 1;
   }
Ejemplo n.º 22
0
void SchematicToggle::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) {
  if (!(m_flags & eIsParentColumn)) return;
  if (m_imageOn2.isNull()) {
    QMenu *menu                = new QMenu(0);
    CommandManager *cmdManager = CommandManager::instance();
    menu->addAction(cmdManager->getAction("MI_EnableThisColumnOnly"));
    menu->addAction(cmdManager->getAction("MI_EnableSelectedColumns"));
    menu->addAction(cmdManager->getAction("MI_EnableAllColumns"));
    menu->addAction(cmdManager->getAction("MI_DisableAllColumns"));
    menu->addAction(cmdManager->getAction("MI_DisableSelectedColumns"));
    menu->addAction(cmdManager->getAction("MI_SwapEnabledColumns"));
    QAction *action = menu->exec(cme->screenPos());
  } else {
    QMenu *menu                = new QMenu(0);
    CommandManager *cmdManager = CommandManager::instance();
    menu->addAction(cmdManager->getAction("MI_ActivateThisColumnOnly"));
    menu->addAction(cmdManager->getAction("MI_ActivateSelectedColumns"));
    menu->addAction(cmdManager->getAction("MI_ActivateAllColumns"));
    menu->addAction(cmdManager->getAction("MI_DeactivateAllColumns"));
    menu->addAction(cmdManager->getAction("MI_DeactivateSelectedColumns"));
    menu->addAction(cmdManager->getAction("MI_ToggleColumnsActivation"));
    QAction *action = menu->exec(cme->screenPos());
  }
}
//==============================================================================
HostFilterComponent::HostFilterComponent (HostFilterBase* const ownerFilter_)
    : AudioProcessorEditor (ownerFilter_),
      tooltipWindow (0),
      toolbar (0),
      main (0),
      navigator(0),
      browser (0),
      verticalDividerBar (0),
      horizontalDividerBar (0)
{
    DBG ("HostFilterComponent::HostFilterComponent");

    Config* config = Config::getInstance();

    // global look and feel
    lookAndFeel.readColourFromConfig ();
    LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);

    // register tooltip window
    tooltipWindow = 0;
    if (config->showTooltips)
        tooltipWindow = new TooltipWindow (0, 1000);

    // register ourselves with the plugin - it will use its ChangeBroadcaster base
    // class to tell us when something has changed.
    getFilter()->addChangeListener (this);
    // getFilter()->addListenerToParameters (this);

    // add toolbar / main tabbed component / tabbed browser / divider
    factory = new ToolbarMainItemFactory (this);
    
    addAndMakeVisible (toolbar = new Toolbar ());
    addAndMakeVisible (main = new MainTabbedComponent (this));
//    addAndMakeVisible (browser = new BrowserTabbedComponent (this));
//    addAndMakeVisible (navigator = new ViewportNavigator (0));

    addAndMakeVisible (resizer = new ResizableCornerComponent (this, &resizeLimits));
    resizeLimits.setSizeLimits (150, 150, 1280, 1024);

    // And use our item factory to add a set of default icons to it...
    toolbar->setVertical (false);
    if (config->toolbarSet != String::empty)
        toolbar->restoreFromString (*factory, config->toolbarSet);
    else
        toolbar->addDefaultItems (*factory);

    // build layout
    setBrowserVisible (config->showBrowser,
                       config->browserLeft,
                       false);

    // set its size
    int initialWidth = 800, initialHeight = 600;
    setSize (initialWidth, initialHeight);

    // get the command manager
    CommandManager* commandManager = CommandManager::getInstance();
    commandManager->registerAllCommandsForTarget (this);
    commandManager->setFirstCommandTarget (this);

//    commandManager->getKeyMappings()->resetToDefaultMappings();
//    addKeyListener (commandManager->getKeyMappings());

#ifndef JOST_VST_PLUGIN
    addKeyListener (commandManager->getKeyMappings());
#endif

   // beautiful annoying splash icon in your face
   commandManager->invokeDirectly (CommandIDs::appAbout, false);

    // register as listener to transport
    getFilter()->getTransport()->addChangeListener (this);
    
        XmlElement* const savedPluginList = ApplicationProperties::getInstance()
                                          ->getUserSettings()
                                          ->getXmlValue (T("pluginList"));

    if (savedPluginList != 0)
    {
        knownPluginList.recreateFromXml (*savedPluginList);
        delete savedPluginList;
    }

    // add internal VST plugins
    const File deadMansPedalFile (ApplicationProperties::getInstance()->getUserSettings()->getFile().getSiblingFile ("RecentlyCrashedPluginsList"));
#if JUCE_MAC
    File internalPluginFolder = File::getSpecialLocation(File::currentApplicationFile).getChildFile("./Contents/PlugIns"); // nicely hidden inside bundle on mac os x
#else
    File internalPluginFolder = File::getSpecialLocation(File::currentApplicationFile).getChildFile("../Plugins"); // plugin folder alongside app on other platforms.. for now
#endif
    VSTPluginFormat vst;
    PluginDirectoryScanner internalPluginScanner(internalPluginList, vst, FileSearchPath(internalPluginFolder.getFullPathName()), false, deadMansPedalFile);
    while (internalPluginScanner.scanNextFile(true)) {
       // keep looking
    }    

    knownPluginList.addChangeListener (this);
    pluginSortMethod = (KnownPluginList::SortMethod) ApplicationProperties::getInstance()->getUserSettings()
                            ->getIntValue (T("pluginSortMethod"), KnownPluginList::sortByManufacturer);
}
Ejemplo n.º 24
0
void FilmstripFrames::contextMenuEvent(QContextMenuEvent *event) {
  QMenu *menu             = new QMenu();
  TXshSimpleLevel *sl     = getLevel();
  bool isSubsequenceLevel = (sl && sl->isSubsequence());
  bool isReadOnly         = (sl && sl->isReadOnly());
  CommandManager *cm      = CommandManager::instance();

  menu->addAction(cm->getAction(MI_SelectAll));
  menu->addAction(cm->getAction(MI_InvertSelection));
  menu->addSeparator();
  if (!isSubsequenceLevel && !isReadOnly) {
    menu->addAction(cm->getAction(MI_Cut));
  }
  menu->addAction(cm->getAction(MI_Copy));

  if (!isSubsequenceLevel && !isReadOnly) {
    menu->addAction(cm->getAction(MI_Paste));
    menu->addAction(cm->getAction(MI_PasteInto));
    menu->addAction(cm->getAction(MI_Insert));
    menu->addAction(cm->getAction(MI_Clear));
    menu->addSeparator();
    menu->addAction(cm->getAction(MI_Reverse));
    menu->addAction(cm->getAction(MI_Swing));
    menu->addAction(cm->getAction(MI_Step2));
    menu->addAction(cm->getAction(MI_Step3));
    menu->addAction(cm->getAction(MI_Step4));
    menu->addAction(cm->getAction(MI_Each2));
    menu->addAction(cm->getAction(MI_Each3));
    menu->addAction(cm->getAction(MI_Each4));
    menu->addSeparator();
    menu->addAction(cm->getAction(MI_Duplicate));
    menu->addAction(cm->getAction(MI_MergeFrames));
  }
  menu->addAction(cm->getAction(MI_ExposeResource));
  if (!isSubsequenceLevel && !isReadOnly) {
    menu->addAction(cm->getAction(MI_AddFrames));
    menu->addAction(cm->getAction(MI_Renumber));
    if (sl && sl->getType() == TZP_XSHLEVEL)
      menu->addAction(cm->getAction(MI_RevertToCleanedUp));
    if (sl &&
        (sl->getType() == TZP_XSHLEVEL || sl->getType() == PLI_XSHLEVEL ||
         (sl->getType() == OVL_XSHLEVEL && sl->getPath().getType() != "psd")))
      menu->addAction(cm->getAction(MI_RevertToLastSaved));
  }

  menu->exec(event->globalPos());
}
Ejemplo n.º 25
0
int main(int argc, char *argv[]){
    
    /* simple test on CommandManager */
   
    CommandManager cmdMan ;
    
    IUndoRedoCommand* addCmd1 = new AddCommand(2,"AddCommand1(+2)",cmdMan.getSomme());
    IUndoRedoCommand* dltCmd1 = new DeleteCommand(4,"DeleteCommand1(-4)",cmdMan.getSomme());
    IUndoRedoCommand* addCmd2 = new AddCommand(20,"AddCommand2(+20)",cmdMan.getSomme());
    IUndoRedoCommand* dltCmd2 = new DeleteCommand(1,"DeleteCommand2(-1)",cmdMan.getSomme());
    
    std::cout << cmdMan.getSomme().getSommeValue() << std::endl;
    
    cmdMan.pushNewCommand(addCmd1);
    cmdMan.pushNewCommand(dltCmd1);
    cmdMan.pushNewCommand(addCmd2);
    
    
    std::cout << cmdMan.getSomme().getSommeValue() << std::endl;

    cmdMan.undo();
    
    std::cout << cmdMan.getSomme().getSommeValue() << std::endl;
    
    cmdMan.pushNewCommand(dltCmd2);
    
    std::cout << cmdMan.getSomme().getSommeValue() << std::endl;
    
    std::cout << "It's gonna undooooing" << std::endl;
    
    for(int i = 0; i <3;++i)    cmdMan.undo();
    
    std::cout << cmdMan.getSomme().getSommeValue() << std::endl;
    
    std::cout << "It's gonna redooooing" << std::endl;
    
    for(int i = 0; i <3;++i)    cmdMan.redo();
    
    
    std::cout << cmdMan.getSomme().getSommeValue() << std::endl;
   
    
    
    
    QApplication app(argc, argv);
    

    
    UndoView* undoView = new UndoView(&cmdMan);
    
    QWidget * undoWidget = new UndoWidget(undoView);
    undoWidget->setWindowTitle("Command List");
    undoWidget->show();
    
    
    
    return app.exec();
    
    //return EXIT_SUCCESS;
}
Ejemplo n.º 26
0
int main() {
	Json::Reader reader;
	Json::Value v;

	IO<Json::Value> io(std::cin, std::cout);
	CommandManager<std::string, std::function<Json::Value (const Json::Value&)> > commands;

	SessionManager<RealPDAL> session;

	commands.add("isSessionValid", [&session](const Json::Value&) -> Json::Value {
		Json::Value r;
		r["valid"] = session.isValid();

		return r;
	});

	commands.add("create", [&session](const Json::Value& params) -> Json::Value {
        // std::string desc = params["pipelineDesc"].asString();
		session.create(params);

		return Json::Value();
	});

	commands.add("destroy", [&session](const Json::Value&) -> Json::Value {
		session.destroy();
		return Json::Value();
	});

	commands.add("getNumPoints", [&session](const Json::Value&) -> Json::Value {
		Json::Value v;
		v[std::string("count")] = (int)session.getNumPoints();

		return v;
	});

	commands.add("getSRS", [&session](const Json::Value&) -> Json::Value {
		Json::Value v;
		v[std::string("srs")] = session.getSRS();

		return v;
	});

	commands.add("read", [&session](const Json::Value& params) -> Json::Value {
		size_t npoints = session.getNumPoints();

		size_t start = params.isMember("start") ? params["start"].asInt() : 0;
		size_t count = params.isMember("count") ? params["count"].asInt() : npoints;

		size_t nbufsize = session.stride() * count;

		std::string host = params["transmitHost"].asString();
		int port = params["transmitPort"].asInt();

		boost::shared_array<char> pbuf(new char[nbufsize]);
		count = session.read(pbuf.get(), start, count);

		std::thread t(BufferTransmitter(host, port, pbuf, nbufsize));
		t.detach();

		Json::Value v;
		v["message"] = "Read request queued for points to be delivered to specified host:port";
		v["pointsRead"] = (int)count;
		v["bytesCount"] = (int)nbufsize;

		return v;
	});

	// indicate that we're ready to our controller program
	Json::Value vReady; vReady["ready"] = 1;
	io.write(vReady);

	io.forInput([&commands](const Json::Value& v) -> Json::Value {
		return commands.dispatch(v["command"].asString(), v["params"]);
	});

    


	return 0;
}
Ejemplo n.º 27
0
SceneViewerContextMenu::SceneViewerContextMenu(SceneViewer *parent)
    : QMenu(parent), m_viewer(parent), m_groupIndexToBeEntered(-1) {
  TApp *app                      = TApp::instance();
  bool isEditingLevel            = app->getCurrentFrame()->isEditingLevel();
  bool ret                       = true;
  QAction *action                = 0;
  CommandManager *commandManager = CommandManager::instance();

  /*- サブカメラの消去 -*/
  if (parent->isEditPreviewSubcamera()) {
    action = addAction(tr("Reset Subcamera"));
    ret =
        ret &&
        parent->connect(action, SIGNAL(triggered()), SLOT(doDeleteSubCamera()));
    addSeparator();
  }

  // tool
  TTool *tool = app->getCurrentTool()->getTool();
  if (tool && tool->isEnabled()) tool->addContextMenuItems(this);

  // fullscreen
  if (ImageUtils::FullScreenWidget *fsWidget =
          dynamic_cast<ImageUtils::FullScreenWidget *>(
              m_viewer->parentWidget())) {
    bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0;

    action =
        commandManager->createAction(V_ShowHideFullScreen, this, !isFullScreen);
    addAction(action);
    ret = ret &&
          parent->connect(action, SIGNAL(triggered()), fsWidget,
                          SLOT(toggleFullScreen()));
  }

  // swap compared
  if (parent->canSwapCompared()) {
    action = addAction(tr("Swap Compared Images"));
    ret    = ret &&
          parent->connect(action, SIGNAL(triggered()), SLOT(swapCompared()));
  }

  // reset
  action = commandManager->createAction(V_ZoomReset, this);
  addAction(action);
  ret = ret &&
        parent->connect(action, SIGNAL(triggered()), SLOT(resetSceneViewer()));

  if (!isEditingLevel) {
    // fit camera
    action = commandManager->createAction(V_ZoomFit, this);
    addAction(action);
    ret = ret &&
          parent->connect(action, SIGNAL(triggered()), SLOT(fitToCamera()));
  }

  // actual pixel size
  action = commandManager->createAction(V_ActualPixelSize, this);
  addAction(action);
  ret =
      ret &&
      parent->connect(action, SIGNAL(triggered()), SLOT(setActualPixelSize()));

  // onion skin
  if (Preferences::instance()->isOnionSkinEnabled() &&
      !parent->isPreviewEnabled())
    OnioniSkinMaskGUI::addOnionSkinCommand(this);

  // preview
  if (parent->isPreviewEnabled()) {
    addSeparator();

    // save previewed frames
    action = addAction(tr("Save Previewed Frames"));
    action->setShortcut(QKeySequence(
        CommandManager::instance()->getKeyFromId(MI_SavePreviewedFrames)));
    ret = ret &&
          parent->connect(action, SIGNAL(triggered()), this,
                          SLOT(savePreviewedFrames()));

    // regenerate preview
    action = addAction(tr("Regenerate Preview"));
    action->setShortcut(QKeySequence(
        CommandManager::instance()->getKeyFromId(MI_RegeneratePreview)));
    ret =
        ret &&
        parent->connect(action, SIGNAL(triggered()), SLOT(regeneratePreview()));

    // regenerate frame preview
    action = addAction(tr("Regenerate Frame Preview"));
    action->setShortcut(QKeySequence(
        CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr)));
    ret = ret &&
          parent->connect(action, SIGNAL(triggered()),
                          SLOT(regeneratePreviewFrame()));
  }

  assert(ret);
}