Tom Molesworth > Tickit-Widget-Tree > Tickit::Widget::Tree

Download:
Tickit-Widget-Tree-0.108.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.108   Source  

NAME ^

Tickit::Widget::Tree - tree widget implementation for Tickit

VERSION ^

Version 0.108

SYNOPSIS ^

 use Tickit::Widget::Tree;
 my $tree = Tickit::Widget::Tree->new(root => Tree::DAG_Node->new);

DESCRIPTION ^

NOTE: Versions 0.003 and below used a custom graph management implementation which had various problems with rendering glitches and performance. This version has been rewritten from scratch to use Tree::DAG_Node to handle the tree structure, and as such is not backward compatible.

Tree widget in action

STYLES ^

The following style keys are recognised, in addition to base styling which will be applied to the tree lines:

Tree widget styles

Key bindings are currently:

calculate_size

Calculate the minimum size needed to contain the full tree with all nodes expanded.

Used internally.

new

Instantiate. Takes the following named parameters:

Example usage:

 Tickit:Widget::Tree->new(
  data => [
        node1 => [
                qw(some nodes here)
        ],
        node2 => [
                qw(more nodes in this one),
                and => [
                        qw(this has a few child nodes too)
                ]
        ],
  ];
 );

root

Accessor for the root node. If given a parameter, will set the root node accordingly (and mark the tree for redraw), returning $self.

Otherwise, returns the root node - or undef if we do not have one.

window_gained

Work out our size, when we have a window to fit in.

set_scrolling_extents

Called by Tickit::Widget::ScrollBox or other scroll-capable containers to set up the extent objects which determine the drawable viewport offset.

scrolled

Called by Tickit::Widget::ScrollBox or other scroll-capable containers to indicate when scroll actions have occurred.

render_to_rb

Render method. Used internally.

position_adapter

Returns the "position" adapter. This is an Adapter::Async::OrderedList::Array indicating where we are in the tree - it's a list of all the nodes leading to the currently-highlighted one.

Note that this will return Tree::DAG_Node items. You'd probably want the "name" in Tree::DAG_Node method to get something printable.

Example usage:

 my $tree = Tickit::Widget::Tree->new(...);
 my $where_am_i = Tickit::Widget::Breadcrumb->new(
  item_transformations => sub {
   shift->name
  }
 );
 $where_am_i->adapter($tree->position_adapter);

reshape

Workaround to avoid warnings from Tickit::Window. This probably shouldn't be here, pretend you didn't see it.

on_mouse

Mouse callback. Used internally.

key_first_row

Jump to the first row. Normally bound to the Home key.

key_last_row

Jump to the last row. Normally bound to the End key.

key_previous_row

Go up a node.

key_next_row

Move down a node.

key_up_tree

Going "up" the tree means the parent of the current node.

key_down_tree

Going "down" the tree means the first child node, if we have one and we're open.

highlight_node

Change the currently highlighted node.

key_open_node

Open this node.

key_close_node

Close this node.

key_activate

Call the on_activate coderef if we have it.

TODO ^

Plenty of features and bugfixes left on the list, in no particular order:

INHERITED METHODS ^

Tickit::Widget

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, window_lost

Mixin::Event::Dispatch

add_handler_for_event, clear_event_handlers, event_handlers, invoke_event, subscribe_to_event, unsubscribe_from_event

AUTHOR ^

Tom Molesworth <cpan@perlsite.co.uk>

LICENSE ^

Copyright Tom Molesworth 2011-2013. Licensed under the same terms as Perl itself.

syntax highlighting: