예제 #1
0
/*
 * Function    : _libaroma_ctl_fragment_direct_canvas
 * Return Value: byte
 * Descriptions: set as direct canvas
 */
byte _libaroma_ctl_fragment_direct_canvas(LIBAROMA_CONTROLP ctl, byte state){
  _LIBAROMA_CTL_CHECK(
    _libaroma_ctl_fragment_handler, _LIBAROMA_CTL_FRAGMENTP, 0
  );
  libaroma_mutex_lock(me->dmutex);
  if ((me->win_n<1)||(me->win_pos==-1)) {
    libaroma_mutex_unlock(me->dmutex);
    return 0;
  }
  LIBAROMA_WINDOWP win = me->wins[me->win_pos];
  if (state){
    me->on_direct_canvas=1;
  }
  else{
    if (me->on_direct_canvas){
      LIBAROMA_CANVASP ccv = libaroma_control_draw_begin(ctl);
      if (ccv) {
        libaroma_draw(win->dc,ccv,0,0,0);
        libaroma_canvas_free(ccv);
      }
    }
    me->on_direct_canvas=0;
  }
  libaroma_mutex_unlock(me->dmutex);
  return 1;
} /* End of _libaroma_ctl_fragment_direct_canvas */
예제 #2
0
/*
 * Function    : libaroma_ctl_list_del_itemp_internal
 * Return Value: byte
 * Descriptions: del item from list
 */
