Esempio n. 1
0
/*
 * Function    : libaroma_window_free
 * Return Value: byte
 * Descriptions: free window
 */
byte libaroma_window_free(
  LIBAROMA_WINDOWP win
){
  __CHECK_WM(0);
  if (win==NULL){
    return 0;
  }
  
  /* inactivate it */
  if (win->parent==NULL){
    if (libaroma_wm_get_active_window()==win){
      /* detach active window from window manager */
      libaroma_wm_set_active_window(NULL);
    }
    
    LIBAROMA_MSG _msg;
    libaroma_window_process_event(win,
      libaroma_wm_compose(&_msg, LIBAROMA_MSG_WIN_INACTIVE, NULL, 0, 0));
  }
  
  if (win->handler!=NULL){
    if (win->handler->prefree!=NULL){
      win->handler->prefree(win);
    }
  }
  
  /* delete childs */
  int i;
  if (win->childn>0){
#ifdef LIBAROMA_CONFIG_OPENMP
  #pragma omp parallel for
#endif
    for (i=0;i<win->childn;i++){
      libaroma_control_free(win->childs[i]);
    }
    free(win->childs);
  }
  if (win->bg){
    libaroma_canvas_free(win->bg);
    win->bg=NULL;
  }
  if (win->dc){
    libaroma_canvas_free(win->dc);
    win->dc=NULL;
  }
  

  if (win->handler!=NULL){
    if (win->handler->postfree!=NULL){
      win->handler->postfree(win);
    }
  }
  free(win);
  return 1;
} /* End of libaroma_window_free */
Esempio n. 2
0
/*
 * Function    : _libaroma_ctl_pager_direct_canvas
 * Return Value: byte
 * Descriptions: set as direct canvas
 */
byte _libaroma_ctl_pager_direct_canvas(LIBAROMA_CONTROLP ctl, byte state){
  _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;
  if (state){
    if (!me->on_direct_canvas){
      me->on_direct_canvas=1;
    }
  }
  else{
    if (me->on_direct_canvas){
      LIBAROMA_CANVASP ccv = libaroma_control_draw_begin(ctl);
      if (ccv) {
        // libaroma_draw_ex(me->win->dc,ccv,0,0,xt,0,ccv->w,ccv->h,0,0xff);
        libaroma_draw_ex(me->win->dc,ccv,xt,0,0,0,ccv->w,ccv->h,0,0xff);
        libaroma_canvas_free(ccv);
      }
      me->on_direct_canvas=0;
    }
  }
  //libaroma_mutex_unlock(me->mutex);
  return 1;
} /* End of _libaroma_ctl_pager_direct_canvas */
Esempio n. 3
0
/*
 * Function    : _libaroma_window_updatebg
 * Return Value: byte
 * Descriptions: update window background
 */
byte _libaroma_window_updatebg(LIBAROMA_WINDOWP win){
  if (win==NULL){
    ALOGW("window_recalculate win is NULL");
    return 0;
  }
  if (win->handler!=NULL){
    if (win->handler->updatebg!=NULL){
      return win->handler->updatebg(win);
    }
  }
  if (win->parent!=NULL){
    return 0;
  }
  int w = win->w;
  int h = win->h;
  
  /* draw background */
  if (win->bg!=NULL){
    if ((win->bg->w==w)&&(win->bg->h==h)){
      /* not need recreate background */
      return 1;
    }
    libaroma_canvas_free(win->bg);
  }
  win->bg = libaroma_canvas(w,h);
  libaroma_canvas_setcolor(
    win->bg,
    libaroma_colorget(NULL,win)->window_bg,
    0xff
  );
  return 1;
} /* End of _libaroma_window_updatebg */
/*
 * 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 */
/*
 * 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 */
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);
}
Esempio n. 7
0
/*
 * Function    : _libaroma_ctl_pager_window_updatebg
 * Return Value: byte
 * Descriptions: window update background
 */
byte _libaroma_ctl_pager_window_updatebg(LIBAROMA_WINDOWP win){
  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;
  }
  int w = win->w;
  int h = win->h;
  /* draw background */
  if (win->bg!=NULL){
    if ((win->bg->w==w)&&(win->bg->h==h)){
      /* not need recreate background */
      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
  );
  
  return 1;
} /* End of _libaroma_ctl_pager_window_sync */
Esempio n. 8
0
/*
 * Function    : _libaroma_ctl_list_dodraw_item
 * Return Value: byte
 * Descriptions: do draw item directly
 */
