NAME Tickit::WidgetRole::Movable - support for resizable/movable "panels" SYNOPSIS package Tickit::Widget::MovingThing; use parent qw(Tickit::WidgetRole::Movable Tickit::Widget); sub lines { 2 } sub cols { 2 } sub render_to_rb { ... } DESCRIPTION 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 _movable_role hashref in $self , so this requires instances to be blessed hashrefs. MIN_HEIGHT Minimum height to apply to this widget. Default is 2. MIN_WIDTH Minimum width to apply to this widget. Default is 2. METHODS export_subs_for Empty implementation for Tickit::WidgetRole export_subs_for. 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: * "mouse_press" - first click, this is either a one-off or the start of a drag event * "mouse_release" - mouse has been released, either after a click or after dragging * "mouse_drag" - one or more mouse buttons are pressed and the mouse has moved mouse_press Handle a mouse press event. We're either in: * a corner - start resizing in both directions * an edge - start resizing in one dimension * the title bar - start moving the window position_is_corner If this location is a corner of the window, return the appropriate constant (NORTHEAST, NORTHWEST, SOUTHEAST, SOUTHWEST), otherwise returns false. position_is_corner If this location is an edge for this window, return the appropriate constant (NORTH, EAST, SOUTH, WEST), otherwise returns false. position_is_title If this location is somewhere in the title (currently defined as "top row, apart from corners and close button), returns true. start_resize_from_corner Start resizing from a corner. start_resize_from_edge Start resizing from an edge. start_moving Start moving the window. mouse_drag Deal with our drag events by changing window geometry accordingly. move Handle ongoing move events. resize_from_corner Resize action, from a corner. resize_from_edge Resize action - starting from an edge. mouse_release On release make sure we hand back input to the previous handler. change_geometry Default action when attempting to change geometry is to proxy this to the Tickit::Window directly. Override this in subclasses to implement constraints (e.g. clamp co-ordinates and pass to -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). SEE ALSO * Tickit::Window * Tickit::WidgetRole::Borderable AUTHOR Tom Molesworth LICENSE Copyright Tom Molesworth 2012-2024. Licensed under the same terms as Perl itself.