Gtk Canvas

This page tries to collect highlights and drawbacks for the most known canvases around, plus some other information that hopefully will be useful to determine a sensible feature set and the best candidates to fill the canvas gap in GTK+.

Potential candidates for a new GtkCanvas are marked with a colored row. Other canvases are just for comparison.

WARNING: This is not a list of all canvases in the entire world; it's just meant to list potential canvases that can be used by, or folded in, GTK+ for a future release. Do not add your favourite pet canvas library.

Use Cases

  • Interactive diagrams
    • plots
    • UML editor, entity-relationship, ...
    • Desktop publishing app
    • Multi-track audio editor
    • Air traffic controller simulator.
    • Database relationship viewer.
    • PIM Synchronizer connection viewer.
    • ...
  • Possibly several views on the same data
  • Printing
  • Creating fancier UIs for apps, possibly with embedded widgets (control-center shell, MugShot, something like GMail, ...)

  • Animations and games
  • show and manipulate pre-drawn graphical content (i.e. load from a .svg, get objects by their name, ...)
  • Having a concept of "scale" for zoomable UIs.

GnomeCanvas

This is the existing (unloved) GNOME canvas, included here for reference. We should try to avoid regressions when choosing functionality for a new canvas

libccc

A potential candidate for the new GtkCanvas

GooCanvas

A potential candidate for the new GtkCanvas

FooCanvas

Unmaintained

Hippo-Canvas

Unmaintained

GeoCanvas

Uses an internal copy of FooCanvas, seems unmaintained

clutter

3D canvas, hardware accelerated, used by GNOME Shell

Qt4 Graphics View Framework

Added only for reference

Rapicorn

Written in C++

Concepts

Canvas

Primary Layout Model

Model/View Split

Infinite Scrolling

Backend

gnomecanvas

scene graph

{X}

{X}

GDK/libart(aa)

ccc

scene graph

(./)

{X}

cairo

goocanvas

scene graph

(./) (optional)

{X}

cairo

hippocanvas

boxed

{X}

{X}

cairo

foocanvas

scene graph

{X}

{X}

GDK

geocanvas

scene graph

{X}

(./)

cairo

clutter

scene graph

{X}

{X}

GLX/Win32/OSX/EGL/EGLX

Qt4

(./)

{X}

Qt

Rapicorn

(./)

{X}

cairo

Notes

  • Primary Layout model: How items are layed out on the canvas:
    • "scene graph": the entire scene is constructed free-form, with every component of the scene declaring its spatial and dimensional attributes; the whole scene is a graph (hence the name) where every node might have children and at least one parent (often just a single parent). Layout constraints are usually implemented inside containers. See Scene graph on Wikipedia.

      • Roughly like GtkFixed or SVG.

    • "boxed": the scene graph is constructed only following layout constraints, usually following a "box model". See Box modeling on Wikipedia.

      • Roughly like GtkBox, GtkTable, etc. or HTML/CSS.

  • Infinite scrolling should be defined or removed; as far as I understand, it's the ability to wrap around the viewport, which is expected from a canvas displaying maps but it's not really a requirement. many canvases can implement this functionality right on top of their own API. EmmanueleBassi

    • It's the ability to scroll beyond the "core document", just like in gnumeric where you can scroll to the last row available in a spreadsheet and beyond that.

Basic Features

Canvas

Generic Positioning

Accessibility

Printing Support

Item Grouping

Unit Support

Embedded GTK+ Widgets

GTK+ CellRenderer

Pixel Alignment

Automatic Layout

Primitives

gnomecanvas

(./)

(./)

{X}

(./)

Without transformation

{X}

{X}

ccc

436932

379331

(./)

(./)

Not yet,
waiting for GTK+ offscreen-rendering support
to implement transformation.

(./)

(./)

354331

Camera, Caret, Circle, Line, Pixbuf, Rectangle, Rounded Rectangle, Shape, SimpleItem, Text

goocanvas

Patch at 555097

(./)

(./) (no pagination)

(./)

(./)

Without transformation

{X}

only for tables

WxH

Ellipse, Group, Image, Path, Polyline, Rect, Table, Text, Widget

hippocanvas

N/A

{X}

{X}

(./)

{X}

(./)

{X}

mandatory

(./)

Box, Entry, Gradient, ImageButton, Image, Link, Scrollbars, Text

foocanvas

(./)

{X}

(./)

{X}

{X}

geocanvas

{X}

{X}

(./)

{X}

{X}

clutter

(./)

(./)
Since 1.4

{X}

(./)

(./)

(./)
Use clutter-gtk

{X}

(./)

WxH, HxW, NaS

Group, Text, Texture, Rectangle

Qt4

(./)

(./)

{X}

{X}

Rapicorn

{X}

{X}

(./)

(./)

{X}

(./)

Notes

  • Generic Positioning: Whether items can be positioned via a base class interface, instead of only via specific APIs for derived shape classes.
  • Accessibility: Whether it uses ATK to provide information about the items.
  • Printing Support: For instance, make it easy to render to a cairo context in a GtkPrintOperation.

  • Item Grouping: TODO: This should be more clearly defined.
  • Unit Support: Whether distances can be specified in real units rather than just pixels.
  • Embedded GTK+ Widgets: Whether the canvas can show, for instance, a GtkEntry. Ideally, the widget would scale/rotate/etc just as other canvas items do when they are transformed.

  • GTK+ CellRenderer: Whether the library offers a GtkCellRenderer objects that can render the canvas into a treeview cell.

  • Pixel Alignment: Whether attempts are made to align items on display pixels for better appearance.
  • Automatic Layout: What modes are used, when automatic layout is offered - that means any automatic layout (like GtkBox) rather than just exact positioning (like GtkFixed):

    • WxH: Width for Height
    • HxW: Height for Width
    • NaS: Natural Size
  • Primitives: The basic items offered by the library.

Highlevel Features

Canvas

Animation Framework

Collision Detection

Builtin DnD Support

Non-scaled items

Theming

Inline Text Editing

Serialization

Rapid Prototyping

gnomecanvas

{X}

{X}

{X}

{X}

{X}

ccc

379327

{X}

436934

{X}

planned

(./)

in progress, using GtkBuilder

Signals of CcSimpleItem

goocanvas

fixed set of animations

{X}

{X}

{X}

{X}

{X}

{X}

hippocanvas

{X}

{X}

{X}

{X}

{X}

{X}

{X}

foocanvas

{X}

{X}

{X}

{X}

{X}

geocanvas

{X}

{X}

{X}

{X}

{X}

clutter

(./)

(./) a complete physics engine is provided through an integration library

(./)

{X}

{X}

(./)

(./)
using JSON and not GtkBuilder

(./)
using JSON and not GtkBuilder

Qt4

(./)

(./)

(./)

{X}

{X}

Rapicorn

{X}

{X}

{X}

{X}

Notes

  • Built-in DnD support: Whether items can be moved on the canvas without needing to implement much code.
  • Serialization: Whether the state of the items (including its children) can be saved (e.g. to a text markup) and reloaded later.
  • Rapid Prototyping: Whether the GtkBuilder API (and glade in future) can be used to place items on the canvas. Probably related to Serialization.

  • Inline text editing: Support for text editing without an embedded GTK+ widget. This provides better visual feed back, as you see what you get when editing.
  • Non-scaled items: Whether items can be marked as not-for-scaling when the entire canvas (or maybe group) scales. For instance, graph axis names, place names on maps.

API Details

Canvas

Opaque Object Structures

Initial Object Ownership

gnomecanvas

{X}

floating (GtkObject)

ccc

almost finished

floating (GInitiallyUnowned)

goocanvas

{X}

scope (GObject)

hippocanvas

{X}

floating?

foocanvas

{X}

floating (GtkObject)

geocanvas

(./)

floating (GtkObject)

clutter

(./)

floating (GInitiallyUnowned)

Qt4

Rapicorn

Notes

  • Opaque Data Structures: Whether the C struct may be accessed directly, or if only functions should be used.
    • Doesn't seem unfixable, so it doesn't seem very relevant to the choice. murrayc.
      • It's unfixable without breaking API/ABI, so it should be done before integrating any code in GTK+. EmmanueleBassi

  • Initial Object Ownership: C Convenience API to reduce repetitive code.
    • For instance, GtkWidget uses an initial floating reference, in combination with GtkContainer which sinks that initial reference.

    • Not relevant to most language bindings.

Metrics

Canvas

Phys. Lines of Code

API Reference

Tutorial

Roadmap

Bindings

Regression Tests

gnomecanvas

(./)

{X}

{X}

C, C++, Perl, Python, Ruby

(./)

ccc

7,617 - 2007/10/15

(./)

(./)

(./)

C, C++, C#, Python

(./)

goocanvas

17,121 - 2009/06/05

(./)

(./)

TODO list

C, C++, Python

{X}

hippocanvas

9,246 - 0.2.23

{X}

{X}

C, Python

(./)

foocanvas

{X}

{X}

C, C++

{X}

geocanvas

(./)

{X}

C, Python

(./)

clutter

110,827 - 2010/08/15

(./)

(./)

Bugzilla

C, C++, C#, Perl, Python, Ruby, Vala

(./)

Qt4

(./)

(./)

C++, Perl, Python

Rapicorn

{X}

{X}

{X}

C++

  • Lines of code regarding sloccount, without auxiliary code like test suites, examples or similar.

Comments

  • A lot of desktop apps that render into a canvas, will eventually want to export/render to HTML as well and in this case it might make sense to keep the two implementations in sync by simple always exporting to HTML and just using a webkit "webview" to render the HTML in the desktop app. HTML5 has webgl and canvas for non-retained mode drawing, it offers nice interaction and if you prefer scene graph you can always use plain HTML with CSS animations/transitions.
  • Another thing to compare is performance: for instance, to how many canvas does each implementation scale? (a bench could be tring to draw 1000, 10000, 100000 etc simple rectangles, both with and without intersactions etc) - PaoloBorelli

    • I'm working on some benchmarks for - at least - goocanvas and libccc (as these seem to be the two candidates with maintainers who like to see a GTK+ inclusion) - SvenHerzberg

    • Evas performance is done with a tool (named Expedite) which compares the speed of each feature for all the supported engines. It could be used to compare the different canvases.
  • "Items Grouping" should be more clearly defined, or split into sub-features. For instance, in goocanvas, child items use the transformation and style of their parent group. What does it mean for the other canvases? murrayc
    • the same happens for Clutter as well: the transformation matrix of a container actor is also applied to its children (or should be: it's not enforced, so you can override this behaviour). - EmmanueleBassi

  • A minimal code example (preferably in Python) that does the same thing for each canvas widget would be most interesting.

Any thoughts/comments? please write them here

Attic/ProjectRidley/CanvasOverview (last edited 2013-11-23 01:05:07 by WilliamJonMcCann)