/*
 * 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 */
Esempio n. 2
0
/*
 * Function    : _libaroma_ctl_pager_window_invalidate
 * Return Value: byte
 * Descriptions: window invalidate
 */
byte _libaroma_ctl_pager_window_invalidate(LIBAROMA_WINDOWP win, byte sync){
  LIBAROMA_CONTROLP ctl=(LIBAROMA_CONTROLP) win->client_data;
  _LIBAROMA_CTL_CHECK(
    _libaroma_ctl_pager_handler, _LIBAROMA_CTL_PAGERP, 0
  );
  if (me->win!=win){
    return 0;
  }
  if ((me->win->dc)&&(me->win->bg)){
    libaroma_draw(me->win->dc,me->win->bg,0,0,0);
    /* draw childs */
    int i;
#ifdef LIBAROMA_CONFIG_OPENMP
  #pragma omp parallel for
#endif
    for (i=0;i<win->childn;i++){
      /* draw no sync */
      libaroma_control_draw(win->childs[i], 0);
    }
  }
  if (sync){
    return _libaroma_ctl_pager_window_sync(win,0,0,win->w,win->h);
  }
  return 1;
} /* End of _libaroma_ctl_pager_window_invalidate */
Esempio n. 3
0
/*
 * Function    : libaroma_window_invalidate
 * Return Value: byte
 * Descriptions: invalidate window drawing
 */
byte libaroma_window_invalidate(LIBAROMA_WINDOWP win, byte sync){
  __CHECK_WM(0);
  if (win==NULL){
    ALOGW("window_invalidate win is null");
    return 0;
  }
  if (win->handler!=NULL){
    if (win->handler->invalidate!=NULL){
      return win->handler->invalidate(win,sync);
    }
  }
  if (win->parent!=NULL){
    return 0;
  }
  
  if (!libaroma_window_isactive(win)){
    ALOGW("window_invalidate win is not active window");
    return 0;
  }
  if (win->dc==NULL){
    ALOGW("window_invalidate dc is null");
    return 0;
  }
  
  if ((!win->lock_sync)||(sync==10)){
    /* draw bg */
    libaroma_draw(
      win->dc,
      win->bg,
      0, 0, 1);
    
    /* draw childs */
    int i;
#ifdef LIBAROMA_CONFIG_OPENMP
  #pragma omp parallel for
#endif
    for (i=0;i<win->childn;i++){
      /* draw no sync */
      libaroma_control_draw(win->childs[i], 0);
    }
  
    /* sync */
    if (sync){
      libaroma_window_sync(win, 0, 0, win->w, win->h);
    }
  }
  return 1;
} /* End of libaroma_window_invalidate */
/*
 * Function    : _libaroma_ctl_fragment_window_invalidate
 * Return Value: byte
 * Descriptions: window invalidate
 */
byte _libaroma_ctl_fragment_window_invalidate(LIBAROMA_WINDOWP win, byte sync){
  _VALIDATE_FRAGMENT(0);
  if ((win->dc)&&(win->bg)){
    libaroma_draw(win->dc,win->bg,0,0,0);
    int i;
#ifdef LIBAROMA_CONFIG_OPENMP
  #pragma omp parallel for
#endif
    for (i=0;i<win->childn;i++){
      /* draw no sync */
      libaroma_control_draw(win->childs[i], 0);
    }
  }
  if (sync){
    return _libaroma_ctl_fragment_window_sync(win,0,0,win->w,win->h);
  }
  return 1;
} /* End of _libaroma_ctl_fragment_window_invalidate */
Esempio n. 5
0
void recovery_statusbar_sidebar_list_cb(
  LIBAROMA_CONTROLP ctl,LIBAROMA_CANVASP cv,int sy){
  if (recovery_statusbar_overlay_canvas){
    if ((recovery_statusbar_overlay_canvas->w!=cv->w)||
       (recovery_statusbar_overlay_canvas->h!=cv->h)){
      libaroma_canvas_free(recovery_statusbar_overlay_canvas);
    }
  }
  if (recovery_statusbar_overlay_canvas==NULL){
    recovery_statusbar_overlay_canvas=libaroma_canvas(
      cv->w, cv->h
    );
  }
  libaroma_draw(
    recovery_statusbar_overlay_canvas, cv, 0, 0, 0
  );
  if (recovery_statusbar_side_w){
    recovery_statusbar_force_update=1;
  }
}
Esempio n. 6
0
/*
 * Function    : libaroma_window_anishow
 * Return Value: byte
 * Descriptions: show window - animated
 */
