Position, resize and zoom a graphics overlay
Name
ggiOvlSetPos, ggiOvlMove, ggiOvlGetPos, ggiOvlSetSize, ggiOvlGetSize, ggiOvlSetLense, ggiOvlGetLense, ggiOvlSetVals : Position, resize and zoom a graphics overlay
Synopsis
#include <ggi/ovl.h> int ggiOvlSetPos(ggiOvl_t ovl, long x, long y); int ggiOvlMove(ggiOvl_t ovl, long x, long y); int ggiOvlGetPos(ggiOvl_t ovl, long *x, long *y); int ggiOvlSetSize(ggiOvl_t ovl, long w, long h); int ggiOvlGetSize(ggiOvl_t ovl, long *x, long *y); int ggiOvlSetLense(ggiOvl_t ovl, long x, long y, long w, long h); int ggiOvlGetLense(ggiOvl_t ovl, long *x, long *y, long *w, long *h); int ggiOvlSetVals(ggiOvl_t ovl, long x, long y, long w, long h, long lx, long ly, long lw, long lh);
Description
all the coordinates and sizes are given in the units which were last set with the function ggiOvlSetCoordBase. In addition, where noted below, coordinates are offset by the values last passed to ggiOvlSetCoordBase(3). New resources, upon which ggiOvlSetCoordbase has never been used, start with their point of origin at the top left corner of the visual, and use the same units that were used to negotiate them via the ggiOvlAdd* or ggiOvlCreate* functions. If you didn't specifically ask for certain units, then you should call ggiOvlSetCoordBase(3) to set the desired units before attempting to use these functions.
ggiOvlSetPos positions the graphics overlay with the top left corner at the given coordinates x and y. The actual coordinates used may be altered by the target subsystem if there are restrictions on the placement of the resource. ggiOvlGetPos will read the actual position of the resource into the offered parameters x and y. ggiOvlMove is just another name for ggiOvlSetPos. The lense origin (see below) is interpolated to match the new position.
ggiOvlSetSize alters the visible size of a graphics overlay. The actual sizes used may be altered by the target subsystem if their are restrictions on the pplacement of the resource. ggiOvlGetSize will read the actual position of the resource into the offered parameters x and y. The lense parameters (see below) are not interpolated to the new size of the resource, and as such more of the contents of the resource may be displayed.
ggiOvlSetLense alters the contents displayed inside the overlay on resources which support zooming, tesselation, and panning. The parameters are given in the same units as those of the above five functions, and if the contents are not to be panned or zoomed, x, y will have the same values as last supplied to ggiOvlSetPos and w, h will have the same values as last supplied to ggiOvlSetLense. Their usage is best described by example, see below.
ggiOvlSetVals is used to set all the positioning and lense parameters at the same time. It is recommended to use this function, rather than the above, when you need to perform a combination of positioning, sizing, or zooming operations on the overlay, for two reasons: Firstly, if you are setting these parameters on an overlay which is not hidden, this will likely induce less user-visible artifacts; Secondly, some resources may not support the intermediate states you traverse by using combinations of the other functions above, and you may find they fail to actually implement the requested changes.
Return value
All functions return 0 on success, or a negative value if an error occurred.
Examples
Move, zoom, and pan a video overlay:
long sizex, sizey, posx, posy; ggi_mode mode; ggiGetMode(vis, &mode); /* Set the units to millimeters */ ggiOvlSetCoordBase(ovl, GA_COORBASE_MILLIMETERS, 0, 0, 0, 0); /* Get the current size of the overlay */ ggiOvlGetSize(ovl, &sizex, &sizey); err = ggiOvlMove(video,(mode.size.x - sizex)/2,(mode.size.y - sizey)/2)); if (err) { fprintf(stderr, "Could not center the video display\n"); } /* Get the current position of the overlay, which may be slightly off from the above. */ ggiOvlGetPos(ovl, &posx, &posy); /* Zoom the contents of the overlay to twice their normal size. */ ggiOvlSetLense(ovl, posx, posy, sizex * 2, sizey * 2); /* Slowly pan over from the top left quadrant of the video image, where we are now, to the lower right quadrant */ for (i = 100; i > 0; i++) { ggiOvlSetLense(ovl, posx + sizex * i/ 100, posy + sizey * i/100, sizex * 2, sizey * 2); usleep(10000); }