Tickit::Widget::Layout::Relative - apply sizing to a group of Tickit widgets


version 0.005


 my $l = Tickit::Widget::Layout::Relative->new;
  title  => 'Little panel',
  id     => 'second',
  border => 'round dashed single',
  width  => '33%',
  height => '5em',
  title     => 'Another panel',
  id        => 'first',
  below     => 'second',
  top_align => 'second',
  border    => 'round dashed single',
  width     => '33%',
  height    => '10em',
  title        => 'Something on the right',
  id           => 'overview',
  right_of     => 'first',
  bottom_align => 'first',
  margin_top   => '1em',
  margin_right => '3em',
 Tickit->new(root => $l)->run;


A container widget which provides 'relative' layout for widgets: specify the relations between the widget locations and this will attempt to fit them to the available space.

Relative layout



Instantiate a new layout. Takes a single named parameter:

  • layout - the optional Tickit::Layout::Relative layout to use for initial positioning, will create a new one if none is supplied


Returns the Tickit::Layout::Relative instance.


Returns the number of lines, carefully calculated using science.


Number of columns.


Adds the given widget. Also takes a plethora of named options to help decide where to put said widget and how it should be rendered:

  • title - a label to apply to this pane, default is blank

  • id - an ID used for looking up widgets in an existing layout, see "widget_by_id" and "window_by_id" for more details

  • left_of - attempt to position this to the left of the pane with the given ID

  • right_of - try to arrange this widget on the right of the given ID

  • above - if we can, stick this widget above the given pane ID

  • below - we want to be below the given ID

  • top_align - try to align the top edge with the given widgets (string containing space-separated list, or arrayref, of IDs)

  • bottom_align - align the bottom edge with the given panes (as top_align)

  • left_align - we would like this things to be aligned on the left (as top_align)

  • right_align - we would like this things to be aligned on the right (as top_align)

  • margin - margin to apply around this widget, this is a measurement (see "MEASUREMENTS").

  • margin_left - left margin

  • margin_right - right margin

  • margin_top - top margin

  • margin_bottom - bottom margin

  • padding - padding to apply around this widget, this is a measurement (see "MEASUREMENTS").

  • padding_left - left padding

  • padding_right - right padding

  • padding_top - top padding

  • padding_bottom - bottom padding

  • width - how big we'd like to be, see "MEASUREMENTS"

  • height - how big we'd like to be, see "MEASUREMENTS"

Don't rely on the return value. It may change in future.


  Tickit::Widget::Static->new(text => '...'),
  title  => 'Some panel',
  id     => 'send',
  border => 'single',
  width  => '85%',
  height => '15em',


Renders the layout to the given Tickit::RenderBuffer. Used internally.


Render the corners. Purely for aesthetic reasons (rounded corners look better than the usual square corners formed by vline/hline). Used internally.


When we get a window, we perform some unfortunate hacks to allow focus notification. Most of this is highly likely to change in future.


Called when our main window changes shape. We recalculate layout to match the new dimensions then update all child widgets accordingly.



child_opts, child_resized, children_changed, find_child, focus_next, remove, set_child_opts, window_lost


get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, on_pen_changed, parent, pen, redraw, requested_cols, requested_lines, requested_size, resized, set_parent, set_pen, set_requested_size, set_style, set_style_tag, set_window, style_classes, take_focus, window


Tom Molesworth <>


Copyright Tom Molesworth 2012-2014. Licensed under the same terms as Perl itself.