*/}}

la_widgets_viewers.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  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. extern struct _tnsMain *T;
  21. //============================================================= [Draw]
  22. extern tnsFontManager *FM;
  23. void la_RootObjectDrawFullscreenQuad(tnsOffscreen* DeferredOffScr,tnsCamera* c, real Aspect){
  24. real FOV = c->FOV;
  25. tnsMatrix44d mat;
  26. tnsGetMVMatrix(mat);
  27. real vv[3]={0,0,-1};
  28. real ViewDir[3]={0},vdTR[3]={0},vdBR[3]={0},vdTL[3]={0},vdBL[3]={0};
  29. tnsApplyRotation43d(ViewDir,mat,vv);
  30. real fovv=FOV/2, fovh=fovh=atan(tan(FOV/2)*Aspect);
  31. vv[0]=tan(fovh); vv[1]=tan(fovv); tnsApplyRotation43d(vdTR,mat,vv); // note don't normalize those.
  32. vv[0]=tan(fovh); vv[1]=tan(-fovv);tnsApplyRotation43d(vdBR,mat,vv);
  33. vv[0]=tan(-fovh);vv[1]=tan(-fovv);tnsApplyRotation43d(vdBL,mat,vv);
  34. vv[0]=tan(-fovh);vv[1]=tan(fovv); tnsApplyRotation43d(vdTL,mat,vv);
  35. tnsUseRayShader();
  36. tnsEnableShaderv(T->RayShader);
  37. tnsSetRayShaderUniformTextures(DeferredOffScr);
  38. real uv[12]; tnsMakeQuad3d(uv, LA_COLOR3(vdTL), LA_COLOR3(vdTR), LA_COLOR3(vdBR), LA_COLOR3(vdBL));
  39. real vt[8]; tnsMakeQuad2d(vt, -1,1, 1,1, 1,-1, -1,-1);
  40. tnsTexCoordArray3d(uv,4);
  41. tnsVertexArray2d(vt,4);
  42. tnsPackAs(GL_TRIANGLE_FAN);
  43. glUniform3f(T->RayShader->uViewDir,LA_COLOR3(ViewDir));
  44. glUniform3f(T->RayShader->uViewPos,LA_COLOR3(c->Base.Location));
  45. glUniform1f(T->RayShader->uFOV,FOV);
  46. tnsFlush();
  47. tnsUseImmShader();
  48. }
  49. #define LA_DEPTH_RESOLUTION 1024
  50. void la_3DViewEnsureCamera(laCanvasExtra* e);
  51. void la_RootObjectDraw(laBoxedTheme *bt, tnsObject *root, laUiItem* ui){
  52. laCanvasExtra *e = ui->Extra;
  53. la_3DViewEnsureCamera(e);
  54. tnsCamera *c = e->UsingCamera ? e->UsingCamera : e->ViewingCamera;
  55. int W, H;
  56. W = ui->R - ui->L;
  57. H = ui->B - ui->U;
  58. tnsFlush();
  59. if (!W || !H) return;
  60. if (!e->OffScr || e->OffScr->pColor[0]->Height != ui->B - ui->U || e->OffScr->pColor[0]->Width != ui->R - ui->L){
  61. if (e->OffScr) tnsDelete2DOffscreen(e->OffScr);
  62. //if (e->DeferredOffScr) tnsDelete2DOffscreen(e->DeferredOffScr);
  63. e->OffScr = tnsCreateDeferredOffscreen(W,H,MAIN.PanelMultisample);//tnsCreate2DOffscreen(GL_RGBA, W, H, MAIN.PanelMultisample ,1, 0);
  64. //e->DeferredOffScr = tnsCreateDeferredOffscreen(W,H,MAIN.PanelMultisample);
  65. }
  66. if (0){//(e->CurrentScene && e->CurrentScene->ActiveSun){
  67. //if(!e->OffScrShadow) e->OffScrShadow = tnsCreate2DOffscreen(0, LA_DEPTH_RESOLUTION, LA_DEPTH_RESOLUTION, MAIN.PanelMultisample, 1, 0);
  68. //tnsUseNoTexture();
  69. //tnsDrawToOffscreen(e->OffScrShadow, 1, TNS_ATTACHMENT_ARRAY_NONE);
  70. //tnsViewportWithScissor(0,0,LA_DEPTH_RESOLUTION,LA_DEPTH_RESOLUTION);
  71. //glEnable(GL_DEPTH_TEST);
  72. //glClearDepth(1.0); glClear(GL_DEPTH_BUFFER_BIT);
  73. //tnsResetViewMatrix();tnsResetModelMatrix();tnsResetProjectionMatrix();
  74. //tnsEnableShaderv(T->ShadowShader);
  75. //tnsUseShadowShader();
  76. //tnsApplyShadowCameraView(e->CurrentScene->ActiveSun);
  77. //
  78. //real p[12];
  79. //tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  80. //tnsMakeQuad3d(p, -100,-100, 25,-100,100, 25,100,100, 25,100,-100, 25);
  81. //tnsVertexArray3d(p, 4); tnsPackAs(GL_TRIANGLE_FAN);
  82. //tnsMakeQuad3d(p, -100,-100, 74,-100,100, 74,100,100, 74,100,-100, 74);
  83. //tnsVertexArray3d(p, 4); tnsPackAs(GL_TRIANGLE_FAN);
  84. ////tnsDrawFloor(e->ViewingCamera->Base.GLocation, e->ViewingCamera->ZMax, e->ShowAxis);
  85. //tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  86. //tnsDrawFloor(e->ViewingCamera->Base.GLocation, e->ViewingCamera->ZMax, e->ShowAxis);
  87. //tnsEnableShaderv(T->immShader);
  88. //tnsFlush();
  89. tnsDrawToOffscreen(e->OffScr,1,0);
  90. tnsViewportWithScissor(0, 0, W, H);
  91. tnsClearColorv(laThemeColor(bt,LA_BT_NORMAL));
  92. tnsClearAll();
  93. //tnsUseSceneShader();
  94. //tnsEnableShaderv(T->SceneShader);
  95. //tnsApplyShadowCameraView(e->CurrentScene->ActiveSun);
  96. tnsApplyCameraView(W, H, c);
  97. //
  98. //tnsUseTexture(e->OffScrShadow->pDepth);
  99. //
  100. //tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  101. //tnsMakeQuad3d(p, -100,-100, 25,-100,100, 25,100,100, 25,100,-100, 25);
  102. //tnsVertexArray3d(p, 4); tnsPackAs(GL_TRIANGLE_FAN);
  103. //tnsMakeQuad3d(p, -100,-100, 74,-100,100, 74,100,100, 74,100,-100, 74);
  104. //tnsVertexArray3d(p, 4); tnsPackAs(GL_TRIANGLE_FAN);
  105. //tnsUseNoTexture();
  106. //if (!e->LineDrawingMode && e->ShowFloorGrid){
  107. // tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  108. // tnsDrawFloor(e->ViewingCamera->Base.GLocation, e->ViewingCamera->ZMax, e->ShowAxis);
  109. // tnsFlush();
  110. //}
  111. //
  112. //tnsFlush();
  113. }else if(e->OffScrShadow){ tnsDelete2DOffscreen(e->OffScrShadow); }
  114. //{
  115. // tnsDrawToOffscreen(e->OffScr, 1, 0);
  116. // //tnsUseShader(T->TEST_MatcapShader);
  117. // tnsEnableShaderv(T->TEST_MatcapShader);
  118. // tnsViewportWithScissor(0, 0, W, H);
  119. // tnsClearColorv(laThemeColor(bt,LA_BT_NORMAL));
  120. // tnsClearAll();
  121. //}
  122. tnsDrawToOffscreen(e->OffScr,3,TNS_ATTACHMENT_ARRAY_0_1_2);
  123. //tnsDrawToOffscreen(e->DeferredOffScr,3,TNS_ATTACHMENT_ARRAY_0_1_2);
  124. tnsViewportWithScissor(0, 0, W, H); glDepthMask(GL_TRUE);
  125. tnsClearColorv(laThemeColor(bt,LA_BT_NORMAL)); tnsClearAll(); float gpos_clear[]={-1e20, -1e20, -1e20, 0};
  126. glClearBufferfv(GL_COLOR, 2, gpos_clear);
  127. tnsApplyCameraView(W, H, c);
  128. tnsPushMatrix();
  129. tnsPopMatrix(); //those are necessary when ui is the first in list;
  130. laListHandle xrays={0};
  131. if(root){
  132. glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND);
  133. tnsUseShader(T->immShader); tnsEnableShaderv(T->immShader);
  134. tnsUnbindTexture(); tnsUniformUseTexture(T->immShader,0,0); tnsUseMultiplyColor(0);
  135. tnsDrawObjectTree(root, 0, 0, e->SelectMode, 0, e->SelectThrough,&xrays);
  136. glLineWidth(3);
  137. glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(-1,-1);
  138. glDepthMask(GL_FALSE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  139. tnsDrawObjectTree(root, root->Active, 1, 0, 0, 0, 0);
  140. glDepthMask(GL_TRUE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
  141. glLineWidth(1);
  142. glDisable(GL_POLYGON_OFFSET_LINE);
  143. }
  144. if (!e->LineDrawingMode && e->ShowFloorGrid){
  145. tnsUseNoTexture();
  146. real* color=laThemeColor(bt,LA_BT_BORDER); tnsColor4d(LA_COLOR3(color),0.4);
  147. tnsDrawFloor(e->ViewingCamera->Base.GLocation, e->ViewingCamera->ZMax, e->ShowAxis);
  148. tnsFlush();
  149. }
  150. tnsDrawXRay(&xrays,e->SelectMode,0,e->SelectThrough);
  151. if(root){
  152. glDisable(GL_DEPTH_TEST);
  153. tnsDrawCursor(root);
  154. glPointSize(8);
  155. tnsDrawObjectOrigins(root,root->Active,0); tnsFlush();
  156. glPointSize(1);
  157. glEnable(GL_DEPTH_TEST);
  158. }
  159. //laInvoke(0,"M_select",e,&ui->ExtraPP,0,0);
  160. //glColorMask(GL_FALSE, GL_FALSE,GL_FALSE,GL_FALSE);
  161. //tnsDrawObjectTree(e->CurrentScene, 0);
  162. tnsFlush();
  163. //glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
  164. glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND);
  165. //tnsDrawToOffscreen(e->OffScr, 1,0);
  166. //tnsClearColorv(laThemeColor(bt,LA_BT_NORMAL)); tnsClearAll();
  167. //la_RootObjectDrawFullscreenQuad(e->DeferredOffScr, c, (real)W/(real)H);
  168. }
  169. void la_RootObjectDrawOverlay(laUiItem *ui, int h){
  170. laCanvasExtra *e = ui->Extra;
  171. laBoxedTheme *bt = (*ui->Type->Theme);
  172. tnsDraw2DTextureDirectly(e->OffScr->pColor[0], ui->L, ui->U, ui->R - ui->L, ui->B - ui->U);
  173. //if(e->OffScrShadow){
  174. //tnsDraw2DTextureDirectly(e->OffScrShadow->pDepth, ui->L, ui->U, ui->R - ui->L, ui->B - ui->U);
  175. //}
  176. tnsUseNoTexture();
  177. if (e->DrawCursor){
  178. if(e->DrawCursor==LA_CANVAS_CURSOR_ARROW){
  179. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  180. tnsVertex2d(e->OnX, e->OnY); tnsVertex2d(e->TargetX, e->TargetY);
  181. tnsPackAs(GL_LINES);
  182. }else{
  183. if(e->DrawCursor==LA_CANVAS_CURSOR_BOX){
  184. tnsColor4dv(laAccentColor(LA_BT_NORMAL));
  185. tnsVertex2d(e->ClickedX, e->ClickedY); tnsVertex2d(e->ClickedX, e->OnY);
  186. tnsVertex2d(e->OnX, e->OnY); tnsVertex2d(e->OnX, e->ClickedY);
  187. tnsPackAs(GL_TRIANGLE_FAN);
  188. tnsColor4dv(laAccentColor(LA_BT_TEXT));
  189. tnsVertex2d(e->ClickedX, e->ClickedY); tnsVertex2d(e->ClickedX, e->OnY);
  190. tnsVertex2d(e->OnX, e->OnY); tnsVertex2d(e->OnX, e->ClickedY);
  191. tnsPackAs(GL_LINE_LOOP);
  192. }
  193. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  194. int drawx=(e->DrawCursor==LA_CANVAS_CURSOR_CROSS)||(e->DrawCursor==LA_CANVAS_CURSOR_X);
  195. int drawy=(e->DrawCursor==LA_CANVAS_CURSOR_CROSS)||(e->DrawCursor==LA_CANVAS_CURSOR_Y);
  196. if(drawx) tnsVertex2d(e->OnX, ui->U); tnsVertex2d(e->OnX, ui->B);
  197. if(drawy) tnsVertex2d(ui->L, e->OnY); tnsVertex2d(ui->R, e->OnY);
  198. tnsPackAs(GL_LINES);
  199. }
  200. }
  201. if(MAIN.CurrentWindow->MaximizedUi!=ui){
  202. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  203. tnsVertex2d(ui->L, ui->U);
  204. tnsVertex2d(ui->R, ui->U);
  205. tnsVertex2d(ui->R, ui->B);
  206. tnsVertex2d(ui->L, ui->B);
  207. tnsPackAs(GL_LINE_LOOP);
  208. }
  209. tnsFlush();
  210. char* MaxIco=(MAIN.CurrentWindow->MaximizedUi!=ui)?"🡹":"🡻";
  211. tnsVector4d color; tnsVectorCopy4d(laThemeColor(bt,LA_BT_TEXT),color);
  212. color[3]=ui->State==LA_UI_NORMAL?0.0:(ui->State==LA_UI_ACTIVE?0.5:1.0);
  213. int startx=(ui->R+ui->L)/2-LA_RH2*2;
  214. tnsDrawStringAuto("☰",color,startx, startx+LA_RH, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  215. tnsDrawStringAuto(MaxIco,color,startx+LA_RH, startx+LA_2RH, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  216. if(ui->Expand>=0 && ui!=MAIN.CurrentWindow->MaximizedUi)
  217. tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  218. }
  219. void la_CanvasDrawTexture(laBoxedTheme *bt, tnsTexture *t, laUiItem* ui){
  220. laCanvasExtra* e=ui->Extra;
  221. int W, H; W = ui->R - ui->L; H = ui->B - ui->U;
  222. if (W<=0 || H<=0) return;
  223. tnsFlush();
  224. if (!e->OffScr || e->OffScr->pColor[0]->Height != ui->B - ui->U || e->OffScr->pColor[0]->Width != ui->R - ui->L){
  225. if (e->OffScr) tnsDelete2DOffscreen(e->OffScr);
  226. e->OffScr = tnsCreate2DOffscreen(GL_RGBA, W, H, MAIN.PanelMultisample, 1, 0);
  227. }
  228. tnsDrawToOffscreen(e->OffScr, 1, 0);
  229. tnsViewportWithScissor(0, 0, W, H);
  230. tnsResetViewMatrix();tnsResetModelMatrix();tnsResetProjectionMatrix();
  231. tnsOrtho(e->PanX - W * e->ZoomX / 2, e->PanX + W * e->ZoomX / 2, e->PanY - e->ZoomY * H / 2, e->PanY + e->ZoomY * H / 2, 100, -100);
  232. //glClearColor(0.3,0.3,0.3, 1);
  233. if (e->ClearBackground){ tnsClearColorv(laThemeColor(bt,LA_BT_NORMAL)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); }
  234. // above is basic routine setup
  235. real V[8] = {0};
  236. real UV[8] = {0};
  237. if (t){
  238. real w2=t->Width/2, h2=t->Height/2;
  239. tnsDraw2DTextureDirectly(t, -w2, h2, t->Width, -t->Height);
  240. tnsFlush();
  241. if (e->ImageDrawBorder){
  242. tnsUseNoTexture();
  243. tnsMakeQuad2d(V, -w2, -h2, -w2, h2, w2, h2, w2, -h2);
  244. tnsVertexArray2d(V, 4);
  245. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  246. tnsVertexArray2d(V, 4);
  247. tnsPackAs(GL_LINE_LOOP);
  248. tnsFlush();
  249. }
  250. }
  251. }
  252. real la_CanvasDrawGetDisplayStep(real Max, real Min, int AreaSize){
  253. real r;
  254. real Step = 1.0;
  255. real DispW;
  256. real Div[3] = {2.0, 2.5, 2.0};
  257. int Times = 302;
  258. while (1){
  259. Times++;
  260. r = tnsGetRatiod(0, Max - Min, Step);
  261. DispW = tnsLinearItp(0, AreaSize, r);
  262. if (DispW > 100){
  263. Step /= Div[Times % 3];
  264. }elif (DispW < 40){
  265. Step *= Div[Times % 3];
  266. }else break;
  267. }
  268. return Step;
  269. }
  270. void la_CanvasDrawGridW(real Ratio, int RealW, real Min, real Max, real U, real B){
  271. real t;
  272. real Step = la_CanvasDrawGetDisplayStep(Max, Min, RealW);
  273. t = (real)((int)(Min / Step)) * Step;
  274. for (t; t <= Max; t += Step){
  275. tnsVertex2d(t, U);
  276. tnsVertex2d(t, B);
  277. tnsPackAs(GL_LINES);
  278. }
  279. }
  280. void la_CanvasDrawGridH(real Ratio, int RealH, real Min, real Max, real L, real R){
  281. real t;
  282. real Step = la_CanvasDrawGetDisplayStep(Max, Min, RealH);
  283. t = (real)((int)(Min / Step)) * Step;
  284. for (t; t <= Max; t += Step){
  285. tnsVertex2d(L, t);
  286. tnsVertex2d(R, t);
  287. tnsPackAs(GL_LINES);
  288. }
  289. }
  290. void la_CanvasDrawRulerW(real Ratio, laBoxedTheme *bt, int RealW, real Min, real Max, int B){
  291. char buf[20] = {0};
  292. real t, IL;
  293. real Step = la_CanvasDrawGetDisplayStep(Max, Min, RealW);
  294. int U = B - LA_RH;
  295. tnsUseNoTexture();
  296. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  297. tnsVertex2d(0, U);
  298. tnsVertex2d(RealW, U);
  299. tnsVertex2d(RealW, B);
  300. tnsVertex2d(0, B);
  301. tnsPackAs(GL_TRIANGLE_FAN);
  302. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT_ACTIVE));
  303. tnsVertex2d(0, U + 0.5);
  304. tnsVertex2d(RealW, U + 0.5);
  305. tnsPackAs(GL_LINES);
  306. t = (real)((int)(Min / Step)) * Step;
  307. for (t; t <= Max; t += Step){
  308. IL = tnsGetRatiod(Min, Max, t) * (RealW);
  309. sprintf(buf, "%.0f", t);
  310. tnsDrawStringAuto(buf, bt->Active, IL, IL + 100, U, 0);
  311. }
  312. }
  313. void la_CanvasDrawRulerRWithBkg(real Ratio, laBoxedTheme *bt, int RealH, real Min, real Max, int R){
  314. real t, OrigT;
  315. char buf[50][20] = {0};
  316. real IL[50];
  317. int i = 0;
  318. int W = 0, MaxW = 0;
  319. int RH = LA_RH, hH = RH / 2;
  320. int L;
  321. real Step = la_CanvasDrawGetDisplayStep(Max, Min, RealH);
  322. int IS = Step > 1 ? 0 : (Step > 0.09 ? 1 : 2);
  323. t = OrigT = (real)((int)(Min / Step)) * Step;
  324. for (t; t <= Max; t += Step, i++){
  325. sprintf(buf[i], "%.*f", IS, t);
  326. W = tnsStringGetWidth(buf[i], 0, 0);
  327. if (W > MaxW) MaxW = W;
  328. }
  329. L = R - MaxW - 4;
  330. tnsUseNoTexture();
  331. for (t = OrigT, i = 0; t <= Max; t += Step, i++){
  332. IL[i] = tnsGetRatiod(Max, Min, t) * (RealH);
  333. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  334. tnsVertex2d(R, IL[i] - hH);
  335. tnsVertex2d(R, IL[i] + hH);
  336. tnsVertex2d(L, IL[i] + hH);
  337. tnsVertex2d(L, IL[i] - hH);
  338. tnsPackAs(GL_TRIANGLE_FAN);
  339. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT_ACTIVE));
  340. tnsVertex2d(R, IL[i] - hH);
  341. tnsVertex2d(R, IL[i] + hH);
  342. tnsVertex2d(L, IL[i] + hH);
  343. tnsVertex2d(L, IL[i] - hH);
  344. tnsPackAs(GL_LINE_LOOP);
  345. }
  346. for (t = OrigT, i = 0; t <= Max; t += Step, i++){
  347. tnsDrawStringAuto(buf[i], bt->Active, L + 2, R, IL[i] - hH, 0);
  348. }
  349. }
  350. void la_CanvasDraw(laUiItem *ui, int h){
  351. laBoxedTheme *bt = (*ui->Type->Theme);
  352. if (ui->CanvasTemplate && ui->CanvasTemplate->Draw) ui->CanvasTemplate->Draw(bt, ui->PP.EndInstance, ui);
  353. }
  354. void la_CanvasDefaultOverlay(laUiItem* ui, int h){
  355. laCanvasExtra *e = ui->Extra;
  356. laBoxedTheme *bt = (*ui->Type->Theme);
  357. tnsUseNoTexture();
  358. if(MAIN.CurrentWindow->MaximizedUi!=ui){
  359. tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
  360. tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
  361. tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
  362. tnsPackAs(GL_LINE_LOOP);
  363. }
  364. if (e->DrawCursor){
  365. tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
  366. int drawx=(e->DrawCursor==LA_CANVAS_CURSOR_CROSS)||(e->DrawCursor==LA_CANVAS_CURSOR_X);
  367. int drawy=(e->DrawCursor==LA_CANVAS_CURSOR_CROSS)||(e->DrawCursor==LA_CANVAS_CURSOR_Y);
  368. if(drawx) tnsVertex2d(e->OnX, ui->U); tnsVertex2d(e->OnX, ui->B);
  369. if(drawy) tnsVertex2d(ui->L, e->OnY); tnsVertex2d(ui->R, e->OnY);
  370. tnsPackAs(GL_LINES);
  371. tnsFlush();
  372. }
  373. char* MaxIco=(MAIN.CurrentWindow->MaximizedUi!=ui)?"🡹":"🡻";
  374. tnsVector4d color; tnsVectorCopy4d(laThemeColor(bt,LA_BT_TEXT),color);
  375. color[3]=ui->State==LA_UI_NORMAL?0.0:(ui->State==LA_UI_ACTIVE?0.5:1.0);
  376. int startx=(ui->R+ui->L)/2-LA_RH2*2;
  377. tnsDrawStringAuto("☰",color,startx, startx+LA_RH, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  378. tnsDrawStringAuto(MaxIco,color,startx+LA_RH, startx+LA_2RH, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  379. if(ui->Expand>=0 && ui!=MAIN.CurrentWindow->MaximizedUi)
  380. tnsDrawStringAuto("◿",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
  381. tnsFlush();
  382. }
  383. void la_CanvasDrawOverlay(laUiItem *ui, int h){
  384. laCanvasExtra *e = ui->Extra;
  385. laBoxedTheme *bt = (*ui->Type->Theme);
  386. tnsDraw2DTextureDirectly(e->OffScr->pColor[0], ui->L, ui->U, ui->R - ui->L, ui->B - ui->U);
  387. la_CanvasDefaultOverlay(ui, h);
  388. }
  389. int la_AnimateUiListRecursive(laUiList *uil);
  390. void laDefault3DViewOverlay(laUiItem *ui){
  391. laUiList *uil, *gu;
  392. laColumn *c, *cl, *cll, *clr, *cr, *crl, *crr, *gc, *gcl, *gcr;
  393. laPropPack *e = &ui->ExtraPP;
  394. laUiItem *b, *g, *b1;
  395. if (!(uil = ui->Subs.pFirst)) uil = laAddTabPage(ui, "New Group");
  396. c = laFirstColumn(uil);
  397. laSplitColumn(uil, c, 0.8);
  398. cl = laLeftColumn(c, 0);
  399. cr = laRightColumn(c, 0);
  400. laSplitColumn(uil, cl, 0.25);
  401. cll = laLeftColumn(cl, 0);
  402. clr = laRightColumn(cl, 0);
  403. laShowColumnAdjuster(uil, c);
  404. g = laMakeFoldableGroup(uil, cll, "Tools", 0, 1, 0);{
  405. gu = g->Page; gc = laFirstColumn(gu);
  406. laSplitColumn(gu, gc, 0.35); gcl = laLeftColumn(gc, 0); gcr = laRightColumn(gc, 0);
  407. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_delete");
  408. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_make_parent");
  409. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_unparent");
  410. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_add");
  411. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_grab");
  412. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_scale");
  413. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_rotate");
  414. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_clear_transformations");
  415. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_extrude");
  416. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_make");
  417. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_knife");
  418. laShowItemFull(gu,gc,&ui->ExtraPP,"_this_M_knife",0,"mode=loop_cut;text=Loop Cut",0,0);
  419. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_merge");
  420. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_subdiv");
  421. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_separate");
  422. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_combine");
  423. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_duplicate");
  424. laShowItem(gu,gc,&ui->ExtraPP,"_this_M_recalculate_normals");
  425. }
  426. g = laMakeFoldableGroup(uil, cr, "Scene Info", 0, 1, 0);{
  427. gu = g->Page;
  428. gc = laFirstColumn(gu);
  429. laSplitColumn(gu, gc, 0.35);
  430. gcl = laLeftColumn(gc, 0);
  431. gcr = laRightColumn(gc, 0);
  432. laShowItemFull(gu, gc, &ui->PP, 0, LA_WIDGET_COLLECTION_SELECTOR,0,laui_IdentifierOnly,0);
  433. laShowLabel(gu, gcl, "Rename:", 0, 0);
  434. laShowItem(gu, gcr, &ui->PP, "name");
  435. }
  436. g = laMakeFoldableGroup(uil, cr, "Object Info", 0, 0, 0);{
  437. gu = g->Page;
  438. gc = laFirstColumn(gu);
  439. laSplitColumn(gu, gc, 0.5);
  440. gcl = laLeftColumn(gc, 6);
  441. gcr = laRightColumn(gc, 0);
  442. b1=laOnConditionThat(gu,gc,laPropExpression(&ui->PP,"active"));{
  443. laShowItem(gu, gc, &ui->PP, "active.name");
  444. b=laOnConditionThat(gu,gc,laPropExpression(&ui->ExtraPP, "delta_mode"));{
  445. laShowLabel(gu, gcl, "DLoc:", 0, 0);laShowItem(gu, gcr, &ui->PP, "active.dlocation")->Flags|=LA_UI_FLAGS_TRANSPOSE;
  446. laShowSeparator(gu,gc);
  447. laShowLabel(gu, gcl, "DRot:", 0, 0);laShowItem(gu, gcr, &ui->PP, "active.drotation")->Flags|=LA_UI_FLAGS_TRANSPOSE;
  448. laShowItem(gu, gc, &ui->PP, "active.dscale");
  449. }laElse(gu,b);{
  450. laShowLabel(gu, gcl, "Loc:", 0, 0);laShowItem(gu, gcr, &ui->PP, "active.location")->Flags|=LA_UI_FLAGS_TRANSPOSE;
  451. laShowSeparator(gu,gc);
  452. laShowLabel(gu, gcl, "Rot:", 0, 0);laShowItem(gu, gcr, &ui->PP, "active.rotation")->Flags|=LA_UI_FLAGS_TRANSPOSE;
  453. laShowItem(gu, gc, &ui->PP, "active.scale");
  454. }laEndCondition(gu,b);
  455. }laElse(gu,b1);{
  456. laShowLabel(gu, gc, "No active object.", 0, 0);
  457. }laEndCondition(gu,b1);
  458. }
  459. g = laMakeFoldableGroup(uil, cr, "Display", 0, 1, 0);{
  460. gu = g->Page;
  461. gc = laFirstColumn(gu);
  462. laSplitColumn(gu, gc, 0.35);
  463. gcl = laLeftColumn(gc, 0);
  464. gcr = laRightColumn(gc, 0);
  465. laShowLabel(gu, gcl, "Axis:", 0, 0);
  466. laWidget w={_LA_UI_ENUM_SELECTOR, LA_UI_FLAGS_ICON|LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_TRANSPOSE};
  467. laShowItemFull(gu, gcr, e, "show_axis",&w, "show_prefix=true;" ,0,0);
  468. laShowLabel(gu, gcl, "Floor Grid:", 0, 0);
  469. laShowItemFull(gu, gcr, e, "show_floor_grid", LA_WIDGET_ENUM_CYCLE, 0, 0, 0);
  470. laShowItem(gu, gc, e, "grid_size");
  471. laShowItem(gu, gc, e, "grid_span");
  472. //laShowLabel(gu, gcl, "NPR:", 0, 0);
  473. //laShowItemFull(gu, gcr, e, "npr_line_mode", LA_WIDGET_ENUM_CYCLE, 0, 0, 0);
  474. }
  475. }
  476. void la_3DViewEnsureCamera(laCanvasExtra* e){
  477. if(e->ViewingCamera) return;
  478. tnsVector3d pos={-15, -20, 7};
  479. tnsCamera* c= tnsCreateCamera(0, "VIEWING_CAMERA", rad(50), LA_COLOR3(pos), rad(70), 0, rad(-40), 25);
  480. memAssignRef(e,&e->ViewingCamera,c);
  481. tnsVector3d target={0,0,0}; tnsVector3d up={0,0,1};
  482. tnsLookAt(e->ViewingCamera, target, up);
  483. e->ViewingCamera->FocusDistance=tnsDist3dv(pos,target);
  484. }
  485. void la_3DViewInit(laUiItem *ui){
  486. laCanvasExtra *e = ui->Extra;
  487. if (e){
  488. return;
  489. }else{
  490. e = memAcquireHyper(sizeof(laCanvasExtra));
  491. }
  492. ui->Extra = e;
  493. e->ParentUi = ui;
  494. la_3DViewEnsureCamera(e);
  495. e->GridSize = 10;
  496. e->GridSpan = 15;
  497. e->ShowAxis[0] = 1;
  498. e->ShowAxis[1] = 1;
  499. e->ShowFloorGrid = 1;
  500. //e->DisplayMode = LA_3D_VIEW_DISPLAY_WIRE;
  501. e->HeightCoeff = 10;
  502. laFirstColumn(laAddTabPage(ui, "New Group"));
  503. laRecordDifferences(0,"tns.world");
  504. laPushDifferences("Created camera for 3D view widget,",0);
  505. }
  506. void la_3DViewDestroy(laUiItem *ui){
  507. laCanvasExtra *e = ui->Extra;
  508. tnsDelete2DOffscreen(e->OffScr);
  509. tnsDelete2DOffscreen(e->OffScrShadow);
  510. if(e->ViewingCamera) tnsDestroyObject(e->ViewingCamera);
  511. memFree(e);
  512. }
  513. void laDefault2DViewOverlayRight(laUiItem *ui){
  514. laUiList *uil, *gu;
  515. laColumn *c, *cr, *crl, *crr, *gc, *gcl, *gcr, *cl;
  516. laPropPack *e = &ui->ExtraPP;
  517. laUiItem *b, *b1, *b2, *g;
  518. if (!(uil = ui->Subs.pFirst)) uil = laAddTabPage(ui, "New Group");
  519. uil->HeightCoeff=-1;
  520. c = laFirstColumn(uil);
  521. laSplitColumn(uil, c, 0.7);
  522. cl = laLeftColumn(c, 0);
  523. cr = laRightColumn(c, 0);
  524. laShowColumnAdjuster(uil, c);
  525. b=laBeginRow(uil,cl,0,0);
  526. laShowLabel(uil, cl, "Line Width:", 0, 0);
  527. laShowItem(uil, cl, e, "adaptive_line_width")->Flags|=LA_UI_FLAGS_PLAIN;
  528. laEndRow(uil,b);
  529. b=laBeginRow(uil,cl,0,0);
  530. laShowItem(uil, cl, &ui->PP, "size")->Flags|=LA_UI_FLAGS_PLAIN|LA_UI_FLAGS_TRANSPOSE|LA_TEXT_ALIGN_LEFT;
  531. laEndRow(uil,b);
  532. laShowItem(uil, cl, &ui->PP, "internal_type")->Flags|=LA_UI_FLAGS_PLAIN;
  533. g = laMakeFoldableGroup(uil, cr, "Display", 0, 1, 0);{
  534. gu = g->Page;
  535. gc = laFirstColumn(gu);
  536. laSplitColumn(gu, gc, 0.35);
  537. gcl = laLeftColumn(gc, 0);
  538. gcr = laRightColumn(gc, 0);
  539. // needs another mode for access the ExtraPP.
  540. // laShowItem(gu, gc, &ui->ExtraPP, "maximize");
  541. laShowLabel(gu, gcl, "Transparency:", 0, 0);
  542. laShowItem(gu, gcr, e, "draw_image_alpha");
  543. laShowLabel(gu, gcl, "Border:", 0, 0);
  544. laShowItemFull(gu, gcr, e, "draw_image_border", LA_WIDGET_ENUM_CYCLE, 0, 0, 0);
  545. laShowLabel(gu, gcl, "Line Width:", 0, 0);
  546. laShowItemFull(gu, gcr, e, "adaptive_line_width", LA_WIDGET_ENUM_CYCLE, 0, 0, 0);
  547. laShowLabel(gu, gcl, "Cursor:", 0, 0);
  548. laShowItemFull(gu, gcr, e, "draw_cursor", LA_WIDGET_ENUM_CYCLE, 0, 0, 0);
  549. }laEndFoldableGroup(uil,g);
  550. }
  551. void la_CanvasUiInit(laUiItem* ui){ laCanvasTemplate* ct=ui->CanvasTemplate; if(ct->Init) ct->Init(ui); }
  552. void la_CanvasUiDestroy(laUiItem *ui){ laCanvasTemplate* ct=ui->CanvasTemplate; if(ct->Destroy) ct->Destroy(ui); }
  553. void la_CanvasInit(laUiItem *ui){
  554. laCanvasExtra *e = ui->Extra;
  555. if (!e){ e = memAcquireHyper(sizeof(laCanvasExtra)); ui->Extra = e; }
  556. e->ParentUi = ui;
  557. e->HeightCoeff = 10;
  558. e->ZoomX = 1;
  559. e->ZoomY = 1;
  560. e->ImageDrawAlpha = 1;
  561. e->ImageDrawBorder = 1;
  562. e->AdaptiveLineWidth = 1;
  563. e->ClearBackground = 1;
  564. laFirstColumn(laAddTabPage(ui, "New Group"));
  565. }
  566. void la_CanvasDestroy(laUiItem *ui){
  567. laCanvasExtra *e = ui->Extra;
  568. tnsDelete2DOffscreen(e->OffScr);
  569. memFree(e);
  570. }
  571. //============================================================= [Operators]
  572. int OPINV_3DOr2DViewUiItem(laOperator *a, laEvent *e){
  573. laUiItem *ui = a->Instance;
  574. a->CustomData = ui->Extra;
  575. return LA_RUNNING;
  576. }
  577. int OPEXT_3DOr2DViewUiItem(laOperator *a, int ExitCode){
  578. return 0;
  579. }
  580. int la_CanvasDetectButtons(laUiItem* ui, laBoxedTheme* bt, int x,int y, int total_buttons, int* very_close){
  581. int midx=(ui->R+ui->L)/2-LA_RH2*(total_buttons-1), midy=ui->B-LA_RH2-bt->BM;
  582. if(y>ui->B-LA_2RH-bt->BM || y<ui->U+LA_2RH+bt->TM || x<ui->L+LA_2RH+bt->TM || x>ui->R-LA_2RH-bt->RM)
  583. { if(very_close)*very_close=1; }else return 0;
  584. if(y<ui->B-LA_RH-bt->BM)return 0;
  585. for(int i=0;i<total_buttons;i++){ if(x>=midx-LA_RH2 && x<midx+LA_RH2) return i+1; midx+=LA_RH;}
  586. return 0;
  587. }
  588. int OPMOD_Canvas(laOperator *a, laEvent *e){
  589. laUiItem *ui = a->Instance;
  590. laBoxedTheme *bt = (*ui->Type->Theme);
  591. laCanvasExtra *ex = a->CustomData;
  592. laUiList *subu;
  593. laUiItem *subui = 0;
  594. laListHandle Locals = {0};
  595. int px = e->x, py = e->y;
  596. if (!laIsInUiItem(ui, e->x, e->y) && !ex->Dragging){
  597. ex->OnX = INT_MAX; ex->OnY = INT_MAX; if(ui->State!=LA_UI_NORMAL){ ui->State=LA_UI_NORMAL; laRedrawCurrentPanel(); }
  598. return LA_FINISHED_PASS;
  599. }
  600. //int x=e->x,y=e->y; laPanel*p=MAIN.CurrentPanel,*dp;
  601. //laLocalToWindow(0, p, &x, &y); if(!p) p=MAIN.CurrentWindow->MaximizedUiPanel;
  602. //if(dp = laDetectPanel(x,y) && dp!=p){ return LA_RUNNING_PASS; }
  603. if(e->Type&LA_MOUSE_EVENT){
  604. if(e->Type == LA_L_MOUSE_DOWN && ui->Expand>=0 && e->x>ui->R-bt->RM-LA_RH && e->y>ui->B-bt->BM-LA_RH){
  605. ex->Dragging=1; ex->ClickedX=e->x; ex->ClickedY=e->y; ex->TargetIndexVali=ui->Expand;
  606. return LA_RUNNING;
  607. }
  608. if(ex->Dragging==1){
  609. if(e->Type==LA_MOUSEMOVE){ ui->Expand=ex->TargetIndexVali+((real)e->y-ex->ClickedY+0.5)/LA_RH;
  610. if(ex->HeightCoeff<1) ex->HeightCoeff=1; laRecalcCurrentPanel(); }
  611. elif(e->Type==LA_L_MOUSE_UP){ ex->Dragging=0; }
  612. elif(e->Type==LA_R_MOUSE_DOWN){ ex->Dragging=0; ui->Expand=ex->TargetIndexVali; laRecalcCurrentPanel(); }
  613. return LA_RUNNING;
  614. }
  615. int VeryClose=0; int btn=la_CanvasDetectButtons(ui, bt, e->x, e->y, 2, &VeryClose);
  616. if(e->Type==LA_L_MOUSE_DOWN){
  617. if(btn==2){ if(MAIN.CurrentWindow->MaximizedUi==ui) laRestoreCanvasUI(); else laMaximizeCanvasUI(ui,MAIN.CurrentPanel); return LA_RUNNING; }
  618. if(btn==1){
  619. if(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)ui->Flags&=~LA_UI_FLAGS_NO_OVERLAY; else ui->Flags|=LA_UI_FLAGS_NO_OVERLAY;
  620. laRedrawCurrentPanel(); return LA_RUNNING;
  621. }
  622. }
  623. int state=VeryClose?(btn?LA_UI_EDITING:LA_UI_ACTIVE):LA_UI_NORMAL;
  624. if(state!=ui->State){ ui->State=state; laRedrawCurrentPanel(); }
  625. }
  626. //laLocalToPanel(a, &px, &py);
  627. if(!(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)){
  628. for (subu = ui->Subs.pFirst; subu; subu = subu->Item.pNext){
  629. if (subui = la_DetectUiItemRecursive(subu, px, py, ui->B, &Locals, 0)){
  630. if (subui && !a->Child && subui->Type->OperatorType){
  631. //printf("invui %d\n", tui);
  632. laUiList *luil = ((laUiListDrawItem *)Locals.pFirst)->Target;
  633. laSetOperatorLocalizer(a->ToPanel);
  634. if (laInvokeUiP(a, subui->Type->OperatorType, e, subui, &Locals, 0) >= 0) laRetriggerOperators();
  635. lstClearPointer(&Locals);
  636. return LA_RUNNING_PASS;
  637. }
  638. }
  639. lstClearPointer(&Locals);
  640. }
  641. }
  642. if (ex->DrawCursor){
  643. ex->OnX = e->x;
  644. ex->OnY = e->y;
  645. laRedrawCurrentPanel();
  646. }
  647. if(ui->CanvasTemplate->ExtraModal){ if(!(ui->CanvasTemplate->ExtraModal(a,e)&LA_PASS_ON)) return LA_RUNNING; }
  648. if (laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->CanvasTemplate->KeyMapper, e)) return LA_RUNNING;
  649. if (laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
  650. return LA_RUNNING_PASS;
  651. }
  652. int OPCHK_Is3DViewExtra(laPropPack *This, laStringSplitor *ss){
  653. if (This && This->LastPs->p->SubProp == _LA_PROP_3D_EXTRA) return 1;
  654. return 0;
  655. }
  656. int OPINV_3DViewCameraZoom(laOperator *a, laEvent *e){
  657. laCanvasExtra *ex = a->This->EndInstance;
  658. tnsCamera *c = ex->ViewingCamera;
  659. if (strArgumentMatch(a->ExtraInstructionsP, "direction", "in")){
  660. tnsZoomViewingCamera(c, 0.1);
  661. laRedrawCurrentPanel();
  662. }elif (strArgumentMatch(a->ExtraInstructionsP, "direction", "out")){
  663. tnsZoomViewingCamera(c, -0.1);
  664. laRedrawCurrentPanel();
  665. }
  666. return LA_FINISHED;
  667. }
  668. int OPINV_3DOr2DViewAdjust(laOperator *a, laEvent *e){
  669. laGeneralUiExtraData *ex = memAcquireSimple(sizeof(laGeneralUiExtraData));
  670. laSetWindowCursor(LA_HAND);
  671. a->CustomData = ex;
  672. ex->LastX = e->x;
  673. ex->LastY = e->y;
  674. return LA_RUNNING;
  675. }
  676. int OPEXT_3DOr2DViewAdjust(laOperator *a, int Mark){
  677. if (a->CustomData) memFree(a->CustomData);
  678. laSetWindowCursor(LA_ARROW);
  679. }
  680. int OPMOD_3DViewCameraRotate(laOperator *a, laEvent *e){
  681. laCanvasExtra *ex = a->This->EndInstance;
  682. laGeneralUiExtraData *uex = a->CustomData;
  683. if (e->Type == LA_L_MOUSE_UP || e->Type == LA_M_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN) return LA_FINISHED;
  684. if (e->Type == LA_MOUSEMOVE){
  685. tnsRotateViewingCamera(ex->ViewingCamera, (real)(uex->LastY - e->y) / 150.0, (real)(uex->LastX - e->x) / 150.0);
  686. uex->LastX = e->x;
  687. uex->LastY = e->y;
  688. laRedrawCurrentPanel();
  689. }
  690. return LA_RUNNING;
  691. }
  692. int OPMOD_3DViewCameraMove(laOperator *a, laEvent *e){
  693. laCanvasExtra *ex = a->This->EndInstance;
  694. laGeneralUiExtraData *uex = a->CustomData;
  695. if (e->Type == LA_L_MOUSE_UP || e->Type == LA_M_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN){
  696. laSetWindowCursor(LA_ARROW);
  697. return LA_FINISHED;
  698. }
  699. if (e->Type == LA_MOUSEMOVE){
  700. tnsTranslateViewingCamera(ex->ViewingCamera, ex->ParentUi->R - ex->ParentUi->L, ex->ParentUi->B - ex->ParentUi->U, -e->x + uex->LastX, e->y - uex->LastY);
  701. //tnsTranslateObjectLocal(ex->ViewingCamera,
  702. // -(real)(e->x - uex->LastX) * ex->ViewingCamera->FocusDistance / 100,
  703. // (real)(e->y - uex->LastY) * ex->ViewingCamera->FocusDistance / 100,
  704. // 0);
  705. uex->LastX = e->x;
  706. uex->LastY = e->y;
  707. laRedrawCurrentPanel();
  708. }
  709. return LA_RUNNING;
  710. }
  711. int OPCHK_Is2DViewExtra(laPropPack *This, laStringSplitor *ss){
  712. return 1;
  713. //if (This && (This->LastPs->p->SubProp == _LA_PROP_2D_EXTRA)) return 1;
  714. return 0;
  715. }
  716. int OPINV_CanvasZoom(laOperator *a, laEvent *e){
  717. laCanvasExtra *ex = a->This->EndInstance;
  718. if (strArgumentMatch(a->ExtraInstructionsP, "mode", "mouse")){
  719. laGeneralUiExtraData *ex = memAcquireSimple(sizeof(laGeneralUiExtraData));
  720. laSetWindowCursor(LA_HAND);
  721. a->CustomData = ex;
  722. ex->LastX = e->x;
  723. ex->LastY = e->y;
  724. return LA_RUNNING;
  725. }
  726. if (strArgumentMatch(a->ExtraInstructionsP, "direction", "in")){
  727. if (strArgumentMatch(a->ExtraInstructionsP, "axis", "x")){
  728. ex->ZoomX *= 0.9;
  729. }else{
  730. ex->ZoomX *= 0.9;
  731. ex->ZoomY *= 0.9;
  732. }
  733. laRedrawCurrentPanel();
  734. }elif (strArgumentMatch(a->ExtraInstructionsP, "direction", "out")){
  735. if (strArgumentMatch(a->ExtraInstructionsP, "axis", "x")){
  736. ex->ZoomX *= 1.1;
  737. }else{
  738. ex->ZoomX *= 1.1;
  739. ex->ZoomY *= 1.1;
  740. }
  741. laRedrawCurrentPanel();
  742. }
  743. return LA_FINISHED;
  744. }
  745. int OPMOD_CanvasZoom(laOperator *a, laEvent *e){
  746. laCanvasExtra *ex = a->This->EndInstance;
  747. laGeneralUiExtraData *uex = a->CustomData;
  748. if (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN || e->Type==LA_M_MOUSE_UP){
  749. laSetWindowCursor(LA_ARROW);
  750. return LA_FINISHED;
  751. }
  752. if (e->Type == LA_MOUSEMOVE){
  753. if (strArgumentMatch(a->ExtraInstructionsP, "axis", "x")){
  754. ex->ZoomX *= (1.0 - (e->x - uex->LastX) * MAIN.ZoomSpeed2D);
  755. }elif(strArgumentMatch(a->ExtraInstructionsP, "lock", "true")){
  756. ex->ZoomX *= (1.0 - (e->y - uex->LastY) * MAIN.ZoomSpeed2D); ex->ZoomY = ex->ZoomX;
  757. }else{
  758. ex->ZoomX *= (1.0 - (e->x - uex->LastX) * MAIN.ZoomSpeed2D);
  759. ex->ZoomY *= (1.0 + (e->y - uex->LastY) * MAIN.ZoomSpeed2D);
  760. }
  761. if(ex->ZoomX<0||ex->ZoomX!=ex->ZoomX){
  762. printf("Error zoom!\n"); ex->ZoomX=1; ex->ZoomY=1;
  763. }
  764. uex->LastX = e->x;
  765. uex->LastY = e->y;
  766. laRedrawCurrentPanel();
  767. }
  768. return LA_RUNNING;
  769. }
  770. int OPMOD_CanvasMove(laOperator *a, laEvent *e){
  771. laCanvasExtra *ex = a->This->EndInstance;
  772. laGeneralUiExtraData *uex = a->CustomData;
  773. if (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN || e->Type==LA_M_MOUSE_UP ||
  774. (e->Type==LA_KEY_UP && e->key==' ')) {
  775. laSetWindowCursor(LA_ARROW);
  776. return LA_FINISHED;
  777. }
  778. if (e->Type == LA_MOUSEMOVE){
  779. if (strArgumentMatch(a->ExtraInstructionsP, "axis", "x")){
  780. ex->PanX -= (e->x - uex->LastX) * ex->ZoomX;
  781. }else{
  782. ex->PanX -= (e->x - uex->LastX) * ex->ZoomX;
  783. ex->PanY += (e->y - uex->LastY) * ex->ZoomY;
  784. }
  785. uex->LastX = e->x;
  786. uex->LastY = e->y;
  787. laRedrawCurrentPanel();
  788. }
  789. return LA_RUNNING;
  790. }
  791. int OPINV_CanvasClick(laOperator *a, laEvent *e){
  792. laCanvasExtra *ex = a->This->EndInstance;
  793. laGeneralUiExtraData *uex = a->CustomData;
  794. if (e->Type == LA_L_MOUSE_DOWN){
  795. ex->ClickedX = (e->x - (ex->ParentUi->R - ex->ParentUi->L) / 2 - ex->ParentUi->L) * ex->ZoomX + ex->PanX;
  796. ex->ClickedY = ((ex->ParentUi->B - ex->ParentUi->U) / 2 - e->y + ex->ParentUi->U) * ex->ZoomY + ex->PanY;
  797. laRedrawCurrentPanel();
  798. }
  799. return LA_FINISHED_PASS;
  800. }
  801. void la_RegisterViewerOperators(){
  802. laCreateOperatorType("LA_canvas_operator", "2D View UiItem Operator", "All Visual 2D View Operations Are Called From This Ui",
  803. 0, 0, OPEXT_3DOr2DViewUiItem, OPINV_3DOr2DViewUiItem, OPMOD_Canvas, U'🖦', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
  804. laCreateOperatorType("LA_3d_view_camera_zoom", "Camera Zoom", "Let View Camera Zoom In Or Out",
  805. OPCHK_Is3DViewExtra, 0, 0, OPINV_3DViewCameraZoom, 0, U'🔎', 0);
  806. laCreateOperatorType("LA_3d_view_camera_rotate", "Camera Rotate", "Let View Camera Rotate Along Local X/Y Axis",
  807. OPCHK_Is3DViewExtra, 0, OPEXT_3DOr2DViewAdjust, OPINV_3DOr2DViewAdjust, OPMOD_3DViewCameraRotate, U'🗘', LA_EXTRA_TO_PANEL);
  808. laCreateOperatorType("LA_3d_view_camera_move", "Camera Move", "Let View Camera Move Along Local X/Y Axis",
  809. OPCHK_Is3DViewExtra, 0, OPEXT_3DOr2DViewAdjust, OPINV_3DOr2DViewAdjust, OPMOD_3DViewCameraMove, U'🤚', LA_EXTRA_TO_PANEL);
  810. laCreateOperatorType("LA_2d_view_zoom", "2D Zoom", "Let View 2D Cavans Zoom In Or Out",
  811. OPCHK_Is2DViewExtra, 0, OPEXT_3DOr2DViewAdjust, OPINV_CanvasZoom, OPMOD_CanvasZoom, U'🔎', 0);
  812. laCreateOperatorType("LA_2d_view_move", "2D Move", "Let View 2D Cavans Move Along Local X/Y Axis",
  813. OPCHK_Is2DViewExtra, 0, OPEXT_3DOr2DViewAdjust, OPINV_3DOr2DViewAdjust, OPMOD_CanvasMove, U'🤚', LA_EXTRA_TO_PANEL);
  814. laCreateOperatorType("LA_2d_view_click", "2D Click", "2D Click",
  815. OPCHK_Is2DViewExtra, 0, OPEXT_3DOr2DViewAdjust, OPINV_CanvasClick, 0, U'🖦', LA_EXTRA_TO_PANEL);
  816. }
  817. void *tnsget_detached_FirstScene(void *UNUSED1, void *UNUSED2);
  818. void laset_CanvasSelectMode(laCanvasExtra* ex, int mode){
  819. ex->SelectMode=mode; laUiItem* ui=ex->ParentUi;
  820. tnsObject*root=ui?ui->PP.EndInstance:0; if(!root) return;
  821. if(root->Active){ if(root->Active->Type==TNS_OBJECT_MESH && ((tnsMeshObject*)root->Active)->Mode==TNS_MESH_EDIT_MODE){ tnsMMeshEnsureSelection(root->Active, mode); } }
  822. }
  823. void la_RegisterUiTypesViewerWidgets(){
  824. laPropContainer *pc = 0;
  825. laProp *p = 0;
  826. laKeyMapper *km;
  827. _LA_UI_CANVAS = la_RegisterUiType("LA_canvas_default", 0, "LA_canvas_operator", &_LA_THEME_2D_VIEW, la_CanvasDraw, la_CanvasGetHeight, la_CanvasUiInit, la_CanvasUiDestroy);
  828. _LA_UI_CANVAS->Tag = LA_UI_TAG_NEED_REBUILD;
  829. laCanvasTemplate* ct=laRegisterCanvasTemplate("la_CanvasDrawTexture", "tns_texture", 0, la_CanvasDrawTexture, la_CanvasDrawOverlay, la_CanvasInit, la_CanvasDestroy);
  830. pc = laCanvasHasExtraProps(ct,sizeof(laCanvasExtra),2);{
  831. _LA_PROP_2D_EXTRA = pc;
  832. 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);
  833. p = laAddEnumProperty(pc, "draw_image_alpha", "Draw Image Alpha", "Draw Grid Background On Alpha<1", 0, 0, 0, 0, 0,
  834. offsetof(laCanvasExtra, ImageDrawAlpha), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  835. laAddEnumItem(p, "null", "null", "Don't Draw Grid", 0);
  836. laAddEnumItem(p, "normal", "normal", "Use Normal Color", 0);
  837. laAddEnumItem(p, "bright", "bright", "Draw Alpha Grid Using Very Bright White Color", 0);
  838. }
  839. p = laAddEnumProperty(pc, "draw_image_border", "Draw Image Border", "Draw Image Border Using Same Color As Ui Item", 0, 0, 0, 0, 0,
  840. offsetof(laCanvasExtra, ImageDrawBorder), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  841. laAddEnumItem(p, "no", "No", "Don't Draw Border", U'☐');
  842. laAddEnumItem(p, "yes", "Yes", "Draw Border", U'☑');
  843. }
  844. p = laAddEnumProperty(pc, "adaptive_line_width", "Adaptive Line Width", "glLineWith() will follow 2dview zooming", 0, 0, 0, 0, 0,
  845. offsetof(laCanvasExtra, AdaptiveLineWidth), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  846. laAddEnumItem(p, "constant", "Constant", "Don't change line width", U'☐');
  847. laAddEnumItem(p, "adaptive", "Adaptive", "Adaptive Line Width", U'☑');
  848. }
  849. p = laAddEnumProperty(pc, "line_width_warning", "Line Width Warnning", "Show whether line width is acceptable by hardware", 0, 0, 0, 0, 0,
  850. offsetof(laCanvasExtra, LineWidthWarning), 0, 0, 0, 0, 0, 0, 0, 0, 0, LA_READ_ONLY);{
  851. laAddEnumItem(p, "acceptable", "Acceptable", "Line width is acceptable by graphic hadware", U'✔');
  852. laAddEnumItem(p, "too_wide", "Too Wide", "Line width is too wide for graphic hadware", U'❌');
  853. laAddEnumItem(p, "too_thin", "Too Thin", "Line width is too thin for graphic hadware", U'❌');
  854. }
  855. p = laAddEnumProperty(pc, "clear_background", "Clear Background", "Clear Background", 0, 0, 0, 0, 0, offsetof(laCanvasExtra, ClearBackground), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  856. laAddEnumItem(p, "no", "No", "Don't Clear Background", U'🌔');
  857. laAddEnumItem(p, "yes", "Yes", "Clear Background", U'🌑');
  858. }
  859. p = laAddEnumProperty(pc, "draw_cursor", "Show Cursor", "Show Cursor", 0, 0, 0, 0, 0, offsetof(laCanvasExtra, DrawCursor), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  860. laAddEnumItem(p, "no", "No", "Don't draw cursor", U'🖦');
  861. laAddEnumItem(p, "yes", "Yes", "Draw cursor", U'➕');
  862. }
  863. laAddFloatProperty(pc, "pan", "Pan", "Pan On X,Y Axis", 0, "X,Y", "px", 0, 0, 1, 0, 0, offsetof(laCanvasExtra, PanX), 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0);
  864. laAddFloatProperty(pc, "zoom", "Zoom", "Zoom Factor On X,Y Axis", 0, "X,Y", 0, 0, 0, 0.01, 1, 0, offsetof(laCanvasExtra, ZoomX), 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0);
  865. //laAddSubGroup(pc, "Template", "Template Used To Draw 2D Stuff", "la_2d_view_template",0, 0, 0, -offsetof(laCanvasExtra, Template), 0, 0, 0, 0, 0, 0, 0, 0, LA_UDF_REFER);
  866. laAddOperatorProperty(pc, "zoom", "Zoom", "Zoom 2D Canvans", "LA_2d_view_zoom", U'🔎', 0);
  867. laAddOperatorProperty(pc, "move", "Move", "Move 2D Canvans", "LA_2d_view_move", U'🤚', 0);
  868. laAddOperatorProperty(pc, "click", "Click", "Click On 2D Canvans", "LA_2d_view_click", U'🤚', 0);
  869. laAddSubGroup(pc, "parent_ui", "Parent UI", "The Ui That Holds The Viewer", "ui_item",0, 0, 0, offsetof(laCanvasExtra, ParentUi), 0, 0, 0, 0, 0, 0, 0, LA_UDF_REFER);
  870. }
  871. km = &ct->KeyMapper;
  872. laAssignNewKey(km, 0, "LA_2d_view_zoom", LA_KM_SEL_UI_EXTRA, 0, LA_MOUSE_WHEEL_DOWN, 0, "direction=out");
  873. laAssignNewKey(km, 0, "LA_2d_view_zoom", LA_KM_SEL_UI_EXTRA, 0, LA_MOUSE_WHEEL_UP, 0, "direction=in");
  874. laAssignNewKey(km, 0, "LA_2d_view_move", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_L_MOUSE_DOWN, 0, 0);
  875. laAssignNewKey(km, 0, "LA_2d_view_click", LA_KM_SEL_UI_EXTRA, 0, LA_L_MOUSE_DOWN, 0, 0);
  876. ct=laRegisterCanvasTemplate("la_3DView", "tns_object", 0, la_RootObjectDraw, la_RootObjectDrawOverlay, la_3DViewInit, la_3DViewDestroy);
  877. pc = laCanvasHasExtraProps(ct, sizeof(laCanvasExtra), 2);{
  878. _LA_PROP_3D_EXTRA = pc;
  879. laAddIntProperty(pc, "grid_size", "Grid Size", "Floor Grid Size Per Cell", 0, 0, "Unit", 100, 1, 1, 10, 0, offsetof(laCanvasExtra, GridSize), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  880. laAddIntProperty(pc, "grid_span", "Grid Span", "How Many Grids Are Drawn", 0, 0, 0, 25, 1, 1, 10, 0, offsetof(laCanvasExtra, GridSpan), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  881. p = laAddEnumProperty(pc, "show_axis", "Show Axis", "Show Global X,Y,Z Axis", LA_WIDGET_ENUM_CYCLE, "X,Y,Z", 0, 0, 0, offsetof(laCanvasExtra, ShowAxis), 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);{
  882. laAddEnumItem(p, "HIDDEN", "Hidden", "Current Axis Is Hidden", U'🌔');
  883. laAddEnumItem(p, "SHOWN", "Shown", "Current Axis Is Shown", U'🌑');
  884. }
  885. p = laAddEnumProperty(pc, "show_floor_grid", "Show Floor Grid", "Show Floor Grid", 0, 0, 0, 0, 0, offsetof(laCanvasExtra, ShowFloorGrid), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  886. laAddEnumItem(p, "HIDDEN", "Hidden", "Current Axis Is Hidden", U'🌔');
  887. laAddEnumItem(p, "SHOWN", "Shown", "Current Axis Is Shown", U'🌑');
  888. }
  889. p = laAddEnumProperty(pc, "select_mode", "Select Mode", "Select by vertices or edges", 0, 0, 0, 0, 0, offsetof(laCanvasExtra, SelectMode), 0, laset_CanvasSelectMode, 0, 0, 0, 0, 0, 0, 0, 0);{
  890. laAddEnumItemAs(p, "VERTS", "Verts", "Select by vertices", LA_CANVAS_SELECT_MODE_VERTS,0);
  891. laAddEnumItemAs(p, "EDGES", "Edges", "Select by edges", LA_CANVAS_SELECT_MODE_EDGES,0);
  892. }
  893. p = laAddEnumProperty(pc, "select_through", "Select Through", "Select through stuff", LA_WIDGET_ENUM_HIGHLIGHT, 0, 0, 0, 0, offsetof(laCanvasExtra, SelectThrough), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  894. laAddEnumItemAs(p, "OFF", "Off", "Don't select through stuff", LA_CANVAS_SELECT_THROUGH_OFF,0);
  895. laAddEnumItemAs(p, "ON", "On", "Select through stuff", LA_CANVAS_SELECT_THROUGH_ON,0);
  896. }
  897. p = laAddEnumProperty(pc, "delta_mode", "Delta Mode", "Toggle delta transformation mode for animation editing", 0, 0, 0, 0, 0, offsetof(laCanvasExtra, DeltaMode), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);{
  898. laAddEnumItemAs(p, "NONE", "None", "Regular mode",0,0);
  899. laAddEnumItemAs(p, "DELTA", "Delta", "Delta mode",1,0);
  900. }
  901. 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);
  902. laAddOperatorProperty(pc, "zoom", "Zoom", "Zoom Viewing Camera", "LA_3d_view_camera_zoom", U'🔎', 0);
  903. laAddOperatorProperty(pc, "rotate", "Rotate", "Rotate Viewing Camera", "LA_3d_view_camera_rotate", U'🗘', 0);
  904. laAddOperatorProperty(pc, "move", "Move", "Move Viewing Camera", "LA_3d_view_camera_move", U'🤚', 0);
  905. //laAddSubGroup(pc, "Viewing Camera", "Unique Camera That Is Used To Draw 3D Viewport", "tns_object",0, 0, 0, -offsetof(laCanvasExtra, ViewingCamera), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  906. laAddSubGroup(pc, "parent_ui", "Parent Ui", "Parent Ui (Mostly Used To Determin Viewport Size)", "ui_item",0, 0, 0, offsetof(laCanvasExtra, ParentUi), 0, 0, 0, 0, 0, 0, 0, LA_UDF_REFER);
  907. laAddOperatorProperty(pc, "align_camera_to_view", "Align Active Camera To View", "Align Active Camera To View", "TNS_align_camera_to_view", U'🎥', 0);
  908. laAddOperatorProperty(pc, "align_view_to_camera", "Align View To Active Camera", "Align View To Active Camera", "TNS_align_view_to_camera", U'🎥', 0);
  909. laAddOperatorProperty(pc, "_this_M_delete", "Delete", "Delete parts of mesh", "M_delete", 0, 0);
  910. laAddOperatorProperty(pc, "_this_M_make_parent", "Make parent", "Parent objects to active objects or unparent selected ones", "M_make_parent", 0, 0);
  911. laAddOperatorProperty(pc, "_this_M_unparent", "Unparent", "Unparent selected objects", "M_unparent", 0, 0);
  912. laAddOperatorProperty(pc, "_this_M_add", "Add", "Add objects/primitives", "M_add", 0, 0);
  913. laAddOperatorProperty(pc, "_this_M_grab", "Grab", "Grab things and move around", "M_grab", 0, 0);
  914. laAddOperatorProperty(pc, "_this_M_scale", "Scale", "Scale selected things", "M_scale", 0, 0);
  915. laAddOperatorProperty(pc, "_this_M_rotate", "Rotate", "Rotation selected things", "M_rotate", 0, 0);
  916. laAddOperatorProperty(pc, "_this_M_extrude", "Extrude", "Extrude parts of the mesh", "M_extrude", 0, 0);
  917. laAddOperatorProperty(pc, "_this_M_delete", "Delete", "Delete parts of the mesh", "M_delete", 0, 0);
  918. laAddOperatorProperty(pc, "_this_M_make", "Make", "Make mesh primitive from selected ones", "M_make", 0, 0);
  919. laAddOperatorProperty(pc, "_this_M_subdiv", "Subdiv", "Subdivide edges", "M_subdiv", 0, 0);
  920. laAddOperatorProperty(pc, "_this_M_add", "Add", "Add objects/primitives", "M_add", 0, 0);
  921. laAddOperatorProperty(pc, "_this_M_separate", "Separate", "Separate mesh parts", "M_separate", 0, 0);
  922. laAddOperatorProperty(pc, "_this_M_combine", "Combine", "Combine mesh objects", "M_combine", 0, 0);
  923. laAddOperatorProperty(pc, "_this_M_duplicate", "Duplicate", "Duplicate objects", "M_duplicate", 0, 0);
  924. laAddOperatorProperty(pc, "_this_M_recalculate_normals", "Recalculate Normals", "Recalculate normals", "M_recalculate_normals", 0, 0);
  925. laAddOperatorProperty(pc, "_this_M_knife", "Knife", "Cut though edges", "M_knife", 0, 0);
  926. laAddOperatorProperty(pc, "_this_M_merge", "Merge", "Merge vertices", "M_merge", 0, 0);
  927. laAddOperatorProperty(pc, "_this_M_clear_transformations", "Clear Transformations", "Clear object transformations", "M_clear_transformations", 0, 0);
  928. }
  929. km = &ct->KeyMapper;
  930. laAssignNewKey(km, 0, "LA_3d_view_camera_zoom", LA_KM_SEL_UI_EXTRA, 0, LA_MOUSE_WHEEL_DOWN, 0, "direction=out");
  931. laAssignNewKey(km, 0, "LA_3d_view_camera_zoom", LA_KM_SEL_UI_EXTRA, 0, LA_MOUSE_WHEEL_UP, 0, "direction=in");
  932. laAssignNewKey(km, 0, "LA_3d_view_camera_rotate", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_L_MOUSE_DOWN, 0, 0);
  933. laAssignNewKey(km, 0, "LA_3d_view_camera_rotate", LA_KM_SEL_UI_EXTRA, 0, LA_M_MOUSE_DOWN, 0, 0);
  934. laAssignNewKey(km, 0, "LA_3d_view_camera_move", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT, LA_M_MOUSE_DOWN, 0, 0);
  935. laAssignNewKey(km, 0, "LA_3d_view_camera_move", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT | LA_KEY_ALT, LA_L_MOUSE_DOWN, 0, 0);
  936. //laAssignNewKey(km, 0, "TNS_align_camera_to_view", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT | LA_KEY_SHIFT, LA_R_MOUSE_DOWN, 0, 0);
  937. //laAssignNewKey(km, 0, "TNS_align_view_to_camera", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, '0', 0);
  938. laAssignNewKey(km, 0, "M_set_cursor", LA_KM_SEL_UI_EXTRA, 0, LA_L_MOUSE_DOWN, 0, 0);
  939. laAssignNewKey(km, 0, "M_toggle_edit_mode", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, LA_KEY_TAB, 0);
  940. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_R_MOUSE_DOWN, 0, 0);
  941. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT|LA_KEY_CTRL, LA_R_MOUSE_DOWN, 0, 0);
  942. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT, LA_R_MOUSE_DOWN, 0, 0);
  943. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT|LA_KEY_ALT, LA_R_MOUSE_DOWN, 0, 0);
  944. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT|LA_KEY_ALT|LA_KEY_CTRL, LA_R_MOUSE_DOWN, 0, 0);
  945. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, 0, LA_R_MOUSE_DOWN, 0, 0);
  946. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'b', "mode=box;");
  947. laAssignNewKey(km, 0, "M_select", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'a', "mode=toggle;");
  948. laAssignNewKey(km, 0, "M_grab", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'g', 0);
  949. laAssignNewKey(km, 0, "M_scale", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 's', 0);
  950. laAssignNewKey(km, 0, "M_rotate", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'r', 0);
  951. laAssignNewKey(km, 0, "M_clear_transformations", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_KEY_DOWN, 'g', "channel=loc");
  952. laAssignNewKey(km, 0, "M_clear_transformations", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_KEY_DOWN, 's', "channel=sca");
  953. laAssignNewKey(km, 0, "M_clear_transformations", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_KEY_DOWN, 'r', "channel=rot");
  954. laAssignNewKey(km, 0, "M_clear_transformations", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_KEY_DOWN, 't', 0);
  955. laAssignNewKey(km, 0, "M_make_parent", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'p', 0);
  956. laAssignNewKey(km, 0, "M_unparent", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_KEY_DOWN, 'p', 0);
  957. laAssignNewKey(km, 0, "M_extrude", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'e', 0);
  958. laAssignNewKey(km, 0, "M_extrude", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT, LA_KEY_DOWN, 'd', "duplicate_only=true;text=Duplicate;");
  959. laAssignNewKey(km, 0, "M_delete", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'x', 0);
  960. laAssignNewKey(km, 0, "M_make", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'f', 0);
  961. laAssignNewKey(km, 0, "M_subdiv", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'w', 0);
  962. laAssignNewKey(km, 0, "M_add", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT, LA_KEY_DOWN, 'a', 0);
  963. laAssignNewKey(km, 0, "M_separate", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'p', 0);
  964. laAssignNewKey(km, 0, "M_combine", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'j', 0);
  965. laAssignNewKey(km, 0, "M_duplicate", LA_KM_SEL_UI_EXTRA, LA_KEY_SHIFT, LA_KEY_DOWN, 'd', 0);
  966. laAssignNewKey(km, 0, "M_recalculate_normals", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'n', 0);
  967. laAssignNewKey(km, 0, "M_knife", LA_KM_SEL_UI_EXTRA, 0, LA_KEY_DOWN, 'k', 0);
  968. laAssignNewKey(km, 0, "M_knife", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'r', "mode=loop_cut");
  969. laAssignNewKey(km, 0, "M_merge", LA_KM_SEL_UI_EXTRA, LA_KEY_ALT, LA_KEY_DOWN, 'm', 0);
  970. }