NAME

UAV::Pilot::SDL::Window

SYNOPSIS

my $window = UAV::Pilot::SDL::Window->new;
$window->add_child( $window_event_handler );

# In the child's draw method
$window->clear_screen;
$window->draw_line( [0, 0], [128, 128], $color );
$window->draw_circle( [ 512, 512 ], 10, $color );

DESCRIPTION

A basic windowing system for drawing widgets. Currently only supports adding new widgets on top or below an existing widget.

Does the UAV::Pilot::EventHandler role.

METHODS

add_child

add_child( $handler, $float ).

Pass a child that does the UAV::Pilot::SDL::WindowEventHandler role. Float should be <$window-TOP>> or <$window-BOTTOM>> for the location to draw this child. The window will be expanded to fit the child's width/height.

add_child_with_yuv_overlay

add_child_with_yuv_overlay( $handle, $overlay_flag, $float )

Pass a child that does the UAV::Pilot::SDL::WindowEventHandler role. The $overlay_flag will be the flag passed to SDL::Overlay (see that module's docs for details). The $float param is the same as add_child().

sdl

Returns the SDLx::App object for the given SDL window.

yuv_overlay

If a child was added with add_child_with_yuv_overlay(), returns the SDL::Overlay object.

yuv_overlay_rect

If a child was added with add_child_with_yuv_overlay(), returns an SDL::Rect object that covers the overlay area.

DRAWING METHODS

The should only be used by widgets when their draw() method is called.

All $x, $y coordinates are relative to the widgets's drawing area.

clear_screen

Blanks the area that the current widget is being drawn in.

draw_txt

draw_txt( $string, $x, $y, $sdl_text )

Draws text to the screen. Params:

$string: The string to write

$x, $y: The coords to draw at

$sdl_text: An SDLx::Text object

draw_line

draw_line( [$x0,$y0], [$x1,$y1], $color )

Draws a line. The $color param is an SDL::Color object.

draw_circle

draw_circle( [$x,$y], $radius, $color )

Draws a circle. The $color param is an SDL::Color object.

draw_rect

draw_rect( [$x, $y, $width, $height], $color )

Draws a rect. The $color param is an SDL::Color object.

update_rect

update_rect( $width, $height )

Updates the draw area for the active window.