1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#ifndef AS_MOVERESIZE_H_HEADER_FILE_INCLUDED
#define AS_MOVERESIZE_H_HEADER_FILE_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/****h* libAfterWidget/moveresize.h
* SYNOPSIS
* Protocols for interactive widget movement/sizing.
* DESCRIPTION
* Initiating widget/app calls :
* move_widget_interactively() or resize_widget_interactively()
* Those functions initialize ASMoveResizeData, register event handler
* with main widget's event handler and return pointer to the data.
*
* When interactive event loop neds to chage placement of widget -
* it calls method stored in data.
*
* When interactive action is complete or cancelled - another method is
* called pointer to which is stored in data, then data and loop
* unregister self from the main even handler.
*
* AvoidCover algorithm:
* When we are resizing - everything is nice and simple. At most 2 sides
* are allowed to move at any time - for each we check if we reached any
* AvoidCover gridline - and if yes - we stop, and also we check if we
* reached attracting distance of any other gridline, and if so - we
* snap to it.
*
* When we are moving - things get complicated, since we actually need to
* move past AvoidCover windows if user insistently drags the mouse over
* it. We are looking for point with x*x+y*y < dX*dX+dY*dY in one of the
* 4 possible quadrants( depending on move direction ). Then we nee to
* find such point that has lesser (x-Px)*(x-Px)+(y-Py)*(y-Py) where
* Px,Py are current position of pointer. This point should also be placed
* so that all the gridlines with negative gravity are avoided.
*
* SEE ALSO
* Structures :
* Functions :
* Other libAfterWidget modules :
* AUTHOR
* Sasha Vasko <sasha at aftercode dot net>
******
*/
struct ASEvent;
struct ASOutlineSegment;
struct ASMoveResizeData;
struct ASGrid;
struct ASHints;
struct ASStatusHints;
typedef struct MRRectangle { int x, y, width, height ; } MRRectangle ;
typedef void (*as_interactive_pointer_handler) (struct ASMoveResizeData *data, int x, int y);
typedef void (*as_interactive_apply_handler) (struct ASMoveResizeData *data);
typedef void (*as_interactive_subwindow_handler)(struct ASMoveResizeData *data, struct ASEvent *event);
typedef void (*as_interactive_complete_handler) (struct ASMoveResizeData *data, Bool cancelled);
typedef int (*as_outline_handler) (struct ASOutlineSegment *s,
struct MRRectangle *geom,
unsigned int scr_width,
unsigned int scr_height);
extern Bool (*_as_grab_screen_func)( struct ScreenInfo *scr, Cursor cursor );
extern void (*_as_ungrab_screen_func) ();
typedef struct ASOutlineSegment
{
Window w ;
int x, y;
int size ;
Bool vertical ;
}ASOutlineSegment;
typedef struct ASHintWindow
{
Window w;
ASCanvas *canvas ;
ASTBarData *bar ;
struct ScreenInfo *scr;
struct MyLook *look ;
}ASHintWindow;
ASHintWindow *create_ashint_window( ScreenInfo *scr, struct MyLook *look, const char *hint );
void destroy_ashint_window( ASHintWindow **hw );
void update_ashint_text( ASHintWindow *hw, const char *new_text );
void update_ashint_geometry( ASHintWindow *hw, Bool force_redraw );
typedef struct ASMoveResizeData
{
/* mandatrory things : */
struct ASWidget *parent;
struct ASWidget *mr;
struct ASFeel *feel ;
struct MyLook *look ;
as_interactive_apply_handler apply_func;
as_interactive_complete_handler complete_func;
/* what leg ... err, side are we pulling on ??? ( see FR_* values) */
int side ;
/* Internally managed things : */
as_interactive_pointer_handler pointer_func;
MRRectangle curr, last, start;
int bw ; /* bloody border width */
char *geometry_string;
struct ASHintWindow *geometry_display;
/* ratios to be applied to geometry before displaying : */
unsigned int geom_x_mult, geom_x_div ;
unsigned int geom_y_mult, geom_y_div ;
int geom_x_origin, geom_y_origin ;
int origin_x, origin_y ; /* parent's window root
* coordinates */
int last_x, last_y ;
int lag_x, lag_y ;
ASOutlineSegment *outline;
unsigned int pointer_state ;
Time pointer_grab_time;
Window curr_subwindow;
/* Optional things : */
as_interactive_subwindow_handler subwindow_func;
Window below_sibling ; /* outline will be placed
* just below this sibling */
struct ASGrid *grid ;
/* optional size constraints : */
unsigned int min_width, width_inc, max_width, frame_width;
unsigned int min_height, height_inc, max_height, frame_height;
Bool stop_on_button_press; /* when true operation will complete on ButtonPress event - not on ButtonRelease */
Bool move_only ;
int title_north, title_west ;
}ASMoveResizeData;
ASOutlineSegment *make_outline_segments( struct ASWidget *parent, struct MyLook *look );
void move_outline( ASMoveResizeData * data );
void destroy_outline_segments( ASOutlineSegment **psegments );
ASMoveResizeData *
move_widget_interactively(struct ASWidget *parent,
struct ASWidget *mr,
struct ASEvent *trigger,
as_interactive_apply_handler apply_func,
as_interactive_complete_handler complete_func );
ASMoveResizeData*
resize_widget_interactively( struct ASWidget *parent,
struct ASWidget *mr,
struct ASEvent *trigger,
as_interactive_apply_handler apply_func,
as_interactive_complete_handler complete_func,
int side );
void set_moveresize_restrains( ASMoveResizeData *data, struct ASHints *hints, struct ASStatusHints *status );
void set_moveresize_aspect( ASMoveResizeData *data, int x_mult, int x_div, int y_mult, int y_div, int x_origin, int y_origin );
Bool check_moveresize_event( struct ASEvent *event );
void complete_interactive_action( ASMoveResizeData *data, Bool cancel );
void move_func (struct ASMoveResizeData *data, int x, int y);
void resize_func (struct ASMoveResizeData *data, int x, int y);
#ifdef __cplusplus
}
#endif
#endif
|