*/}}

la_animation.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. /*
  2. * LaGUI: A graphical application framework.
  3. * Copyright (C) 2022-2023 Wu Yiming
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "la_5.h"
  19. extern LA MAIN;
  20. int la_GetKeyablePropertyStorageSize(laProp* p);
  21. laAction* laAnimiationNewAction(char* Name){
  22. laAction* aa=memAcquire(sizeof(laAction));
  23. if(!Name || !Name[0]){ Name="New Action"; }
  24. strSafeSet(&aa->Name,Name);
  25. aa->Length=5; aa->FrameCount=120;
  26. memAssignRef(MAIN.Animation,&MAIN.Animation->CurrentAction,aa);
  27. lstAppendItem(&MAIN.Animation->Actions,aa); laNotifyUsers("la.animation.actions");
  28. return aa;
  29. }
  30. laActionChannel* laAnimationEnsureChannel(laAction* aa, void* hyper1, laProp* p){
  31. laActionChannel* acf=0;
  32. int DataSize=la_GetKeyablePropertyStorageSize(p); if(!DataSize) return 0;
  33. for(laActionChannel* ac=aa->Channels.pFirst;ac;ac=ac->Item.pNext){
  34. if(ac->For==hyper1 && ac->Prop==p){ acf=ac; break; }
  35. }
  36. if(acf) return acf;
  37. acf=memAcquire(sizeof(laActionChannel));
  38. memAssignRef(acf,&acf->For,hyper1); acf->Prop=p;
  39. acf->DataSize = DataSize;
  40. char _name[128]={0}, *name=_name; laTryGetInstanceIdentifier(hyper1, p->Container,_name,&name);
  41. strSafeSet(&acf->CachedName,name); strSafePrint(&acf->CachedName," ⯈ %s",p->Identifier);
  42. lstAppendItem(&aa->Channels,acf); laNotifyUsers("la.animation.current_action.channels");
  43. return acf;
  44. }
  45. laActionChannel* laAnimationEnsureFrame(laActionChannel* ac, int frame){
  46. laActionKey* akf=0,*beforeakf=0;
  47. for(laActionKey* ak=ac->Keys.pFirst;ak;ak=ak->Item.pNext){
  48. if(ak->At==frame){ akf=ak; break; } if(ak->At>frame){ beforeakf=ak; break; }
  49. }
  50. if(!akf){
  51. akf=memAcquireSimple(sizeof(laActionKey)-sizeof(uint64_t)+ac->DataSize);
  52. akf->At=frame;
  53. if(beforeakf){ lstInsertItemBefore(&ac->Keys, akf, beforeakf); }
  54. else{ lstAppendItem(&ac->Keys, akf); }
  55. }
  56. return akf;
  57. }
  58. void laAnimationStoreKeyValue(laActionChannel* ac, laActionKey* ak){
  59. laPropPack PP={0}; laPropStep PS={0};
  60. PS.p=ac->Prop; PS.Type='.'; PS.UseInstance=ac->For; PP.LastPs=&PS; PP.EndInstance=ac->For;
  61. switch(ac->Prop->PropertyType){
  62. case LA_PROP_INT: case LA_PROP_INT | LA_PROP_ARRAY: laGetIntArray(&PP,(int*)&ak->Data); break;
  63. case LA_PROP_FLOAT: case LA_PROP_FLOAT | LA_PROP_ARRAY: laGetFloatArray(&PP,(real*)&ak->Data); break;
  64. case LA_PROP_ENUM: case LA_PROP_ENUM | LA_PROP_ARRAY: laGetEnumArray(&PP,(laEnumItem**)&ak->Data); break;
  65. case LA_PROP_SUB: case LA_PROP_OPERATOR: case LA_PROP_STRING: case LA_PROP_RAW: default: return;
  66. }
  67. }
  68. laActionKey* laAnimationInsertKeyFrame(laAction* aa, void* hyper1, laProp* p){
  69. if(!aa) return 0;
  70. laActionChannel* ac=laAnimationEnsureChannel(aa,hyper1,p); if(!ac || !ac->For) return;
  71. int frame=LA_ACTION_FRAME(aa);
  72. laActionKey* ak=laAnimationEnsureFrame(ac,frame);
  73. laAnimationStoreKeyValue(ac,ak);
  74. laNotifyUsers("la.animation.current_action");
  75. return ak;
  76. }
  77. void laAnimationSetPlayStatus(int PlayStatus){
  78. if(PlayStatus>3||PlayStatus<0) PlayStatus=0; MAIN.Animation->PlayStatus=PlayStatus;
  79. if(PlayStatus) laRecordTime(&MAIN.Animation->TimeOrigin);
  80. laNotifyUsers("la.animation.play_status");
  81. }
  82. void laAnimationSetPlayHead(real time){
  83. MAIN.Animation->PlayHead=time;
  84. }
  85. int OPINV_AnimationNewAction(laOperator *a, laEvent *e){
  86. laAnimiationNewAction(0);
  87. return LA_FINISHED;
  88. }
  89. int OPINV_AnimationPlayAction(laOperator *a, laEvent *e){
  90. char* str=strGetArgumentString(a->ExtraInstructionsP, "mode");
  91. int PlayStatus=LA_ANIMATION_STATUS_PAUSED;
  92. if(strSame(str,"forward")){ PlayStatus=LA_ANIMATION_STATUS_PLAY_FWD; }
  93. elif(strSame(str,"reverse")){ if(MAIN.Animation->PlayHead>0) PlayStatus=LA_ANIMATION_STATUS_PLAY_REV; }
  94. laAnimationSetPlayStatus(PlayStatus);
  95. return LA_FINISHED;
  96. }
  97. int OPINV_AnimationResetTime(laOperator *a, laEvent *e){
  98. laAnimationSetPlayHead(0);
  99. return LA_FINISHED;
  100. }
  101. laActionChannel* laAnimationGetFrame(laActionChannel* ac, int frame){
  102. if(ac->Keys.pFirst==ac->Keys.pLast){ return ac->Keys.pFirst; }
  103. for(laActionKey* ak=ac->Keys.pFirst;ak;ak=ak->Item.pNext){
  104. if(ak->At<=frame){ return ak; }
  105. }
  106. return ac->Keys.pFirst;
  107. }
  108. void la_AnimationInterpolateKeys(laActionChannel* ac, laActionKey* ak1, laActionKey* ak2, real PlayHead_mul_Length, void** data){
  109. int* id1,*id2,*iret=(*data); real* fd1,*fd2,*fret=(*data);
  110. if(!ak2){ *data=&ak1->Data; return; }
  111. int arrlen=ac->Prop->Len?ac->Prop->Len:1;
  112. real fac=tnsGetRatiod(ak1->At,ak2->At,PlayHead_mul_Length); TNS_CLAMP(fac,0,1);
  113. switch(ac->Prop->PropertyType){
  114. case LA_PROP_INT: case LA_PROP_INT|LA_PROP_ARRAY:
  115. id1=&ak1->Data;id2=&ak2->Data; for(int i=0;i<arrlen;i++){ iret[i]=tnsLinearItp(id1[i],id2[i],fac); } break;
  116. case LA_PROP_FLOAT: case LA_PROP_FLOAT|LA_PROP_ARRAY:
  117. fd1=&ak1->Data;fd2=&ak2->Data; for(int i=0;i<arrlen;i++){ fret[i]=tnsLinearItp(fd1[i],fd2[i],fac); } break;
  118. default:
  119. *data=ak1->Data; break;
  120. }
  121. }
  122. void la_AnimationSetChannelValue(laActionChannel* ac, void* data){
  123. laPropPack PP={0}; laPropStep PS={0};
  124. PS.p=ac->Prop; PS.Type='.'; PS.UseInstance=ac->For; PP.LastPs=&PS; PP.EndInstance=ac->For;
  125. switch(ac->Prop->PropertyType){
  126. case LA_PROP_INT: laSetInt(&PP,*((int*)data)); break;
  127. case LA_PROP_INT|LA_PROP_ARRAY: laSetIntArrayAllArray(&PP,(int*)data); break;
  128. case LA_PROP_FLOAT: laSetFloat(&PP,*((real*)data)); break;
  129. case LA_PROP_FLOAT|LA_PROP_ARRAY: laSetFloatArrayAllArray(&PP,(real*)data); break;
  130. case LA_PROP_ENUM: laSetEnum(&PP,*((int*)data)); break;
  131. //case LA_PROP_ENUM|LA_PROP_ARRAY: laSetEnumArrayAllArray(&PP,(real*)data); break; //doesnt work
  132. default: break;
  133. }
  134. }
  135. void la_AnimationEvaluateActionChannels(laAction* aa){
  136. int64_t _data[16]; void* data=_data;
  137. int frame=LA_ACTION_FRAME(aa); real totframe=aa->PlayHead*aa->FrameCount;
  138. for(laActionChannel* ac=aa->Channels.pFirst;ac;ac=ac->Item.pNext){
  139. laActionKey* ak1=laAnimationGetFrame(ac,frame); if(!ak1) continue;
  140. laActionKey* ak2=ak1->Item.pNext;
  141. la_AnimationInterpolateKeys(ac,ak1,ak2,totframe,&data);
  142. la_AnimationSetChannelValue(ac, data);
  143. }
  144. }
  145. void la_AnimationEvaluateActions(){
  146. int any=0;
  147. for(laAction* aa=MAIN.Animation->Actions.pFirst;aa;aa=aa->Item.pNext){
  148. real UseTime=MAIN.Animation->PlayHead-aa->Offset;
  149. int repeats=UseTime/aa->Length;
  150. real remaining=UseTime-repeats*aa->Length;
  151. while(remaining<0){ remaining+=aa->Length; }
  152. if(aa->PlayMode==LA_ANIMATION_PLAY_MODE_REPEAT){ aa->PlayHead=remaining/aa->Length; }
  153. elif(aa->PlayMode==LA_ANIMATION_PLAY_MODE_HOLD){ aa->PlayHead=(UseTime>aa->Length)?1.0:(UseTime<0?0:UseTime/aa->Length); }
  154. elif(aa->PlayMode==LA_ANIMATION_PLAY_MODE_BOUNCE){ real t=remaining/aa->Length; aa->PlayHead=(repeats%2)?(1-t):t; }
  155. any=1;
  156. la_AnimationEvaluateActionChannels(aa);
  157. }
  158. if(any) laNotifyUsers("la.animation");
  159. }
  160. void la_AnimationPreFrame(){
  161. if(MAIN.Animation->PlayHead<0){
  162. MAIN.Animation->PlayHead=0; laAnimationSetPlayStatus(0);
  163. la_AnimationEvaluateActions();
  164. laNotifyUsers("la.animation.play_head");
  165. }
  166. if(MAIN.Animation->PlayStatus){
  167. la_AnimationEvaluateActions();
  168. }
  169. }
  170. void la_AnimationPostFrame(){
  171. laTimeRecorder cur={0};
  172. if(MAIN.Animation->PlayStatus){ laRecordTime(&cur);
  173. real td=laTimeElapsedSecondsf(&cur,&MAIN.Animation->TimeOrigin);
  174. laRecordTime(&MAIN.Animation->TimeOrigin);
  175. if(MAIN.Animation->PlayStatus==LA_ANIMATION_STATUS_PLAY_REV){ td*=-1; }
  176. MAIN.Animation->PlayHead+=td; laNotifyUsers("la.animation.play_head");
  177. }
  178. }
  179. void laget_AnimationChannelName(laActionChannel *p, char *result, char** here){
  180. }
  181. int LAMOD_AnimationActionsCanvas(laOperator *a, laEvent *e){
  182. laUiItem *ui = a->Instance; laBoxedTheme *bt = (*ui->Type->Theme);
  183. laCanvasExtra *ex = a->CustomData; laAction* aa=ui->PP.EndInstance;
  184. if(!aa) LA_RUNNING_PASS;
  185. int W, H; W = ui->R - ui->L; H = ui->B - ui->U;
  186. int ShowSide=(ex->ShowLegend&&ex->LW<W-2*LA_RH);
  187. int ll=ui->L, lr=ll+(ShowSide?ex->LW:0), tl=lr, tr=ui->R;
  188. int FW=LA_RH/2;
  189. int Channels=aa?lstCountElements(&aa->Channels):0;
  190. int Modal=0; int mid=((W-lr)/2);
  191. if(e->Type==LA_M_MOUSE_DOWN){
  192. ex->UiMode=1; ex->ClickedX=e->x; ex->ClickedY=e->y; Modal=1; ex->Dragging=10;
  193. }elif(e->Type==LA_M_MOUSE_UP || e->Type==LA_L_MOUSE_UP){
  194. ex->UiMode=0; Modal=1; ex->Dragging=0; ex->TargetIndexVali=0;
  195. }
  196. if(ex->UiMode==1){
  197. if(e->Type&LA_MOUSE_EVENT){
  198. ex->PanY-=e->y-ex->ClickedY; ex->PanX-=e->x-ex->ClickedX;
  199. ex->ClickedX=e->x; ex->ClickedY=e->y; Modal=1;
  200. }
  201. }elif(ex->UiMode==2){
  202. if(e->Type&LA_MOUSE_EVENT){
  203. ex->LW=e->x-ui->L+LA_SEAM_W; ex->ClickedX=e->x; ex->ClickedY=e->y; Modal=1;
  204. if(ex->LW<LA_RH*3 && ex->LW>=LA_RH/2){ ex->LW=LA_RH*3; }
  205. if(ex->LW<LA_RH/2 && ex->Dragging!=12){ ex->ShowLegend=0; ex->LW=0; }
  206. if(ex->LW<LA_RH*3){ ex->LW=LA_RH*3;}
  207. }
  208. }
  209. int MaxDN=LA_RH*(Channels+1)-H+bt->TP+bt->BP; if(MaxDN<0) MaxDN=0;
  210. if(!Modal){
  211. if(e->x<=lr){
  212. if(e->Type==LA_MOUSE_WHEEL_DOWN){ ex->PanY+=LA_RH*MAIN.ScrollingSpeed; Modal=1; }
  213. if(e->Type==LA_MOUSE_WHEEL_UP){ ex->PanY-=LA_RH*MAIN.ScrollingSpeed; Modal=1; }
  214. if(e->x>=lr-LA_SEAM_W*2){ if(!ex->TargetIndexVali){ ex->TargetIndexVali=1; Modal=1; }
  215. if(e->Type==LA_L_MOUSE_DOWN){
  216. ex->UiMode=2; ex->ClickedX=e->x; ex->ClickedY=e->y; Modal=1; ex->Dragging=10; Modal=1;
  217. }
  218. }else{ if(ex->TargetIndexVali){ ex->TargetIndexVali=0; Modal=1; } }
  219. }else{
  220. if((!ex->ShowLegend)&&e->x<=ll+LA_SEAM_W*2){
  221. if(!ex->TargetIndexVali){ ex->TargetIndexVali=1; Modal=1; }
  222. if(e->Type==LA_L_MOUSE_DOWN){ ex->LW=LA_RH*4; ex->Dragging=12; ex->ShowLegend=1; Modal=1; ex->UiMode=2; ex->TargetIndexVali=1; }
  223. }else{ if(ex->TargetIndexVali){ ex->TargetIndexVali=0; Modal=1; } }
  224. if(e->Type==LA_MOUSE_WHEEL_DOWN){ ex->ZoomX*=0.9; ex->PanX+=mid; ex->PanX*=0.9; ex->PanX-=mid; Modal=1; }
  225. if(e->Type==LA_MOUSE_WHEEL_UP){ ex->ZoomX*=1.1; ex->PanX+=mid; ex->PanX*=1.1; ex->PanX-=mid; Modal=1; }
  226. }
  227. }
  228. if(ex->PanY>MaxDN){ ex->PanY=MaxDN; } if(ex->PanY<0){ ex->PanY=0; }
  229. if(ex->PanX<0){ ex->PanX=0; }
  230. if(ex->TargetIndexVali){ laSetWindowCursor(LA_LEFT_AND_RIGHT); }else{ laSetWindowCursor(LA_ARROW); }
  231. if(Modal){ laRedrawCurrentPanel(); return LA_RUNNING; }
  232. return LA_RUNNING_PASS;
  233. }
  234. void la_AnimationActionCanvasInit(laUiItem *ui){
  235. la_CanvasInit(ui);
  236. laCanvasExtra* ex=ui->Extra; ex->LW=LA_RH*7; ex->ShowLegend=1;
  237. }
  238. void la_AnimationActionDrawCanvas(laBoxedTheme *bt, laAction *aa, laUiItem* ui){
  239. laCanvasExtra* ex=ui->Extra; //laAction* aa=ui->PP.EndInstance;
  240. int W, H; W = ui->R - ui->L; H = ui->B - ui->U; if (W<=0 || H<=0) return;
  241. int ShowSide=(ex->ShowLegend&&ex->LW<W-2*LA_RH);
  242. int ll=ui->L, lr=ll+(ShowSide?ex->LW-1:0), tl=lr, tr=ui->R;
  243. int FW=LA_RH/2;
  244. //if (!e->OffScr || e->OffScr->pColor[0]->Height != ui->B - ui->U || e->Be.OffScr->pColor[0]->Width != ui->R - ui->L){
  245. // if (e->OffScr) tnsDelete2DOffscreen(e->OffScr);
  246. // e->OffScr = tnsCreate2DOffscreen(GL_RGBA, W, H, MAIN.PanelMultisample, 1, 0);
  247. //}
  248. real *bkg=laThemeColor(bt,LA_BT_NORMAL);
  249. real *txt=laThemeColor(bt,LA_BT_TEXT);
  250. real *act=laThemeColor(bt,LA_BT_ACTIVE);
  251. tnsUseNoTexture();
  252. tnsColor4d(LA_COLOR3(bkg),bkg[3]*0.3);
  253. tnsVertex2d(tl, ui->U); tnsVertex2d(tr, ui->U);
  254. tnsVertex2d(tr, ui->B); tnsVertex2d(tl, ui->B);
  255. tnsPackAs(GL_TRIANGLE_FAN);
  256. int row=1,curframe,cx; real fl,fr;
  257. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  258. tnsVertex2d(ui->L, ui->U+bt->TP+LA_RH); tnsVertex2d(ui->R, ui->U+bt->TP+LA_RH);
  259. tnsVertex2d(ui->R, ui->U); tnsVertex2d(ui->L, ui->U);
  260. tnsPackAs(GL_TRIANGLE_FAN);
  261. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  262. tnsVertex2d(tl, LA_RH+ui->U); tnsVertex2d(tr, LA_RH+ui->U);
  263. tnsPackAs(GL_LINES);
  264. tnsFlush();
  265. int sx,sy,sw,sh,vl,vr,vu,vb;
  266. la_DoUiScissor(ui,&sx,&sy,&sw,&sh,&vl,&vr,&vu,&vb);
  267. if(aa){
  268. curframe=LA_ACTION_FRAME(aa); fl=tl+curframe*FW*ex->ZoomX-ex->PanX, fr=tl+(curframe+1)*FW*ex->ZoomX-ex->PanX;
  269. tnsUseNoTexture();
  270. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  271. tnsVertex2d(fl, ui->U); tnsVertex2d(fr, ui->U);
  272. tnsVertex2d(fr, ui->B); tnsVertex2d(fl, ui->B);
  273. tnsPackAs(GL_TRIANGLE_FAN);
  274. tnsFlush(); glLineWidth(2);
  275. for(laActionChannel* ac=aa->Channels.pFirst;ac;ac=ac->Item.pNext){
  276. real ku=ui->U+bt->TP+row*LA_RH-ex->PanY,kb=ku+LA_RH;
  277. for(laActionKey* ak=ac->Keys.pFirst;ak;ak=ak->Item.pNext){
  278. real kl=tl+ak->At*FW*ex->ZoomX-ex->PanX, kr=tl+(ak->At+1)*FW*ex->ZoomX-ex->PanX;
  279. if(curframe==ak->At) tnsColor4d(LA_COLOR3(txt),txt[3]*0.6);
  280. else tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
  281. tnsVertex2d(kl, ku); tnsVertex2d(kr, ku);
  282. tnsVertex2d(kr, kb); tnsVertex2d(kl, kb);
  283. tnsPackAs(GL_TRIANGLE_FAN);
  284. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT_ACTIVE));
  285. tnsVertex2d(kl, ku); tnsVertex2d(kr, ku);
  286. tnsVertex2d(kr, kb); tnsVertex2d(kl, kb);
  287. tnsPackAs(GL_LINE_LOOP);
  288. }
  289. row++;
  290. }
  291. tnsFlush(); glLineWidth(1);
  292. tnsColor4dv(laAccentColor(LA_BT_TEXT_ACTIVE));
  293. cx=tl+aa->PlayHead*aa->FrameCount*FW*ex->ZoomX-ex->PanX; tnsVertex2d(cx, ui->U); tnsVertex2d(cx, ui->B);
  294. tnsPackAs(GL_LINES); glLineWidth(3); tnsFlush(); glLineWidth(1);
  295. tnsColor4dv(laAccentColor(LA_BT_TEXT_ACTIVE));
  296. tnsVertex2d(cx, ui->U+LA_RH); tnsVertex2d(cx+LA_RH, ui->U+LA_RH);
  297. tnsVertex2d(cx+LA_RH, ui->U); tnsVertex2d(cx, ui->U);
  298. tnsPackAs(GL_TRIANGLE_FAN);
  299. char buf[32]; sprintf(buf,"%d",curframe);
  300. tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_TEXT_ACTIVE),cx+bt->LP,cx+LA_RH*2,ui->U+bt->TP,0);
  301. tnsPackAs(GL_TRIANGLE_FAN); tnsUseNoTexture();
  302. }
  303. if(ShowSide){
  304. tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
  305. tnsVertex2d(ll, ui->U); tnsVertex2d(lr, ui->U);
  306. tnsVertex2d(lr, ui->B); tnsVertex2d(ll, ui->B);
  307. tnsPackAs(GL_TRIANGLE_FAN);
  308. if(!aa){
  309. tnsDrawStringAuto("No action selected",laThemeColor(bt,LA_BT_TEXT),ll+bt->LP,lr-bt->RP,ui->U+bt->BP,0);
  310. }else{ int row=1;
  311. for(laActionChannel* ac=aa->Channels.pFirst;ac;ac=ac->Item.pNext){
  312. tnsDrawStringAuto(ac->CachedName->Ptr,laThemeColor(bt,LA_BT_TEXT),ll+bt->LP,lr-bt->RP,ui->U+bt->TP+row*LA_RH-ex->PanY,0);
  313. row++;
  314. }
  315. }
  316. }
  317. if(ex->TargetIndexVali==1){
  318. int LR=TNS_MAX2(lr,ui->L+LA_SEAM_W*2);
  319. tnsColor4dv(act);tnsUseNoTexture();
  320. tnsVertex2d(LR, ui->B); tnsVertex2d(LR-LA_SEAM_W*2, ui->B);
  321. tnsVertex2d(LR-LA_SEAM_W*2, ui->U); tnsVertex2d(LR, ui->U);
  322. tnsPackAs(GL_TRIANGLE_FAN);
  323. }
  324. tnsFlush();
  325. tnsViewportWithScissor(sx,sy,sw,sh);
  326. tnsOrtho(vl,vr,vb,vu,-100,100);
  327. tnsUseNoTexture();
  328. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  329. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  330. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  331. tnsPackAs(GL_LINE_LOOP);
  332. }
  333. void la_AnimationActionDrawOverlay(laUiItem *ui, int h){
  334. laCanvasExtra *e = ui->Extra; laBoxedTheme *bt = (*ui->Type->Theme);
  335. tnsUseImmShader();
  336. if(MAIN.CurrentWindow->MaximizedUi!=ui){
  337. tnsUseNoTexture();
  338. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  339. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  340. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  341. tnsPackAs(GL_LINE_LOOP);
  342. }
  343. if (e->DrawCursor){
  344. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  345. int drawx=(e->DrawCursor==LA_CANVAS_CURSOR_CROSS)||(e->DrawCursor==LA_CANVAS_CURSOR_X);
  346. int drawy=(e->DrawCursor==LA_CANVAS_CURSOR_CROSS)||(e->DrawCursor==LA_CANVAS_CURSOR_Y);
  347. if(drawx) tnsVertex2d(e->OnX, ui->U); tnsVertex2d(e->OnX, ui->B);
  348. if(drawy) tnsVertex2d(ui->L, e->OnY); tnsVertex2d(ui->R, e->OnY);
  349. tnsPackAs(GL_LINES);
  350. tnsFlush();
  351. }
  352. return;
  353. }
  354. void la_RegisterAnimationResources(){
  355. laPropContainer *pc; laProp *p; laOperatorType *at; laEnumProp *ep;
  356. laCreateOperatorType("LA_animation_new_action", "New Action", "Add a new action",0,0,0,OPINV_AnimationNewAction,0,U'🞦',0);
  357. laCreateOperatorType("LA_animation_set_play_status", "Set Play", "Set global animation player status",0,0,0,OPINV_AnimationPlayAction,0,0,0);
  358. laCreateOperatorType("LA_animation_reset_time", "Reset Time", "Reset Time",0,0,0,OPINV_AnimationResetTime,0,U'🡄',0);
  359. laCanvasTemplate* ct=laRegisterCanvasTemplate("la_AnimationActionDrawCanvas", "la_animation_action", LAMOD_AnimationActionsCanvas, la_AnimationActionDrawCanvas, la_AnimationActionDrawOverlay, la_AnimationActionCanvasInit, la_CanvasDestroy);
  360. pc = laCanvasHasExtraProps(ct,sizeof(laCanvasExtra),2); laAddIntProperty(pc, "height_coeff", "Ui Height", "Ui Height Coefficiency Entry", 0, 0, "Rows", 100, -100, 1, 0, 0, offsetof(laCanvasExtra, HeightCoeff), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  361. }