Exemplo n.º 1
0
void Viewport::setViewPositionProportionately (const double x, const double y)
{
    if (contentComp != nullptr)
        setViewPosition (jmax (0, roundToInt (x * (contentComp->getWidth()  - getWidth()))),
                         jmax (0, roundToInt (y * (contentComp->getHeight() - getHeight()))));
}
Exemplo n.º 2
0
void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset)
{
    setViewPosition (Point<int> (xPixelsOffset, yPixelsOffset));
}
Exemplo n.º 3
0
void GameObjectView::setViewPosition( float x, float y, float z ) {
  setViewPosition(x,y,z,1);
  }
Exemplo n.º 4
0
void GameObjectView::setViewPosition( float x, float y, float z,
                                      float interp ) {
  float nx[3] = {};
  nx[0] = m.vpos[0] + (x - m.vpos[0])*interp;
  nx[1] = m.vpos[1] + (y - m.vpos[1])*interp;
  nx[2] = m.vpos[2] + (z - m.vpos[2])*interp;

  if( m.vpos[0] == nx[0] &&
      m.vpos[1] == nx[1] &&
      m.vpos[2] == nx[2] )
    return;

  wrld.updateIntent(this);

  std::copy( nx, nx+3, m.vpos );

  for( size_t i=0; i<env.size(); ++i ){
    //setViewPosition( env[i], getClass().view[i], x, y, z );
    EnvObject::Form & form = env[i].form;

    float dp[3] = { env[i].model().cenX(),
                    env[i].model().cenY(),
                    env[i].model().cenZ() };

    for( int r=0; r<3; ++r ){
      dp[r] = dp[r]*getClass().view[ env[i].viewID ].size[r];
      }

    float a = atan2( (double)m.intentDirY, (double)m.intentDirX );
    float s = sin(a), c = cos(a);
    float ax = dp[0], ay = dp[1];
    dp[0] = c*ax - s*ay;
    dp[1] = s*ax + c*ay;

    if( form.sphere.isValid() )
      form.sphere.setPosition(x+dp[0], y+dp[1], z+dp[2] );

    if( form.box.isValid() )
      form.box.setPosition( x+dp[0], y+dp[1], z+dp[2] );
    }

  for( size_t i=0; i<view.size(); ++i ){
    setViewPosition( view[i], getClass().view[i], x, y, z, interp );
    }

  for( size_t i=0; i<smallViews.size(); ++i ){
    setViewPosition( *smallViews[i], smallViews[i]->view, x, y, z, interp );
    }

  for( size_t i=0; i<particles.size(); ++i ){
    particles[i].setPosition( x, y, z );
    }

  float wx = World::coordCastD(x)/Terrain::quadSizef,
        wy = World::coordCastD(y)/Terrain::quadSizef;
  //float zland = World::coordCast( std::max( wrld.terrain().heightAt(wx,wy),
  //                                          wrld.terrain().atF(wx,wy) ) );
  float zland = World::coordCast( wrld.terrain().heightAt(wx,wy) );

  for( int i=0; i<selectModelsCount; ++i ){
    float x1 = selection[i]->x() + (x-selection[i]->x())*interp;
    float y1 = selection[i]->y() + (y-selection[i]->y())*interp;

    if( selection[i]->isVisible() )
      selection[i]->setPosition( x1, y1, zland+0.01 );
    }
    //selection[i]->setPosition( x, y, zland+0.01, interp );

  float dx = 0, dy = 0, dz = 0;
  if( view.size() ){
    const int * align = getClass().view[0].align;
    double alignSize  = getClass().view[0].alignSize;

    dx = m.modelSize[0]*view[0].sizeX()*align[0]*alignSize;
    dy = m.modelSize[1]*view[0].sizeY()*align[1]*alignSize;
    dz = m.modelSize[2]*view[0].sizeZ()*align[2]*alignSize;
    }

  if( anim.sphere.isValid() ){
    anim.sphere.setPosition(x+dx,y+dy,z+dz);
    }
  if( anim.box.isValid() ){
    anim.box.setPosition(x+dx,y+dy,z+dz);
    }
  }
Exemplo n.º 5
0
void GameObjectView::setViewPosition(float x, float y) {
  int z = wrld.terrain().heightAt( World::coordCastD(x)/Terrain::quadSizef,
                                   World::coordCastD(y)/Terrain::quadSizef );

  setViewPosition( x, y, World::coordCast(z) );
  }
Exemplo n.º 6
0
//-------------------------------------------------------------------------------------------------------
long AudioEffectX::dispatcher (long opCode, long index, long value, void *ptr, float opt)
{
    long v = 0;
    switch(opCode)
    {
    // VstEvents
    case effProcessEvents:
        v = processEvents ((VstEvents*)ptr);
        break;

    // parameters and programs
    case effCanBeAutomated:
        v = canParameterBeAutomated (index) ? 1 : 0;
        break;
    case effString2Parameter:
        v = string2parameter (index, (char*)ptr) ? 1 : 0;
        break;

    case effGetNumProgramCategories:
        v = getNumCategories ();
        break;
    case effGetProgramNameIndexed:
        v = getProgramNameIndexed (value, index, (char*)ptr) ? 1 : 0;
        break;
    case effCopyProgram:
        v = copyProgram (index) ? 1 : 0;
        break;

    // connections, configuration
    case effConnectInput:
        inputConnected (index, value ? true : false);
        v = 1;
        break;
    case effConnectOutput:
        outputConnected (index, value ? true : false);
        v = 1;
        break;
    case effGetInputProperties:
        v = getInputProperties (index, (VstPinProperties*)ptr) ? 1 : 0;
        break;
    case effGetOutputProperties:
        v = getOutputProperties (index, (VstPinProperties*)ptr) ? 1 : 0;
        break;
    case effGetPlugCategory:
        v = (long)getPlugCategory ();
        break;

    // realtime
    case effGetCurrentPosition:
        v = reportCurrentPosition ();
        break;

    case effGetDestinationBuffer:
        v = (long)reportDestinationBuffer ();
        break;

    // offline
    case effOfflineNotify:
        v = offlineNotify ((VstAudioFile*)ptr, value, index != 0);
        break;
    case effOfflinePrepare:
        v = offlinePrepare ((VstOfflineTask*)ptr, value);
        break;
    case effOfflineRun:
        v = offlineRun ((VstOfflineTask*)ptr, value);
        break;

    // other
    case effSetSpeakerArrangement:
        v = setSpeakerArrangement ((VstSpeakerArrangement*)value, (VstSpeakerArrangement*)ptr) ? 1 : 0;
        break;
    case effProcessVarIo:
        v = processVariableIo ((VstVariableIo*)ptr) ? 1 : 0;
        break;
    case effSetBlockSizeAndSampleRate:
        setBlockSizeAndSampleRate (value, opt);
        v = 1;
        break;
    case effSetBypass:
        v = setBypass (value ? true : false) ? 1 : 0;
        break;
    case effGetEffectName:
        v = getEffectName ((char *)ptr) ? 1 : 0;
        break;
    case effGetErrorText:
        v = getErrorText ((char *)ptr) ? 1 : 0;
        break;
    case effGetVendorString:
        v = getVendorString ((char *)ptr) ? 1 : 0;
        break;
    case effGetProductString:
        v = getProductString ((char *)ptr) ? 1 : 0;
        break;
    case effGetVendorVersion:
        v = getVendorVersion ();
        break;
    case effVendorSpecific:
        v = vendorSpecific (index, value, ptr, opt);
        break;
    case effCanDo:
        v = canDo ((char*)ptr);
        break;
    case effGetIcon:
        v = (long)getIcon ();
        break;
    case effSetViewPosition:
        v = setViewPosition (index, value) ? 1 : 0;
        break;
    case effGetTailSize:
        v = getGetTailSize ();
        break;
    case effIdle:
        v = fxIdle ();
        break;

    case effGetParameterProperties:
        v = getParameterProperties (index, (VstParameterProperties*)ptr) ? 1 : 0;
        break;

    case effKeysRequired:
        v = (keysRequired () ? 0 : 1);	// reversed to keep v1 compatibility
        break;
    case effGetVstVersion:
        v = getVstVersion ();
        break;

#if VST_2_1_EXTENSIONS
    case effEditKeyDown:
        if (editor)
        {
            VstKeyCode keyCode = {index, (unsigned char)value, (unsigned char)opt};
            v = editor->onKeyDown (keyCode);
        }
        break;

    case effEditKeyUp:
        if (editor)
        {
            VstKeyCode keyCode = {index, (unsigned char)value, (unsigned char)opt};
            v = editor->onKeyUp (keyCode);
        }
        break;

    case effSetEditKnobMode:
        if (editor)
            v = editor->setKnobMode (value);
        break;

    case effGetMidiProgramName:
        v = getMidiProgramName (index, (MidiProgramName*)ptr);
        break;
    case effGetCurrentMidiProgram:
        v = getCurrentMidiProgram (index, (MidiProgramName*)ptr);
        break;
    case effGetMidiProgramCategory:
        v = getMidiProgramCategory (index, (MidiProgramCategory*)ptr);
        break;
    case effHasMidiProgramsChanged:
        v = hasMidiProgramsChanged (index) ? 1 : 0;
        break;
    case effGetMidiKeyName:
        v = getMidiKeyName (index, (MidiKeyName*)ptr) ? 1 : 0;
        break;

    case effBeginSetProgram:
        v = beginSetProgram () ? 1 : 0;
        break;
    case effEndSetProgram:
        v = endSetProgram () ? 1 : 0;
        break;

#endif // VST_2_1_EXTENSIONS

#if VST_2_3_EXTENSIONS
    case effGetSpeakerArrangement:
        v = getSpeakerArrangement ((VstSpeakerArrangement**)value, (VstSpeakerArrangement**)ptr) ? 1 : 0;
        break;

    case effSetTotalSampleToProcess:
        v = setTotalSampleToProcess (value);
        break;

    case effShellGetNextPlugin:
        v = getNextShellPlugin ((char*)ptr);
        break;

    case effStartProcess:
        v = startProcess ();
        break;
    case effStopProcess:
        v = stopProcess ();
        break;

    case effSetPanLaw:
        v = setPanLaw (value, opt) ? 1 : 0;
        break;

    case effBeginLoadBank:
        v = beginLoadBank ((VstPatchChunkInfo*)ptr);
        break;
    case effBeginLoadProgram:
        v = beginLoadProgram ((VstPatchChunkInfo*)ptr);
        break;
#endif // VST_2_3_EXTENSIONS

    // version 1.0 or unknown
    default:
        v = AudioEffect::dispatcher (opCode, index, value, ptr, opt);
    }
    return v;
}
Exemplo n.º 7
0
//==============================================================================
void Viewport::updateVisibleArea()
{
    const int scrollbarWidth = getScrollBarThickness();
    const bool canShowAnyBars = getWidth() > scrollbarWidth && getHeight() > scrollbarWidth;
    const bool canShowHBar = showHScrollbar && canShowAnyBars;
    const bool canShowVBar = showVScrollbar && canShowAnyBars;

    bool hBarVisible = canShowHBar && ! horizontalScrollBar.autoHides();
    bool vBarVisible = canShowVBar && ! verticalScrollBar.autoHides();

    Rectangle<int> contentArea (getLocalBounds());

    if (contentComp != nullptr && ! contentArea.contains (contentComp->getBounds()))
    {
        hBarVisible = canShowHBar && (hBarVisible || contentComp->getX() < 0 || contentComp->getRight() > contentArea.getWidth());
        vBarVisible = canShowVBar && (vBarVisible || contentComp->getY() < 0 || contentComp->getBottom() > contentArea.getHeight());

        if (vBarVisible)
            contentArea.setWidth (getWidth() - scrollbarWidth);

        if (hBarVisible)
            contentArea.setHeight (getHeight() - scrollbarWidth);

        if (! contentArea.contains (contentComp->getBounds()))
        {
            hBarVisible = canShowHBar && (hBarVisible || contentComp->getRight() > contentArea.getWidth());
            vBarVisible = canShowVBar && (vBarVisible || contentComp->getBottom() > contentArea.getHeight());
        }
    }

    if (vBarVisible)
        contentArea.setWidth (getWidth() - scrollbarWidth);

    if (hBarVisible)
        contentArea.setHeight (getHeight() - scrollbarWidth);

    contentHolder.setBounds (contentArea);

    Rectangle<int> contentBounds;
    if (contentComp != nullptr)
        contentBounds = contentHolder.getLocalArea (contentComp, contentComp->getLocalBounds());

    Point<int> visibleOrigin (-contentBounds.getPosition());

    if (hBarVisible)
    {
        horizontalScrollBar.setBounds (0, contentArea.getHeight(), contentArea.getWidth(), scrollbarWidth);
        horizontalScrollBar.setRangeLimits (0.0, contentBounds.getWidth());
        horizontalScrollBar.setCurrentRange (visibleOrigin.getX(), contentArea.getWidth());
        horizontalScrollBar.setSingleStepSize (singleStepX);
        horizontalScrollBar.cancelPendingUpdate();
    }
    else if (canShowHBar)
    {
        visibleOrigin.setX (0);
    }

    if (vBarVisible)
    {
        verticalScrollBar.setBounds (contentArea.getWidth(), 0, scrollbarWidth, contentArea.getHeight());
        verticalScrollBar.setRangeLimits (0.0, contentBounds.getHeight());
        verticalScrollBar.setCurrentRange (visibleOrigin.getY(), contentArea.getHeight());
        verticalScrollBar.setSingleStepSize (singleStepY);
        verticalScrollBar.cancelPendingUpdate();
    }
    else if (canShowVBar)
    {
        visibleOrigin.setY (0);
    }

    // Force the visibility *after* setting the ranges to avoid flicker caused by edge conditions in the numbers.
    horizontalScrollBar.setVisible (hBarVisible);
    verticalScrollBar.setVisible (vBarVisible);

    setViewPosition (visibleOrigin);

    const Rectangle<int> visibleArea (visibleOrigin.getX(), visibleOrigin.getY(),
                                      jmin (contentBounds.getWidth() - visibleOrigin.getX(),  contentArea.getWidth()),
                                      jmin (contentBounds.getHeight() - visibleOrigin.getY(), contentArea.getHeight()));

    if (lastVisibleArea != visibleArea)
    {
        lastVisibleArea = visibleArea;
        visibleAreaChanged (visibleArea);
    }

    horizontalScrollBar.handleUpdateNowIfNeeded();
    verticalScrollBar.handleUpdateNowIfNeeded();
}
Exemplo n.º 8
0
void Viewport::setViewPosition (const Point<int>& newPosition)
{
    setViewPosition (newPosition.getX(), newPosition.getY());
}
Exemplo n.º 9
0
void Viewport::setViewPosition (const int xPixelsOffset, const int yPixelsOffset)
{
    setViewPosition ({ xPixelsOffset, yPixelsOffset });
}