*/}}
1
0

la_widgets_viewers.c 49 KB

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