<html><head></head><body><div>This reply is getting archived here for future reference, thanks for the detailed explanation Joshua</div><div>On Tue, 2016-04-19 at 19:47 +1200, Joshua Leung wrote:</div><blockquote type="cite"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hi Erick,<br></div><br>For a useful (though overly broad/general) introduction to the key 
concepts of how updates in Blender happen in general, see this:<br><a href="https://wiki.blender.org/index.php/Dev:2.5/Source/Architecture/Window_Manager">https://wiki.blender.org/index.php/Dev:2.5/Source/Architecture/Window_Manager</a><br><br><br></div>Here you go  (this was originally go to be "in short", but then it turned out to be a lot longer reply ;):<br></div><div></div>* The code in your "operator" modifies the keyframes/etc. data (i.e. stuff stored in the SDNA structs that form that Main database)<br></div>* When your operator is done, it sends a "notifier"  - WM_event_add_notifier(C, ....notifier flags..., NULL); <br>  For keyframe editing, this is usually something like NC_ANIMATION | ND_KEYFRAME | NA_EDITED (i.e. notifier for "animation context", "keyframe data", "editing performed/action").<br></div><div>* Notifiers are added to a global queue to be processed the next time we go through flushing updates (more about this below), instead of being handled immediately (i.e. the "callback" style of updates that other toolkits - notably Qt, GTK, and all of the Java ones - Swing, etc. use. However, the "callback style" has some serious disadvantages - i.e. some updates happening multiple times, bad performance if you inadvertently chain up a bunch of these by relying on delegating to other callbacks, and "callback hell" if that chaining accidentally forms a loop.)<br></div>* As in any GUI program, Blender has what's known as an "event loop".  Basically, it's like you've got a piece of code in your main function 
that does: <br>  while (true) {<br>        get_event();<br>        handle_event();    // run operators, and/or exit the program<br>        flush_updates();   // handle notifiers<br>        refresh_and_redraw(); <br>   }<br><br></div>  In Blender, notifiers are handled in the "flush_updates()" step, after the operator runs (i.e. handle_event() == an operator gets run, or some event gets sent to the UI handler, or something like that). What that means is that it goes through each window -> editor -> region, and for each of the queued up notifiers, it asks those if it would like to do anything about that notifier. (You could say it's sort of Observer Pattern stuff I guess, except it's deferred updates, and we're still really only asking if they'd like to do any updates). So, each of the animation editors will listen for NC_ANIMATION | ND_KEYFRAME events, and when they hear them, will tag themselves to be redrawn.<br></div>  <br>  Finally, when it's time to redraw the UI, only the editors/regions that are tagged to get redrawn will be redrawn (since redrawing everything all the time, even if nothing has changed is slow, and would make everything laggy). So, at this point, all the visible animation editors would get redrawn, because they tagged themselves to get redrawn, in response to the notifier that got sent out.<br><br></div><div><br><br></div>Now, all of the above is only just updating the UI (which is what your question was about). If you were to talk about how you get those animation changes flushed to the actual models and rigs, then you'll need to be talking about the dependency graph stuff then. But, there it's really a similar idea again :)<br><br><br></div><div>(Also, if you're just concerned with the transform code, have a look in transform_generics.c -> recalcData() for how things get tagged for updates there :)<br></div><div><br><br><br></div>Regards,<br></div>Joshua<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 19, 2016 at 7:19 PM, Erick Blender <span dir="ltr"><<a href="mailto:erickblender@gmail.com" target="_blank">erickblender@gmail.com</a>></span> wrote:<br><blockquote type="cite"><div dir="ltr"><div><div><div>Hi there!<br><br></div>Wanted to ask about Blender animation logic, how graph editor, timeline, dopesheet and NLA work together?<br></div>Reading code files in blender/editor/animation i find many useful code and i found as well  that in blender/editor/transform/transform_conversion.c there is basic keyframes move, ... <br><br></div><div>My question is how graph editor, timeline, dopesheet and NLA talk to each other for example when moving a keyframe in graph it get updated in the dopesheet or vise versa. Is there some where in the code that Blender update dopesheet when action happening in the graph editor?<br><br></div><div>Thanks in advance :)<br></div></div><div><br>
<table style="border-top:1px solid #aaabb6">
        <tbody><tr>
        <td style="width:55px;padding-top:13px"><a href="https://www.avast.com/en-us/lp-esg-fav?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=oa-2109-v2-b" target="_blank"><img></a></td>
                <td style="width:470px;padding-top:15px;color:#41424e;font-size:13px;font-family:Arial,Helvetica,sans-serif;line-height:18px">Virus-free. <a href="https://www.avast.com/en-us/lp-esg-fav?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=oa-2109-v2-b" style="color:#4453ea" target="_blank">www.avast.com</a>
                </td>
        </tr>
</tbody></table><a href="#m_8821382711635120639_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"></a></div>
<br>_______________________________________________<br>
Bf-animsys mailing list<br>
<a href="mailto:Bf-animsys@blender.org">Bf-animsys@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-animsys" rel="noreferrer" target="_blank">https://lists.blender.org/mailman/listinfo/bf-animsys</a><br>
<br></blockquote></div><br></div>
<pre>_______________________________________________
Bf-animsys mailing list
<a href="mailto:Bf-animsys@blender.org">Bf-animsys@blender.org</a>
<a href="https://lists.blender.org/mailman/listinfo/bf-animsys">https://lists.blender.org/mailman/listinfo/bf-animsys</a>
</pre></blockquote></body></html>