When was the last time
You saw a spreadsheet embedded in an image? What, you say you never heard of such a thing? But here it is:
Yes, I did it. I took the first step making Krita a fully paid-up member of KOffice by enabling it to embed any other KOffice application. While I concede that nobody would really want to embed a spreadsheet in an image (unless you could somehow use not the spreadsheets sheet, but the results of its calculation as input for a layer), and a project planner is silly, too. But think of it this way: we've got a world-class text tool for free now.
Oh, and embedding Karbon vector graphics, too, of course:
I started hacking on this yesterday evening and did most of the work on the train to the Hague and back; so it's not finished yet.
My basic design is pretty simple: I couple every embedded object with a Krita paint device. The embedded layer paints itself on the paint device when it's deactivated, and from that moment, you can use all Krita's composition algorithms with that layer. It also offers possibilities for adjustment layers.
However, there are a couple of problems that I haven't solved yet.
- KOffice parts are supposed to be tiled, not stacked. They all want a rectangle of their own and are activated if you click on them. This assumption seems to be really deep down in the KOffice code. Activation on selecting the layer is harder.
- Most KOffice applications assume they'll be rendered onto a white page and they render themselves opaque. I'd prefer if there was a way to make them render on a transparent QImage. I though the transparent flag in the paintContent would help, but it doesn't.
- KWord and Karbon assume the existence of something like a page, instead of just an expanse of pixels. This doesn't fit with Krita all that well -- an image doesn't have pages.
- KOffice parts don't agree about things like zooming and resolution. There are comments all over the code about this, but there's no clear concensus. That also hurts when you embed Krita in, say, KWord.
- Didn't implement saving; on saving your object is discarded and the representation in a Krita paint device is saved. But this is a minor issue.
- Karbon's dockers don't work well when embedded. Neither do Krita's dockers. Both clash a lot; I have written the beginning of a generic docker library, but I should probably have extended kxmlgui to include support for QDockWindows.
But despite these problems, I'm quite pleased, and impressed, too, by the framework.
/hacking/krita | permanent link | |