byte _libaroma_ctl_list_dodraw_item(
    LIBAROMA_CONTROLP ctl,
    LIBAROMA_CTL_LIST_ITEMP item
){
  if (!item){
    return 0;
  }
  byte res=0;
  if (libaroma_ctl_scroll_is_visible(ctl,item->y,item->h)){
    word bgcolor = libaroma_ctl_scroll_get_bg_color(ctl);
    LIBAROMA_CANVASP canvas=libaroma_canvas(ctl->w,item->h);
    if (canvas!=NULL){
      _libaroma_ctl_list_draw_item(
        ctl,item,canvas,bgcolor
      );
      res=libaroma_ctl_scroll_blit(
         ctl, 
         canvas,
         0, item->y, canvas->w, canvas->h,
         0
      );
      libaroma_canvas_free(canvas);
    }
  }
  return res;
} /* End of _libaroma_ctl_list_dodraw_item */
Esempio n. 9
0
/*
 * Function    : _libaroma_ctl_list_free_state
 * Return Value: void
 * Descriptions: free state
 */
void _libaroma_ctl_list_free_state(LIBAROMA_CTL_LIST_ITEMP item){
  if (item->state!=NULL){
    if (item->state->cache_rest){
      libaroma_canvas_free(item->state->cache_rest);
    }
    if (item->state->cache_push){
      libaroma_canvas_free(item->state->cache_push);
    }
    if (item->state->cache_client){
      libaroma_canvas_free(item->state->cache_client);
    }
    free(item->state);
    ALOGT("[X] State Freed %x",item->id);
  }
  item->state=NULL;
} /* End of _libaroma_ctl_list_free_state */
Esempio n. 10
0
/*
 * Function    : libaroma_control_draw_end
 * Return Value: void
 * Descriptions: end control ondraw
 */
void libaroma_control_draw_end(
  LIBAROMA_CONTROLP ctl, LIBAROMA_CANVASP c, byte sync
){
  if (sync){
    libaroma_control_draw_flush(ctl, c, sync);
  }
  libaroma_canvas_free(c);
} /* End of libaroma_control_draw_end */
Esempio n. 11
0
/* Release UI */
byte recovery_release_ui(){
  if (_recovery.win){
    libaroma_window_free(_recovery.win);
    _recovery.win=NULL;
    _recovery.sidebar=NULL;
    _recovery.appbar=NULL;
    _recovery.fragment=NULL;
    _recovery.sidemenu=NULL;
    return 1;
  }
  if (recovery_statusbar_overlay_canvas){
    libaroma_canvas_free(recovery_statusbar_overlay_canvas);
  }
  return 0;
}
Esempio n. 12
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 */
Esempio n. 13
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. 14
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 */
Esempio n. 15
0
/*
 * Function    : _libaroma_window_ready
 * Return Value: byte
 * Descriptions: window is ready
 */
byte _libaroma_window_ready(LIBAROMA_WINDOWP win){
  __CHECK_WM(0);
  if (win==NULL){
    ALOGW("window_resize win is NULL");
    return 0;
  }
  int x = win->x;
  int y = win->y;
  int w = win->w;
  int h = win->h;
  if (w==0){
    w = libaroma_wm()->w;
    x = 0;
  }
  if (h==0){
    h = libaroma_wm()->h;
    y = 0;
  }
  /* set position */
  if (win->dc!=NULL){
    libaroma_canvas_free(win->dc);
    win->dc=NULL;
  }
  win->dc= libaroma_wm_canvas(x, y, w, h);
  if (win->dc==NULL){
    ALOGW("window_ready cannot allocate workspace drawing canvas");
    return 0;
  }
  if (libaroma_window_isactive(win)){
    libaroma_wm_clean_workspace();
  }
  win->x = x;
  win->y = y;
  win->w = win->dc->w;
  win->h = win->dc->h;
  _libaroma_window_measure_save(win,NULL);
  _libaroma_window_recalculate(win);
  return 1;
} /* End of _libaroma_window_ready */
Esempio n. 16
0
/*
 * Function    : _libaroma_ctl_list_draw_item_fresh
 * Return Value: void
 * Descriptions: fresh item drawing
 */
void _libaroma_ctl_list_draw_item_fresh(
  LIBAROMA_CONTROLP ctl,
  LIBAROMA_CTL_LIST_ITEMP item,
  LIBAROMA_CANVASP canvas,
  word bgcolor,
  int hpad,
  byte flag
){
  if ((!canvas)||(!item)||(!ctl)) {
    return;
  }
  
  /* cleanup */
  if (!(flag&LIBAROMA_CTL_LIST_ITEM_DRAW_ADDONS)){
    libaroma_canvas_setcolor(canvas,bgcolor,0xff);
  }
  LIBAROMA_CANVASP tcanvas=NULL;
  LIBAROMA_CANVASP ccv = canvas;
  /* have horizontal padding */
  if (hpad>0){
    tcanvas = libaroma_canvas_area(
      canvas, hpad, 0, canvas->w-hpad*2, canvas->h
    );
    if (tcanvas){
      ccv = tcanvas;
    }
  }
  /* draw directly */
  if (item->handler->draw!=NULL){
    item->handler->draw(ctl,item,ccv,bgcolor,
      flag);
  }
  if (tcanvas){
    libaroma_canvas_free(tcanvas);
  }
} /* End of _libaroma_ctl_list_draw_item_fresh */
Esempio n. 17
0
void bar_test(){
  
  LIBAROMA_WINDOWP win = libaroma_window(
    NULL, 0, 0, LIBAROMA_SIZE_FULL, LIBAROMA_SIZE_FULL);
  
  int _y = 0;
  LIBAROMA_CONTROLP bar = libaroma_ctl_bar(
    win, 1,
    0, _y, LIBAROMA_SIZE_FULL, 56,
    "Libaroma Test", RGB(009385), RGB(ffffff)
  );
  
  libaroma_ctl_bar_set_icon_mask(bar,1,1);
  
  _y+=56;
  LIBAROMA_CONTROLP tabs=libaroma_ctl_tabs(
    win, 2,
    0, _y, LIBAROMA_SIZE_FULL, 48,
    RGB(009385), RGB(ffffff), 0, 0
  );
  
  _y+=48;
  LIBAROMA_CONTROLP pager=libaroma_ctl_pager(
    win, 3, 5,
    0, _y, LIBAROMA_SIZE_FULL, LIBAROMA_SIZE_FULL
  );
  
  /* set pager & tab text */
  char * tab_texts[5]={ "FIRST TABS", "SECOND TABS", "THIRD TABS", "FOURTH TABS", "FIFTH TABS" };
  libaroma_ctl_tabs_set_texts(tabs,tab_texts,5,0);
  libaroma_ctl_tabs_set_pager(tabs,pager);
  
  /* pager window */
  LIBAROMA_WINDOWP win2 = libaroma_ctl_pager_get_window(pager);
  int pw = libaroma_px(pager->w);
  
  LIBAROMA_CONTROLP button_exit = libaroma_ctl_button(
    win2, 5, pw, 0, pw, 60,
    "Exit Libaroma", LIBAROMA_CTL_BUTTON_COLORED|LIBAROMA_CTL_BUTTON_RAISED,
    RGB(880000)
  );
  
  LIBAROMA_CONTROLP button_style = libaroma_ctl_button(
    win2, 6, pw, 60, pw, 60,
    "Update App Bar", LIBAROMA_CTL_BUTTON_RAISED, 0
  );
  
  LIBAROMA_CONTROLP button_gapstyle = libaroma_ctl_button(
    win2, 7, pw, 120, pw, 60,
    "Change App Bar Text Gap", LIBAROMA_CTL_BUTTON_RAISED, 0
  );
  
  LIBAROMA_CONTROLP button_2 = libaroma_ctl_button(
    win2, 8, pw*2, 0, pw, 60,
    "Second Button", LIBAROMA_CTL_BUTTON_COLORED|LIBAROMA_CTL_BUTTON_RAISED, RGB(008800)
  );
  
  LIBAROMA_CONTROLP buttonx_2 = libaroma_ctl_button(
    win2, 181, pw*2, 60, 72, 72,
    "X", LIBAROMA_CTL_BUTTON_COLORED|LIBAROMA_CTL_BUTTON_RAISED|LIBAROMA_CTL_BUTTON_CIRCLE,
    RGB(44688)
  );
  
  LIBAROMA_CONTROLP buttonx_3 = libaroma_ctl_button(
    win2, 182, pw*2+72, 60, 72, 72,
    "A", LIBAROMA_CTL_BUTTON_COLORED|LIBAROMA_CTL_BUTTON_RAISED|LIBAROMA_CTL_BUTTON_CIRCLE,
    RGB(ffffff)
  );
  
  
  
  LIBAROMA_CONTROLP progress2 = libaroma_ctl_progress(
    win2, 51,
    (pw*3.5)-24, 48, 48, 48,
    LIBAROMA_CTL_PROGRESS_INDETERMINATE|LIBAROMA_CTL_PROGRESS_CIRCULAR,
    100,
    0
  );
  
  /* list */
  LIBAROMA_CONTROLP list = libaroma_ctl_list(
    win2, 77, /* win, id */
    0, 0, pw, LIBAROMA_SIZE_FULL, /* x,y,w,h */
    0, 0 /*8*/, /* horiz, vert padding */
    RGB(ffffff), /* bgcolor */
    LIBAROMA_CTL_SCROLL_WITH_SHADOW
    |LIBAROMA_CTL_SCROLL_WITH_HANDLE
  );
  
  libaroma_listitem_image(
    list,1,
    libaroma_image_uri("file:///sdcard/wall2.jpg"),
    120,
    LIBAROMA_LISTITEM_IMAGE_FREE|LIBAROMA_LISTITEM_WITH_SEPARATOR|
    LIBAROMA_LISTITEM_IMAGE_FILL|LIBAROMA_LISTITEM_IMAGE_PROPORTIONAL|
    LIBAROMA_CTL_LIST_ITEM_RECEIVE_TOUCH,
    -1);
  
  
  LIBAROMA_CANVASP list_icon =
    libaroma_image_uri("file:///sdcard/card.png");
  LIBAROMA_CANVASP list_icon2 =
    libaroma_image_uri("file:///sdcard/gesture.png");
  LIBAROMA_CANVASP list_icon3 =
    libaroma_image_uri("file:///sdcard/inbox.png");
  
  /* fill color */
  libaroma_canvas_fillcolor(list_icon,libaroma_colorget(NULL,NULL)->primary);
  libaroma_canvas_fillcolor(list_icon2,libaroma_colorget(NULL,NULL)->primary);
  libaroma_canvas_fillcolor(list_icon3,libaroma_colorget(NULL,NULL)->primary);
    
  char main_text[256];
  char extra_text[256];
  int itm=0;
  int kdv=0;
  for (itm=0;itm<50;itm++){
    if (itm==10){
      libaroma_listitem_image(
        list,1,
        libaroma_image_uri("file:///sdcard/wall1.jpg"),
        150,
        LIBAROMA_LISTITEM_IMAGE_FREE|LIBAROMA_LISTITEM_WITH_SEPARATOR|
        LIBAROMA_LISTITEM_IMAGE_FILL|LIBAROMA_LISTITEM_IMAGE_PROPORTIONAL|
        LIBAROMA_CTL_LIST_ITEM_RECEIVE_TOUCH|LIBAROMA_LISTITEM_IMAGE_PARALAX,
      -1);
    }
    
    if (itm%6==4){
      libaroma_listitem_divider(
        list, 1, (((kdv++)%2)==0)?LIBAROMA_LISTITEM_DIVIDER_SUBSCREEN:
          LIBAROMA_LISTITEM_SEPARATOR_TEXTALIGN, -1);
    }
    
    if (itm%15==0){
      snprintf(main_text,256,"List Caption %i",itm);
      libaroma_listitem_caption(
        list, 200, main_text, -1);
    }
    
    snprintf(main_text,256,"Item id#%i",itm);
    word add_flags=0;
    if (itm%3==1){
      add_flags=LIBAROMA_LISTITEM_CHECK_SWITCH;
      snprintf(extra_text,256,
        "Secondary text for list item %i is three line list item text",itm);
    }
    else if (itm%3==2){
      snprintf(extra_text,256,"Secondary text %i",itm);
    }
    if (itm%5==0){
      libaroma_listitem_check(
        list, itm+10, 0,
        main_text,
        (itm%3!=0)?extra_text:NULL,
        NULL,
        LIBAROMA_LISTITEM_WITH_SEPARATOR|
        LIBAROMA_LISTITEM_CHECK_LEFT_CONTROL|
        add_flags,
        -1
      );
    }
    else{
      libaroma_listitem_check(
        list, itm+10, 0,
        main_text,
        (itm%3!=0)?extra_text:NULL,
        ((itm%3==1)?list_icon:(itm%3==2)?list_icon2:list_icon3),
        LIBAROMA_LISTITEM_CHECK_INDENT_NOICON|
        LIBAROMA_LISTITEM_WITH_SEPARATOR|
        LIBAROMA_LISTITEM_CHECK_SHARED_ICON|
        add_flags,
        -1
      );
    }
  }
  
  /* set bar tools */
  LIBAROMA_CTL_BAR_TOOLSP bar_tools=libaroma_ctl_bar_tools(2);
  libaroma_ctl_bar_tools_set(
    bar_tools, 0, 1, "one", list_icon, LIBAROMA_CTL_BAR_TOOL_ICON_SHARED
  );
  libaroma_ctl_bar_tools_set(
    bar_tools, 1, 3, "two", list_icon, 
    LIBAROMA_CTL_BAR_TOOL_SWITCH|LIBAROMA_CTL_BAR_TOOL_ICON_SHARED
  );
  libaroma_ctl_bar_set_tools(
    bar,bar_tools, 0);
  libaroma_ctl_bar_set_icon(
    bar,NULL,0,LIBAROMA_CTL_BAR_ICON_DRAWER, 1
  );

  
  LIBAROMA_WINDOWP sidebar=libaroma_window_sidebar(win,0);
  if (sidebar){
    printf("SIDEBAR INITIALIZED\n");
    
    /* list */
    LIBAROMA_CONTROLP sblist = libaroma_ctl_list(
      sidebar, 88, /* win, id */
      0, 0, LIBAROMA_SIZE_FULL, LIBAROMA_SIZE_FULL, /* x,y,w,h */
      0, 0 /*8*/, /* horiz, vert padding */
      RGB(ffffff), /* bgcolor */
      LIBAROMA_CTL_SCROLL_WITH_SHADOW
    );
    
    libaroma_listitem_image(
      sblist,1,
      libaroma_image_uri("file:///sdcard/wall2.jpg"),
      150,
      LIBAROMA_LISTITEM_IMAGE_FREE|LIBAROMA_LISTITEM_WITH_SEPARATOR|
      LIBAROMA_LISTITEM_IMAGE_FILL|LIBAROMA_LISTITEM_IMAGE_PROPORTIONAL|
      LIBAROMA_CTL_LIST_ITEM_RECEIVE_TOUCH|LIBAROMA_LISTITEM_IMAGE_PARALAX,
    -1);
    int r;
    char xtext[256];
    for (r=0;r<20;r++){
      if (r%5==0){
        snprintf(xtext,256,"SIDEBAR CAPTION %i",itm);
        libaroma_listitem_caption_color(
          sblist, 200, xtext, RGB(888888), -1);
      }
      
      if (r%3==0){
        libaroma_listitem_divider(
          sblist, 1, (((kdv++)%2)==0)?LIBAROMA_LISTITEM_DIVIDER_SUBSCREEN:
            LIBAROMA_LISTITEM_SEPARATOR_TEXTALIGN,
            -1);
      }
    
      snprintf(xtext,256,"Sidebar Menu #%i",r);
      libaroma_listitem_menu(
        sblist, r+100,
        xtext, NULL,
        ((r%3==1)?list_icon:(r%3==2)?list_icon2:list_icon3),
        LIBAROMA_LISTITEM_CHECK_INDENT_NOICON|
        LIBAROMA_LISTITEM_CHECK_SHARED_ICON|
        LIBAROMA_LISTITEM_CHECK_SMALL_ICON|
        0,
        -1
      );
    }
    
  }
  else{
    printf("SIDEBAR FAILED\n");
  }
  /*
  LIBAROMA_CONTROLP buttonsidebar = libaroma_ctl_button(
    sidebar, 88, 0, 0, LIBAROMA_SIZE_FULL, 60,
    "Side Button", LIBAROMA_CTL_BUTTON_COLORED, RGB(008800)
  );
  */
  // libaroma_window_layer_init(win);
  
  libaroma_window_anishow(win, LIBAROMA_WINDOW_SHOW_ANIMATION_PAGE_LEFT, 400);
  
  
  
  
  // libaroma_window_layer_init(win);
  
  
  
  byte gap_wide = 1;
  int change_id=0;
  byte onpool=1;
  do{
    LIBAROMA_MSG msg;
    dword command=libaroma_window_pool(win,&msg);
    byte cmd  = LIBAROMA_CMD(command);
    word id   = LIBAROMA_CMD_ID(command);
    byte param = LIBAROMA_CMD_PARAM(command);
    
    if (msg.msg==LIBAROMA_MSG_KEY_SELECT){
      if (msg.state==0){
        printf("Screenshoot... and exit\n");
        libaroma_png_save(libaroma_fb()->canvas,"/sdcard/libaroma_screenshoot.png");
        onpool = 0;
        break;
      }
    }
    else if (cmd){
      if (cmd==LIBAROMA_CMD_HOLD){
        if (id==button_exit->id){
          printf("Exit Button Pressed...\n");
          onpool = 0;
        }
      }
      else if (cmd==1){
        if (id==1){
          if (param==1){
            /* drawer icon touched */
            printf("Open sidebar %i\n",
              libaroma_window_sidebar_show(sidebar, 1)
            );
          }
        }
        else if (id==8){
          dialog_demo(win);
        }
        else if (id==7){
          libaroma_ctl_bar_set_textgap(bar,gap_wide,1);
          gap_wide=gap_wide?0:1;
        }
        else if (id==6){
          if (change_id==0){
            libaroma_ctl_bar_set_tools(
              bar,NULL, 0);
            libaroma_ctl_bar_set_subtitle(
              bar,
              "an embedded ui toolkit", 0
            );
            libaroma_ctl_bar_set_color(
              bar, RGB(9C27B0), RGB(ffffff), 1
            );
            libaroma_ctl_tabs_set_color(
              tabs,RGB(9C27B0), RGB(ffffff),1);
          }
          else if (change_id==1){
            libaroma_ctl_bar_set_subtitle(
              bar,
              NULL, 0
            );
            libaroma_ctl_bar_set_title(
              bar,
              "Inbox", 1
            );
          }
          else if (change_id==2){
            libaroma_ctl_bar_set_touchable_title(bar,1);
            libaroma_ctl_bar_set_subtitle(
              bar,
              "Title now touchable", 0
            );
            libaroma_ctl_bar_set_color(
              bar, RGB(009385), RGB(ffffff), 0
            );
            libaroma_ctl_tabs_set_color(
              tabs,RGB(009385), RGB(ffffff),1);
            libaroma_ctl_bar_set_icon(
              bar,list_icon,0,0,1
            );
          }
          else if (change_id==3){
            libaroma_ctl_bar_set_tools(
              bar,bar_tools, 1);
          }
          else if (change_id==4){
            libaroma_ctl_bar_set_subtitle(
              bar,
              NULL, 0
            );
            libaroma_ctl_bar_set_menuid(bar,50,1);
          }
          else if (change_id==5){
            libaroma_ctl_bar_tools_set(
              bar_tools, 1, 3, "three", list_icon, 
              LIBAROMA_CTL_BAR_TOOL_SWITCH|LIBAROMA_CTL_BAR_TOOL_ICON_SHARED
            );
            libaroma_ctl_bar_set_icon(
              bar,NULL,0,LIBAROMA_CTL_BAR_ICON_DRAWER,1
            );
          }
          else if ((change_id==6)||(change_id==8)){
            libaroma_ctl_bar_tools_set(
              bar_tools, 1, 3, "three", NULL,
              LIBAROMA_CTL_BAR_TOOL_SWITCH|
              LIBAROMA_CTL_BAR_TOOL_SWITCH_CHECKED
            );
            libaroma_ctl_bar_set_icon(
              bar,NULL,0,LIBAROMA_CTL_BAR_ICON_ARROW,1
            );
          }
          else if (change_id==7){
            libaroma_ctl_bar_set_touchable_title(bar,0);
            libaroma_ctl_bar_tools_set(
              bar_tools, 1, 3, "three", NULL,
              LIBAROMA_CTL_BAR_TOOL_SWITCH
            );
            libaroma_ctl_bar_set_title(
              bar,
              "Libaroma Demo", 0
            );
            libaroma_ctl_bar_set_subtitle(
              bar,
              "an embedded ui toolkit...", 0
            );
            libaroma_ctl_bar_set_icon(
              bar,NULL,0,LIBAROMA_CTL_BAR_ICON_DRAWER,1
            );
          }
          else if (change_id==9){
            libaroma_ctl_bar_tools_set(
              bar_tools, 1, 3, "three", list_icon,
              LIBAROMA_CTL_BAR_TOOL_SWITCH|LIBAROMA_CTL_BAR_TOOL_ICON_SHARED
            );
            libaroma_ctl_bar_set_icon(
              bar,list_icon,0,0,1
            );
            libaroma_ctl_bar_set_color(
              bar, RGB(311B92), RGB(ffffff), 1
            );
            libaroma_ctl_tabs_set_color(
              tabs,RGB(311B92), RGB(ffffff),1);
          }
          else if (change_id==10){
            libaroma_ctl_bar_set_subtitle(
              bar,
              NULL, 0
            );
            libaroma_ctl_bar_set_menuid(bar,0,0);
            libaroma_ctl_bar_set_tools(
              bar,NULL, 0);
            libaroma_ctl_bar_set_title(
              bar,
              "Libaroma Test", 0
            );
            libaroma_ctl_bar_set_icon(
              bar,NULL,0,0,1
            );
            change_id=-1;
          }
          change_id++;
        }
      }
      printf("Window Command = (CMD: %i, ID: %i, Param: %i)\n",
        LIBAROMA_CMD(command),
        LIBAROMA_CMD_ID(command),
        LIBAROMA_CMD_PARAM(command)
      );
    }
  }
  while(onpool);
  
  libaroma_ctl_bar_tools_free(bar_tools);
  
  libaroma_canvas_free(list_icon);
  libaroma_canvas_free(list_icon2);
  libaroma_canvas_free(list_icon3);
  
  printf("Free Window\n");
  libaroma_window_free(win);
  printf("FREED\n");
}
Esempio n. 18
0
/* init recovery */
byte recovery_init(){
  /* 
    snprintf(libaroma_config()->fb_shm_name,64,"recovery-mainfb");
    libaroma_config()->runtime_monitor = LIBAROMA_START_UNSAFE;
  */
  
  /* disable shared fb */
  libaroma_config()->runtime_monitor = LIBAROMA_START_UNSAFE;
  libaroma_config()->fb_shm_name[0]=0;
  
  /* start libaroma */
  if (!libaroma_start()){
    RLOG("recovery_init: libaroma_start failed");
    return 0;
  }
  
  /*
  LIBAROMA_CANVASP svg1=libaroma_image(
    libaroma_stream(
      "file:///sdcard/23.svg"
    ),
    1
  );
  if (svg1){
    libaroma_draw(libaroma_fb()->canvas,svg1,0,0,1);
    libaroma_sync();
    sleep(4);
  }
  else{
    printf("\n\nSVG RENDER ERROR\n\n\n");
  }
  */
  
  /* set workspace size */
  libaroma_wm_set_workspace(
    0,
    libaroma_dp(24),
    libaroma_fb()->w,
    libaroma_fb()->h-libaroma_dp(24)
  );
  
  /* clean display */
  libaroma_canvas_blank(libaroma_fb()->canvas);
  
  /* create statusbar canvas area */
  _recovery.status_canvas=libaroma_canvas_area(
    libaroma_fb()->canvas,
    0, 0, libaroma_fb()->w, libaroma_dp(24)
  );
  if (!_recovery.status_canvas){
    RLOG("recovery_init: _recovery.status_canvas failed");
    libaroma_end();
    return 0;
  }
  
  /* set wm ui thread */
  libaroma_wm_set_ui_thread(recovery_statusbar_ui_thread);
  recovery_statusbar_setcolor(0);
  
  /* load zip resource */
  _recovery.zip = libaroma_zip("/sdcard/recovery.zip");
  if (!_recovery.zip){
    RLOG("recovery_init: libaroma_zip resource failed");
    libaroma_canvas_free(_recovery.status_canvas);
    libaroma_end();
    return 0;
  }
  
  /* init stream callback */
  libaroma_stream_set_uri_callback(recovery_stream_uri_cb);
  
  /* load font id=0 */
  libaroma_font(0,
    libaroma_stream(
      "res:///fonts/Roboto-Regular.ttf"
    )
  );
  
  if (!recovery_init_ui()){
    recovery_release();
    return 0;
  }
  
  /* cleanup display */
  libaroma_sync();
  
  return 1;
}
Esempio n. 19
0
/*
 * Function    : libaroma_art_busy_progress
 * Return Value: LIBAROMA_CANVASP
 * Descriptions: create busy progress sprite canvas
 */
LIBAROMA_CANVASP libaroma_art_busy_progress(
    word basecolor) {
  int i, j;
  
  /* calculate size */
  int dp1   = libaroma_dp(1);
  int dp36  = libaroma_dp(36);
  int dp72  = libaroma_dp(72);
  int dp144 = dp72 * 2;
  int dp288 = dp144 * 2;
  int dp28  = libaroma_dp(28);
  int dp56  = dp28 * 2;
  int dp116 = dp144 - dp28;
  
  /* main + temp canvas */
  LIBAROMA_CANVASP load  = libaroma_canvas_ex(dp72 * 13, dp72, 1);
  if (!load){
    return NULL;
  }
  LIBAROMA_CANVASP load1 = libaroma_canvas_ex(dp288, dp288, 1);
  if (!load1){
    libaroma_canvas_free(load);
    return NULL;
  }
  LIBAROMA_CANVASP load2 = libaroma_canvas_ex(dp56, dp56, 1);
  if (!load2){
    libaroma_canvas_free(load1);
    libaroma_canvas_free(load);
    return NULL;
  }
  
  /* cleanup */
  libaroma_canvas_setcolor(load, 0x0000, 0);
  
  /* frame loop */
  for (j = 0; j < 13; j++) {
    /* angle per frame */
    double added = ((27.69230769230769 * j) / 360);
    
    /* cleanup load1 */
    libaroma_canvas_setcolor(load1, 0x0000, 0);
    
    /* circle draw */
    for (i = 0; i < 12; i++) {
      /* position */
      double angle = 2 * __PI * ((((double) i) / 12.0) + added);
      int xpos     = round(dp116 * cos(angle));
      int ypos     = round(dp116 * sin(angle));
      
      /* cleanup load2 */
      libaroma_canvas_setcolor(load2, 0x0000, 0);
      int b = 2;
      
      /* draw */
      libaroma_gradient_ex(
        load2,
        b * dp1,
        b * dp1,
        dp56 - (b * dp1 * 2),
        dp56 - (b * dp1 * 2),
        basecolor,
        basecolor,
        dp28,
        0x1111,
        MIN(0xff, ((i + 1) * 18) + 39),
        MIN(0xff, ((i + 1) * 18))
      );
      
      /* Stretch Copy to load1 */
      libaroma_draw_scale_smooth(
        load1,
        load2,
        dp144 + xpos - dp28,
        dp144 + ypos - dp28,
        dp56,
        dp56,
        0,
        0,
        dp56,
        dp56
      );
    }
    
    /* Stretch Copy to load canvas */
    libaroma_draw_scale_smooth(
      load,
      load1,
      j * dp72,
      0,
      dp72,
      dp72,
      0,
      0,
      dp288,
      dp288
    );
  }
  
  /* free temp canvases */
  libaroma_canvas_free(load1);
  libaroma_canvas_free(load2);
  
  /* return canvas */
  LIBAROMA_CANVASP load_out =
    libaroma_canvas_ex(dp36 * 13, dp36, 1);
  if (!load_out){
    libaroma_canvas_free(load);
    return NULL;
  }
  libaroma_canvas_setcolor(load_out, 0x0000, 0);
  
  /* draw */
  libaroma_draw_scale_smooth(
    load_out, load,
    0, 0, dp36 * 13, dp36,
    0, 0, dp72 * 13, dp72
  );
  libaroma_canvas_free(load);
  return load_out;
} /* End of libaroma_art_busy_progress */
Esempio n. 20
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. 21
0
/*
 * Function    : libaroma_blur_ex
 * Return Value: LIBAROMA_CANVASP
 * Descriptions: create new blur-ed canvas - extended
 */
LIBAROMA_CANVASP libaroma_blur_ex(
    LIBAROMA_CANVASP src,
    const int inRadius,
    byte isMask,
    word maskColor
) {
    if (inRadius < 1) {
        return NULL;
    }
    byte usealpha = (src->alpha ? 1 : 0);
    if (isMask && !usealpha) {
        return NULL;
    }
    float * kernel = _libaroma_blur_kernel(inRadius);
    int radius2 = inRadius * 2;
    int pixels_on_row = radius2 + 1;
    int height = src->h;
    int width = src->w;
    int x, y, o;
    int nwidth = width + radius2;
    int nheight = height + radius2;
    LIBAROMA_CANVASP t1 = libaroma_canvas_ex(nwidth, nheight, usealpha);
    if (!t1) {
        return NULL;
    }
    LIBAROMA_CANVASP t2 = libaroma_canvas_ex(nwidth, nheight, usealpha);
    if (!t2) {
        libaroma_canvas_free(t1);
        return NULL;
    }
    libaroma_canvas_setcolor(t1,0,0);
    if (isMask) {
        libaroma_canvas_setcolor(t2,maskColor,0);
    }
    else {
        libaroma_canvas_setcolor(t2,0,0);
    }

    int sz = nwidth * nheight;
    if (usealpha) {
        memset(t1->alpha, 0, sz);
        memset(t2->alpha, 0, sz);
    }
    int r, g, b, a;
    /* X PASS */
    for (y = 0; y < height; y++) {
        int row = y * src->l;
        int drw = (y + inRadius) * t1->l;
        for (x = 0; x < nwidth; x++) {
            r = g = b = a = 0;
            for (o = 0; o < pixels_on_row; o++) {
                int sx = (x - radius2) + o;
                if (!libaroma_draw_limited(sx, width)) {
                    int pos = row + sx;
                    if (!isMask) {
                        word c = src->data[pos];
                        r += libaroma_color_r(c) * kernel[o];
                        g += libaroma_color_g(c) * kernel[o];
                        b += libaroma_color_b(c) * kernel[o];
                    }
                    if (usealpha) {
                        a += src->alpha[pos] * kernel[o];
                    }
                }
            }
            int dpos = drw + x;
            if (!isMask) {
                r = MAX(MIN(r, 0xff), 0);
                g = MAX(MIN(g, 0xff), 0);
                b = MAX(MIN(b, 0xff), 0);
                t1->data[dpos] = libaroma_dither_rgb(x, y, r, g, b);
                if (usealpha) {
                    a = MAX(MIN(a, 0xff), 0);
                    t1->alpha[dpos] = a;
                }
            }
            else {
                a = MAX(MIN(a, 0xff), 0);
                t1->alpha[dpos] = a;
            }
        }
    }
    /* Y PASS */
    for (y = 0; y < nheight; y++) {
        int row = y * t1->l;
        for (x = 0; x < nwidth; x++) {
            r = g = b = a = 0;
            for (o = 0; o < pixels_on_row; o++) {
                int sy = (y - inRadius) + o;
                if (!libaroma_draw_limited(sy, nheight)) {
                    int pos = (sy * t1->l) + x;
                    if (!isMask) {
                        word c = t1->data[pos];
                        r += libaroma_color_r(c) * kernel[o];
                        g += libaroma_color_g(c) * kernel[o];
                        b += libaroma_color_b(c) * kernel[o];
                    }
                    if (usealpha) {
                        a += t1->alpha[pos] * kernel[o];
                    }
                }
            }
            int dpos = row + x;
            if (!isMask) {
                r = MAX(MIN(r, 0xff), 0);
                g = MAX(MIN(g, 0xff), 0);
                b = MAX(MIN(b, 0xff), 0);
                t2->data[dpos] = libaroma_dither_rgb(x, y, r, g, b);
                if (usealpha) {
                    a = MAX(MIN(a, 0xff), 0);
                    t2->alpha[dpos] = a;
                }
            }
            else {
                a = MAX(MIN(a, 0xff), 0);
                t2->alpha[dpos] = a;
            }
        }
    }
    free(kernel);
    libaroma_canvas_free(t1);
    return t2;
} /* End of libaroma_blur_ex */
Esempio n. 22
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. 23
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 */