.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Tickit::Widget::Scroller 3pm" .TH Tickit::Widget::Scroller 3pm "2020-06-18" "perl v5.30.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" "Tickit::Widget::Scroller" \- a widget displaying a scrollable collection of items .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Tickit; \& use Tickit::Widget::Scroller; \& use Tickit::Widget::Scroller::Item::Text; \& \& my $tickit = Tickit\->new; \& \& my $scroller = Tickit::Widget::Scroller\->new; \& \& $scroller\->push( \& Tickit::Widget::Scroller::Item::Text\->new( "Hello world" ), \& Tickit::Widget::Scroller::Item::Text\->new( "Here are some lines" ), \& map { Tickit::Widget::Scroller::Item::Text\->new( "" ) } 1 .. 50, \& ); \& \& $tickit\->set_root_widget( $scroller ); \& \& $tickit\->run .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class provides a widget which displays a scrollable list of items. The view of the items is scrollable, able to display only a part of the list. .PP A Scroller widget stores a list of instances implementing the \&\f(CW\*(C`Tickit::Widget::Scroller::Item\*(C'\fR interface. .SH "STYLE" .IX Header "STYLE" The default style pen is used as the widget pen. .PP The following style pen prefixes are used: .IP "indicator => \s-1PEN\s0" 4 .IX Item "indicator => PEN" The pen used for the scroll position indicators at the top or bottom of the display .SH "KEYBINDINGS" .IX Header "KEYBINDINGS" The following keys are bound .IP "\(bu" 2 Down .Sp Scroll one line down .IP "\(bu" 2 Up .Sp Scroll one line up .IP "\(bu" 2 PageDown .Sp Scroll half a window down .IP "\(bu" 2 PageUp .Sp Scroll half a window up .IP "\(bu" 2 Ctrl-Home .Sp Scroll to the top .IP "\(bu" 2 Ctrl-End .Sp Scroll to the bottom .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .SS "new" .IX Subsection "new" .Vb 1 \& $scroller = Tickit::Widget::Scroller\->new( %args ) .Ve .PP Constructs a new \f(CW\*(C`Tickit::Widget::Scroller\*(C'\fR object. The new object will start with an empty list of items. .PP Takes the following named arguments: .IP "gravity => \s-1STRING\s0" 8 .IX Item "gravity => STRING" Optional. If given the value \f(CW\*(C`bottom\*(C'\fR, resize events and the \f(CW\*(C`push\*(C'\fR method will attempt to preserve the item at the bottom of the screen. Otherwise, will preserve the top. .IP "gen_top_indicator => \s-1CODE\s0" 8 .IX Item "gen_top_indicator => CODE" .PD 0 .IP "gen_bottom_indicator => \s-1CODE\s0" 8 .IX Item "gen_bottom_indicator => CODE" .PD Optional. Generator functions for the top and bottom indicators. See also \&\f(CW\*(C`set_gen_top_indicator\*(C'\fR and \f(CW\*(C`set_gen_bottom_indicator\*(C'\fR. .SH "METHODS" .IX Header "METHODS" .SS "on_scrolled" .IX Subsection "on_scrolled" .SS "set_on_scrolled" .IX Subsection "set_on_scrolled" .Vb 1 \& $on_scrolled = $scroller\->on_scrolled \& \& $scroller\->set_on_scrolled( $on_scrolled ) .Ve .PP Return or set the \s-1CODE\s0 reference to be called when the scroll position is adjusted. .PP .Vb 1 \& $on_scrolled\->( $scroller, $delta ) .Ve .PP This is invoked by the \f(CW\*(C`scroll\*(C'\fR method, including the \f(CW\*(C`scroll_to\*(C'\fR, \&\f(CW\*(C`scroll_to_top\*(C'\fR and \f(CW\*(C`scroll_to_bottom\*(C'\fR. In normal cases it will be given the delta offset that \f(CW\*(C`scroll\*(C'\fR itself was invoked with, though this may be clipped if this would scroll past the beginning or end of the display. .SS "push" .IX Subsection "push" .Vb 1 \& $scroller\->push( @items ) .Ve .PP Append the given items to the end of the list. .PP If the Scroller is already at the tail (that is, the last line of the last item is on display) and the gravity mode is \f(CW\*(C`bottom\*(C'\fR, the newly added items will be displayed, possibly by scrolling downward if required. While the scroller isn't adjusted by using any of the \f(CW\*(C`scroll\*(C'\fR methods, it will remain following the tail of the items, scrolling itself downwards as more are added. .SS "unshift" .IX Subsection "unshift" .Vb 1 \& $scroller\->unshift( @items ) .Ve .PP Prepend the given items to the beginning of the list. .PP If the Scroller is already at the head (that is, the first line of the first item is on display) and the gravity mode is \f(CW\*(C`top\*(C'\fR, the newly added items will be displayed, possibly by scrolling upward if required. While the scroller isn't adjusted by using any of the \f(CW\*(C`scroll\*(C'\fR methods, it will remain following the head of the items, scrolling itself upwards as more are added. .SS "shift" .IX Subsection "shift" .Vb 1 \& @items = $scroller\->shift( $count ) .Ve .PP Remove the given number of items from the start of the list and returns them. .PP If any of the items are on display, the Scroller will be scrolled upwards an amount sufficient to close the gap, ensuring the first remaining item is now at the top of the display. .PP The returned items may be re-used by adding them back into the scroller again either by \f(CW\*(C`push\*(C'\fR or \f(CW\*(C`unshift\*(C'\fR, or may be discarded. .SS "pop" .IX Subsection "pop" .Vb 1 \& @items = $scroller\->pop( $count ) .Ve .PP Remove the given number of items from the end of the list and returns them. .PP If any of the items are on display, the Scroller will be scrolled downwards an amount sufficient to close the gap, ensuring the last remaining item is now at the bottom of the display. .PP The returned items may be re-used by adding them back into the scroller again either by \f(CW\*(C`push\*(C'\fR or \f(CW\*(C`unshift\*(C'\fR, or may be discarded. .SS "scroll" .IX Subsection "scroll" .Vb 1 \& $scroller\->scroll( $delta ) .Ve .PP Move the display up or down by the given \f(CW$delta\fR amount; with positive moving down. This will be a physical count of displayed lines; if some items occupy multiple lines, then fewer items may be scrolled than lines. .SS "scroll_to" .IX Subsection "scroll_to" .Vb 1 \& $scroller\->scroll_to( $line, $itemidx, $itemline ) .Ve .PP Moves the display up or down so that display line \f(CW$line\fR contains line \&\f(CW$itemline\fR of item \f(CW$itemidx\fR. Any of these counts may be negative to count backwards from the display lines, items, or lines within the item. .SS "scroll_to_top" .IX Subsection "scroll_to_top" .Vb 1 \& $scroller\->scroll_to_top( $itemidx, $itemline ) .Ve .PP Shortcut for \f(CW\*(C`scroll_to\*(C'\fR to set the top line of display; where \f(CW$line\fR is 0. If \f(CW$itemline\fR is undefined, it will be passed as 0. If \f(CW$itemidx\fR is also undefined, it will be passed as 0. Calling this method with no arguments, therefore scrolls to the very top of the display. .SS "scroll_to_bottom" .IX Subsection "scroll_to_bottom" .Vb 1 \& $scroller\->scroll_to_bottom( $itemidx, $itemline ) .Ve .PP Shortcut for \f(CW\*(C`scroll_to\*(C'\fR to set the bottom line of display; where \f(CW$line\fR is \&\-1. If \f(CW$itemline\fR is undefined, it will be passed as \-1. If \f(CW$itemidx\fR is also undefined, it will be passed as \-1. Calling this method with no arguments, therefore scrolls to the very bottom of the display. .SS "line2item" .IX Subsection "line2item" .Vb 1 \& $itemidx = $scroller\->line2item( $line ) \& \& ( $itemidx, $itemline ) = $scroller\->line2item( $line ) .Ve .PP Returns the item index currently on display at the given line of the window. In list context, also returns the line number within item. If no window has been set, or there is no item on display at that line, \f(CW\*(C`undef\*(C'\fR or an empty list are returned. \f(CW$line\fR may be negative to count backward from the last line on display; the last line taking \f(CW\*(C`\-1\*(C'\fR. .SS "item2line" .IX Subsection "item2line" .Vb 1 \& $line = $scroller\->item2line( $itemidx, $itemline ) \& \& ( $line, $offscreen ) = $scroller\->item2line( $itemidx, $itemline, $count_offscreen ) .Ve .PP Returns the display line in the window of the given line of the item at the given index. \f(CW$itemidx\fR may be given negative, to count backwards from the last item. \f(CW$itemline\fR may be negative to count backward from the last line of the item. .PP In list context, also returns a value describing the offscreen nature of the item. For items fully on display, this value is \f(CW\*(C`undef\*(C'\fR. If the given line of the given item is not on display because it is scrolled off either the top or bottom of the window, this value will be either \f(CW"above"\fR or \f(CW"below"\fR respectively. If \f(CW$count_offscreen\fR is true, then the returned \f(CW$line\fR value will always be defined, even if the item line is offscreen. This will be negative for items \f(CW"above"\fR, and a value equal or greater than the number of lines in the scroller's window for items \f(CW"below"\fR. .SS "lines_above" .IX Subsection "lines_above" .Vb 1 \& $count = $scroller\->lines_above .Ve .PP Returns the number of lines of content above the scrolled display. .SS "lines_below" .IX Subsection "lines_below" .Vb 1 \& $count = $scroller\->lines_below .Ve .PP Returns the number of lines of content below the scrolled display. .SS "set_gen_top_indicator" .IX Subsection "set_gen_top_indicator" .SS "set_gen_bottom_indicator" .IX Subsection "set_gen_bottom_indicator" .Vb 1 \& $scroller\->set_gen_top_indicator( $method ) \& \& $scroller\->set_gen_bottom_indicator( $method ) .Ve .PP Accessors for the generators for the top and bottom indicator text. If set, each should be a \s-1CODE\s0 reference or method name on the scroller which will be invoked after any operation that changes the contents of the window, such as scrolling or adding or removing items. It should return a text string which, if defined and non-empty, will be displayed in an indicator window. This will be a small one-line window displayed at the top right or bottom right corner of the Scroller's window. .PP .Vb 1 \& $text = $scroller\->$method() .Ve .PP The ability to pass method names allows subclasses to easily implement custom logic as methods without having to capture a closure. .SS "update_indicators" .IX Subsection "update_indicators" .Vb 1 \& $scroller\->update_indicators .Ve .PP Calls any defined generators for indicator text, and updates the indicator windows with the returned text. This may be useful if the functions would return different text now. .SH "TODO" .IX Header "TODO" .IP "\(bu" 4 Abstract away the \*(L"item storage model\*(R" out of the actual widget. Implement more storage models, such as database-driven ones.. more dynamic. .IP "\(bu" 4 Keybindings .SH "AUTHOR" .IX Header "AUTHOR" Paul Evans