Example #1
0
/**
 * set size of frame (and the platform representation)
 * @param width new width
 * @param height new height
 * @return true on success
 */
bool CFrame::setSize (CCoord width, CCoord height)
{
	if ((width == getViewSize ().getWidth ()) && (height == getViewSize ().getHeight ()))
		return false;

	CRect newSize (getViewSize ());
	newSize.setWidth (width);
	newSize.setHeight (height);

	if (getEditor ())
	{
		if (getEditor ()->beforeSizeChange (newSize, getViewSize ()) == false)
			return false;
	}
	if (platformFrame)
	{
		if (platformFrame->setSize (newSize))
		{
			CViewContainer::setViewSize (newSize);
			return true;
		}
		return false;
	}
	CViewContainer::setViewSize (newSize);
	return true;
}
Example #2
0
void Spinner::setEditable(bool Editable)
{
    if(getEditor() != NULL && getEditor()->getType().isDerivedFrom(SpinnerEditor::getClassType()))
    {
        dynamic_cast<SpinnerEditor*>(getEditor())->setEditable(Editable);
    }
}
Example #3
0
void FileReader::setParameter (int parameterIndex, float newValue)
{
    switch (parameterIndex)
    {
        //Change selected recording
        case 0:
            setActiveRecording (newValue);
            break;

        //set startTime
        case 1: 
            startSample = millisecondsToSamples (newValue);
            currentSample = startSample;

            static_cast<FileReaderEditor*> (getEditor())->setCurrentTime (samplesToMilliseconds (currentSample));
            break;

        //set stop time
        case 2:
            stopSample = millisecondsToSamples(newValue);
            currentSample = startSample;

            static_cast<FileReaderEditor*> (getEditor())->setCurrentTime (samplesToMilliseconds (currentSample));
            break;
    }
}
Example #4
0
void ComboBox::updateSelectionFromEditor(void)
{
    if(getEditable() && getEditor() != NULL)
    {
        const boost::any& EditorItem = getEditor()->getItem();

        std::string EditorString;
        std::string ModelItemString;
        bool ExitLoop(false);
        for(UInt32 i(0) ; i<getModel()->getSize() && !ExitLoop ; ++i)
        {
            try
            {
                EditorString = lexical_cast(EditorItem);
                ModelItemString = lexical_cast(getModel()->getElementAt(i));
            }
            catch (boost::bad_lexical_cast &)
            {
                //Could not convert to string
            }
            if(EditorString.compare(ModelItemString) == 0)
            {
                ExitLoop = true;

                getModel()->setSelectedItem(i);
            }
        }
    }
}
Example #5
0
void ComboBox::handleMenuItemActionPerformed(ActionEventDetails* const e)
{
    //Called by the MenuItems in my popupMenu

    //Need to determine the index of this MenuItem
    UInt32 i(0);
    while(i<getComboListPopupMenu()->getNumItems() && 
          getComboListPopupMenu()->getItem(i) != dynamic_cast<MenuItem*>(e->getSource()))
    {
        ++i;
    }

    if(i < getComboListPopupMenu()->getNumItems())
    {
        getModel()->setSelectedItem(i);
        if(getEditable() && getEditor() != NULL && getEditor()->getEditorComponent() != NULL)
        {
            getEditor()->selectAll();
            getEditor()->getEditorComponent()->takeFocus();
        }
        if(!getEditable() && getComponentGeneratorSelectedItem() != NULL)
        {
            getComponentGeneratorSelectedItem()->takeFocus();
        }
    }
}
Example #6
0
// *********************************************************************************************************
bool CDisplayerLua::init(const CLuaObject &parameters)
{
	//H_AUTO(R2_CDisplayerLua_init)
	// parameters should be a function that create the lua displayer
	CLuaStackChecker lsc(parameters.getLuaState());
	_ToLua._LuaTable.release();
	if (parameters.isString())
	{
		getEditor().getEnv()[parameters.toString()].push(); // get method from the R2 env
	}
	else
	{
		parameters.push();
	}
	CLuaState &ls = *parameters.getLuaState();
	getEditor().getEnv().push(); // this is a method call
	if (CLuaIHM::executeFunctionOnStack(ls,  1,  1))
	{
		_ToLua._LuaTable.pop(ls);
	}
	else
	{
		nlwarning("<CDisplayerLua::init> Error while calling displayer ctor (parameter should be a r2 method, or the *name* of a r2 method) : param is : ");
		parameters.dump();
		return false;
	}
	return CDisplayerBase::init(parameters);
}
void DefaultComboBoxEditor::selectAll(void)
{
	if(getEditor() != NULL)
	{
		getEditor()->selectAll();
	}
}
Example #8
0
void ComboBox::setEmptyDescText(const std::string& text)
{
    if(getEditor() != NULL &&
       getEditor()->getEditorComponent() != NULL &&
       getEditor()->getEditorComponent()->getType().isDerivedFrom(TextField::getClassType()))
    {
        dynamic_cast<TextField*>(getEditor()->getEditorComponent())->setEmptyDescText(text);
    }
}
Example #9
0
/** @brief Get the canvas for this panel

*/
CtrlrPanelCanvas *CtrlrPanel::getCanvas()
{
	if (getEditor())
	{
		return (getEditor()->getCanvas());
	}

	return (0);
}
Example #10
0
// **********************************************
void CToolPick::updateAfterRender()
{
	//H_AUTO(R2_CToolPick_updateAfterRender)
	// See if the mouse is over a valid position
	_ValidPos = false;
	sint32 mouseX,  mouseY;
	getMousePos(mouseX,  mouseY);
	if (!isInScreen(mouseX,  mouseY))
	{
		getEditor().setFocusedInstance(NULL);
		setMouseCursor(_CursCannotPickPos);
		return;
	}
	_CandidateInstance = NULL;
	CInstance *instanceUnder = checkInstanceUnderMouse();
	bool ignoreInstanceUnder = false;
	if(instanceUnder && _IgnoreInstances.size()>0)
	{
		for(uint i=0; i<_IgnoreInstances.size(); i++)
		{
			if(instanceUnder->isKindOf(_IgnoreInstances[i]))
			{
				ignoreInstanceUnder = true;
				break;
			}
		}
	}
	if (!instanceUnder || ignoreInstanceUnder)
	{
		if (isMouseOnUI() && !isMouseOnContainer())
		{
			setMouseCursor(DEFAULT_CURSOR);
		}
		else
		{
			CTool::CWorldViewRay worldViewRay;
			computeWorldViewRay(mouseX,  mouseY,  worldViewRay);
			CVector inter;
			_ValidPos = (ValidPacsPos == computeLandscapeRayIntersection(worldViewRay,  _Intersection));
			setMouseCursor(_ValidPos ? _CursCanPickPos : _CursCannotPickPos);
			getEditor().setFocusedInstance(NULL);
		}
		return;
	}
	getEditor().setFocusedInstance(instanceUnder);
	if (canPick(*instanceUnder))
	{
		_CandidateInstance = instanceUnder;
		setMouseCursor(_CursCanPickInstance);
	}
	else
	{
		setMouseCursor(_CursCannotPickInstance);
	}
}
void CActionHistoric::CRequestInsertNode::undo(IDynamicMapClient *dmc, CScenario &scenario)
{
	//H_AUTO(R2_CRequestInsertNode_undo)
	nlassert(scenario.getHighLevel()); // if this assert fires, then 'clear' was called with a NULL pointer ! The action historic need a start scenario to have undo capability
	nlassert(dmc);
	// if there's a key here, not good for us :(
	// so try to find another shorter name for this object...
	if (!_Key.empty())
	{
		std::string instanceId;
		std::string attrName;
		sint32      position;
		CObject *currObj = scenario.find(_InstanceId, _AttrName, _Position, _Key);
		if (!currObj) return;
		if (currObj->getShortestName(instanceId, attrName, position))
		{
			// modify local version
			scenario.eraseNode(instanceId, attrName, position);
			// send to network
			dmc->doRequestEraseNode(instanceId, attrName, position);

			CLuaIHM::push(getEditor().getLua(), instanceId);
			getEditor().callEnvMethod("setUndoRedoInstances", 1, 0);
		}
		else
		{
			nlassert(0); // TMP : can this really happen in practice ?
			nlwarning("Can't build request insert node reciprocal");
		}
	}
	else
	{
		// special here : if position is -1, requestEraseNode will erase the
		// table, not the last element!
		if (!_AttrName.empty() && _Position == -1)
		{
			CObject *parentTable = scenario.find(_InstanceId, _AttrName);
			if (parentTable && parentTable->isTable())
			{
				uint index = parentTable->getSize() - 1;
				// modify local version
				scenario.eraseNode(_InstanceId, _AttrName, index);
				// send to network
				dmc->doRequestEraseNode(_InstanceId, _AttrName, index);
			}
		}
		else
		{
			// modify local version
			scenario.eraseNode(_InstanceId, _AttrName, _Position);
			// send to network
			dmc->doRequestEraseNode(_InstanceId, _AttrName, _Position);
		}
	}
}
Example #12
0
// *********************************************************************************************************
bool CDisplayerVisual::isActiveInCurrentAct() const
{
	//H_AUTO(R2_CDisplayerVisual_isActiveInCurrentAct)
	// parent act should be the base act (always exists), or the selected act
	CInstance *parentAct = getDisplayedInstance()->getParentAct();
	if (parentAct == getEditor().getBaseAct() || parentAct == getEditor().getCurrentAct())
	{
		return true;
	}
	return false;
}
Example #13
0
bool Spinner::getEditable(void) const
{
    if(getEditor() != NULL && getEditor()->getType().isDerivedFrom(SpinnerEditor::getClassType()))
    {
        return dynamic_cast<SpinnerEditor*>(getEditor())->getEditable();
    }
    else
    {
        return false;
    }
}
Example #14
0
void DeleteSelectedBlocks::execute(QString, QString, QString, QString, QString)
{    
    QGraphicsScene* scene = getEditor()->getScene();
      
    QList<BlockItem*> selectedBlocks = SceneDetective::getSelectedBlocks(scene);
    foreach(BlockItem* block, selectedBlocks)
    {
        getEditor()->runScriptCommand(
            QString("Delete the block %1")
            .arg(block->name())
            );        
    }
Example #15
0
void DefaultComboBoxEditor::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

	if((whichField & EditorFieldMask) && getEditor() != NULL)
	{
        _TextFieldFocusGainedConnection = getEditor()->connectFocusGained(boost::bind(&DefaultComboBoxEditor::handleTextFieldFocusGained, this, _1));
        _TextFieldFocusLostConnection = getEditor()->connectFocusLost(boost::bind(&DefaultComboBoxEditor::handleTextFieldFocusLost, this, _1));
	}
}
Example #16
0
void CDynamicMapClient::onNpcAnimationTargeted(uint32 mode)
{
	//H_AUTO(R2_CDynamicMapClient_onNpcAnimationTargeted)
	nlinfo("R2Cl: DSS_TARGET");

	CLuaState &lua = getEditor().getLua();
	CLuaStackChecker lsc(&lua);

	int initialStackSize = lua.getTop();


	if (mode & CAnimationProp::Spawnable)
	{
		lua.push("r2ed_anim_despawn");
	}

	if (mode & CAnimationProp::Alive)
	{
		lua.push("r2ed_anim_kill");
		if (mode & CAnimationProp::Grouped)	{	lua.push("r2ed_anim_grp_kill"); }
		lua.push("r2ed_anim_add_hp");
		if (mode & CAnimationProp::Grouped)	{	lua.push("r2ed_anim_grp_heal"); }

	}

	if (mode & CAnimationProp::Controlable)
	{
		if (mode & CAnimationProp::Controled )
		{
			lua.push("r2ed_anim_stop_control");
		}
		else
		{
			lua.push("r2ed_anim_control");
		}
	}

	if (mode & CAnimationProp::Speaking)
	{
		if(mode & CAnimationProp::SpeakedAs)
		{
			lua.push("r2ed_anim_stop_speak");
		}
		else
		{
			lua.push("r2ed_anim_speak_as");
		}
	}

	//
	getEditor().callEnvMethod("updateAnimBarActions", lua.getTop() - initialStackSize);

}
Example #17
0
void CtrlrManager::valueTreePropertyChanged (ValueTree &treeWhosePropertyHasChanged, const Identifier &property)
{
	if (property == Ids::ctrlrAutoSave)
	{
		if ((bool)getProperty (property) == true)
		{
			startTimer (TIMER_AUTO_SAVE, (int)getProperty (Ids::ctrlrAutoSaveInterval)*1000);
		}
		else
		{
			stopTimer (TIMER_AUTO_SAVE);
		}
	}
	else if (property == Ids::ctrlrAutoSaveInterval)
	{
		stopTimer (TIMER_AUTO_SAVE);

		if ((bool)getProperty (Ids::ctrlrAutoSave) == true)
		{
			startTimer (TIMER_AUTO_SAVE, (int)getProperty (Ids::ctrlrAutoSaveInterval)*1000);
		}
	}
	else if (property == Ids::ctrlrLogToFile)
	{
		ctrlrLog.setLogToFile ((bool)getProperty(property));
	}
	else if (property == Ids::ctrlrLuaDebug)
	{
		for (int i=0; i<ctrlrPanels.size(); i++)
		{
			ctrlrPanels[i]->setLuaDebug((bool)getProperty(property));
		}
	}
	else if (property == Ids::ctrlrLogOptions)
	{
		ctrlrLog.setMidiLogOptions (getProperty(property));
	}
	else if (property == Ids::ctrlrNativeAlerts)
	{
		if (getCtrlrLookAndFeel())
		{
			getCtrlrLookAndFeel()->setUsingNativeAlerts(getProperty(property));
		}
	}
	else if (property == Ids::ctrlrUsingOpenGL)
    {
        if (getEditor())
        {
            getEditor()->setUsingOpenGL (getProperty (property));
        }
    }
}
Example #18
0
void ComboBox::updateSelectedItemComponent(void)
{
    //Update the Editor
    if(getEditable() && getEditor() != NULL && getModel()->getSelectedItemIndex() >=0 )
    {
        getEditor()->setItem(getModel()->getElementAt(getModel()->getSelectedItemIndex()));
    }

    //Update the Selected Item Component
    if( !getEditable() )
    {
        updateComponentGeneratorSelectedItem();
    }
}
Example #19
0
void WidgetsManager::changeListenerCallback(
    juce::ChangeBroadcaster *source) {
  // No other change broacaster than the processor for now!
  OPENMINI_ASSERT(&(getEditor()) == source);
  // Update UI components without sending back
  // notifications to the processor
  for (int param_id(0);
       param_id < widgets_.size();
       ++param_id) {
    Widget* widget = widgets_[param_id];
    widget->setValue(getEditor().GetParamValue(param_id),
                     juce::dontSendNotification);
  }
}
Example #20
0
// ***************************************************************
bool CToolSelectRotate::onMouseLeftButtonDown()
{
	//H_AUTO(R2_CToolSelectRotate_onMouseLeftButtonDown)
	bool result = CToolMaintainedAction::onMouseLeftButtonDown();
	if (!result) return false;
	if (_State == ActionNotPossible)
	{
		CTool::TSmartPtr holder(this);
		cancel();
		// for ergonomy, switch to the 'move' tool
		getEditor().setCurrentTool(new CToolSelectMove);
		return getEditor().getCurrentTool()->onMouseLeftButtonDown();
	}
	return true;
}
Example #21
0
//***************************************************************
void CToolCreateEntity::updateAfterRender()
{
	//H_AUTO(R2_CToolCreateEntity_updateAfterRender)
	if (_CreateState != DrawArray)
	{
		CToolChoosePos::updateAfterRender();
		return;
	}
	switch(_ArrayWantedAction)
	{
		case ArrayActionNone:
		break;
		case ArrayActionValidate:
		{
			commitArray();
			CTool::TSmartPtr hold(this);
			getUI().runActionHandler("r2ed_create_entity", NULL, "PaletteId="+_PaletteId);
			return;
		}
		break;
		case ArrayActionCancel:
		{
			CTool::TSmartPtr hold(this);
			cancel();
			getEditor().setCurrentTool(NULL);
			return;
		}
		break;
	}
	updateArray(NULL);
}
Example #22
0
void LfpDisplayNode::setSampleRate(float r)
{
	sampleRate = r;

	LfpDisplayEditor* editor = (LfpDisplayEditor*) getEditor();
	editor->updateSampleRate(r);
}
Example #23
0
void OpenMaEditorTask::open() {
    if (stateInfo.hasError() || (maObject.isNull() && documentsToLoad.isEmpty())) {
        return;
    }
    if (maObject.isNull()) {
        Document* doc = documentsToLoad.first();
        if(!doc){
            stateInfo.setError(tr("Documet removed from project"));
            return;
        }
        if (unloadedReference.isValid()) {
            GObject* obj = doc->findGObjectByName(unloadedReference.objName);
            if (obj!=NULL && obj->getGObjectType() == type) {
                maObject = qobject_cast<MultipleAlignmentObject*>(obj);
            }
        } else {
            QList<GObject*> objects = doc->findGObjectByType(type, UOF_LoadedAndUnloaded);
            maObject = objects.isEmpty() ? NULL : qobject_cast<MultipleAlignmentObject*>(objects.first());
        }
        if (maObject.isNull()) {
            stateInfo.setError(tr("Multiple alignment object not found"));
            return;
        }
    }
    viewName = GObjectViewUtils::genUniqueViewName(maObject->getDocument(), maObject);
    uiLog.details(tr("Opening MSA editor for object: %1").arg(maObject->getGObjectName()));

    MaEditor* v = getEditor(viewName, maObject);
    GObjectViewWindow* w = new GObjectViewWindow(v, viewName, false);
    MWMDIManager* mdiManager = AppContext::getMainWindow()->getMDIManager();
    mdiManager->addMDIWindow(w);

}
Example #24
0
//***************************************************************
CAutoGroup::CAutoGroup()
{
	CPrimLook primGroup;
	primGroup.init(getEditor().getEnv()["PrimRender"]["AutoGroupLook"]);
	_AutoGroup.setLook(primGroup);
	_AutoGroupEnabled = false;
}
Example #25
0
void FileReader::process (AudioSampleBuffer& buffer)
{
    const int samplesNeededPerBuffer = int (float (buffer.getNumSamples()) * (getDefaultSampleRate() / m_sysSampleRate));
    m_samplesPerBuffer.set(samplesNeededPerBuffer);
    // FIXME: needs to account for the fact that the ratio might not be an exact
    //        integer value
    
    // if cache window id == 0, we need to read and cache BUFFER_WINDOW_CACHE_SIZE more buffer windows
    if (bufferCacheWindow == 0)
    {
        switchBuffer();
    }
    
    for (int i = 0; i < currentNumChannels; ++i)
    {
        // offset readBuffer index by current cache window count * buffer window size * num channels
        input->processChannelData (*readBuffer + (samplesNeededPerBuffer * currentNumChannels * bufferCacheWindow),
                                   buffer.getWritePointer (i, 0),
                                   i,
                                   samplesNeededPerBuffer);
    }
    
    setTimestampAndSamples(timestamp, samplesNeededPerBuffer);
	timestamp += samplesNeededPerBuffer;

	static_cast<FileReaderEditor*> (getEditor())->setCurrentTime(samplesToMilliseconds(startSample + timestamp % (stopSample - startSample)));
    
    bufferCacheWindow += 1;
    bufferCacheWindow %= BUFFER_WINDOW_CACHE_SIZE;
}
Example #26
0
//***************************************************************
CToolCreateEntity::CToolCreateEntity(uint ghostSlot, const std::string &paletteId, bool arrayMode) : CToolChoosePos(ghostSlot)
{
	_PaletteId = paletteId;
	if (!arrayMode)
	{
		enableMultiPos();
	}
	_CreateState = CreateSingle;
	_ArrayOrigin.set(0.f, 0.f, 0.f);
	_ArrayEnd.set(0.f, 0.f, 0.f);
	_ArrayDefaultAngle = 0.f;
	if (arrayMode)
	{
		CObject *paletteNode = getEditor().getDMC().getPaletteElement(paletteId);
		if (paletteNode)
		{
			std::string sheetClient = getString(paletteNode, "SheetClient");
			if (isBotObjectSheet(CSheetId(sheetClient)))
			{
				_CreateState = ChooseArrayOrigin;
			}
		}
	}
	_ArrayWantedAction = ArrayActionNone;
}
void CActionHistoric::CRequestInsertNode::redo(IDynamicMapClient *dmc, CScenario &scenario)
{
	//H_AUTO(R2_CRequestInsertNode_redo)
	nlassert(dmc);
	if (scenario.getHighLevel())
	{
		// modify local version
		scenario.insertNode(_InstanceId, _AttrName, _Position, _Key, cloneObject(_Value));
	}
	// send to network
	dmc->doRequestInsertNode(_InstanceId, _AttrName, _Position, _Key, _Value);

	CObject* nodeId = _Value->findAttr("InstanceId");
	CLuaIHM::push(getEditor().getLua(), nodeId->toString());
	getEditor().callEnvMethod("setUndoRedoInstances", 1, 0);
}
Example #28
0
// ***************************************************************
void CToolSelectRotate::setEntityAngle(CEntityCL &/* entity */, CInstance &instance, float angle)
{
	//H_AUTO(R2_CToolSelectRotate_setEntityAngle)
	CObjectNumber *angleObject = new CObjectNumber(angle);
	getEditor().requestSetLocalNode(instance.getId(), "Angle", angleObject);
	delete angleObject;
}
Example #29
0
bool SpikeDisplayNode::disable()
{
    std::cout << "SpikeDisplayNode disabled!" << std::endl;
    SpikeDisplayEditor* editor = (SpikeDisplayEditor*) getEditor();
    editor->disable();
    return true;
}
// ************************************************************************
bool CObjectRefIdClient::set(const std::string &key, const std::string & value)
{
	//H_AUTO(R2_CObjectRefIdClient_set)
	//nlwarning("# Setting CObjectRefIdClient 0x%x value to %s", (int) this, value.c_str());
	if (_Enabled)
	{
		nlassert(getValue().empty() == (_ObserverHandle == CEditor::BadInstanceObserverHandle));
	}
	if (value == getValue()) return true;
	if (_Enabled)
	{
		removeObserverHandle();
	}
	bool nodeSet = CObjectRefId::set(key, value);
	if (_Enabled)
	{
		if (!value.empty())
		{
			_ObserverHandle = getEditor().addInstanceObserver(value, this);
		}

		nlassert(getValue().empty() == (_ObserverHandle == CEditor::BadInstanceObserverHandle));
	}
	return nodeSet;
}