=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with Tickit::WidgetRole::Movable
at lib/Tickit/WidgetRole/Movable.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=encoding utf8

=cut

=head1 NAME

Tickit::WidgetRole::Movable - support for resizable/movable "panels"

=head1 VERSION

Version 0.001

=head1 SYNOPSIS

 package Tickit::Widget::MovingThing;
 use parent qw(Tickit::WidgetRole::Movable Tickit::Widget);

 sub lines { 2 }
 sub cols { 2 }
 sub render_to_rb { ... }

=head1 DESCRIPTION

B< WARNING >: This is an early preview release. Things may change.

Apply this as a parent class to a widget to provide for resize/move semantics, similar to
behaviour provided by common window managers.

Expects the widget to be contained by a parent object which provides a suitable area in
which to resize/move the widget.

State information is stored in the C< _movable_role > hashref in C< $self >, so this requires
instances to be blessed hashrefs.

=head2 MIN_HEIGHT

Minimum height to apply to this widget. Default is 2.

=head2 MIN_WIDTH

Minimum width to apply to this widget. Default is 2.

=head1 METHODS

=head2 export_subs_for

Empty implementation for L<Tickit::WidgetRole> C<export_subs_for>.

=head2 on_mouse

Handle mouse events.

We can be in one of three states here: a mouse press, a drag event, or a release.

We delegate each of these to separate methods - see:

=over 4

=item * L</mouse_press> - first click, this is either a one-off or the start of a drag event

=item * L</mouse_release> - mouse has been released, either after a click or after dragging

=item * L</mouse_drag> - one or more mouse buttons are pressed and the mouse has moved

=back

=head2 mouse_press

Handle a mouse press event.

We're either in:

=over 4

=item * a corner - start resizing in both directions

=item * an edge - start resizing in one dimension

=item * the title bar - start moving the window

=back

=head2 position_is_corner

If this location is a corner of the window, return the
appropriate constant (NORTHEAST, NORTHWEST, SOUTHEAST,
SOUTHWEST), otherwise returns false.

=head2 position_is_corner

If this location is an edge for this window, return the
appropriate constant (NORTH, EAST, SOUTH, WEST), otherwise
returns false.

=head2 position_is_title

If this location is somewhere in the title (currently defined
as "top row, apart from corners and close button), returns true.

=head2 start_resize_from_corner

Start resizing from a corner.

=head2 start_resize_from_edge

Start resizing from an edge.

=head2 start_moving

Start moving the window.

=head2 mouse_drag

Deal with our drag events by changing window geometry
accordingly.

=head2 move

Handle ongoing move events.

=head2 resize_from_corner

Resize action, from a corner.

=head2 resize_from_edge

Resize action - starting from an edge.

=head2 mouse_release

On release make sure we hand back input to the previous handler.

=head2 change_geometry

Default action when attempting to change geometry is to proxy this
to the L<Tickit::Window> directly. Override this in subclasses to
implement constraints (e.g. clamp co-ordinates and pass to C< ->SUPER::change_geometry >,
or return early without applying the action) or linked window actions
(move/resize another window after applying the geometry change to
this one).

=head1 SEE ALSO

=over 4

=item * L<Tickit::Window>

=item * L<Tickit::WidgetRole::Borderable>

=back

=head1 INHERITED METHODS

=over 4

=item L<Tickit::WidgetRole>

L<import|Tickit::WidgetRole/import>

=back

=head1 AUTHOR

Tom Molesworth <cpan@perlsite.co.uk>

=head1 LICENSE

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