Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show hidden objects only when a viewing a specific slide/frame #57

Closed
sjn opened this issue Aug 6, 2011 · 14 comments
Closed

Show hidden objects only when a viewing a specific slide/frame #57

sjn opened this issue Aug 6, 2011 · 14 comments

Comments

@sjn
Copy link

sjn commented Aug 6, 2011

Hi! Thanks for making a very useful piece of software!

Is there a way to hide objects that aren't related to the "current view"? Here's my use case:

I have a presentation with text in it, and I would like to take a closer look at different parts of the text throughout the presentation. When I focus at one part (e.g. a paragraph, or a specific quote somewhere) I would like that some supporting objects are revealed, e.g. some arrows and comments, or a rectangle placed behind the text to attract attention to it. I would also like that these supporting objects are otherwise hidden when I view at another part of the text even if the other view location overlaps the first view.

Is this something that can be emulated? (e.g. adding an event handler that changes visibility of some objects when the presentation starts, and then subsequently shows and then hides different objects as the presentation proceeds from one frame to the next...)

If this can be done with adding an event handler, I'd be happy with that, but my Javascript skills are quite limited, so an example would be very much appreciated. :)

@sjn
Copy link
Author

sjn commented Aug 6, 2011

One naïve way to handle this might be to add a "show when in frame" sub-option to the "hide" option in the dialog; making the object in question hidden until it is the active frame (and then hide it again when moving away from that frame).

@aumouvantsillage
Copy link
Collaborator

It's an interesting idea. But other users are expecting a more general solution.
Currently, you can add a script to your presentation with a handler for the "framechange" event of Sozi.
This handler will show/hide objects depending on the current frame index.

In this example, an object will be visible in frame 42 only (note that the first frame index is 0).

var objectToShow = document.getElementById("idOfObjectToShow");
sozi.events.listen("framechange", function (index) {
     if (index === 42) {
         objectToShow.style.visibility = "visible";
    }
    else {
         objectToShow.style.visibility = "hidden";
    }
});

@aumouvantsillage
Copy link
Collaborator

Here is a sample document with 3 frames and 3 objects.
https://gist.github.com/1132368 (go to line 131)

The objects to show/hide are paths with XML ids "path3095", "path3097" and "path3099" (see lines 109 to 126).
Array "objList" provides information about which object to show in which frame.
The event handler will loop through this array and show/hide the object depending on the current frame index.

@rkappeler
Copy link

Hi!

I just stumbled across the same problem while trying to create a presentation with sozi. Do I get it right: the solution you proposed is to create the presentation and thereafter hack the .svg file? I don't mind coding a little bit by myself, but that doesn't really convince me... Just imagine, I want to make a change shortly before a presentation - maybe I have 40 slides... Quite frightening prospects!

What about working with layers? Could that be an approach to implement it?

@aumouvantsillage
Copy link
Collaborator

Do I get it right: the solution you proposed is to create the presentation and thereafter hack the .svg file?

Not exactly.
I have received multiple requests for this feature. Some people couldn't wait until it was available, so I gave them an example to show how the desired effect could be obtained.

It is still not clear how this feature should be designed: there are concerns about the document structure and the UI.

Working with layers is a possibility, but AFAIK, there is no standard definition of layers in the SVG standard. Inkscape uses SVG groups with custom XML attributes.
If I want to keep the player part of Sozi independent from any SVG editor, I prefer not to rely on how Inkscape implements layers.

@rkappeler
Copy link

Oh, are you already working/planing the feature? Thats great news!

I was browsing the code today. Really nicely commented and organized. Great work!

I am just thinking loud: the layers as defined in inkscape are transferred to the svg file, aren't they? So one could retrieve the information from the svg, couldn't it?
One would have to add a new attribute to the frame definition, e.g. activeLayers which could be of type dictionary (layerName : and if hidden or visible in this particular frame).

  • the js player would have to set the activeLayers upon startup/initialization and if necessary change the visibility while walking through the frames
  • the gui would need to have for each frame a list of all the layers and for each of the layers a checkbox to select if visible or hidden
  • hmm, what else?

@aumouvantsillage
Copy link
Collaborator

I am already implementing a new feature related to layers.
The purpose is not to show or hide objects but to have separate camera movements for each layer.

See a demo here:
http://sozi.baierouge.fr/wiki/_media/layers-demo.svg

@rkappeler
Copy link

Oh wow! I can't wait to try the new features!

Thank you very much! I love sozi!

btw: I've read on sozi's website, that the target browser is firefox. I usually also use firefox for browsing. However, the presentation, which I made with sozi, was running really slow (even stumbling) on firefox. Then I tried rekonq, which uses qtwebkit, and there the svg runs smoothly.

Obviously, it is known, that firefox performs poorly with svg and javascript ( http://blogs.msdn.com/b/ie/archive/2011/03/08/comparing-hardware-accelerated-svg-across-browsers-with-santa-s-workshop.aspx ). Maybe, this information would be helpful on the sozi website. Something like: if you have performance issues (running to slow) try to use another browser.
Let's hope, that firefox will improve a lot with svg ...

@Guillaume-Savaton-ESEO
Copy link
Contributor

Yes. Animations can be really smoother in webkit.

Maybe the website is misleading: it was not my intention to promote Firefox as the "target" browser for Sozi.
Sozi is known to work very well in both Gecko and Webkit.

@johanrosenkilde
Copy link

I have written a small Python script one can run on a Sozi presentation after creating or modifying it for basically automating the proposed hack. It uses a hide file, a line-by-line specification of which objects should be visible at only certain frames, and it support numbering or naming the frames.
The script makes it very reliable to modify a presentation 2 min before the show, without worrying about stuff not working, but since it is not part of the Inkscape gui, it is not ideally elegant.

The code is on this repo: https://bitbucket.org/jsrn/sozi_hiding

@maronin
Copy link

maronin commented Feb 20, 2015

~~It seems that ~~

sozi.events.listen("framechange", function (index) { }

doesn't work anymore. I tried adding the script to my svg file, but I get a "sozi is not defined" error.

I tried using the one two three example and it worked fine. However, when I tried editing it in InkScape and changing some Sozi stuff and saving the file, I got the same error.

nvm, it seems that using the onFrameChange function does the same thing and it works.

@aumouvantsillage
Copy link
Collaborator

@maronin There is an up-to-date example here: https://github.com/senshu/Sozi/blob/master/samples/show-hide-objects.svg
The correct way to setup the event listener is:

sozi.events.listen("sozi.player.framechange", function (index) {...});

@maronin
Copy link

maronin commented Feb 23, 2015

Thank you that works!

@aumouvantsillage
Copy link
Collaborator

In Sozi 15, layer opacity allows to achieve a similar effect as showing/hiding objects.
Please try Sozi 15 and open a new issue if you think that your problem still deserves to be addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants