/** * desktopmanage dialog_open - the user zoomed into the dialog */ static int desktopmanage_dialog_open(liqcell *self,liqcelleventargs *args, liqcell *context) { liqapp_log("desktopmanage_dialog_open start"); desktopmanage_updateticks(self); liqapp_log("desktopmanage_dialog_open fin"); return 0; }
static int liqcell_filter_run(liqcell *c,char *searchterm) { liqcellfiltereventargs filterargs; filterargs.filterinuse= (searchterm ? 1 : 0); filterargs.searchterm = searchterm; filterargs.searchtags = NULL; filterargs.resultoutof= 1; filterargs.resultshown= 0; if(!filterargs.resultshown) { if(searchterm && *searchterm) { } else { filterargs.resultshown = 1; } } if(!filterargs.resultshown) { if(c->name) filterargs.resultshown = ( stristr(c->name,searchterm) != NULL ); } if(!filterargs.resultshown) { if(c->classname) filterargs.resultshown = ( stristr(c->classname,searchterm) != NULL ); } liqcell *ccontent = liqcell_getcontent( c ); if(ccontent) { liqapp_log("searching in cont '%s', %i",c->name,filterargs.resultshown); liqcell_handlerrun( ccontent , "filter", &filterargs ); } else { liqapp_log("searching in flat '%s', %i",c->name,filterargs.resultshown); liqcell_handlerrun( c , "filter", &filterargs ); } if(filterargs.resultshown) { liqcell_setvisible(c,1); return 1; } else { liqcell_setvisible(c,0); return 0; } }
/** * invar.destroy */ static int invar_destroy(liqcell *self,liqcellclickeventargs *args, liqcell *liqcam) { // we must stop the camera! // technically we could change this to: // we should decrement the counter of users of this camera source // that way, multiple apps can see the same data liqapp_log("invar_destroy hmm1"); liqcameraface_stop(); liqapp_log("invar_destroy hmm2"); return 0; }
static int monitor_run(liqcell *context) { char *target;//[FILENAME_MAX]; int result; int fd; int wd; /* watch descriptor */ char * folder = liqcell_propgets(context,"monitorpath","."); if( (!folder) || (!*folder) || (!liqapp_pathexists(folder)) ) { liqapp_log( "inotify monitor path does not exist\n"); return -1; } //strcpy (target, folder); target=strdup(folder); if(!target) { liqapp_log( "inotify could not alloc target\n"); return -1; } liqapp_log("inotify about to init() for '%s'",target); fd = inotify_init(); liqapp_log("inotify init() returned %i",fd); if (fd < 0) { liqapp_log( "monitor error init: %s\n", strerror(errno)); free(target); return 1; } liqapp_log("inotify about to add_watch for '%s'",target); wd = inotify_add_watch(fd, target, IN_CLOSE_WRITE | IN_MOVED_TO);//IN_ALL_EVENTS); //wd = inotify_add_watch(fd, target, IN_ALL_EVENTS); liqapp_log("inotify add_watch returned %i",wd); if (wd < 0) { liqapp_log( "monitor error add: %s\n", strerror(errno)); free(target); return -1; } liqapp_log("inotify looping for '%s'",target); //monitor_get_event(fd, target,context); while (1) { liqapp_sleep(25); monitor_get_event(fd, target,context); } free(target); return 0; }
int liqrecentsketches_scroller_mouse(liqcell *self, liqcellmouseeventargs *args, void *liqrecentsketches) { liqapp_log("knob mouse!"); liqcell *backplane = liqcell_child_lookup( liqrecentsketches,"backplane"); liqcell *body = liqcell_child_lookup( backplane,"body"); liqcell *scroller = liqcell_child_lookup( liqrecentsketches,"scroller"); liqcell *knob = liqcell_child_lookup( scroller,"knob"); int py = args->mey - scroller->y ; if(py<0)py=0; if(py<knob->h/2)py=knob->h/2; if(py>scroller->h-knob->h/2)py=scroller->h-knob->h/2; //liqcell_setpos(knob, 0, py - (knob->h/2) ); //liqcell_forceinboundparent(knob); double range = scroller->h - knob->h; double pos = py - (knob->h/2); double frac = 0; if(range==0) frac = 0; else frac = pos / range ; double outrange = body->h - backplane->h; if(outrange<0)outrange=0; liqapp_log("knob %d :: %3.3f %3.3f %3.3f == %3.3f :: %3.3f",py, range,pos,frac, outrange, outrange * frac); liqcell_setpos( body,0, -outrange * frac ); return 0; }
int desktopmanage_live_tickone(liqcell *desktopmanage,char *name) { liqapp_log("desktopmanage: updating ticks"); liqcell *list1 = liqcell_child_lookup( desktopmanage,"list1"); //############################# backplane:picturebox liqcell *backplane =liqcell_child_lookup( list1,"backplane"); //############################# listitem:picturebox liqcell *listitem = liqcell_getlinkchild_visual(backplane); while(listitem) { //if(liqcell_getflagvisual(listitem)) { char *key=listitem->name; liqcell *listitemlive = liqcell_child_lookup( listitem,"listitemlive"); if( (strcasecmp(key,name)==0) ) { liqcell_setcaption(listitemlive,"Y"); liqcell_propsets( listitemlive, "textcolor", "rgb(0,255,,0)" ); } } listitem=liqcell_getlinknext_visual(listitem); } }
int desktopmanage_live_gettick(liqcell *desktopmanage,char *namebuf,int namelen) { liqapp_log("desktopmanage: updating ticks"); snprintf(namebuf,namelen,""); liqcell *list1 = liqcell_child_lookup( desktopmanage,"list1"); //############################# backplane:picturebox liqcell *backplane =liqcell_child_lookup( list1,"backplane"); //############################# listitem:picturebox liqcell *listitem = liqcell_getlinkchild_visual(backplane); while(listitem) { //if(liqcell_getflagvisual(listitem)) { char *key=listitem->name; liqcell *listitemlive = liqcell_child_lookup( listitem,"listitemlive"); char *cap = liqcell_getcaption(listitemlive); if( (strcasecmp(cap,"Y")==0) ) { snprintf(namebuf,namelen,"%s",key); return 0; } } listitem=liqcell_getlinknext_visual(listitem); } return -1; }
/** * create a new invar_run widget */ liqcell *invar_run_create() { liqcell *self = liqcell_quickcreatewidget("invar_run", "form", 800, 480); if(!self) {liqapp_log("liqcell error not create 'invar_run'"); return NULL; } // Optimization: The aim is to REDUCE the number of drawn layers and operations called. // Optimization: use only what you NEED to get an effect // Optimization: Minimal layers and complexity // Optimization: defaults: background, prefer nothing, will be shown through if there is a wallpaper // Optimization: defaults: text, white, very fast rendering //############################# body:label liqcell *body = liqcell_quickcreatevis("body", "invar_rawview", 0, 0, 800, 480); //liqcell_setfont( body, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (12), 0) ); //liqcell_setcaption(body, "body" ); //liqcell_propsets( body, "textcolor", "rgb(255,255,255)" ); //liqcell_propsets( body, "backcolor", "rgb(64,64,64)" ); //liqcell_propseti( body, "textalign", 0 ); //liqcell_propseti( body, "textaligny", 0 ); liqcell_child_append( self, body); //liqcell_propsets( self, "backcolor", "rgb(0,0,0)" ); //liqcell_setimage( self , liqimage_cache_getfile( "/usr/share/liqbase/invar/media/invar_run_back.png",0,0,0) ); liqcell_handleradd_withcontext(self, "filter", (void*)invar_run_filter ,self); liqcell_handleradd_withcontext(self, "refresh", (void*)invar_run_refresh ,self); liqcell_handleradd_withcontext(self, "shown", (void*)invar_run_shown ,self); //liqcell_handleradd_withcontext(self, "resize", (void*)invar_run_resize ,self); //liqcell_handleradd_withcontext(self, "keypress", (void*)invar_run_keypress,self ); //liqcell_handleradd_withcontext(self, "keyrelease", (void*)invar_run_keyrelease ,self); //liqcell_handleradd_withcontext(self, "mouse", (void*)invar_run_mouse,self ); //liqcell_handleradd_withcontext(self, "click", (void*)invar_run_click ,self); //liqcell_handleradd_withcontext(self, "paint", (void*)invar_run_paint ,self); // use only if required, heavyweight liqcell_handleradd_withcontext(self, "dialog_open", (void*)invar_run_dialog_open ,self); liqcell_handleradd_withcontext(self, "dialog_close", (void*)invar_run_dialog_close ,self); return self; }
static int edit_click(liqcell *self, liqcellclickeventargs *args, void *context) { liqapp_log("hello click edit!"); liqcell *mydialog = quickdialog_create(); // liqcell_easyrun(mydialog); return 1; }
/** * liqpostcard widget refresh, all params set, present yourself to the user. */ static int liqpostcard_refresh(liqcell *self,liqcelleventargs *args, liqcell *context) { // there might be an OS level variable called filter // it should be set and adjusted correctly prior to calling this routine // you should do your best to account for this filter in any way you see fit liqcell *cmdconfigure = liqcell_child_lookup(self, "cmdconfigure"); liqcell *cmdsend = liqcell_child_lookup(self, "cmdsend"); char *username = app.username; char *userpassmd5 = liqapp_pref_getvalue("userpass",NULL); char *twitname = liqapp_pref_getvalue_def("twitname",NULL); char *twitpass = liqapp_pref_getvalue_def("twitpass",NULL); if(!username || !*username || !userpassmd5 || !*userpassmd5 || !twitname || !*twitname) { liqcell_setenabled(cmdsend,0); liqapp_log("liqpostcard not allowed, no username/userpass/twitname/twitpass configured"); return -1; } // everything ok :) liqcell_setenabled(cmdsend,1); return 0; }
/** * sheepdrawing_pictureselect.cmdselect clicked */ static int cmdselect_click(liqcell *self,liqcelleventargs *args, liqcell *sheepdrawing_pictureselect) { // we are done here. liqcell *sheepdrawing_picturegrid = liqcell_child_lookup(sheepdrawing_pictureselect, "sheepdrawing_picturegrid"); //########## major sideways hack. classes need declarations and header files. int sheepdrawing_picturegrid_getselectedphoto_filename(liqcell *self,char *buffer,int bufferlen); char selfn[FILENAME_MAX]={0}; sheepdrawing_picturegrid_getselectedphoto_filename(sheepdrawing_picturegrid,selfn,sizeof(selfn) ); //liqapp_log("selimg a %s",selfn); //char *selfn=liqcell_propgets( oneedit, "imagefilenameselected",NULL ); if( selfn && *selfn ) { liqapp_log("selimg got sel %s",selfn); liqcell_propsets( sheepdrawing_pictureselect, "imagefilenameselected", selfn ); } // liqcell_setvisible(sheepdrawing_pictureselect,0); liqcell_propseti(sheepdrawing_pictureselect,"dialog_running",0); return 0; }
int liqcanvas_close() { if(!liqcanvas_isopen()) { liqapp_log("canvas close : wasnt opened"); return-1; } //liqapp_log("canvas close"); //if(canvas.font) liqcanvas_closefont(); //canvas.font=NULL; //liqcanvas_xv_close(); liqx11info_close(liqcanvas_getx11info()); canvas.customx11display=NULL; canvas.customx11window =NULL; //liqapp_log("canvas close end"); canvas.pixelwidth =0; canvas.pixelheight=0; return 0; }
/** * liqrecentphotos layout2 - make any adjustments to fill the content as are required */ static int liqrecentphotos_layout2(liqcell *self,liqcelleventargs *args, liqcell *context) { liqapp_log("hmm"); liqcell *title= liqcell_child_lookup(self, "title"); liqcell *body= liqcell_child_lookup(self, "body"); liqcell *headskip= liqcell_child_lookup(body, "__headskip"); // make a normal grid liqcell_setrect( body, 0, 0, liqcell_getw(self),liqcell_geth(self) ); liqcell_child_arrange_makegrid(body,5,3); //liqcell_child_arrange_easytile(body); //### use only if title in use // make sure the headerskip is adjusted // liqcell_setsize(headskip,liqcell_getw(title),liqcell_geth(title)); // now flow the rest // liqcell_child_arrange_autoflow(body); // and make sure its positioned correctly // liqcell_setrect( body, 0, 0, liqcell_getw(self),liqcell_geth(body) ); return 0; }
int liqcanvas_takepicture() { char fmtnow[255]; liqapp_formatnow(fmtnow,255,"yyyymmdd_hhmmss"); //char buf[FILENAME_MAX+1]; int pngerr =0; liqimage *imgfrom=NULL;//liqcamera_getimage(); if(!imgfrom) { // camera not on, we are doing desktop imgfrom = canvas.rotation_native_surface;//canvas.surface; } if(imgfrom) { /* if(imgfrom != canvas.surface) { // save camera image snprintf(buf,FILENAME_MAX,"%s/liq.%s.%s.cam.png",app.sketchpath,fmtnow,app.username ); liqapp_log("Fullscreen Pressed, saving camera as '%s'",buf); pngerr=liqimage_pagesavepng(imgdesk,buf); } else */ { // save screenshot char fmtnow[255]; liqapp_formatnow(fmtnow,255,"yyyymmdd_hhmmss"); char buf[FILENAME_MAX+1]; snprintf(buf,FILENAME_MAX,"liq.%s.%s.scr.png",fmtnow,"lib" ); liqapp_log("liqcanvas_takepicture, saving canvas as '%s'",buf); pngerr=liqimage_pagesavepng(imgfrom,buf); } } else { // no canvas liqapp_log("liqcanvas_takepicture, no canvas"); } return 0; }
static int widget_click(liqcell *self, liqcellclickeventargs *args, void *context) { liqapp_log("hmm why not clicking? %s",self->name); args->newdialogtoopen = self;//liqcell_child_lookup( self, "body" ); //args->newdialogtoopen = liqcell_child_lookup( self, "body" ); return 1; }
int desktopmanage_updateticks(liqcell *desktopmanage) { liqapp_log("desktopmanage: updating ticks"); desktopmanage_live_untickall(desktopmanage); char *liveback = liqapp_pref_getvalue("liveback"); if(liveback && *liveback) { desktopmanage_live_tickone(desktopmanage,liveback); } liqcell *list1 = liqcell_child_lookup( desktopmanage,"list1"); //############################# backplane:picturebox liqcell *backplane =liqcell_child_lookup( list1,"backplane"); //############################# listitem:picturebox liqcell *listitem = liqcell_getlinkchild_visual(backplane); while(listitem) { //if(liqcell_getflagvisual(listitem)) { char *key=listitem->name; liqcell *listitemicon = liqcell_child_lookup( listitem,"listitemtick"); char *cap = liqcell_getcaption(listitemicon); if( !liqbase_playground_check_if_class_shown(key) ) { liqcell_setcaption(listitemicon,"N"); liqcell_propsets( listitemicon, "textcolor", "rgb(255,0,0)" ); } else { //liqapp_log("desktopmanage: tick yes '%s'",key); liqcell_setcaption(listitemicon,"Y"); liqcell_propsets( listitemicon, "textcolor", "rgb(0,255,0)" ); } } listitem=liqcell_getlinknext_visual(listitem); } liqapp_log("desktopmanage: updated ticks"); }
/** * create a new liqtasks_new widget */ liqcell *liqtasks_new_create() { liqcell *self = liqcell_quickcreatewidget("liqtasks_new", "form", 800, 480); if(!self) {liqapp_log("liqcell error not create 'liqtasks_new'"); return NULL; } // Optimization: The aim is to REDUCE the number of drawn layers and operations called. // Optimization: use only what you NEED to get an effect // Optimization: Minimal layers and complexity // Optimization: defaults: background, prefer nothing, will be shown through if there is a wallpaper // Optimization: defaults: text, white, very fast rendering //############################# editor:label liqcell *editor = liqcell_quickcreatevis("editor", "label", 0, 0, 800, 480); liqcell_setfont( editor, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (12), 0) ); liqcell_setcaption(editor, "backplane" ); liqcell_propsets( editor, "textcolor", "rgb(255,0,0)" ); liqcell_propsets( editor, "backcolor", "rgb(64,64,64)" ); liqcell_propseti( editor, "textalign", 2 ); liqcell_propseti( editor, "textaligny", 2 ); liqcell_child_append( self, editor); //############################# title:label liqcell *title = liqcell_quickcreatevis("title", "label", 0, 0, 800, 52); liqcell_setfont( title, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (29), 0) ); liqcell_setcaption(title, "New Task" ); liqcell_propsets( title, "textcolor", "rgb(255,255,255)" ); liqcell_propsets( title, "backcolor", "xrgb(128,128,128)" ); liqcell_propseti( title, "textalign", 0 ); liqcell_propseti( title, "textaligny", 0 ); liqcell_child_append( self, title); //############################# cmdsave:label liqcell *cmdsave = liqcell_quickcreatevis("cmdsave", "label", 594, 432, 206, 48); liqcell_setfont( cmdsave, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (29), 0) ); liqcell_setcaption(cmdsave, "Save" ); liqcell_propsets( cmdsave, "textcolor", "rgb(255,255,255)" ); liqcell_propsets( cmdsave, "backcolor", "xrgb(0,64,0)" ); liqcell_propsets( cmdsave, "bordercolor", "rgb(255,255,255)" ); liqcell_propseti( cmdsave, "textalign", 2 ); liqcell_propseti( cmdsave, "textaligny", 2 ); liqcell_handleradd_withcontext(cmdsave, "click", (void*)cmdsave_click, self ); liqcell_child_append( self, cmdsave); //liqcell_propsets( self, "backcolor", "rgb(0,0,0)" ); //liqcell_setimage( self , liqimage_cache_getfile( "/usr/share/liqbase/liqtasks/media/liqtasks_new_back.png",0,0,0) ); liqcell_handleradd_withcontext(self, "filter", (void*)liqtasks_new_filter ,self); liqcell_handleradd_withcontext(self, "refresh", (void*)liqtasks_new_refresh ,self); liqcell_handleradd_withcontext(self, "shown", (void*)liqtasks_new_shown ,self); liqcell_handleradd_withcontext(self, "resize", (void*)liqtasks_new_resize ,self); liqcell_handleradd_withcontext(self, "layout", (void*)liqtasks_new_layout ,self); //liqcell_handleradd_withcontext(self, "keypress", (void*)liqtasks_new_keypress,self ); //liqcell_handleradd_withcontext(self, "keyrelease", (void*)liqtasks_new_keyrelease ,self); //liqcell_handleradd_withcontext(self, "mouse", (void*)liqtasks_new_mouse,self ); //liqcell_handleradd_withcontext(self, "click", (void*)liqtasks_new_click ,self); //liqcell_handleradd_withcontext(self, "paint", (void*)liqtasks_new_paint ,self); // use only if required, heavyweight liqcell_handleradd_withcontext(self, "dialog_open", (void*)liqtasks_new_dialog_open ,self); liqcell_handleradd_withcontext(self, "dialog_close", (void*)liqtasks_new_dialog_close ,self); return self; }
/** * liqcalc_run paint - being rendered. use the vgraph held in args to do custom drawing at scale */ static int liqcalc_run_paint(liqcell *self, liqcellpainteventargs *args,liqcell *liqcalc_run) { // big heavy event, use sparingly liqcell *solarcell = liqcell_child_lookup(liqcalc_run, "solarcell"); liqcell *calclcd = liqcell_child_lookup(liqcalc_run, "calclcd"); if( liqcell_easyrun_getactivecontrol() == solarcell && liqcell_easyrun_fingerpressed) { // fade the text.. int solarbrightness = liqcell_propgeti(calclcd,"solarbrightness",255); liqapp_log("solar -- %d",solarbrightness); if(solarbrightness>0) { solarbrightness-=4; if(solarbrightness<0)solarbrightness=0; if(solarbrightness>255)solarbrightness=255; liqcell_propsets_printf(calclcd,"backcolor","rgb(%d,%d,%d)",solarbrightness,solarbrightness,solarbrightness); liqcell_propseti( calclcd, "solarbrightness", solarbrightness ); liqcell_setdirty(calclcd,1); } } else { int solarbrightness = liqcell_propgeti(calclcd,"solarbrightness",255); liqapp_log("solar ++ %d",solarbrightness); if(solarbrightness<255) { solarbrightness+=16; if(solarbrightness<0)solarbrightness=0; if(solarbrightness>255)solarbrightness=255; liqcell_propsets_printf(calclcd,"backcolor","rgb(%d,%d,%d)",solarbrightness,solarbrightness,solarbrightness); liqcell_propseti( calclcd, "solarbrightness", solarbrightness ); liqcell_setdirty(calclcd,1); } // bring the text back up ;) } return 0; }
/** * invar mouse - occurs all the time as you stroke the screen */ static int invar_mouse(liqcell *self, liqcellmouseeventargs *args,liqcell *context) { float px = (float)args->mex / (float)liqcell_getw(self); float py = (float)args->mey / (float)liqcell_geth(self); hotspot_matchu = (unsigned char)(255.0*px); hotspot_matchv = (unsigned char)(255.0*py); liqapp_log("hotspot match %d,%d",hotspot_matchu,hotspot_matchv); return 0; }
liqcell *liqflow_massive_create() { liqcell *self = liqcell_quickcreatewidget("liqflow_massive","form", 800*5,480*5); if(!self) {liqapp_log("liqcell error not create 'liqflow_massive'"); return NULL; } // Optimization: The aim is to REDUCE the number of drawn layers and operations called. // Optimization: use only what you NEED to get an effect // Optimization: Minimal layers and complexity // Optimization: defaults: background, prefer nothing, will be shown through if there is a wallpaper // Optimization: defaults: text, white, very fast rendering //############################# liqflow:label liqcell *liqflow_tiny = liqcell_quickcreatevis("liqflow_tiny", "liqflow_tiny", 0,0,800,480); liqcell *backer = liqcell_quickcreatevis("backer", NULL, 0,0,self->w,self->h); liqcell_setcontent(backer,liqflow_tiny); liqcell_child_append( self, backer); liqcell_handleradd_withcontext(backer, "paint", sketchedit_mouse,self); int x,y; for(y=0;y<5;y++) { for(x=0;x<5;x++) { //############################# piece4:label liqcell *piece4 = liqcell_quickcreatevis("liqflowx", "liqflowsmall", x*800,y*480,800,480); //liqcell_propsets( piece4, "imagefilename", "/usr/share/liqbase/liqcontrolpanel/media/liqflowmassive_4.png" ); //liqcell_propseti( piece4 , "lockaspect", 0 ); liqcell_child_append( self, piece4); } } /* for(framecount=0;framecount<10;framecount++) { saveframe(self,framecount); } */ liqcell_handleradd_withcontext(self, "paint", widget_paint,self); return self; }
liqcell *liqtimer_create() { liqcell *self = liqcell_quickcreatewidget("liqtimer","liqtimer", 0,0); if(self) { // todo: should make sure we break out of duldrums if the user enables or disables us liqcell_setvisible(self,0); // not visible in the render window ever liqcell_setenabled(self,0); liqcell_propseti(self,"timerinterval",100); pthread_t *tid = (pthread_t *)malloc(sizeof(pthread_t)); if(!tid) { liqapp_log("liqtimer, cannot alloc thread"); return 0; } //pthread_t tid; int tres=thread_createwithpriority(tid,0,liqtimer_workthread,self); if(tres) { liqapp_log("liqtimer, thread create fail"); free(tid); return 0; } liqcell_setdata(self,tid); //liqcell_propseti(self,"timerenabled",0); } return self; }
int liqcanvas_init_usecustomwindow( int pixelwidth,int pixelheight,void *customx11display,void *customx11window) { // if(canvas.pixelwidth || canvas.pixelheight) { { liqapp_log("canvas liqcanvas_xv_init already open"); } return -1; } canvas.customx11display=customx11display; canvas.customx11window =customx11window; return liqcanvas_init(pixelwidth,pixelheight,0); }
static int accel_read(int *ax,int *ay,int *az) { FILE *fd; int rs; fd = fopen(accel_filename, "r"); if(fd==NULL){ liqapp_log("accel, cannot open for reading"); return -1;} rs=fscanf((FILE*) fd,"%i %i %i",ax,ay,az); //rc=fgets(result, resultmaxlength, (FILE*) fd); fclose(fd); if(rs != 3){ liqapp_log("accel, cannot read information"); return -2;} if(ocnt>0) { int dx = *ax-oax; int dy = *ay-oay; int dz = *az-oaz; int fat = ABS(dx)+ABS(dy)+ABS(dz); if(accel_fat>0) { accel_fat = accel_fat * 0.8; } if(accel_fat<0)accel_fat=0; accel_fat += fat; } oax=*ax; oay=*ay; oaz=*az; ocnt++; return 0; }
static int liqrecentsketches_sketch_add(liqcell *self,char *filenamebuffer) { // 20090528_215559 lcuk : first attempt at runtime expansion // 20090528_215639 lcuk : its a hack because i should be using the filemonitor class elsewhere // 20090528_215654 lcuk : and it should be automatic // 20090528_215943 lcuk : class should be pre-tested or something here // 20090528_215951 lcuk : this runtime function would obviously be too slow for normal use liqapp_log("adding %s",filenamebuffer); struct pagefilename pfn; if( (pagefilename_breakapart(&pfn,filenamebuffer) == 0) ) { liqrecentsketches_sketch_insert(self,filenamebuffer); return 0; /* char buf[FILENAME_MAX]; snprintf(buf,sizeof(buf),"%s%s",pfn.filedate,pfn.filetitle); liqcell *body = liqcell_child_lookup( self,"body"); liqcell *c = liqcell_quickcreatevis(buf, "sketch", 1,1,1,1 ); liqcell_propseti(c,"lockaspect",1); liqcell_propsets(c,"sketchfilename",filenamebuffer); //######################################### liqapp_log("name: %s",pfn.fileuser); char fn[FILENAME_MAX]; snprintf(fn,sizeof(fn),"media/avatars/%s.png",pfn.fileuser); if(!liqapp_fileexists(fn)) { snprintf(fn,sizeof(fn),"media/avatars/%s.jpg",pfn.fileuser); } if(liqapp_fileexists(fn)) { liqcell *p = liqcell_quickcreatevis(fn, "user", 0,0,42,42 ); liqcell_propseti(p,"lockaspect",1); liqcell_propsets(p,"imagefilename",fn); liqcell_child_insert( c, p); } liqcell_child_insertsortedbyname( body, c,0); liqcell_setsize(body,self->w,self->h); liqcell_child_arrange_makegrid(body,3,3); */ } return 0; }
static void monitor_get_event(int fd, const char * target,liqcell *context) { ssize_t len=0, i = 0; char action[81+FILENAME_MAX] = {0}; char buff[BUFF_SIZE] = {0}; //liqapp_log("inotify_getevent reading from '%s'",target); len = read (fd, buff, BUFF_SIZE); while (i < len) { struct inotify_event *pevent = (struct inotify_event *)&buff[i]; char action[81+FILENAME_MAX] = {0}; if ( (pevent->len) ) { char *ext=liqapp_filename_walktoextension(pevent->name); if(!ext || !*ext) { } else { // silly hack if( strcasecmp(ext,"filepart")==0 ) goto nextitem; } snprintf(action,sizeof(action),"%s/%s",target,pevent->name); liqapp_log("inotify_getevent '%s', %i %i %i::'%s'",target,i,len,pevent->mask,action); // dealing with a file if( (pevent->mask & IN_CLOSE_WRITE) || (pevent->mask & IN_MOVED_TO) ) { liqrecentphotos_item_add(context,action); } // if(pevent->mask & IN_CREATE) // liqrecentsketches_sketch_add(context,pevent->name); } nextitem: {} i += sizeof(struct inotify_event) + pevent->len; } }
static int liqrecentsketches_sketch_add(liqcell *self,char *filenamebuffer) { // 20090528_215559 lcuk : first attempt at runtime expansion // 20090528_215639 lcuk : its a hack because i should be using the filemonitor class elsewhere // 20090528_215654 lcuk : and it should be automatic // 20090528_215943 lcuk : class should be pre-tested or something here // 20090528_215951 lcuk : this runtime function would obviously be too slow for normal use liqapp_log("adding %s",filenamebuffer); struct pagefilename pfn; if( (pagefilename_breakapart(&pfn,filenamebuffer) == 0) ) { liqrecentsketches_sketch_insert(self,filenamebuffer); return 0; } return 0; }
/** Construct a simplebar */ liqcell *simplebar_create() { liqcell *self = liqcell_quickcreatewidget("simplebar", "form", 600, 50); // exit if fail create if(!self) { liqapp_log("liqcell error not create 'simplebar'"); return NULL; } // create label liqcell *simple_label = liqcell_quickcreatevis("simple_label", "label", 20, 7, 200, 36); liqcell_setfont(simple_label, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (22), 0)); liqcell_setcaption(simple_label, "Body Caption:"); liqcell_propsets(simple_label, "textcolor", GREEN); liqcell_propseti(simple_label, "textalign", 1); liqcell_child_append(self, simple_label); // create textbox liqcell *simple_textbox = liqcell_quickcreatevis("simple_textbox", "textbox", 220, 7, 200, 36); liqcell_setfont(simple_textbox, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (22), 0) ); liqcell_setcaption(simple_textbox, ""); liqcell_propsets(simple_textbox, "textcolor", WHITE); liqcell_propsets(simple_textbox, "backcolor", BLACK); liqcell_propsets(simple_textbox, "bordercolor", GREEN); liqcell_propseti(simple_textbox, "textalign", 0); liqcell_propseti(simple_textbox, "textaligny", 2); liqcell_child_append(self, simple_textbox); // create buttom: Submit liqcell *simple_submit = liqcell_quickcreatevis("simple_submit", "commandbutton", 460, 7, 76, 32); liqcell_setfont(simple_submit, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (22), 0) ); liqcell_setcaption(simple_submit, "Submit"); liqcell_propsets(simple_submit, "textcolor", GREEN); liqcell_propsets(simple_submit, "backcolor", BLACK); liqcell_handleradd_withcontext(simple_submit, "click", simplebar_submit_click, self); liqcell_propseti(simple_submit, "textalign", 1); liqcell_child_append(self, simple_submit); return self; }
/** * create a new dialog_selectcolor_colorcube widget */ liqcell *dialog_selectcolor_colorcube_create() { liqcell *self = liqcell_quickcreatewidget("dialog_selectcolor_colorcube", "form", 294, 284); if(!self) {liqapp_log("liqcell error not create 'dialog_selectcolor_colorcube'"); return NULL; } // Optimization: The aim is to REDUCE the number of drawn layers and operations called. // Optimization: use only what you NEED to get an effect // Optimization: Minimal layers and complexity // Optimization: defaults: background, prefer nothing, will be shown through if there is a wallpaper // Optimization: defaults: text, white, very fast rendering //############################# image1:image //liqcell *image1 = liqcell_quickcreatevis("image1", "image", 0, 0, 236, 204); //liqcell_propsets( image1, "bordercolor", "rgb(255,255,255)" ); //liqcell_child_append( self, image1); //liqcell_propsets( self, "backcolor", "rgb(235,233,237)" ); liqcell_handleradd_withcontext(self, "refresh", (void*)dialog_selectcolor_colorcube_refresh ,self); liqcell_handleradd_withcontext(self, "shown", (void*)dialog_selectcolor_colorcube_shown ,self); liqcell_handleradd_withcontext(self, "resize", (void*)dialog_selectcolor_colorcube_resize ,self); liqcell_handleradd_withcontext(self, "paint", (void*)dialog_selectcolor_colorcube_paint ,self); // use only if required, heavyweight return self; }
/** * create a new nokiapicture widget */ liqcell *nokiapicture_create() { liqcell *self = liqcell_quickcreatewidget("nokiapicture", "form", 130, 24); if(!self) {liqapp_log("liqcell error not create 'nokiapicture'"); return NULL; } // Optimization: The aim is to REDUCE the number of drawn layers and operations called. // Optimization: use only what you NEED to get an effect // Optimization: Minimal layers and complexity // Optimization: defaults: background, prefer nothing, will be shown through if there is a wallpaper // Optimization: defaults: text, white, very fast rendering /* //############################# picnokia:label liqcell *picnokia = liqcell_quickcreatevis("picnokia", "label", 0, 0, 132, 24); liqcell_setfont( picnokia, liqfont_cache_getttf("/usr/share/fonts/nokia/nosnb.ttf", (10), 0) ); liqcell_setcaption(picnokia, "Nokia" ); liqcell_propsets( picnokia, "textcolor", "rgb(192,192,192)" ); liqcell_propsets( picnokia, "backcolor", "rgb(64,64,64)" ); liqcell_propseti( picnokia, "textalign", 2 ); liqcell_child_append( self, picnokia); */ liqcell_propsets( self, "imagefilename", "/usr/share/liqbase/onedotzero/media/2_nokia.png" ); liqcell_propseti( self, "autosize", 1 ); //liqcell_propsets( self, "backcolor", "rgb(235,233,237)" ); liqcell_handleradd_withcontext(self, "refresh", nokiapicture_refresh ,self); liqcell_handleradd_withcontext(self, "shown", nokiapicture_shown ,self); //liqcell_handleradd_withcontext(self, "resize", nokiapicture_resize ,self); //liqcell_handleradd_withcontext(self, "keypress", nokiapicture_keypress,self ); //liqcell_handleradd_withcontext(self, "keyrelease", nokiapicture_keyrelease ,self); //liqcell_handleradd_withcontext(self, "mouse", nokiapicture_mouse,self ); //liqcell_handleradd_withcontext(self, "click", nokiapicture_click ,self); //liqcell_handleradd_withcontext(self, "paint", nokiapicture_paint ,self); // use only if required, heavyweight liqcell_handleradd_withcontext(self, "dialog_open", nokiapicture_dialog_open ,self); liqcell_handleradd_withcontext(self, "dialog_close", nokiapicture_dialog_close ,self); // Mon Sep 07 12:09:53 2009 lcuk : remove for now, karsten change request liqcell_setvisible(self,0); return self; }
int liqrecentsketches_sketchitem_click(liqcell *self, liqcellclickeventargs *args, void *context) { liqapp_log("hello click edit!"); //liqcell *mydialog = quickdialog_create(); //liqcell_easyrun(mydialog); //liqcell_release(mydialog); liqcell_setselected(self,1); if(current_selection && current_selection!=self) liqcell_setselected(current_selection,0); current_selection = self; return 0; char *sketchfilename = liqcell_propgets(self,"sketchfilename",NULL); if(!sketchfilename) return -1; liqsketch *mysketch=liqsketch_newfromfile(sketchfilename);// liqcell_getsketch(self); if(!mysketch)return -1; liqcell * top = liqcell_quickcreatevis("liqtop1", "liqtop", 0,0, 800,480); liqcell_setsketch(top, mysketch ); //liqcell_propseti(top,"autorotate",1); // args->newdialogtoopen = top; liqcell_release(top); return 1; }