KritaFlake
The Flake library is a low level library for all kinds of graphical content to be placed on any Krita canvas. This includes a line to text-areas or even movies. Just as important, this library will include tools to manipulate the graphical content. At least at the level of Flake objects. This goes from moving/rotating the object to a basis for complex brushes for a paint program.
Who uses Flake
Flake is a middle layer between the applications and the content providers. The applications will allow flake to be plugged in by implementing the KoCanvasController interface while providers of content (like a chart engine or a text component) will extend KoShape and optionally KoToolBase to do their work.
A shape is a rectangle or a text or a movie. A shape paints itself and has content. A Tool get user input. Tools do things on data, tools do things on shapes. Both shapes and tools are plugins. So they are independent of applications. For example; I have a textshape that paints text. It comes with a texttool that takes mouse and keyboard events and alters the text that the textshape shows. This idea of combining a shape and a text is done in flake by "ID"s . Each shape has an ID and a tool has an ID. If they have the same ID they belong together. Example; I select a text shape and the toolbox will show a icon to activate the text tool.
The way that a shape is kept separate from the application and from the Flake layer is similar to how a widget in a GUI is kept separate from the application. The shape inherits from the abstract KoShape class and all the logic embedded in the KoShape class is enough for the flake layer to do all things with it like positioning and moving as well as rotating and deleting it. Just like a widget does not know the difference between painting on one app, or another a shape will not know the difference. The flake library will take care of all details.
It is common to combine a shape-plugin with one or more tools which are made specifically to work on that shape type. So, a text shape comes with a tool that knows how to address the shape not only by the abstract KoShape class, but also by the KoTextShape API and is therefore able to alter the data that shape displays. In this case text.
Flake natively only has a vector shape. All other types of shapes (including the text one used in the example above) are plugins and not part of Flake itself.
Use KoShape as a base object for any application-specific graphical content, and extend KoShapeContainer for objects that can contain others.
KoShape is the base class for all flake objects. Flake objects extend it to allow themselves to be manipulated by the KoToolBase s. The content of such an object is independent and based on the model of the data this object represents.
If you want to be a supplier of shape objects; create a library with a KoShapeFactoryBase class and install a .desktop service file with the following content:
[Desktop Entry] Encoding=UTF-8 Name=My Flake Shapes Plugin ServiceTypes=Krita/Shape Type=Service X-KDE-PluginInfo-Name=myflakeshapes X-KDE-Library=myflakeshapesplugin X-Flake-MinVersion=27 X-Flake-PluginVersion=27
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Apr 13 2021 23:34:01 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.