*/}}

la_widgets_viewers.c 48 KB

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