Script should still work after loadsvg is used
[ipdf/code.git] / src / debugscript.cpp
index b8746ed..fa32fc2 100644 (file)
@@ -60,15 +60,40 @@ void DebugScript::ParseAction()
                currentAction.type = AT_ZoomPx;
                return;
        }
+       else if (actionType == "gpu")
+       {
+               currentAction.type = AT_SetGPURendering;
+               return;
+       }
+       else if (actionType == "cpu")
+       {
+               currentAction.type = AT_SetCPURendering;
+               return;
+       }
+       else if (actionType == "lazy")
+       {
+               currentAction.type = AT_EnableLazyRendering;
+               return;
+       }
+       else if (actionType == "nolazy")
+       {
+               currentAction.type = AT_DisableLazyRendering;
+               return;
+       }
        else if (actionType == "quit")
        {
                currentAction.type = AT_Quit;
        }
+       else if (actionType == "loadsvg")
+       {
+               currentAction.type = AT_LoadSVG;
+               inp >> currentAction.filename;
+       }
 }
 
 bool DebugScript::Execute(View *view, Screen *scr)
 {
-       if (currentAction.loops == 0)
+       if (currentAction.loops <= 0)
                ParseAction();
 
        switch(currentAction.type)
@@ -89,6 +114,31 @@ bool DebugScript::Execute(View *view, Screen *scr)
        case AT_ZoomPx:
                view->ScaleAroundPoint(Real(currentAction.ix)/Real(scr->ViewportWidth()),Real(currentAction.iy)/Real(scr->ViewportHeight()), Real(expf(-currentAction.iz/20.f)));
                break;
+       case AT_SetGPURendering:
+               view->SetGPURendering(true);
+               break;
+       case AT_SetCPURendering:
+               view->SetGPURendering(false);
+               break;
+       case AT_EnableLazyRendering:
+               view->SetLazyRendering(true);
+               break;
+       case AT_DisableLazyRendering:
+               view->SetLazyRendering(false);
+               break;
+       case AT_LoadSVG:
+               #ifdef TRANSFORM_OBJECTS_NOT_VIEW
+                       view->Doc().LoadSVG(currentAction.filename, Rect(Real(1)/Real(2),Real(1)/Real(2),Real(1)/Real(800),Real(1)/Real(600))); 
+               #else
+                       Rect & bounds = view->GetBounds();
+                       view->Doc().LoadSVG(currentAction.filename, Rect(bounds.x+bounds.w/Real(2),bounds.y+bounds.h/Real(2),bounds.w/Real(800),bounds.h/Real(600)));
+               #endif
+               currentAction.type = AT_WaitFrame;
+               view->ForceRenderDirty();
+               view->ForceBufferDirty();
+               view->ForceBoundsDirty();
+               currentAction.loops = 1;
+               break;
        default:
                Fatal("Unknown script command in queue.");
        }

UCC git Repository :: git.ucc.asn.au