byte libaroma_ctl_list_del_itemp_internal(
  LIBAROMA_CONTROLP ctl, LIBAROMA_CTL_LIST_ITEMP f
){
  LIBAROMA_CTL_SCROLL_CLIENTP client = libaroma_ctl_scroll_get_client(ctl);
  if (!client){
    return 0;
  }
  if (client->handler!=&_libaroma_ctl_list_handler){
    return 0;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  libaroma_mutex_lock(mi->imutex);
  libaroma_mutex_lock(mi->mutex);
  if (f){
    if ((f==mi->first)&&(f==mi->last)){
      mi->first=mi->last=NULL;
    }
    else if (f==mi->first){
      mi->first = f->next;
      mi->first->prev=NULL;
      __libaroma_ctl_list_repos_next_items(
        mi->first,
        f->y
      );
    }
    else if (f==mi->last){
      mi->last=f->prev;
      mi->last->next=NULL;
    }
    else{
      f->prev->next = f->next;
      f->next->prev = f->prev;
      __libaroma_ctl_list_repos_next_items(
        f->next,
        f->next->prev->y+f->next->prev->h
      );
    }
    
    mi->itemn--;
    mi->h-=f->h;
    if (f->handler->destroy!=NULL){
      f->handler->destroy(ctl,f);
    }
    _libaroma_ctl_list_free_state(f);
    __libaroma_ctl_list_item_unreg_thread(ctl, f);
    if (mi->touched==f){
      mi->touched=NULL;
    }
    free(f);
    libaroma_mutex_unlock(mi->mutex);
    libaroma_mutex_unlock(mi->imutex);
    libaroma_ctl_scroll_request_height(ctl, mi->h);
    return 1;
  }
  libaroma_mutex_unlock(mi->mutex);
  libaroma_mutex_unlock(mi->imutex);
  return 0;
} /* End of libaroma_ctl_list_del_itemp_internal */
예제 #3
0
/*
 * Function    : _libaroma_ctl_list_message
 * Return Value: dword
 * Descriptions: message handler
 */
dword _libaroma_ctl_list_message(
    LIBAROMA_CONTROLP ctl,
    LIBAROMA_CTL_SCROLL_CLIENTP client,
    LIBAROMA_MSGP msg,
    int x, int y){
  if (client->handler!=&_libaroma_ctl_list_handler){
    return 0;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  
  dword res=0;
  
  /* handle the message */
  libaroma_mutex_lock(mi->imutex);
  switch(msg->msg){
    case LIBAROMA_CTL_SCROLL_MSG:{
        res=_libaroma_ctl_list_scroll_message(
          ctl, client, mi, msg->x, msg->y, x, y
        );
      }
      break;
  }
  libaroma_mutex_unlock(mi->imutex);
  return res;
} /* End of _libaroma_ctl_list_message */
예제 #4
0
/*
 * Function    : _libaroma_ctl_fragment_window_control_draw_begin
 * Return Value: LIBAROMA_CANVASP
 * Descriptions: get canvas for child control
 */
LIBAROMA_CANVASP _libaroma_ctl_fragment_window_control_draw_begin(
  LIBAROMA_WINDOWP win,LIBAROMA_CONTROLP cctl
){
  _VALIDATE_FRAGMENT(NULL);
  if (!wind->active_state){
    return NULL;
  }
  LIBAROMA_CANVASP c=NULL;
  libaroma_mutex_lock(me->dmutex);
  if (me->on_direct_canvas){
    int x = cctl->x;
    int y = cctl->y;
    int w = cctl->w;
    int h = cctl->h;
    LIBAROMA_CANVASP ccv = libaroma_control_draw_begin(ctl);
    if (ccv){
      if ((ccv->w>x)&&(ccv->h>y)){
        c = libaroma_canvas_area(ccv,x,y,w,h);
      }
      libaroma_canvas_free(ccv);
    }
  }
  else {
    if (win->dc!=NULL){
      c = libaroma_canvas_area(
        win->dc,
        cctl->x, cctl->y, cctl->w, cctl->h
      );
    }
  }
  libaroma_mutex_unlock(me->dmutex);
  return c;
} /* End of _libaroma_ctl_fragment_window_control_draw_begin */
예제 #5
0
void _libaroma_ctl_fragment_measure(LIBAROMA_WINDOWP win){
  _VALIDATE_FRAGMENT();
  libaroma_mutex_lock(me->dmutex);
  win->x = 0;
  win->y = 0;
  win->ax=ctl->x;
  win->ay=ctl->y;
  win->w = ctl->w;
  win->h = ctl->h;
  if (win->dc){
    if ((win->dc->w!=win->w)||(win->dc->h!=win->h)){
      libaroma_canvas_free(win->dc);
      win->dc=NULL;
    }
  }
  if (!win->dc){
    win->dc = libaroma_canvas(
      win->w,
      win->h
    );
  }
  _libaroma_ctl_fragment_window_updatebg(win);
  int i;
  #ifdef LIBAROMA_CONFIG_OPENMP
    #pragma omp parallel for
  #endif
  for (i=0;i<win->childn;i++){
    libaroma_window_measure(win,win->childs[i]);
  }
  libaroma_mutex_unlock(me->dmutex);
}
예제 #6
0
/*
 * Function    : _libaroma_ctl_pager_window_control_isvisible
 * Return Value: byte
 * Descriptions: check if control is visible
 */
byte _libaroma_ctl_pager_window_control_isvisible(
  LIBAROMA_WINDOWP win,LIBAROMA_CONTROLP cctl
){
  LIBAROMA_CONTROLP ctl=(LIBAROMA_CONTROLP) win->client_data;
  _LIBAROMA_CTL_CHECK(
    _libaroma_ctl_pager_handler, _LIBAROMA_CTL_PAGERP, 0
  );
  libaroma_mutex_lock(me->mutex);
  int xt = me->scroll_x; /*me->page_position * ctl->w;*/
  int ww = ctl->w;
  if (!win->active){
    xt=0;
    ww=win->w;
  }
  int sx = cctl->x-xt;
  int sy = cctl->y;
  libaroma_mutex_unlock(me->mutex);
  if (sx+cctl->w<0){
    return 0;
  }
  if (sx>ww){
    return 0;
  }
  if (sy+cctl->h<0){
    return 0;
  }
  if (sy>win->h){
    return 0;
  }
  return 1;
} /* End of _libaroma_ctl_pager_window_control_isvisible */
예제 #7
0
/*
 * Function : Save display canvas into framebuffer
 *
 */
byte QNXGF_post(
  LIBAROMA_FBP me, wordp __restrict src,
  int dx, int dy, int dw, int dh,
  int sx, int sy, int sw, int sh) {
  if (me == NULL) {
    return 0;
  }
  
  libaroma_mutex_lock(___qnxfbmutex);
  QNXGF_INTERNALP mi = (QNXGF_INTERNALP) me->internal;
  wordp copy_src = (wordp) (src + ((sw * sy) + sx));
  
  gf_draw_begin(mi->context);
  gf_draw_image(
    mi->context,
    (const uint8_t *) copy_src,
    GF_FORMAT_PKLE_RGB565,
    sw * 2,
    dx, dy,
    dw, dh,
    0
  );
  
  gf_draw_flush(mi->context);
  gf_draw_end(mi->context);
  libaroma_mutex_unlock(___qnxfbmutex);
  return 1;
}
예제 #8
0
/*
 * Function    : SDLFBDR_end_post
 * Return Value: byte
 * Descriptions: end post
 */
byte SDLFBDR_end_post(LIBAROMA_FBP me){
  if (me == NULL) {
    return 0;
  }
  SDLFBDR_INTERNALP mi = (SDLFBDR_INTERNALP) me->internal;
  SDLFBDR_flush(me);
  libaroma_mutex_unlock(mi->mutex);
  return 1;
}
예제 #9
0
/*
 * Function    : _libaroma_ctl_pager_window_control_draw_begin
 * Return Value: LIBAROMA_CANVASP
 * Descriptions: get canvas for child control
 */
LIBAROMA_CANVASP _libaroma_ctl_pager_window_control_draw_begin(
  LIBAROMA_WINDOWP win,LIBAROMA_CONTROLP cctl
){
  LIBAROMA_CONTROLP ctl=(LIBAROMA_CONTROLP) win->client_data;
  _LIBAROMA_CTL_CHECK(
    _libaroma_ctl_pager_handler, _LIBAROMA_CTL_PAGERP, NULL
  );
  LIBAROMA_CANVASP c=NULL;
  libaroma_mutex_lock(me->mutex);
  if (!me->on_direct_canvas){
    if (win->dc==NULL){
      libaroma_mutex_unlock(me->mutex);
      return NULL;
    }
    c = libaroma_canvas_area(
      win->dc,
      cctl->x, cctl->y, cctl->w, cctl->h
    );
  }
  else{
    int xt = me->scroll_x;
    int x = cctl->x - xt;
    int y = cctl->y;
    int w = cctl->w;
    int h = cctl->h;
    LIBAROMA_CANVASP ccv = libaroma_control_draw_begin(ctl);
    if (ccv){
      if ((ccv->w>x)&&(ccv->h>y)){
        c = libaroma_canvas_area(
          ccv,x,y,w,h
        );
      }
      libaroma_canvas_free(ccv);
    }
    else{
      libaroma_mutex_unlock(me->mutex);
      return NULL;
    }
  }
  libaroma_mutex_unlock(me->mutex);
  return c;
} /* End of _libaroma_ctl_pager_window_control_draw_begin */
예제 #10
0
byte _libaroma_ctl_image_thread(LIBAROMA_CONTROLP ctl) {
  _LIBAROMA_CTL_CHECK(
	  _libaroma_ctl_image_handler, _LIBAROMA_CTL_IMAGEP, 0
	);
  if (me->update){
    libaroma_mutex_lock(me->mutex);
  	me->update=0;
  	libaroma_mutex_unlock(me->mutex);
    return 1;
  }
  return 0;
}
예제 #11
0
/*
 * Function    : _libaroma_ctl_fragment_window_updatebg
 * Return Value: byte
 * Descriptions: window update background
 */
byte _libaroma_ctl_fragment_window_updatebg(LIBAROMA_WINDOWP win){
  _VALIDATE_FRAGMENT(0);
  libaroma_mutex_lock(me->dmutex);
  int w = win->w;
  int h = win->h;
  if (win->bg!=NULL){
    if ((win->bg->w==w)&&(win->bg->h==h)){
      libaroma_mutex_unlock(me->dmutex);
      return 1;
    }
    libaroma_canvas_free(win->bg);
  }
  win->bg = libaroma_canvas(w,h);
  libaroma_canvas_setcolor(
    win->bg,
    libaroma_colorget(ctl,NULL)->window_bg,
    0xff
  );
  libaroma_mutex_unlock(me->dmutex);
  return 1;
} /* End of _libaroma_ctl_fragment_window_sync */
예제 #12
0
/*
 * Function    : libaroma_ctl_list_get_item_internal
 * Return Value: LIBAROMA_CTL_LIST_ITEMP
 * Descriptions: get item at index or id
 */
LIBAROMA_CTL_LIST_ITEMP libaroma_ctl_list_get_item_internal(
  LIBAROMA_CONTROLP ctl, int index, byte find_id
){
  LIBAROMA_CTL_SCROLL_CLIENTP client = libaroma_ctl_scroll_get_client(ctl);
  if (!client){
    return NULL;
  }
  if (client->handler!=&_libaroma_ctl_list_handler){
    return NULL;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  if (!find_id){
    if (index==-1){
      return mi->last;
    }
    else if (index==0){
      return mi->first;
    }
  }
  int curr_index = 0;
  libaroma_mutex_lock(mi->imutex);
  LIBAROMA_CTL_LIST_ITEMP f = mi->first;
  if (f){
    while(f){
      if (((!find_id)&&(curr_index==index))||((find_id)&&(f->id==index))) {
        libaroma_mutex_unlock(mi->imutex);
        return f;
      }
      f = f->next;
      curr_index++;
    }
  }
  libaroma_mutex_unlock(mi->imutex);
  /* not found */
  return NULL;
} /* End of libaroma_ctl_list_get_item_internal */
예제 #13
0
/*
 * Function    : _libaroma_ctl_list_scroll_message
 * Return Value: dword
 * Descriptions: handle scroll message
 */
dword _libaroma_ctl_list_scroll_message(
    LIBAROMA_CONTROLP ctl,
    LIBAROMA_CTL_SCROLL_CLIENTP client,
    LIBAROMA_CTL_SCROLLP mi,
    int msg,
    int param,
    int x,
    int y){
  switch(msg){
    case LIBAROMA_CTL_SCROLL_MSG_ISNEED_TOUCH:{
        if ((y<mi->vpad)||(y>mi->h-mi->vpad)){
          ALOGT("list_scroll_message ISNEED(%i,%i) not needed",x,y);
          /* no need touch handle */
          return 0;
        }
        LIBAROMA_CTL_LIST_ITEMP item=
            _libaroma_ctl_list_item_by_y(ctl, client, y);
        if (item){
          if (item->flags&LIBAROMA_CTL_LIST_ITEM_RECEIVE_TOUCH){
            mi->touched = item;
            ALOGT("list_scroll_message ISNEED(%i,%i) needed",x,y);
            return LIBAROMA_CTL_SCROLL_MSG_HANDLED;
          }
        }
        ALOGT("list_scroll_message ISNEED(%i,%i) item don't use touch",x,y);
        return 0;
      }
      break;
    case LIBAROMA_CTL_SCROLL_MSG_TOUCH_DOWN:{
        ALOGT("list_scroll_message TOUCH_DOWN(%i,%i)",x,y);
        mi->pos.start_x=x;
        mi->pos.start_y=y;
        mi->pos.last_x=x;
        mi->pos.last_y=y;
        
        byte retval = 0;
        if (mi->touched!=NULL){
          byte mres = 0;
          if (mi->touched->handler->message){
            int cy = y - mi->touched->y;
            mres=mi->touched->handler->message(
              ctl,
              mi->touched,
              LIBAROMA_CTL_LIST_ITEM_MSG_TOUCH_DOWN,
              0,
              x, cy
            );
          }
          if (!(mres&LIBAROMA_CTL_LIST_ITEM_MSGRET_HANDLED)){
            /* init state item */
            if (_libaroma_ctl_list_init_state(mi->touched)){
              _libaroma_ctl_list_init_state_cache(ctl,mi->touched);
              if (mres&LIBAROMA_CTL_LIST_ITEM_MSGRET_HAVE_ADDONS_DRAW){
                mi->touched->state->normal_handler = 2;
              }
              else{
                mi->touched->state->normal_handler = 1;
              }
              libaroma_mutex_lock(mi->mutex);
              libaroma_ripple_down(&mi->touched->state->ripple, x, y);
              /*
              mi->touched->state->touch_start=libaroma_tick();
              mi->touched->state->touch_state=0;
              mi->touched->state->release_state=0.0;
              mi->touched->state->release_start=0;
              mi->touched->state->holded=0;
              mi->touched->state->touched=1;
              */
              
              __libaroma_ctl_list_item_reg_thread(ctl, mi->touched);
              libaroma_mutex_unlock(mi->mutex);
            }
          }
          else if(mi->touched->state){
            mi->touched->state->normal_handler = 0;
          }
          
          if (mres&LIBAROMA_CTL_LIST_ITEM_MSGRET_NEED_DRAW){
            if (_libaroma_ctl_list_dodraw_item(ctl,mi->touched)){
              retval=LIBAROMA_CTL_SCROLL_MSG_NEED_DRAW;
            }
          }
        }
        return retval;
      }
      break;
    case LIBAROMA_CTL_SCROLL_MSG_TOUCH_MOVE:{
        ALOGT("list_scroll_message TOUCH_MOVE(%i,%i)",x,y);
        mi->pos.last_x=x;
        mi->pos.last_y=y;
        byte retval = 0;
        if (mi->touched!=NULL){
          byte mres = 0;
          if (mi->touched->handler->message){
            int cy = y - mi->touched->y;
            mres=mi->touched->handler->message(
              ctl,
              mi->touched,
              LIBAROMA_CTL_LIST_ITEM_MSG_TOUCH_MOVE,
              0,
              x, cy
            );
          }
          if (mi->touched->state){
            libaroma_ripple_move(&mi->touched->state->ripple,x,y);
          }
          if (mres&LIBAROMA_CTL_LIST_ITEM_MSGRET_NEED_DRAW){
            if (_libaroma_ctl_list_dodraw_item(ctl,mi->touched)){
              retval=LIBAROMA_CTL_SCROLL_MSG_NEED_DRAW;
            }
          }
        }
        return retval;
      }
      break;
    case LIBAROMA_CTL_SCROLL_MSG_TOUCH_UP:
    case LIBAROMA_CTL_SCROLL_MSG_TOUCH_CANCEL:{
        ALOGT_IF(msg==LIBAROMA_CTL_SCROLL_MSG_TOUCH_UP,
          "list_scroll_message TOUCH_UP(%i,%i)",x,y);
        ALOGT_IF(msg==LIBAROMA_CTL_SCROLL_MSG_TOUCH_CANCEL,
          "list_scroll_message TOUCH_CANCEL(%i,%i)",x,y);
        mi->pos.last_x=x;
        mi->pos.last_y=y;
        byte retval = 0;
        if (mi->touched!=NULL){
          dword param_msg = 0;
          if (mi->touched->state){
            if (msg==LIBAROMA_CTL_SCROLL_MSG_TOUCH_CANCEL){
              libaroma_ripple_cancel(&mi->touched->state->ripple);
            }
            else{
              byte res = libaroma_ripple_up(&mi->touched->state->ripple,0);
              if (res&LIBAROMA_RIPPLE_HOLDED){
                param_msg = LIBAROMA_CTL_LIST_ITEM_MSGPARAM_HOLDED;
              }
            }
          }
          byte mres = 0;
          if (mi->touched->handler->message){
            int cy = y - mi->touched->y;
            mres=mi->touched->handler->message(
              ctl,
              mi->touched,
              (msg==LIBAROMA_CTL_SCROLL_MSG_TOUCH_UP)?
                LIBAROMA_CTL_LIST_ITEM_MSG_TOUCH_UP:
                LIBAROMA_CTL_LIST_ITEM_MSG_TOUCH_CANCEL,
              param_msg,
              x, cy
            );
          }
          if (mres&LIBAROMA_CTL_LIST_ITEM_MSGRET_NEED_DRAW){
            if (_libaroma_ctl_list_dodraw_item(ctl,mi->touched)){
              retval=LIBAROMA_CTL_SCROLL_MSG_NEED_DRAW;
            }
          }
        }
        return retval;
      }
      break;
  }
  return 0;
} /* End of _libaroma_ctl_list_scroll_message */
예제 #14
0
/*
 * Function    : _libaroma_ctl_list_draw
 * Return Value: void
 * Descriptions: draw routine
 */
void _libaroma_ctl_list_draw(
    LIBAROMA_CONTROLP ctl,
    LIBAROMA_CTL_SCROLL_CLIENTP client,
    LIBAROMA_CANVASP cv,
    int x, int y, int w, int h){
  if (client->handler!=&_libaroma_ctl_list_handler){
    return;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  if (y<mi->vpad){
    libaroma_draw_rect(
      cv, 0, 0, w, mi->vpad-y,
      libaroma_ctl_scroll_get_bg_color(ctl),
      0xff
    );
  }
  if (y+h>mi->h-mi->vpad){
    int dh=(y+h)-(mi->h-mi->vpad);
    libaroma_draw_rect(
      cv, 0, h-dh, w, dh,
      libaroma_ctl_scroll_get_bg_color(ctl),
      0xff
    );
  }
  
  libaroma_mutex_lock(mi->imutex);
  /* find first item */
  int current_index = 0;
  LIBAROMA_CTL_LIST_ITEMP f = mi->first;
  while(f){
    if (f->y+f->h>y){
      break;
    }
    f = f->next;
    current_index++;
  }
  
  word bgcolor = libaroma_ctl_scroll_get_bg_color(ctl);
  
  /* draw routine */
  LIBAROMA_CTL_LIST_ITEMP item = f;
  while(item){
    if (item->y>=y+h){
      break;
    }
    LIBAROMA_CANVASP canvas=NULL;
    byte is_area=0;
    if ((item->y>=y)&&(item->y+item->h<y+cv->h)){
      canvas = libaroma_canvas_area(cv,0,item->y-y,w,item->h);
      is_area=1;
    }
    else{
      canvas = libaroma_canvas(w,item->h);
    }
    if (canvas!=NULL){
      _libaroma_ctl_list_draw_item(
        ctl, item, canvas, bgcolor
      );
      
      /* blit into working canvas */
      if (!is_area){
        libaroma_draw(cv,canvas,0,item->y-y,0);
      }
      libaroma_canvas_free(canvas);
    }
    item=item->next;
    current_index++;
  }
  libaroma_mutex_unlock(mi->imutex);
} /* End of _libaroma_ctl_list_draw */
예제 #15
0
/*
 * Function    : _libaroma_ctl_list_thread
 * Return Value: byte
 * Descriptions: scroll list thread
 */
byte _libaroma_ctl_list_thread(
    LIBAROMA_CONTROLP ctl, LIBAROMA_CTL_SCROLL_CLIENTP client){
  if (client->handler!=&_libaroma_ctl_list_handler){
    return 0;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  
  byte need_redraw=0;
  int i;
  libaroma_mutex_lock(mi->imutex);
  libaroma_mutex_lock(mi->mutex);
  int num_thread = mi->threadn;
  if (num_thread>0){
    LIBAROMA_CTL_LIST_ITEMP * threads = (LIBAROMA_CTL_LIST_ITEMP *) malloc(
      sizeof(LIBAROMA_CTL_LIST_ITEM)*num_thread);
    for (i=0;i<num_thread;i++){
      threads[i]=mi->threads[i];
    }
#ifdef LIBAROMA_CONFIG_OPENMP
  #pragma omp parallel for
#endif
    for (i=0;i<num_thread;i++){
      LIBAROMA_CTL_LIST_ITEMP item = threads[i];
      if (item){
        byte unreg_me=0;
        byte is_draw=0;
        if (item->state){
          /* normal behaviour */
          if (item->state->normal_handler){
            byte res = libaroma_ripple_thread(&item->state->ripple, 0);
            if (res&LIBAROMA_RIPPLE_REDRAW){
              is_draw = 1;
            }
            if (res&LIBAROMA_RIPPLE_HOLDED){
              if (item->handler->message){
                int cx = 0; int cy=0;
                LIBAROMA_CTL_LIST_TOUCHPOSP pos = libaroma_ctl_list_getpos(ctl);
                if (pos){
                  cy = pos->last_y - item->y;
                  cx = pos->last_x;
                }
                byte msgret=item->handler->message(
                  ctl,
                  item,
                  LIBAROMA_CTL_LIST_ITEM_MSG_TOUCH_HOLDED,
                  LIBAROMA_CTL_LIST_ITEM_MSGPARAM_HOLDED,
                  cx, cy
                );
                if (msgret&LIBAROMA_CTL_LIST_ITEM_MSGRET_NEED_DRAW){
                  is_draw=1;
                }
                if (msgret&LIBAROMA_CTL_LIST_ITEM_MSGRET_UNREG_THREAD){
                  unreg_me=1;
                }
              }
            }
            if (res&LIBAROMA_RIPPLE_RELEASED){
              _libaroma_ctl_list_free_state(item);
              unreg_me=1;
            }
          }
        }
        if (item->handler->message){
          byte msgret=item->handler->message(
            ctl,
            item,
            LIBAROMA_CTL_LIST_ITEM_MSG_THREAD,
            libaroma_ctl_scroll_is_visible(ctl,item->y,item->h),
            0,
            0
          );
          if (msgret&LIBAROMA_CTL_LIST_ITEM_MSGRET_NEED_DRAW){
            is_draw=1;
          }
          if (msgret&LIBAROMA_CTL_LIST_ITEM_MSGRET_UNREG_THREAD){
            unreg_me=1;
          }
        }
        if (is_draw){
          if (_libaroma_ctl_list_dodraw_item(ctl,item)){
            need_redraw=1;
          }
        }
        
        /* unreg thread */
        if (!unreg_me){
          threads[i] = NULL;
        }
      }
    }
    
    /* unreg threads */
    for (i=0;i<num_thread;i++){
      LIBAROMA_CTL_LIST_ITEMP item = threads[i];
      if (item!=NULL){
        if (!(item->flags&LIBAROMA_CTL_LIST_ITEM_REGISTER_THREAD)){
          __libaroma_ctl_list_item_unreg_thread(ctl, item);
        }
      }
    }
    free(threads);
  }
  libaroma_mutex_unlock(mi->mutex);
  libaroma_mutex_unlock(mi->imutex);
  return need_redraw;
} /* End of _libaroma_ctl_list_thread */
예제 #16
0
/*
 * Function    : libaroma_ctl_list_add_item_internal
 * Return Value: LIBAROMA_CTL_LIST_ITEMP
 * Descriptions: add item internally
 */
LIBAROMA_CTL_LIST_ITEMP libaroma_ctl_list_add_item_internal(
    LIBAROMA_CONTROLP ctl,
    int id,
    int height,
    byte flags,
    voidp internal,
    LIBAROMA_CTL_LIST_ITEM_HANDLERP handler,
    int at_index){
  if (!handler){
    return NULL;
  }
  LIBAROMA_CTL_SCROLL_CLIENTP client = libaroma_ctl_scroll_get_client(ctl);
  if (!client){
    return NULL;
  }
  if (client->handler!=&_libaroma_ctl_list_handler){
    return NULL;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  
  LIBAROMA_CTL_LIST_ITEMP item = (LIBAROMA_CTL_LIST_ITEMP)
      calloc(sizeof(LIBAROMA_CTL_LIST_ITEM),1);
  if (item==NULL){
    ALOGW("list_add_item_internal cannot allocating memory for item");
    return NULL;
  }
  
  libaroma_mutex_lock(mi->imutex);
  libaroma_mutex_lock(mi->mutex);
  item->y=0;
  item->h=height;
  item->id=id;
  item->flags=flags;
  item->handler=handler;
  item->internal=internal;
  
  if (mi->last==NULL){
    mi->first=mi->last=item;
    item->y=mi->vpad;
    mi->h+=item->h;
  }
  else if (at_index<0){
    /* at last */
    item->prev=mi->last;
    mi->last->next = item;
    item->y = mi->last->y + mi->last->h;
    mi->last = item;
    mi->h+=item->h;
  }
  else if (at_index==0){
    /* at first */
    item->next = mi->first;
    item->y=mi->vpad;
    mi->first = item;
    mi->h+=item->h;
    __libaroma_ctl_list_repos_next_items(item,mi->vpad);
  }
  else{
    int curr_index = 0;
    LIBAROMA_CTL_LIST_ITEMP f = mi->first;
    if (f){
      while(f){
        if (curr_index==at_index){
          item->prev = f;
          item->next = f->next;
          __libaroma_ctl_list_repos_next_items(item,f->y+f->h);
          f->next = item;
          if (item->next==NULL){
            mi->last = item;
          }
          mi->h+=item->h;
          break;
        }
        f = f->next;
        if (!f){
          curr_index=-1;
          break;
        }
        curr_index++;
      }
    }
    else{
      curr_index=-1;
    }
    if (curr_index<0){
      /* add in last */
      item->prev=mi->last;
      mi->last->next = item;
      item->y = mi->last->y + mi->last->h;
      mi->last = item;
      mi->h+=item->h;
    }
  }
  mi->itemn++;
  
  if (flags&LIBAROMA_CTL_LIST_ITEM_REGISTER_THREAD){
    __libaroma_ctl_list_item_reg_thread(ctl,item);
  }
  
  libaroma_mutex_unlock(mi->mutex);
  libaroma_mutex_unlock(mi->imutex);
  
  /* set current height */
  libaroma_ctl_scroll_request_height(ctl, mi->h);
  return item;
} /* End of libaroma_ctl_list_add_item_internal */