Sunday, September 2, 2012

[GSoC] Wrapping up the Cantor interface

This year's Summer of Code ended nearly two weeks ago (at least the coding part did), so considering my usual delay this seems to be a good time to write about what happened in Cantor.

My project for this summer was to rewrite Cantor's interface using the Qt Graphics View framework. The old interface was a heavily modified rich text document with a lot of glitches and bugs reaching from visual annoyances to crashes. I spent most of my time reproducing the features of the old interface without reproducing the bugs. But there was also some time to add some new features:

Basic editing features such as undo/redo and cut, copy, paste and drag&drop work properly. Of course that doesn't sound impressive, but I think that the lacking/buggy implementation of these features in the old interface was one of the biggest problems. And it wasn't always easy to implement them either, because the API of QGraphicsTextItem is very poor compared to the API of QTextEdit, so I often found myself working around it, trying to reproduce features that I knew were available in the underlying implementation.

There is a nice search&replace widget that shows up on top of the status bar (similar to, and copied from inspired by, Kate's search).

Visual changes in the worksheet, such as the appearance of a large result (e.g. a multi-row matrix) are animated. This makes it much easier to understand what actually did change and where that put the cursor.

The entries can now be reordered by dragging them around, something I find quite convenient when I use Cantor to develop some idea.

The new implementation is much more flexible, because QGraphicsItems can contain virtually anything, so there is no limit for further features. I originally intended to implement input assistants, which were supposed to make it possible to enter complex objects like matrices in a more readable fashion. During the summer I decided to spend my time on things like the animations and drag&drop instead, but chances are that I'll come back to these assistants. Another feature that could be implemented with the new worksheet are live-editable formulas. I always wanted these, but they would take more time than I'm likely to have in the near future.

There are a lot of other improvements hidden all over the interface: Zooming in and out works more smoothly, the cursor movement is much more sensible, and non-editable parts of the worksheet actually can't be modified, to name a few.

All in all I think Cantor is much more fun to work with now, and I'm really happy everything worked out so well.

In the next weeks I'll still be around fixing bugs (so let me know if you find one), but I probably won't have time to implement new features anytime soon. I do intend to get back to it though, because I still have some ideas about what could be done.

Oh, and I'll be in Randa this month, so I should be doing something Cantor-related there as well :)

I do know Lyx, and I would love to have its formula-editing features in Cantor. From a first look at their code I did not have the impression that I could reuse it easily. Should I decide to implement this in Cantor I would definitely take a closer look at Lyx though.