/*
* Tip shower
* created on 8.1.2001 by Pablo Borobia
*
*
* Some changes by Julien Etelain on 23/09/2001
*
*/

t_point tips_oldpos;
l_int   tips_count;


void tips_func_callback( p_object o ) {

  t_point m = VIEW(o)->get_global_point(VIEW(o), mouse->where);

  if (m.x==tips_oldpos.x && m.y==tips_oldpos.y) {
    tips_count++; }
  else {
    tips_count = 0;
    tips_oldpos = m;
  }

  if (tips_count == 15) {
    p_view tmp = desktop->get_view_under_mouse(desktop);
    if (tmp) {
      while ( tmp->get_view_under_mouse(tmp) != NULL) {
        tmp = tmp->get_view_under_mouse(tmp);
      }
      view_show_info_board(tmp);
    }
    //count = 0;
  }
};

p_view tips_init (p_view o, t_rect r) {
   if ( !o ) return NULL;
   view_init(o, r);
   OBJECT(o)->process_tick = 100;
   OBJECT(o)->func_callback = &tips_func_callback;
   OBJECT(o)->set_options(OBJECT(o), OB_OF_SELECTABLE+OB_OF_ENABLE, false);
   OBJECT(o)->set_options(OBJECT(o), OB_OF_STILLPROCESS, true);
   return o;
};

void tips_system_init ( void ) {
   p_view  o = tips_init(_malloc(sizeof(t_view)),rect_assign(0,0,0,0));
   OBJECT(desktop)->insert(OBJECT(desktop), OBJECT(o));
   o->hide(o);
};
