[AdgDress] First implementation
commit7494dcf41a846fa02103986fe973f281895d3359
authorNicola Fontana <ntd@entidi.it>
Sun, 13 Sep 2009 18:16:51 +0000 (13 20:16 +0200)
committerNicola Fontana <ntd@entidi.it>
Sun, 13 Sep 2009 18:16:51 +0000 (13 20:16 +0200)
tree4b7f7bef8d21be737f15111e32f49f99dce2df1f
parent708b1c7348280eccf2dbd1b77b4fb496500bc18e
[AdgDress] First implementation

This class improves the styling behavior previously done by AdgContext.

The rendering customization is provided throught the interaction of the
following ADG components:

- AdgStyle and children
  The styles, in their basic form, implement the apply() method that
  should be called by the entities whenever needed to change the
  behavior of the current cairo context.
- AdgDress
  This is an abstraction layer to virtualize the styles. The entities
  will always refer to dress instead of style, allowing to do some quite
  complex operation such as overriding a specific style for a given
  branch in the entity hierarchy or implementing different defaults
  for the same style (such as providing diffent font for quote values
  and tolerances). The latter would be possible also without AdgDress by
  instantiating style singletons when required but AdgDress provides a
  central point where all this defaults are grouped, leaving the door
  opened to future improvements.
- AdgEntity
  The entities are the natural consumers of styles. They provide APIs to
  access styles directly, although internally they always use AdgDress
  values. Furthermore, adg_entity_set_style() provides a way to override
  the style of a specific dress for the subject entity and its children.

The main getter function is adg_entity_style(), which requires an
AdgDress value. The following operation are executed up to when a
defined style is found:

1. adg_entity_get_style(entity, dress);
   check if the style is defined directly by this entity type, that
   is if it was explicitely set with adg_entity_set_style();
2. adg_entity_style(parent, dress);
   if the subject entity has a parent returns its style by recursively
   call adg_entity_style() on the parent entity;
3. adg_dress_get_style(dress);
   return the default style for the given AdgDress value.

Without any customization all the styles will be resolved by
adg_dress_get_style(), but this implementation gives a good level of
freedom, allowing the cascade overriding of a dress style with a
single adg_entity_set_style() call. When required, new AdgDress
values can be easily added with adg_dress_new(). Every dress always
requires a default style, just to be sure to resolve any request as
stated above.
adg/adg-dress-private.h [new file with mode: 0644]
adg/adg-dress.c [new file with mode: 0644]
adg/adg-dress.h [new file with mode: 0644]