NAME
Tickit::Widget::Layout::Desktop - provides a holder for "desktop-like" widget behaviour
SYNOPSIS
#!/usr/bin/env perl
use strict;
use warnings;
use Tickit;
use Tickit::Widget::Placegrid;
use Tickit::Widget::Layout::Desktop;
my $tickit = Tickit->new;
my $desktop = Tickit::Widget::Layout::Desktop->new;
$tickit->later(sub {
my $left = int($desktop->window->cols * rand);
my $top = int($desktop->window->lines * rand);
my $cols = 20 + int(10 * rand);
my $lines = 5 + int(20 * rand);
$left = $desktop->window->cols - $cols if $left + $cols >= $desktop->window->cols;
$top = $desktop->window->lines - $lines if $top + $lines >= $desktop->window->lines;
$desktop->create_panel(
label => 'widget',
left => $left,
top => $top,
cols => $cols,
lines => $lines,
)->add(Tickit::Widget::Placegrid->new);
});
$tickit->set_root_widget($desktop);
$tickit->run;
DESCRIPTION
Experimental release for a container that provides move/resize/minimize/maximize "window" behaviour.
Constructed of:
Tickit::Widget::Layout::Desktop::Window - the window implementation
this class - background desktop on which the floats are displayed
and maybe later:
::Desktop::Taskbar - a subclass of statusbar which provides window lists and launchers
METHODS
render_to_rb
Clears the exposed area. All rendering happens in the floating windows on top of this widget.
overlay
Render all window outlines on top of the target widget.
Takes the following parameters:
$rb - the Tickit::RenderBuffer we will be drawing into
$exclude - the current Tickit::Widget we are drawing - this will be used to check for intersections so we don't waste time drawing unrelated areas
window_gained
Records our initial window geometry when the Tickit::Window is first attached.
create_panel
Creates a Tickit::Widget::Layout::Desktop::Window on this Tickit::Widget::Layout::Desktop.
Takes the following named parameters:
top - offset from top of desktop
left - offset from desktop left margin
lines - how many lines the new widget will have, should be >2 to display anything useful
cols - how many columns the new widget will have, should be >2 to display anything useful
label - what label to use, default is the uninspiring text
window
API METHODS
These methods are provided as an API for the Tickit::Widget::Layout::Desktop::Window children. They allow widgets to interact with the desktop for requesting focus etc.
make_active
Makes the requested Tickit::Widget::Layout::Desktop::Window active - brings it to the front of the stack and gives it focus.
Returns $self.
weld
"Welds" edges of windows together.
Takes 4 parameters:
Source widget edge
Source widget
Destination edge
Destination widget
For example:
$desktop->weld(
right => $left_panel,
left => $right_panel,
);
Given a two-panel layout, this would mean any changes to the right edge of the panel on the left would adjust the left edge of the panel on the right, and vice versa.
As you increase the size of the left panel, the right panel shrinks, so instead of the normal behaviour where the widget on the left would start to overlap the one on the right, this maintains the relative positioning by resizing the target widget. This can be used to provide movable dividers between desktop panels, allowing temporary resize without disrupting the layout.
Returns $self
for chaining.
reshape
Deal with reshape requests.
Since our windows are positioned directly, we're going to lose some information if shrink then expand the parent window again. This isn't ideal but hopefully we can get away with it for now.
Returns $self.
cascade
Arrange all the windows in a cascade (first at 1,1, second at 2,2, etc.).
tile
Tiles all the windows. Tries to lay them out so things don't overlap. Since we're resizing, things may end up ridiculously small.
Pass overlap => 1 to have overlapping edges.
Returns $self.
close_all
Close all the windows.
SEE ALSO
Tickit::Widget::FloatBox - eventually ::Desktop will probably start using FloatBox for the float management
INHERITED METHODS
- Tickit::ContainerWidget
-
add, child_opts, child_resized, children_changed, find_child, remove, set_child_opts, window_lost
- Tickit::Widget
-
get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, parent, pen, redraw, requested_cols, requested_lines, requested_size, resized, set_parent, set_requested_size, set_style, set_style_tag, set_window, split_widget_opts, style_classes, take_focus, window
- Object::Pad::UNIVERSAL
AUTHOR
Tom Molesworth <TEAM@cpan.org>
LICENSE
Copyright Tom Molesworth 2011-2017. Licensed under the same terms as Perl itself.