[Tickit-dev] Future plans - Widget styles

Paul LeoNerd Evans leonerd at leonerd.org.uk
Wed Jun 13 16:34:11 BST 2012


I have been thinking about Widgets, styles, and CSS lately.

From a high level perspective, I wonder if something like this would
work:

  my $tickit = Tickit->new( stylesheet => "$ENV{HOME}/.myapp.style" );

  $tickit->set_root_widget(
    Tickit::Widget::VBox->new(
      class => "main",
      children => [
        ... main content here,
        Tickit::Widget::HBox->new(
          class => "status",
          children => [ ... child status widgets ],
        ),
        Tickit::Widget::Entry->new,
      ],
    )
  );

  $tickit->run;

Giving potentially each widget a 'class' attribute; perhaps allowing an
'id' as well. The .myapp.style file could then say something to the
effect of:

  HBox.status {
    pen bg=blue fg=white bold;
  }

  Entry {
    key <Home> = beginning-of-line;
    key <End>  = end-of-line;
  }

I don't think we should go very far into the CSS route of parent/child
relationships here, because e.g. at the time Widgets are constructed
they may not know parents/children. Easier just to keep to fairly simple
declarations based only on entire types of widget, or types of widget
with a given (application-specific) class name. The contents of the
style block would be 'pen' or 'key' definitions.

[Actually we may want to avoid the word 'class' as it has Perl-related
connotations too].

I'm also not too sure how useful a user-wide ".tickit.style" would
necessarily work; that couldn't know anything about application-specific
class names, but I guess it could still set things like key bindings for
widget types.

What does anyone think of this?

-- 
Paul "LeoNerd" Evans

leonerd at leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://mail.leonerd.org.uk/pipermail/tickit-dev/attachments/20120613/39022157/attachment.sig>


More information about the Tickit-dev mailing list