*/}}

la_widgets_viewers.c 50 KB

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