Commit ded83272 authored by claes's avatar claes

Visibility check more sofisticated

parent dc7bd27b
......@@ -42,6 +42,13 @@ typedef enum {
flow_eSelectPolicy_Partial
} flow_eSelectPolicy;
typedef enum {
flow_eVisible_Full,
flow_eVisible_Partial,
flow_eVisible_Top,
flow_eVisible_Bottom
} flow_eVisible;
typedef enum {
flow_eObjectType_NoObject,
flow_eObjectType_Node,
......
......@@ -674,9 +674,19 @@ int brow_GetPreviousSibling( brow_tCtx ctx, brow_tObject object,
return ctx->get_previous_sibling( (FlowArrayElem *)object, (FlowArrayElem **)sibling);
}
int brow_IsVisible( brow_tCtx ctx, brow_tObject object)
int brow_IsVisible( brow_tCtx ctx, brow_tObject object, flow_eVisible type)
{
return ctx->is_visible( (FlowArrayElem *)object);
return ctx->is_visible( (FlowArrayElem *)object, type);
}
int brow_GetFirstVisible( brow_tCtx ctx, brow_tObject *object)
{
return ctx->get_first_visible( (FlowArrayElem **)object);
}
int brow_GetLastVisible( brow_tCtx ctx, brow_tObject *object)
{
return ctx->get_last_visible( (FlowArrayElem **)object);
}
int brow_Page( brow_tCtx ctx, double factor)
......
......@@ -198,7 +198,9 @@ int brow_GetNextSibling( brow_tCtx ctx, brow_tObject object,
brow_tObject *sibling);
int brow_GetPreviousSibling( brow_tCtx ctx, brow_tObject object,
brow_tObject *sibling);
int brow_IsVisible( brow_tCtx ctx, brow_tObject object);
int brow_IsVisible( brow_tCtx ctx, brow_tObject object, flow_eVisible type);
int brow_GetFirstVisible( brow_tCtx ctx, brow_tObject *object);
int brow_GetLastVisible( brow_tCtx ctx, brow_tObject *object);
int brow_Page( brow_tCtx ctx, double factor);
int brow_CreateSecondaryCtx( brow_tCtx ctx, brow_tCtx *secondary_ctx,
int (*init_proc)(brow_tCtx ctx, void *client_data),
......
......@@ -185,7 +185,7 @@ int BrowCtx::print( char *filename)
}
int BrowCtx::is_visible( FlowArrayElem *element)
int BrowCtx::is_visible( FlowArrayElem *element, flow_eVisible type)
{
double ll_x, ll_y, ur_x, ur_y;
double window_low, window_high;
......@@ -193,10 +193,32 @@ int BrowCtx::is_visible( FlowArrayElem *element)
((FlowNode *)element)->measure( &ll_x, &ll_y, &ur_x, &ur_y);
window_low = double(offset_y) / zoom_factor;
window_high = double(offset_y + window_height) / zoom_factor;
if ( ll_y >= window_low && ur_y <= window_high)
return 1;
else
return 0;
switch ( type) {
case flow_eVisible_Full:
if ( ll_y >= window_low && ur_y <= window_high)
return 1;
else
return 0;
case flow_eVisible_Partial:
if ( (ll_y >= window_low && ll_y <= window_high) ||
(ur_y >= window_low && ur_y <= window_high) ||
(ll_y <= window_low && ur_y >= window_high))
return 1;
else
return 0;
case flow_eVisible_Top:
if ( ur_y >= window_low && ur_y <= window_high)
return 1;
else
return 0;
case flow_eVisible_Bottom:
if ( ll_y >= window_low && ll_y <= window_high)
return 1;
else
return 0;
default: ;
}
return 0;
}
void BrowCtx::center_object( FlowArrayElem *object, double factor)
......@@ -215,6 +237,44 @@ void BrowCtx::center_object( FlowArrayElem *object, double factor)
change_scrollbar();
}
int BrowCtx::get_first_visible( FlowArrayElem **element)
{
double ll_x, ll_y, ur_x, ur_y;
double window_low, window_high;
int i;
window_low = double(offset_y) / zoom_factor;
window_high = double(offset_y + window_height) / zoom_factor;
for ( i = 0; i < a.size(); i++) {
((FlowNode *)a[i])->measure( &ll_x, &ll_y, &ur_x, &ur_y);
if ( ll_y >= window_low || ur_y >= window_high) {
*element = a[i];
return 1;
}
}
return 0;
}
int BrowCtx::get_last_visible( FlowArrayElem **element)
{
double ll_x, ll_y, ur_x, ur_y;
double window_low, window_high;
int i;
window_low = double(offset_y) / zoom_factor;
window_high = double(offset_y + window_height) / zoom_factor;
for ( i = a.size() - 1; i >= 0; i--) {
((FlowNode *)a[i])->measure( &ll_x, &ll_y, &ur_x, &ur_y);
if ( ur_y <= window_high || ll_y <= window_low) {
*element = a[i];
return 1;
}
}
return 0;
}
int BrowCtx::page( double factor)
{
double ll_x, ll_y, ur_x, ur_y;
......
......@@ -37,7 +37,9 @@ class BrowCtx : public FlowCtx {
{ return a.brow_get_next_sibling( element, sibling);};
int get_previous_sibling( FlowArrayElem *element, FlowArrayElem **sibling)
{ return a.brow_get_previous_sibling( element, sibling);};
int is_visible( FlowArrayElem *element);
int is_visible( FlowArrayElem *element, flow_eVisible type);
int get_first_visible( FlowArrayElem **element);
int get_last_visible( FlowArrayElem **element);
void center_object( FlowArrayElem *object, double factor);
int page( double factor);
......
......@@ -1601,8 +1601,10 @@ static void event_timer_cb( FlowCtx *ctx)
static void cancel_event_timer( FlowCtx *ctx)
{
draw_tCtx draw_ctx = (draw_tCtx) ctx->draw_ctx;
if ( draw_ctx->timer_id)
if ( draw_ctx->timer_id) {
XtRemoveTimeOut( draw_ctx->timer_id);
draw_ctx->timer_id = 0;
}
// printf( "Timer removed\n");
// sys$cantim( ctx, 0);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment