SplitmediaLabsLimited / xui-old

1 stars 1 forks source link

Is add item with position/coordinates possible #2

Closed dabruhce closed 9 years ago

dabruhce commented 9 years ago

I wrapped some of this in angular for a few quick tests, also poked around some of the functional tests, and I'm getting various odd behavior. Essentially, not able to setname of a scene that is not the active scene after init of .run, however if I preselect a different scene then reexecute the Go() function if will rename the secondary scene. I'm probably simply not executing something correctly as this seemed to work when I mucked with it based on the functional tests. Probably need to digest or apply perhaps.

Also as far as I can tell you can't add an item to a nonactive scene, nor can you add coordinates/positions to an item. Which would be a nice to have feature.

 .run(function($rootScope){

  $rootScope.xuicore = new xui.core.App();
  $rootScope.xuiItem = new xui.core.Item();
  $rootScope.activeScene = new xui.core.View();

document.addEventListener('xui-ready', function() {

      $rootScope.Scene1 = new xui.core.Scene({id: 0, viewID: 0, name: 1});
      $rootScope.Scene2 = new xui.core.Scene({id: 1, viewID: 0, name: 2});

      $rootScope.Scene1.setName("Main");

      //this will work on a 2nd run if active scene is set to scene2
      $rootScope.Scene2.setName("Main2");

}

.controller('DashCtrl', function($scope,$rootScope) {

  $scope.Go = function()
  {
      $scope.datas = "NA";
      var datasScene1 = {};

      $rootScope.Scene1.setName("Main4141");
      $rootScope.Scene2.setName("Main41412");
       $rootScope.xuicore.clearPresentation();

      $rootScope.Scene1.setName("Main4141");
      $rootScope.Scene2.setName("Main4141");

  }

}

This did seem to work prior to wrapping it in angular. Something like this...

         var datasScene1 = {};
        var Scene1 = new xui.core.Scene({id: 0, viewID: 0, name: 1});
        Scene1.setName("Main2");

        var datasScene2 = {};
        var Scene2 = new xui.core.Scene({id: 1, viewID: 0, name: 2});
        Scene2.setName("Question2");

        var Scene3 = new xui.core.Scene({id: 2, viewID: 0, name: 3});
        Scene3.setName("Awnser2");

        var Scene4 = new xui.core.Scene({id: 3, viewID: 0, name: 4});
        Scene4.setName("xyz");
ghost commented 9 years ago

I assume that you're executing that code as a global script or a properties editor based code (setting of scene names wont work on source plugins).

Theoretically, the xui framework should work even if you're using angular. I tried it on my side, and it does work perfectly.

Here's a gist for the code that I made to test it out (angular 1.4.4)

However, please do note that when you do execute Scene.setName() on a new presentation, it would only work on Scenes that are already loaded. This is by design/limitation of XBC client (conserving memory). What I mean is that if you load a presentation that has items until Scene 5, you can only modify Scenes upto Scene 5 using global script.

In order to modify scenes from 1 to 12, you'll have to manually select/activate Scene 12. That way, XBC would allow modifying all scenes from 1 to 12 using global script.

The code to do just that is:

var View = new xui.core.View();
View.setActiveScene(11); // Activate Scene 12
View.setActiveScene(0); // Revert to Scene 1

That's just a workaround, and there's a better way to do it, but it is not yet exposed on this current version of our framework.

So with that, once you already pre-loaded all the scenes, you can now start adding up items to those scenes using Scene.add() method.

As for the positioning of items, the framework currently has no way of initially setting the position of the item, but once you already added it to the scene, you can modify the coordinates of the item using the setPosition() method of Item class.