-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello, and first thanks Emmanuele for your quick help on my previous
question (Re: allocation warnings when resizing Text) :)


Now I am implementing a table LayoutManager for Box, and have problems
with the LayoutMeta. The problem is I can only get Box.pack() to work
correctly (i.e. set LayoutMeta properties) when I call
LayoutManager.get_child_meta right before.  Does anybody see what I am
missing?

This is the code in vala:
===================================================================
class TableChild : LayoutMeta {
  private uint _colspan;
  private uint _rowspan;
  construct {
  }
  public TableChild(LayoutManager man, Container con, Actor act) {
    Object(manager: man, container: con, actor: act);
  }
  public uint colspan {
    get { return _colspan; }
    set { _colspan = value; manager.layout_changed();}
  }
  public uint rowspan {
    get { return _rowspan; }
    set { _rowspan = value; manager.layout_changed();}
  }
}

class TableLayout : LayoutManager {
  public uint numcolums { get; construct set; }
  public uint spacing { get; construct set; }
  construct {
    this.notify.connect(on_property_change);
  }

  public TableLayout (uint colums, uint _spacing=5){
    Object (numcolums: colums, spacing: _spacing);
  }
  public void on_property_change (ParamSpec pspec){
    this.layout_changed();
  }
  public override Type get_child_meta_type (){
    Type t =  Type.from_name ("TableChild");
    return t;
  }

  public override void get_preferred_height (Container container,
    float for_width, float min_height_p, float nat_height_p){
    foreach(Actor child in container.get_children()) {
      var child_meta = get_child_meta(container, child) as TableChild;
      //the next lines only work correctly when I call
      //'get_layout_meta' on the layout manager right before
      //calling 'box.pack'
      if (child_meta!=null)
        stdout.printf("child %s meta: %u, %u\n",
         child.name, child_meta.colspan, child_meta.rowspan);
      else
        stdout.printf("child %s meta null\n", child.name);
    }
  }
 =============================================================
test code:
public Box construct_keyboard() {
  TableLayout table = new TableLayout(12);
  Box keyboard = new Box(table);
  for (unichar letter='A'; letter <= 'Z'; letter++) {
    Text k = new Text.full("Arial", letter.to_string(),
                   Color.from_string ("white"));
    //strange: it only creates the layout meta when
    //I put the following line before calling 'pack'
    var child_meta = table.get_child_meta(keyboard, k)
                     as TableChild;
    keyboard.pack(k,"colspan", 1);
  }
  return keyboard;
}
=================================================================

Any help is appreciated. Thanks again,

Dio.-



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMUiR3AAoJEA3CodwzRLMmeoQIAJaN6u/lmrX9NPsl60cOWaaD
6Rvdpv51dYdWGl21MYiO5a2EqDypLTFhTq3pl9PUEopy/v3nHbf/dPngQORpJBMh
2iJpD0ntP5345yN/JX7ebrP3lekjfTNSLwrtDqDbSajvz+/D68N/rx1dllSDGXp0
7ejFis9aFI26v+eXKRzLuBcu6/4Lx6Vqq2uYMvkLGzE7GtwQQzWkpyzQhtJUg6Uf
vDtgnBHBo2z9LT7tzcoRO0P0qunzwHCqiFM0yC1zAj9vFnlzBh2yALWFop34DqLr
SitNmIiHxtimezRKrdRAMUBNOcCr10VrxuvGB7wCTFo8NCFybN/VOmO/KJU7JwA=
=lg9G
-----END PGP SIGNATURE-----
_______________________________________________
clutter-app-devel-list mailing list
[email protected]
http://lists.clutter-project.org/listinfo/clutter-app-devel-list

Reply via email to