Add "hasKeyframeAtTime" function for Node Python API
ClosedPublic

Authored by scottpetrovic on Jan 8 2019, 3:06 PM.

Details

Reviewers
dkazakov
Group Reviewers
Krita
Summary

For querying the timeline, it is nice to be able to see if a certain frame is a keyframe. This just adds one API call to the Node class to get see if a frame is is a keyframe

Test Plan

I created a test animation KRA file and added a few blank and filled keyframes. I used the new API call to see if the correct frames were keyframes. They appeared to be ok.

I am getting a weird free error on my build, but that happens even without running the script, so I might just need to do a clean build.

tested using this file:

I pasted this Python into the Scripter plugin:

doc = Krita.instance().activeDocument()
currentLayer = doc.activeNode()

layerHasAnimationEnabled = currentLayer.animated()


if layerHasAnimationEnabled:
    # in sample file, keyframes are at frames 0, 4, and 8
    print(currentLayer.hasKeyframeAtTime(0))
    print(currentLayer.hasKeyframeAtTime(1))
    print(currentLayer.hasKeyframeAtTime(8))
    print(currentLayer.hasKeyframeAtTime(120))

Diff Detail

Repository
R37 Krita
Lint
Lint Skipped
Unit
Unit Tests Skipped
scottpetrovic created this revision.Jan 8 2019, 3:06 PM
Restricted Application added a project: Krita. · View Herald TranscriptJan 8 2019, 3:06 PM
scottpetrovic requested review of this revision.Jan 8 2019, 3:06 PM
scottpetrovic retitled this revision from Add getter for Node Python API to Add "hasKeyframeAtTime" function for Node Python API.
scottpetrovic edited the test plan for this revision. (Show Details)

Just a comment

libs/libkis/Node.cpp
438

As far as I know, this check is not needed, because keyframeAt() returns either a frame exactly in position or null. To be sure I would just ass a safe assert (instead of the check):

KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(timeOfCurrentKeyframe->time() == frameNumber, false);
return true;
nolanfa added a subscriber: nolanfa.Jan 9 2019, 1:53 PM
jounip added a subscriber: jounip.Jan 9 2019, 2:06 PM
jounip added inline comments.
libs/libkis/Node.cpp
438

To clarify, keyframeAt works as Dmitry described. There is a separate method activeKeyframeAt which also includes holds.

scottpetrovic edited the test plan for this revision. (Show Details)

Updated the diff removing the extra logic and replacing it with a safe assert. Using the python, it seems ok and I don't get any errors or issues

dkazakov accepted this revision.EditedJan 10 2019, 1:18 PM

Now it should be perfectly fine to push! :)

This revision is now accepted and ready to land.Jan 10 2019, 1:18 PM
dkazakov closed this revision.Jan 11 2019, 10:30 AM

Closed by Scott :)