Rework Layers API
ClosedPublic

Authored by woltherav on Dec 4 2017, 3:06 PM.

Details

Summary

Part 1 of T7487

This adds new classes to the python API that will allow people to create filterlayers, clone layers, grouplayers, filelayers, filllayers, vector lyers, and more.

Unlike the previous version we can now actually set the reference for the clone layer, or the filter on the filterlayer.

It also adds a very simple vector shapes API so we can do something with the vector layers, but sadly, I haven't been able to get it to return anything sensible... (if the layer has any shape in it, QList<Shape*> will return as None...)

Test Plan

Example script to add a filter layer.

import sys
from krita import *

doc = Application.activeDocument()

filter = Filter()
filter.setName("threshold");
vNode = doc.createFilterLayer("pythonfilter", filter, doc.selection())
doc.rootNode().addChildNode(vNode, doc.rootNode().childNodes()[0])

Example script to itterate over top level layers and get some unique information from some of them.

import sys
from krita import *

doc = Application.activeDocument()

root = doc.rootNode()
print(root.type())

for layer in root.childNodes():
    print (str(layer.type())+" "+str(layer.name()))
    if (layer.type()=="grouplayer"):
        print(layer.passThroughMode())
    if (layer.type()=="vectorlayer"):
        print(layer.shapes())

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
woltherav requested review of this revision.Dec 4 2017, 3:06 PM
woltherav created this revision.
rempt accepted this revision.Jan 7 2018, 3:00 PM
This revision is now accepted and ready to land.Jan 7 2018, 3:00 PM
This revision was automatically updated to reflect the committed changes.