byte libaroma_window_anishow(
    LIBAROMA_WINDOWP win,
    byte animation,
    int duration){
  __CHECK_WM(0);
  if (!win){
    return 0;
  }
  if (win->parent!=NULL){
    ALOGW("Child window cannot shown directly...");
    return 0;
  }
  
  /* set initial focus
    libaroma_window_setfocus(win, NULL);
  */
  
  if ((!animation)||(duration<50)){
    return libaroma_wm_set_active_window(win);
  }
  
  /* lock and retval */
  byte retval = 0;
  win->lock_sync = 1;
  
  if (libaroma_wm_set_active_window(win)){
    win->active=2;
    
    /* draw window into temp canvas */
    LIBAROMA_CANVASP wmc = win->dc;
    LIBAROMA_CANVASP tdc = libaroma_canvas(wmc->w,wmc->h);
    libaroma_draw(tdc,wmc,0,0,0);
    win->dc=tdc; /* switch dc */
    
    LIBAROMA_CANVASP back = libaroma_canvas(wmc->w, wmc->h);
    libaroma_draw(back,wmc,0,0,0);
    
    /* invalidate now */
    libaroma_window_invalidate(win, 10);
    
    long start = libaroma_tick();
    int delta = 0;
    while ((delta=libaroma_tick()-start)<duration){
      float state = ((float) delta)/((float) duration);
      if (state>=1.0){
        break;
      }
      switch (animation){
        case LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_LEFT:
        case LIBAROMA_WINDOW_SHOW_ANIMATION_PAGE_LEFT:
          {
            float swift_out_state = libaroma_cubic_bezier_swiftout(state);
            int x = win->w - (swift_out_state * win->w);
            int w = win->w - x;
            if (w>0){
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_LEFT){
                if (w<win->w){
                  libaroma_draw_ex(
                    wmc,
                    back,
                    0, 0, win->w - (win->w - w), 0, win->w - w, win->h,
                    0, 0xff
                  );
                }
              }
              libaroma_draw_ex(
                wmc,
                win->dc,
                x, 0, 0, 0, w, win->h,
                0, 0xff
              );
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_LEFT){
                libaroma_wm_sync(win->x,win->y,win->w,win->h);
              }
              else{
                libaroma_wm_sync(win->x+x,win->y,w, win->h);
              }
            }
          }
          break;
        case LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_RIGHT:
        case LIBAROMA_WINDOW_SHOW_ANIMATION_PAGE_RIGHT:
          {
            float swift_out_state = libaroma_cubic_bezier_swiftout(state);
            int x = 0 - (win->w - (swift_out_state * win->w));
            int w = win->w + x;
            if (w>0){
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_RIGHT){
                if (w<win->w){
                  libaroma_draw_ex(
                    wmc,
                    back,
                    w, 0, 0, 0, win->w - w, win->h,
                    0, 0xff
                  );
                }
              }
              libaroma_draw_ex(
                wmc,
                win->dc,
                0, 0, win->w-w, 0, w, win->h,
                0, 0xff
              );
              if (animation==LIBAROMA_WINDOW_SHOW_ANIMATION_SLIDE_RIGHT){
                libaroma_wm_sync(win->x,win->y,win->w,win->h);
              }
              else{
                libaroma_wm_sync(win->x,win->y,w, win->h);
              }
            }
          }
          break;
        default:
          /* invalid animation */
          start=0;
          break;
      }
    }
    
    retval = 1;
    libaroma_draw(wmc,win->dc,0,0,0);
              
    win->dc=wmc; /* switch dc back */
  
    /* cleanup */
    libaroma_canvas_free(back);
    libaroma_canvas_free(tdc);
  }
  
  win->lock_sync = 0;
  
  /* sync view now */
  if (retval){
    win->active=1;
    libaroma_window_sync(win, 0, 0, win->w, win->h);
  }
  
  /* send activate */
  LIBAROMA_MSG _msg;
  libaroma_window_process_event(win,libaroma_wm_compose(
    &_msg, LIBAROMA_MSG_WIN_ACTIVE, NULL, 10, 0)
  );
  
  return retval;
} /* End of libaroma_window_show */
Esempio n. 7
0
/*
 * Function    : libaroma_text_draw_line_ex
 * Return Value: int
 * Descriptions: draw text line
 */
int libaroma_text_draw_line_ex(
  LIBAROMA_CANVASP dest,
  LIBAROMA_TEXT text,
  int dx,
  int dy,
  int line,
  byte isshadow,
  int radius,
  word shadow_color,
  byte shadow_opacity
) {
  if (!dest) {
    dest = libaroma_fb()->canvas;
  }
  if ((dy > dest->h) || (dx > dest->w)) {
    return 0;
  }
  if (text) {
    _LIBAROMA_TEXTP txt = (_LIBAROMA_TEXTP) text;
    if (line > txt->n - 1) {
      return 0;
    }
    else if (line < 0) {
      return 0;
    }
    _LIBAROMA_TEXTLINEP line_txt = txt->lines[line];
    _libaroma_pubtext_lock(1);
    if (line_txt->span) {
      if (!isshadow) {
        libaroma_textline_draw(
          dest,
          line_txt,
          dx,
          dy - line_txt->y, 0, 0);
      }
      else if (isshadow>=10) {
        libaroma_textline_draw(
          dest,
          line_txt,
          dx,
          dy - line_txt->y, 1, shadow_color);
      }
      else if (radius > 0) {
        byte light = (isshadow == 2) ? 1 : 0;
        int w = line_txt->maxx - line_txt->minx;
        int h = line_txt->lineheight * 1.5;
        int xx, yy;
        LIBAROMA_CANVASP cv = libaroma_canvas_ex(w, h, 0);
        word trans_color = (light) ? 0xffff : 0x0000;
        word fore_color = (light) ? 0x0000 : 0xffff;
        libaroma_canvas_setcolor(cv, trans_color, 0);
        libaroma_textline_draw(
          cv,
          line_txt,
          0 - line_txt->minx,
          0 - line_txt->y, 1, fore_color);
        cv->alpha = (bytep) calloc(cv->s,1);
        for (yy = 0; yy < cv->h; yy++) {
          int row = cv->l * yy;
          for (xx = 0; xx < cv->w; xx++) {
            int pos = row + xx;
            word c = cv->data[pos];
            if (trans_color == c) {
              cv->alpha[pos] = 0;
            }
            else {
              cv->alpha[pos] = shadow_opacity;
            }
          }
        }
        LIBAROMA_CANVASP gb = libaroma_blur_ex(cv, radius, 1, shadow_color);
        if (gb) {
          libaroma_draw(
            dest,
            gb,
            (dx - radius) + line_txt->minx,
            (dy) - radius,
            1);
          libaroma_canvas_free(gb);
        }
        libaroma_canvas_free(cv);
      }
    }
    _libaroma_pubtext_lock(0);
    return line_txt->lineheight;
  }
  return 0;
} /* End of libaroma_text_draw_line_ex */
Esempio n. 8
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 */
Esempio n. 9
0
/*
 * Function    : _libaroma_ctl_list_draw_item
 * Return Value: void
 * Descriptions: draw item
 */
void _libaroma_ctl_list_draw_item(
    LIBAROMA_CONTROLP ctl,
    LIBAROMA_CTL_LIST_ITEMP item,
    LIBAROMA_CANVASP canvas,
    word bgcolor
){
  if ((!item)||(!canvas)){
    return;
  }
  LIBAROMA_CTL_SCROLL_CLIENTP client = libaroma_ctl_scroll_get_client(ctl);
  if (!client){
    return;
  }
  if (client->handler!=&_libaroma_ctl_list_handler){
    return;
  }
  LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) client->internal;
  
  /* normal animation handler */
  if (item->state){
    if (item->state->normal_handler){
      libaroma_draw(canvas, item->state->cache_rest, 0, 0, 0);
      int ripple_i = 0;
      int ripple_p = 0;
      while(libaroma_ripple_loop(&item->state->ripple,&ripple_i,&ripple_p)){
        int x=0;
        int y=(item->y+libaroma_dp(1));
        int size=0;
        byte push_opacity=0;
        byte ripple_opacity=0;
        if (libaroma_ripple_calculation(
          &item->state->ripple, canvas->w, canvas->h,
          &push_opacity, &ripple_opacity,
          &x, &y, &size, ripple_p
        )){
          libaroma_draw_opacity(canvas, 
            item->state->cache_push, 0, 0, 2, 
            (byte) push_opacity
          );
          libaroma_draw_mask_circle(
              canvas, 
              item->state->cache_push, 
              x, y,
              x, y,
              size,
              ripple_opacity
            );
        }
      }
      if (item->state->normal_handler==2){
        _libaroma_ctl_list_draw_item_fresh(
          ctl, item,canvas,bgcolor,mi->hpad,
          LIBAROMA_CTL_LIST_ITEM_DRAW_ADDONS
        );
      }
      return;
    }
  }
  
  /* draw fresh */
  _libaroma_ctl_list_draw_item_fresh(
    ctl, item,canvas,bgcolor,mi->hpad, LIBAROMA_CTL_LIST_ITEM_DRAW_NORMAL
  );
} /* End of _libaroma_ctl_list_draw_item */