|
@@ -0,0 +1,6402 @@
|
|
|
+#include "la_5.h"
|
|
|
+
|
|
|
+#include <stdio.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include <math.h>
|
|
|
+#include <time.h>
|
|
|
+#include <sys/time.h>
|
|
|
+#include <X11/Xlib.h>
|
|
|
+#include <X11/Xutil.h>
|
|
|
+#include <X11/Xos.h>
|
|
|
+#include <X11/keysymdef.h>
|
|
|
+#include <X11/XKBlib.h>
|
|
|
+#include <GL/glx.h>
|
|
|
+//#include <GL/glext.h>
|
|
|
+//#include <GL/glu.h>
|
|
|
+
|
|
|
+LA MAIN;
|
|
|
+
|
|
|
+extern tnsMain *T;
|
|
|
+int deb = 0;
|
|
|
+
|
|
|
+laOperator *DEB;
|
|
|
+
|
|
|
+laColumn *DEBUG_C;
|
|
|
+
|
|
|
+Atom XA_ATOM = 4, XA_STRING = 31;
|
|
|
+
|
|
|
+#define LA_GUI_WNDCLASS_NAME "NUL4_GUI_CLASS"
|
|
|
+
|
|
|
+typedef GLXContext (*glXCreateContextAttribsARBProc)(Display*, GLXFBConfig, GLXContext, Bool, const int*);
|
|
|
+typedef Bool (*glXMakeContextCurrentARBProc)(Display*, GLXDrawable, GLXDrawable, GLXContext);
|
|
|
+typedef void (*glXSwapIntervalEXTProc)(Display *dpy, GLXDrawable drawable, int interval);
|
|
|
+
|
|
|
+glXCreateContextAttribsARBProc glXCreateContextAttribsF;
|
|
|
+glXSwapIntervalEXTProc glXSwapIntervalEXTF;
|
|
|
+
|
|
|
+Window la_CreateWindowX11(int x, int y, int w, int h, char *title, int SyncToVBlank, GLXContext* r_glc){
|
|
|
+ XSetWindowAttributes swa;
|
|
|
+ XWindowAttributes wa;
|
|
|
+ swa.event_mask =
|
|
|
+ KeyPressMask|KeyReleaseMask|StructureNotifyMask|SubstructureNotifyMask|
|
|
|
+ ButtonMotionMask|ButtonPressMask|ButtonReleaseMask|ExposureMask|PointerMotionMask;
|
|
|
+ swa.colormap = MAIN.cmap;
|
|
|
+ Window root = DefaultRootWindow(MAIN.dpy);
|
|
|
+ Window win = XCreateWindow(MAIN.dpy, root, x, y, w, h, 0, MAIN.xvi->depth, InputOutput, MAIN.xvi->visual, CWColormap | CWEventMask, &swa);
|
|
|
+ XSetWMProtocols(MAIN.dpy , win, &MAIN.MsgDelWindow, 1);
|
|
|
+
|
|
|
+ if(x>0||y>0){
|
|
|
+ XSizeHints my_hints = {0};
|
|
|
+ my_hints.flags = PPosition;
|
|
|
+ my_hints.x = x; my_hints.y = y;
|
|
|
+ XSetNormalHints(MAIN.dpy, win, &my_hints);
|
|
|
+ }
|
|
|
+
|
|
|
+ //int attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 3, 0};
|
|
|
+ //if (((*r_glc) = glXCreateContextAttribsF(MAIN.dpy, MAIN.BestFBC, MAIN.glc, GL_TRUE, attribs)) == NULL){
|
|
|
+ // printf("\n\tcannot create gl context\n\n"); exit(0);
|
|
|
+ //}
|
|
|
+
|
|
|
+ XStoreName(MAIN.dpy, win, title);
|
|
|
+ XMapWindow(MAIN.dpy, win);
|
|
|
+ glXMakeContextCurrent(MAIN.dpy, win, win, MAIN.glc);
|
|
|
+
|
|
|
+ int sync=SyncToVBlank?1:0; glXSwapIntervalEXTF(MAIN.dpy, win, sync);
|
|
|
+
|
|
|
+ MAIN.im = XOpenIM(MAIN.dpy, NULL, NULL, NULL);
|
|
|
+ MAIN.ic = XCreateIC(MAIN.im, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, win, NULL);
|
|
|
+ XSetICFocus(MAIN.ic);
|
|
|
+
|
|
|
+ XClassHint ch; ch.res_name = "LAGUI_WINDOW"; ch.res_class = "LAGUI_WINDOW";
|
|
|
+ XSetClassHint(MAIN.dpy, win, &ch);
|
|
|
+
|
|
|
+
|
|
|
+#define _NET_WM_STATE_ADD 1
|
|
|
+ if(w<0&&h<0){
|
|
|
+ XEvent xev;
|
|
|
+ Atom wm_state = XInternAtom(MAIN.dpy, "_NET_WM_STATE", False);
|
|
|
+ Atom max_horz = XInternAtom(MAIN.dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
|
|
+ Atom max_vert = XInternAtom(MAIN.dpy, "_NET_WM_STATE_MAXIMIZED_VERT", False);
|
|
|
+ memset(&xev, 0, sizeof(xev));
|
|
|
+ xev.type = ClientMessage;
|
|
|
+ xev.xclient.window = win;
|
|
|
+ xev.xclient.message_type = wm_state;
|
|
|
+ xev.xclient.format = 32;
|
|
|
+ xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
|
|
|
+ xev.xclient.data.l[1] = max_horz;
|
|
|
+ xev.xclient.data.l[2] = max_vert;
|
|
|
+ XSendEvent(MAIN.dpy, DefaultRootWindow(MAIN.dpy), False, SubstructureNotifyMask, &xev);
|
|
|
+ }
|
|
|
+
|
|
|
+ return win;
|
|
|
+};
|
|
|
+int la_CreateSystemWindow(laWindow *window, int SyncToVBlank){
|
|
|
+ GLXContext glc;
|
|
|
+ Window hwnd = la_CreateWindowX11(window->X, window->Y, window->W, window->H, window->Title->Ptr, SyncToVBlank, &glc);
|
|
|
+ window->win = hwnd;
|
|
|
+ //if (!hwnd)
|
|
|
+ //{
|
|
|
+ // MessageBox(0, "Error Creating Window!", "Error", 0);
|
|
|
+ // return 0;
|
|
|
+ //};
|
|
|
+ //ImmAssociateContext(hwnd,0);
|
|
|
+
|
|
|
+ //la_SetupGLEnviornment(window, hwnd);
|
|
|
+
|
|
|
+ //GetClientRect(window->win, &rc);
|
|
|
+ //window->CW = rc.right - rc.left;
|
|
|
+ //window->CH = rc.bottom - rc.top;
|
|
|
+
|
|
|
+ XWindowAttributes attr;
|
|
|
+ XGetWindowAttributes(MAIN.dpy, window->win, &attr);
|
|
|
+ window->CW =attr.width;
|
|
|
+ window->CH = attr.height;
|
|
|
+ window->glc = glc;
|
|
|
+ return 1;
|
|
|
+};
|
|
|
+void la_DestroySystemWindowX11(laWindow* w){
|
|
|
+ glXMakeCurrent(MAIN.dpy, None, NULL);
|
|
|
+ //glXDestroyContext(MAIN.dpy, w->glc);
|
|
|
+ XDestroyWindow(MAIN.dpy, w->win);
|
|
|
+};
|
|
|
+int la_DestroySystemWindow(laWindow* wnd){
|
|
|
+ la_DestroySystemWindowX11(wnd);
|
|
|
+}
|
|
|
+
|
|
|
+void la_DestroyWindow(laWindow *wnd){
|
|
|
+ laLayout *l; laPanel *p;
|
|
|
+
|
|
|
+ if (!wnd) return;
|
|
|
+
|
|
|
+ strSafeDestroy(&wnd->Title);
|
|
|
+
|
|
|
+ while (p = lstPopItem(&wnd->Panels)){
|
|
|
+ laDestroySinglePanel(p);
|
|
|
+ }
|
|
|
+ while (l = lstPopItem(&wnd->Layouts)){
|
|
|
+ laDestroyBlocksRecursive(l->FirstBlock);
|
|
|
+ strSafeDestroy(&l->ID);
|
|
|
+ memFree(l);
|
|
|
+ }
|
|
|
+ la_DestroySystemWindow(wnd);
|
|
|
+ lstRemoveItem(&MAIN.Windows, wnd);
|
|
|
+
|
|
|
+ memFree(wnd);
|
|
|
+}
|
|
|
+
|
|
|
+void laRenameWindow(laWindow* wnd, char* name){
|
|
|
+ strSafeSet(&wnd->Title, name);
|
|
|
+ XStoreName(MAIN.dpy, wnd->win, name);
|
|
|
+}
|
|
|
+
|
|
|
+int la_ConvertCursorID(int id){
|
|
|
+ return 0;
|
|
|
+ //switch (id)
|
|
|
+ //{
|
|
|
+ //case LA_ARROW:
|
|
|
+ // return IDC_ARROW;
|
|
|
+ //case LA_CROSS:
|
|
|
+ // return IDC_CROSS;
|
|
|
+ //case LA_LEFT_RIGHT:
|
|
|
+ // return IDC_SIZEWE;
|
|
|
+ //case LA_UP_AND_DOWN:
|
|
|
+ // return IDC_SIZENS;
|
|
|
+ //case LA_MOVE:
|
|
|
+ // return IDC_SIZEALL;
|
|
|
+ //case LA_HAND:
|
|
|
+ // return IDC_HAND;
|
|
|
+ //}
|
|
|
+}
|
|
|
+
|
|
|
+void la_MakePanelTitleBar(laPanel *p, laUiDefineFunc ReplaceDefine);
|
|
|
+void la_InitThreadEnviornment(){
|
|
|
+ //pthread_spin_init(&MAIN.csNotifier, //pthread_PROCESS_PRIVATE);
|
|
|
+}
|
|
|
+
|
|
|
+laLogEntry* logEnsure(int Create){
|
|
|
+ if(!MAIN.Logs.pFirst || Create){
|
|
|
+ laLogEntry* le=memAcquireSimple(sizeof(laLogEntry));
|
|
|
+ lstAppendItem(&MAIN.Logs, le);
|
|
|
+ }
|
|
|
+ return MAIN.Logs.pLast;
|
|
|
+}
|
|
|
+void logPrintTV(int Continued, char* format, va_list v){
|
|
|
+ if(!format || !format[0]) return;
|
|
|
+ laLogEntry* le=logEnsure(Continued);
|
|
|
+ va_list aptr;
|
|
|
+ strSafePrintV(&le->Content, format, v);
|
|
|
+ laNotifyUsers("la.logs");
|
|
|
+}
|
|
|
+void logPrintT(int Continued, char* format, ...){
|
|
|
+ if(!format || !format[0]) return;
|
|
|
+ laLogEntry* le=logEnsure(Continued);
|
|
|
+ va_list aptr; va_start(aptr, format);
|
|
|
+ strSafePrint(&le->Content, format, aptr);
|
|
|
+ va_end(aptr);
|
|
|
+ laNotifyUsers("la.logs");
|
|
|
+}
|
|
|
+void logPrint(char* format, ...){
|
|
|
+ va_list aptr; va_start(aptr, format);
|
|
|
+ logPrintTV(0, format, aptr);
|
|
|
+ va_end(aptr);
|
|
|
+}
|
|
|
+void logPrintNew(char* format, ...){
|
|
|
+ logEnsure(1);
|
|
|
+ va_list aptr; va_start(aptr, format);
|
|
|
+ logPrintTV(0, format, aptr);
|
|
|
+ va_end(aptr);
|
|
|
+}
|
|
|
+void logClear(){
|
|
|
+ laLogEntry*l;
|
|
|
+ while(l=lstPopItem(&MAIN.Logs)){ strSafeDestroy(&l->Content); memFree(l); }
|
|
|
+}
|
|
|
+
|
|
|
+//=======================
|
|
|
+
|
|
|
+int laGetReady(){
|
|
|
+ Window root, win;
|
|
|
+ GLint att[] = {GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None};
|
|
|
+ XSetWindowAttributes swa={0};
|
|
|
+ XWindowAttributes wa={0};
|
|
|
+ XEvent xev;
|
|
|
+
|
|
|
+ logPrintNew("Initializing LaGUI...\n");
|
|
|
+
|
|
|
+ setlocale(LC_CTYPE, "zh_CN.utf8");
|
|
|
+ XSetLocaleModifiers("");
|
|
|
+
|
|
|
+ int i;
|
|
|
+
|
|
|
+ if ((MAIN.dpy = XOpenDisplay(NULL)) == NULL){
|
|
|
+ printf("\n\tcannot connect to x server\n\n");
|
|
|
+ exit(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ static int visual_attribs[] =
|
|
|
+ {
|
|
|
+ GLX_X_RENDERABLE , True,
|
|
|
+ GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT,
|
|
|
+ GLX_RENDER_TYPE , GLX_RGBA_BIT,
|
|
|
+ GLX_X_VISUAL_TYPE , GLX_TRUE_COLOR,
|
|
|
+ GLX_RED_SIZE , 8,
|
|
|
+ GLX_GREEN_SIZE , 8,
|
|
|
+ GLX_BLUE_SIZE , 8,
|
|
|
+ GLX_ALPHA_SIZE , 8,
|
|
|
+ GLX_DEPTH_SIZE , 24,
|
|
|
+ //GLX_STENCIL_SIZE , 8,
|
|
|
+ GLX_DOUBLEBUFFER , True,
|
|
|
+ GLX_SAMPLE_BUFFERS , 1,
|
|
|
+ GLX_SAMPLES , 4,
|
|
|
+ None
|
|
|
+ };
|
|
|
+
|
|
|
+ int fbcount = -1;
|
|
|
+ GLXFBConfig* fbconfig = glXChooseFBConfig(MAIN.dpy, DefaultScreen(MAIN.dpy), visual_attribs, &fbcount );
|
|
|
+
|
|
|
+ logPrint("glXChooseFBConfig matched %d\n",fbcount);
|
|
|
+
|
|
|
+ if (!fbcount){ printf("\n\tno matching visual\n\n"); exit(0); }
|
|
|
+
|
|
|
+ MAIN.BestFBC = fbconfig[0];
|
|
|
+ int sample_buf,samples;
|
|
|
+ glXGetFBConfigAttrib(MAIN.dpy, MAIN.BestFBC, GLX_SAMPLE_BUFFERS, &sample_buf);
|
|
|
+ glXGetFBConfigAttrib(MAIN.dpy, MAIN.BestFBC, GLX_SAMPLES, &samples);
|
|
|
+ logPrint(" Chosen framebuffer with: %s %d samples\n",sample_buf?"Multisample":"-",samples);
|
|
|
+
|
|
|
+ MAIN.xvi=glXGetVisualFromFBConfig(MAIN.dpy, MAIN.BestFBC);
|
|
|
+
|
|
|
+ root = DefaultRootWindow(MAIN.dpy);
|
|
|
+ if ((MAIN.cmap = XCreateColormap(MAIN.dpy, root, MAIN.xvi->visual, AllocNone)) == 0){
|
|
|
+ printf("\n\tcannot create colormap\n\n"); exit(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ swa.colormap = MAIN.cmap;
|
|
|
+ root = DefaultRootWindow(MAIN.dpy);
|
|
|
+ win = XCreateWindow(MAIN.dpy, root, 0, 0, 100, 100, 0, MAIN.xvi->depth, InputOutput, MAIN.xvi->visual, CWColormap | CWEventMask, &swa);
|
|
|
+
|
|
|
+ int attribs[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 4, GLX_CONTEXT_MINOR_VERSION_ARB, 6, 0};
|
|
|
+ glXCreateContextAttribsF = (glXCreateContextAttribsARBProc) glXGetProcAddressARB( (const GLubyte *) "glXCreateContextAttribsARB" );
|
|
|
+ if ((MAIN.glc = glXCreateContextAttribsF(MAIN.dpy, MAIN.BestFBC, NULL, GL_TRUE, attribs)) == NULL){
|
|
|
+ printf("\n\tcannot create gl context\n\n"); exit(0);
|
|
|
+ }
|
|
|
+ glXSwapIntervalEXTF = (glXSwapIntervalEXTProc) glXGetProcAddressARB( (const GLubyte *) "glXSwapIntervalEXT" );
|
|
|
+
|
|
|
+ glXMakeContextCurrent(MAIN.dpy, win,win, MAIN.glc);
|
|
|
+
|
|
|
+ int major,minor; glGetIntegerv(GL_MAJOR_VERSION, &major); glGetIntegerv(GL_MINOR_VERSION, &minor);
|
|
|
+ logPrint(" OpenGL Version: %d.%d\n",major,minor);
|
|
|
+ logPrint(" OpenGL Renderer: %s\n",glGetString(GL_RENDERER));
|
|
|
+
|
|
|
+ int err=0;
|
|
|
+ if((err=glewInit())!=GLEW_OK){
|
|
|
+ printf("%d\n",err); printf("%s\n",glewGetErrorString(err));
|
|
|
+ };
|
|
|
+
|
|
|
+ MAIN.MsgDelWindow = XInternAtom(MAIN.dpy, "WM_DELETE_WINDOW", 0);
|
|
|
+ MAIN.bufid = XInternAtom(MAIN.dpy, "CLIPBOARD", False),
|
|
|
+ MAIN.fmtid = XInternAtom(MAIN.dpy, "UTF8_STRING", False),
|
|
|
+ MAIN.propid = XInternAtom(MAIN.dpy, "XSEL_DATA", False),
|
|
|
+ MAIN.incrid = XInternAtom(MAIN.dpy, "INCR", False);
|
|
|
+ MAIN.targets_atom = XInternAtom(MAIN.dpy, "TARGETS",0);
|
|
|
+ MAIN.text_atom = XInternAtom(MAIN.dpy, "TEXT", 0);
|
|
|
+ MAIN.UTF8 = XInternAtom(MAIN.dpy, "UTF8_STRING", 1);
|
|
|
+ MAIN.selection = XInternAtom(MAIN.dpy, "CLIPBOARD", 0);
|
|
|
+ if(MAIN.UTF8 == None) MAIN.UTF8 = XA_STRING;
|
|
|
+
|
|
|
+ la_GetWorkingDirectoryInternal();
|
|
|
+ //laSetAuthorInfo("YimingWu", "(C)Nick'sBest");
|
|
|
+
|
|
|
+ //transInitTranslation_zh_cn();
|
|
|
+ //transState(0, 1); //enable translation
|
|
|
+ MAIN.FontSize = 0.6;
|
|
|
+ MAIN.UiRowHeight = MAIN.ScaledUiRowHeight =24;
|
|
|
+ MAIN.UiScale=1;
|
|
|
+ MAIN.MarginSize = 1;
|
|
|
+
|
|
|
+ tnsInitRenderKernel(64);
|
|
|
+ tnsInitBuiltinShaders();
|
|
|
+
|
|
|
+ tnsSetuptnsFontManager();
|
|
|
+ tnsLoadSystemFont(4,
|
|
|
+ "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc",
|
|
|
+ "/home/yiming/.local/share/fonts/NotoEmoji-Regular.ttf",
|
|
|
+ "/home/yiming/.local/share/fonts/NotoSansSymbols-Regular.ttf",
|
|
|
+ "/home/yiming/.local/share/fonts/NotoSansSymbols2-Regular.ttf"
|
|
|
+ //"/home/yiming/.local/share/fonts/NotoMusic-Regular.ttf",
|
|
|
+ //"/home/yiming/.local/share/fonts/NotoSansEgyptianHieroglyphs-Regular.ttf"
|
|
|
+ );
|
|
|
+ tnsLoadSystemFontMono("/home/yiming/.local/share/fonts/NotoSansMono-Regular.ttf");
|
|
|
+
|
|
|
+ arrEnsureLength(&MAIN.InputBuf,0,&MAIN.InputBufMax,sizeof(char));
|
|
|
+ arrEnsureLength(&MAIN.InputBufU,0,&MAIN.InputBufUMax,sizeof(uint32_t));
|
|
|
+
|
|
|
+ //XDestroyWindow(MAIN.dpy, win);
|
|
|
+
|
|
|
+ MAIN.ColorAccessCorrectGamma = 1;
|
|
|
+ MAIN.Gamma = 1;//2.2; ...?
|
|
|
+
|
|
|
+ //interactions:
|
|
|
+ MAIN.TopFramerate = 60;
|
|
|
+ MAIN.ValuatorThreshold = 8;
|
|
|
+ MAIN.ScrollingSpeed = 3;
|
|
|
+ MAIN.AnimationSpeed = 0.4;
|
|
|
+ MAIN.PanelAnimationSpeed = 0.4;
|
|
|
+ MAIN.ZoomSpeed2D = 0.01;
|
|
|
+ MAIN.IdleTime = 0.75;
|
|
|
+ MAIN.TooltipCloseDistance = 30;
|
|
|
+
|
|
|
+ //display:
|
|
|
+ MAIN.FloatingAlpha = 0.7;
|
|
|
+ MAIN.SolidShadowLength = 20;
|
|
|
+ MAIN.TrackShadowLength = 30;
|
|
|
+ MAIN.WireColorSlices = 16;
|
|
|
+ MAIN.WireThickness = 5;
|
|
|
+ MAIN.WireSaggyness = 5;
|
|
|
+
|
|
|
+ //timeline:
|
|
|
+ MAIN.Animation.FrameBegin = 1;
|
|
|
+ MAIN.Animation.FrameEnd = 250;
|
|
|
+ MAIN.Animation.Frame = 1;
|
|
|
+ MAIN.Animation.FrameRate = 25;
|
|
|
+ MAIN.Animation.FrameStep = 1;
|
|
|
+
|
|
|
+ laAddResourceFolder(".");
|
|
|
+ laAddResourceFolder("/home/yiming/Documents/sync/Projects/2022/nul5/build");
|
|
|
+
|
|
|
+
|
|
|
+ //tns_RegisterResourcesForSoftwareRender();
|
|
|
+ la_RegisterGeneralProps();
|
|
|
+ la_RegisterInternalTemplates();
|
|
|
+ la_RegisterMainThemes();
|
|
|
+ la_RegisterMainOperators();
|
|
|
+ la_RegisterMainUiTypes();
|
|
|
+ la_RegisterModellingOperators();
|
|
|
+ la_RegisterInternalProps();
|
|
|
+ //laRegisterInternalNodes();
|
|
|
+ la_RegisterWindowKeys();
|
|
|
+
|
|
|
+ laFinalizeUiTemplates();
|
|
|
+ laFinalizeOperators();
|
|
|
+
|
|
|
+ la_InitControllers();
|
|
|
+ la_RegisterControllerProps();
|
|
|
+
|
|
|
+ la_InitThreadEnviornment();
|
|
|
+
|
|
|
+ laSetRootInstance(&MAIN);
|
|
|
+
|
|
|
+ laPushDifferences(0, 0);
|
|
|
+ la_MakeDummyManagedUDF();
|
|
|
+
|
|
|
+ la_RegenerateWireColors();
|
|
|
+
|
|
|
+ logPrint("Initialization Completed\n");
|
|
|
+}
|
|
|
+
|
|
|
+void laShutoff(){
|
|
|
+ strSafeDestroy(&MAIN.WorkingDirectory);
|
|
|
+ strSafeDestroy(&MAIN.example_string);
|
|
|
+
|
|
|
+ la_NoLongerRecordUndo();
|
|
|
+
|
|
|
+ laWindow* wi; while(wi=lstPopItem(&MAIN.Windows)){ la_DestroyWindow(wi); }
|
|
|
+ laUiTemplate* uit; while(uit=lstPopItem(&MAIN.PanelTemplates)){ la_DestroyUiTemplate(uit); }
|
|
|
+ laCanvasTemplate* u2t; while(u2t=lstPopItem(&MAIN.View2DTemplates)){ la_DestroyCanvasTemplate(u2t); }
|
|
|
+ laUiType* uit1; while(uit1=lstPopItem(&MAIN.UiTypes)){ la_DestroyUiType(uit1); }
|
|
|
+ laOperatorType* at; for(int i=0;i<256;i++){ while(at=lstPopItem(&MAIN.OperatorTypeHash.Entries[i])) la_DestroyOperatorType(at); }
|
|
|
+ laSharedTypeItem* sti; while(sti=lstPopItem(&MAIN.SharedTypePointerSync)){ memFree(sti); }
|
|
|
+ laKeyMapItem* kmi; while(kmi=lstPopItem(&MAIN.KeyMap.Items)){ la_FreeKeyMapItem(kmi); }
|
|
|
+ laTheme* t; while(t=lstPopItem(&MAIN.Themes)){ la_DestroyTheme(t); }
|
|
|
+
|
|
|
+ arrFree(&MAIN.InputBuf,&MAIN.InputBufNext);
|
|
|
+ arrFree(&MAIN.InputBufU,&MAIN.InputBufUNext);
|
|
|
+
|
|
|
+ strSafeDestroy(&MAIN.CopyPending);
|
|
|
+
|
|
|
+ la_ClearUDFRegistryAndFolders();
|
|
|
+ laClearManagedUDF();
|
|
|
+ laClearSaveProp();
|
|
|
+
|
|
|
+ logClear();
|
|
|
+
|
|
|
+ tnsQuit();
|
|
|
+
|
|
|
+ laPropContainer* pc; while(pc=lstPopItem(&MAIN.PropContainers)){ la_FreePropertyContainer(pc); }
|
|
|
+
|
|
|
+ strSafeDump();
|
|
|
+
|
|
|
+ memNoLonger();
|
|
|
+}
|
|
|
+
|
|
|
+//MSG====================================================
|
|
|
+
|
|
|
+int la_IsThisSysWindow(laWindow *wnd, Window hwnd){
|
|
|
+ if (wnd->win == hwnd) return 1;
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+};
|
|
|
+void la_EnsurePanelSnapping(laPanel *p, int CW, int CH){
|
|
|
+ if (p->SL){ int s=p->SL<0?0:p->SL;
|
|
|
+ if (p->TX != s) p->Refresh |= LA_TAG_RECALC;
|
|
|
+ p->TX = s;
|
|
|
+ }
|
|
|
+ if (p->SR){ int s=p->SR<0?0:p->SR;
|
|
|
+ if (p->TW != CW - p->TX - s) p->Refresh |= LA_TAG_RECALC;
|
|
|
+ p->TW = CW - p->TX - s;
|
|
|
+ }
|
|
|
+ if (p->ST){ int s=p->ST<0?0:p->ST;
|
|
|
+ if (p->TY != s) p->Refresh |= LA_TAG_RECALC;
|
|
|
+ p->TY = s;
|
|
|
+ }
|
|
|
+ if (p->SB){ int s=p->SB<0?0:p->SB;
|
|
|
+ if (p->TH != CH - p->TY - s) p->Refresh |= LA_TAG_RECALC;
|
|
|
+ p->TH = CH - p->TY - s;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_RecalcBlockRecursive(laBlock *b, int X, int Y, int W, int H){
|
|
|
+ laPanel *p = 0;
|
|
|
+ b->X = X;
|
|
|
+ b->Y = Y;
|
|
|
+ b->W = W;
|
|
|
+ b->H = H;
|
|
|
+
|
|
|
+ if (b->B1){
|
|
|
+ int SplitWidth;
|
|
|
+ if (b->Vertical){
|
|
|
+ SplitWidth = H * b->SplitRatio;
|
|
|
+ la_RecalcBlockRecursive(b->B1, X, Y, W, SplitWidth);
|
|
|
+ la_RecalcBlockRecursive(b->B2, X, Y + SplitWidth, W, H - SplitWidth);
|
|
|
+ }else{
|
|
|
+ SplitWidth = W * b->SplitRatio;
|
|
|
+ la_RecalcBlockRecursive(b->B1, X, Y, SplitWidth, H);
|
|
|
+ la_RecalcBlockRecursive(b->B2, X + SplitWidth, Y, W - SplitWidth, H);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //if (!b->CurrentPanel)b->CurrentPanel = b->Panels.pFirst;
|
|
|
+
|
|
|
+ if (p = b->CurrentPanel){
|
|
|
+ int TitleGap=b->Folded?0:LA_RH;
|
|
|
+ p->X = X + LA_SEAM_W; p->Y = Y + LA_SEAM_W + TitleGap;
|
|
|
+ p->TX = X + LA_SEAM_W; p->TY = Y + LA_SEAM_W + TitleGap;
|
|
|
+ p->TW = W - LA_SEAM_W*2; p->TH = H - LA_SEAM_W*2 - TitleGap;
|
|
|
+ p->Refresh |= LA_TAG_RECALC;
|
|
|
+ p->TitleWidth = tnsStringGetWidth(p->Title->Ptr, 0, 0);
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_UpdateUiPlacement(laWindow *w){
|
|
|
+ laLayout *l;
|
|
|
+ laPanel *p;
|
|
|
+ int CW = w->CW;
|
|
|
+ int CH = w->CH;
|
|
|
+ laBoxedTheme* bt = _LA_THEME_FLOATING_PANEL;
|
|
|
+ int MenuHeight=(bt->TM+bt->BM)*2+LA_RH;
|
|
|
+
|
|
|
+ if(w->MaximizedUi && w->MaximizedUiPanel){
|
|
|
+ w->MaximizedUiPanel->Refresh|=LA_TAG_RECALC;
|
|
|
+ }elif(w->MaximizedBlock){
|
|
|
+ la_RecalcBlockRecursive(w->MaximizedBlock, -LA_SEAM_W, MenuHeight, CW+LA_SEAM_W*2, CH-MenuHeight+LA_SEAM_W);
|
|
|
+ }else{
|
|
|
+ for (l = w->Layouts.pFirst; l; l = l->Item.pNext){
|
|
|
+ la_RecalcBlockRecursive(l->FirstBlock, -LA_SEAM_W, MenuHeight, CW+LA_SEAM_W*2, CH-MenuHeight+LA_SEAM_W);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (p = w->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ if(p->IsMenuPanel){
|
|
|
+ p->TH=p->H=MenuHeight;
|
|
|
+ }
|
|
|
+ la_EnsurePanelSnapping(p, CW, CH);
|
|
|
+ p->Refresh |= LA_TAG_RECALC;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_CommandResizeWindow(Window hwnd, int x, int y, int w, int h){
|
|
|
+ laWindow *window = lstFindItem(hwnd, la_IsThisSysWindow, &MAIN.Windows);
|
|
|
+ if (!window) return;
|
|
|
+
|
|
|
+ XWindowAttributes attr;
|
|
|
+ XGetWindowAttributes(MAIN.dpy, window->win, &attr);
|
|
|
+ window->CW = w; window->CH = h;
|
|
|
+ window->W = w; window->H = h;
|
|
|
+ window->X = x; window->Y = y;
|
|
|
+ la_UpdateUiPlacement(window);
|
|
|
+}
|
|
|
+int la_OnWindowDestroy(Window wnd){
|
|
|
+ laListHandle *hlst = &MAIN.Windows;
|
|
|
+ laWindow *w = lstFindItem(wnd, la_IsThisSysWindow, hlst);
|
|
|
+ if (!w) return;
|
|
|
+
|
|
|
+ if (MAIN.Windows.pFirst==MAIN.Windows.pLast){
|
|
|
+ int empty=0; int mod=laRegisterModifications(1,1,&empty,0);
|
|
|
+ if(mod || empty){ laInvoke(0, "LA_managed_save", 0,0,"on_exit=true;",0); return 0; }
|
|
|
+
|
|
|
+ laShutoff();
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ laListHandle h={0};laLayout*l=0;
|
|
|
+ while(l=lstPopItem(&w->Layouts)){ lstAppendItem(&h, l); }
|
|
|
+
|
|
|
+ la_DestroyWindow(w);
|
|
|
+
|
|
|
+ int done=0; for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
+ if(done) glXSwapIntervalEXTF(MAIN.dpy, w->win, 0);
|
|
|
+ else { glXSwapIntervalEXTF(MAIN.dpy, w->win, 1); done=1; while(l=lstPopItem(&h)){ lstAppendItem(&w->Layouts, l); } }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void la_MakeSpecialKeyBit(laEvent *e){
|
|
|
+ e->SpecialKeyBit = MAIN.SpecialKeyStates;
|
|
|
+}
|
|
|
+void la_RegisterSpecialKeys(laEvent* e){
|
|
|
+ if(e->Type&LA_STATE_DOWN){ MAIN.SpecialKeyStates|=e->key&LA_KEY_SPECIALS; }
|
|
|
+ elif(e->Type&LA_STATE_UP){ MAIN.SpecialKeyStates&=~(e->key&LA_KEY_SPECIALS); }
|
|
|
+}
|
|
|
+void la_SaveEvent(Window hwnd, laEvent *e, int use_last_pos){
|
|
|
+ laListHandle *wl = &MAIN.Windows;
|
|
|
+ laListHandle *el = 0;
|
|
|
+ laWindow *wnd = 0;
|
|
|
+
|
|
|
+ wnd = lstFindItem(hwnd, la_IsThisSysWindow, wl);
|
|
|
+ if (!wnd){ FreeMem(e); return; }
|
|
|
+
|
|
|
+ la_MakeSpecialKeyBit(e);
|
|
|
+
|
|
|
+ el = &wnd->EventList;
|
|
|
+
|
|
|
+ if(use_last_pos){
|
|
|
+ laEvent* last_e=el->pLast;
|
|
|
+ if(last_e){ e->x= last_e->x; e->y= last_e->y; }else {
|
|
|
+ Window root_ret, win_ret; int rrx,rry,rx,ry,rmask;
|
|
|
+ XQueryPointer(MAIN.dpy, hwnd, &root_ret,&win_ret,&rrx,&rry,&rx,&ry,&rmask);
|
|
|
+ e->x = rx; e->y = ry;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lstAppendItem(el, (laListItem *)e);
|
|
|
+};
|
|
|
+void la_SendKeyboardEvent(Window hwnd, int type, int key){
|
|
|
+ laEvent *e = CreateNew(laEvent);
|
|
|
+ e->Type = type; e->key = key;
|
|
|
+ la_RegisterSpecialKeys(e);
|
|
|
+ printf("%d %lc\n",key,key);
|
|
|
+ la_SaveEvent(hwnd, e, 1);
|
|
|
+};
|
|
|
+void la_SendInputEvent(Window hwnd, uint32_t Input){
|
|
|
+ laEvent *e = CreateNew(laEvent);
|
|
|
+ e->Type = LA_INPUT; e->Input=Input;
|
|
|
+
|
|
|
+ la_SaveEvent(hwnd, e, 1);
|
|
|
+}
|
|
|
+void la_SendEmptyEvent(Window hwnd){
|
|
|
+ laEvent *e = CreateNew(laEvent);
|
|
|
+
|
|
|
+ e->Type = LA_EMPTY;
|
|
|
+
|
|
|
+ la_SaveEvent(hwnd, e, 1);
|
|
|
+}
|
|
|
+void laSendOperatorTriggerEvent(){
|
|
|
+ if (MAIN.ReTriggerOperators) la_SendEmptyEvent(MAIN.CurrentWindow->win);
|
|
|
+ MAIN.ReTriggerOperators = 0;
|
|
|
+}
|
|
|
+int la_TranslateSpecialKey(int keysym){
|
|
|
+ switch(keysym){
|
|
|
+ case XK_Return: return LA_KEY_ENTER;
|
|
|
+ case XK_BackSpace: return LA_KEY_BACKSPACE;
|
|
|
+ case XK_Delete: return LA_KEY_DELETE;
|
|
|
+ case XK_Escape: return LA_KEY_ESCAPE;
|
|
|
+ case XK_Tab: return LA_KEY_TAB;
|
|
|
+ case XK_Left: return LA_KEY_ARRLEFT;
|
|
|
+ case XK_Right: return LA_KEY_ARRRIGHT;
|
|
|
+ case XK_Up: return LA_KEY_ARRUP;
|
|
|
+ case XK_Down: return LA_KEY_ARRDOWN;
|
|
|
+ case XK_Control_L: return LA_KEY_CTRL;
|
|
|
+ case XK_Control_R: return LA_KEY_CTRL;
|
|
|
+ case XK_Shift_L: return LA_KEY_SHIFT;
|
|
|
+ case XK_Shift_R: return LA_KEY_SHIFT;
|
|
|
+ case XK_Alt_L: return LA_KEY_ALT;
|
|
|
+ case XK_Alt_R: return LA_KEY_ALT;
|
|
|
+ default: return keysym;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_SendMouseEvent(Window hwnd, int type, int x, int y){
|
|
|
+ laEvent *e = CreateNew(laEvent);
|
|
|
+ e->Type = type;
|
|
|
+ e->x = x;
|
|
|
+ e->y = y;
|
|
|
+ la_SaveEvent(hwnd, e, 0);
|
|
|
+ //printf("mouse %d %d\n", e->x, e->y);
|
|
|
+ //if (e->Type == LA_R_MOUSE_DOWN)
|
|
|
+ // la_PrintOperatorStack();
|
|
|
+};
|
|
|
+void la_SendTimerEvent(Window hwnd, int type){
|
|
|
+ laEvent *e = CreateNew(laEvent);
|
|
|
+ e->Type = type;
|
|
|
+ la_SaveEvent(hwnd, e, 1);
|
|
|
+};
|
|
|
+void laRetriggerOperators(){
|
|
|
+ MAIN.ReTriggerOperators = 1;
|
|
|
+}
|
|
|
+
|
|
|
+//====================================================================================================
|
|
|
+
|
|
|
+void la_DestroyTheme(laTheme* t){
|
|
|
+ laBoxedTheme*bt; while(bt=lstPopItem(&t->BoxedThemes)){ strSafeDestroy(&bt->Name); *bt->BackRef=0; memFree(bt); }
|
|
|
+ strSafeDestroy(&t->Name);
|
|
|
+ strSafeDestroy(&t->Author);
|
|
|
+}
|
|
|
+laTheme *laDesignTheme(const char *Name, const char *AuthorName){
|
|
|
+ laTheme *t = memAcquireHyper(sizeof(laTheme));
|
|
|
+ strSafeSet(&t->Name, Name);
|
|
|
+ strSafeSet(&t->Author, AuthorName);
|
|
|
+ lstAppendItem(&MAIN.Themes, t);
|
|
|
+ MAIN.CurrentTheme = t;
|
|
|
+ return t;
|
|
|
+}
|
|
|
+laBoxedTheme *laDesignBoxedTheme(laTheme *t, const char *Name, laBoxedTheme** BackRef,
|
|
|
+ real NormalY,real ActiveY,real BorderY,real TextY,real TextActiveY, real Alpha,
|
|
|
+ real LeftMargin, real RightMargin, real TopMargin, real BottomMargin,
|
|
|
+ real LeftPadding, real RightPadding, real TopPadding, real BottomPadding){
|
|
|
+ laBoxedTheme *bt = memAcquire(sizeof(laBoxedTheme));
|
|
|
+ strSafeSet(&bt->Name, Name);
|
|
|
+ bt->NormalY=NormalY;
|
|
|
+ bt->ActiveY=ActiveY;
|
|
|
+ bt->BorderY=BorderY;
|
|
|
+ bt->TextY=TextY; bt->TextActiveY=TextActiveY; bt->Alpha = Alpha;
|
|
|
+ bt->Margins[0] = LeftMargin; bt->Margins[1] = RightMargin; bt->Margins[2] = TopMargin; bt->Margins[3] = BottomMargin;
|
|
|
+ bt->Paddings[0] = LeftPadding; bt->Paddings[1] = RightPadding; bt->Paddings[2] = TopPadding; bt->Paddings[3] = BottomPadding;
|
|
|
+ bt->BackRef = BackRef;
|
|
|
+ lstAppendItem(&t->BoxedThemes, bt);
|
|
|
+ return bt;
|
|
|
+}
|
|
|
+laBoxedTheme *laGetTheme(const char *ThemeName){
|
|
|
+ laTheme *t = MAIN.Themes.pFirst;
|
|
|
+ for (t; t; t = t->Item.pNext){
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ if (strSame(t->Name->Ptr, ThemeName)) return t;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+laBoxedTheme *laGetBoxedTheme(const char *ThemeName, const char *BoxName){
|
|
|
+ laTheme *t = MAIN.Themes.pFirst;
|
|
|
+ for (t; t; t = t->Item.pNext){
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ if (!strSame(t->Name->Ptr, ThemeName)) continue;
|
|
|
+ bt = t->BoxedThemes.pFirst;
|
|
|
+ for (bt; bt; bt = bt->Item.pNext){
|
|
|
+ if (strSame(bt->Name->Ptr, BoxName)) return bt;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+real* laThemeColor(laBoxedTheme* bt, int which){
|
|
|
+ switch(which){
|
|
|
+ default:
|
|
|
+ case LA_BT_NORMAL: return bt->Normal;
|
|
|
+ case LA_UI_EDITING:
|
|
|
+ case LA_BT_ACTIVE: return bt->Active;
|
|
|
+ case LA_BT_BORDER: return bt->Border;
|
|
|
+ case LA_BT_TEXT: return bt->Text; break;
|
|
|
+ case LA_BT_TEXT_ACTIVE: return bt->TextActive; break;
|
|
|
+ case LA_BT_DISABLED: return bt->Inactive; break;
|
|
|
+ case LA_BT_DISABLED|LA_BT_TEXT: return bt->TextInactive; break;
|
|
|
+ }
|
|
|
+ return bt->Normal;
|
|
|
+}
|
|
|
+real* laAccentColor(int which){
|
|
|
+ switch(which){
|
|
|
+ default:
|
|
|
+ case LA_BT_NORMAL: case LA_UI_EDITING: case LA_BT_ACTIVE: return MAIN.CurrentTheme->SelectionColor;
|
|
|
+ case LA_BT_BORDER: case LA_BT_TEXT: case LA_BT_TEXT_ACTIVE: return MAIN.CurrentTheme->CursorColor;
|
|
|
+ case LA_BT_VERTEX: return MAIN.CurrentTheme->VertexColor;
|
|
|
+ case LA_BT_FACE:
|
|
|
+ case LA_BT_EDGE: return MAIN.CurrentTheme->EdgeColor;
|
|
|
+ case LA_BT_SVERTEX: return MAIN.CurrentTheme->SVertexColor;
|
|
|
+ case LA_BT_SEDGE: return MAIN.CurrentTheme->SEdgeColor;
|
|
|
+ case LA_BT_SFACE: return MAIN.CurrentTheme->SFaceColor;
|
|
|
+ }
|
|
|
+ return MAIN.CurrentTheme->SelectionColor;
|
|
|
+}
|
|
|
+void la_RefreshBoxedThemeColor(laBoxedTheme* bt){
|
|
|
+ real hcy[3];
|
|
|
+ tnsRGBtoHCY(MAIN.CurrentTheme->Color,hcy);
|
|
|
+ hcy[2]=bt->NormalY; tnsHCYtoRGB(hcy, bt->Normal); bt->Normal[3]=bt->Alpha;
|
|
|
+ hcy[2]=bt->ActiveY; tnsHCYtoRGB(hcy, bt->Active); bt->Active[3]=bt->Alpha;
|
|
|
+ hcy[2]=bt->BorderY; tnsHCYtoRGB(hcy, bt->Border); bt->Border[3]=1;
|
|
|
+ hcy[2]=bt->TextY; tnsHCYtoRGB(hcy, bt->Text); bt->Text[3]=1;
|
|
|
+ hcy[2]=bt->TextActiveY; tnsHCYtoRGB(hcy, bt->TextActive); bt->TextActive[3]=1;
|
|
|
+ int *tm=&bt->LM,*tp=&bt->LP;
|
|
|
+ for(int i=0;i<4;i++){
|
|
|
+ tm[i]=bt->Margins[i]*LA_RH*MAIN.MarginSize;
|
|
|
+ tp[i]=bt->Paddings[i]*LA_RH*MAIN.MarginSize;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_RefreshThemeColorSelf(laTheme* th){
|
|
|
+ tnsVectorCopy3d(th->AccentColor, th->CursorColor); th->CursorColor[3]=th->CursorAlpha;
|
|
|
+ tnsVectorCopy3d(th->AccentColor, th->SelectionColor);th->SelectionColor[3]=th->SelectionAlpha;
|
|
|
+ real hcy[3], usehcy[3];
|
|
|
+ tnsRGBtoHCY(th->Color,hcy); tnsVectorCopy3d(hcy,usehcy);
|
|
|
+ usehcy[2]=th->VertexBrightness; tnsHCYtoRGB(usehcy, th->VertexColor); th->VertexColor[3]=th->VertexTransparency;
|
|
|
+ usehcy[2]=th->EdgeBrightness; tnsHCYtoRGB(usehcy, th->EdgeColor); th->EdgeColor[3]=th->EdgeTransparency;
|
|
|
+ tnsVectorCopy3d(th->AccentColor, th->SVertexColor); th->SVertexColor[3]=th->SelectedVertexTransparency;
|
|
|
+ tnsVectorCopy3d(th->AccentColor, th->SEdgeColor); th->SEdgeColor[3]=th->SelectedEdgeTransparency;
|
|
|
+ tnsVectorCopy3d(th->AccentColor, th->SFaceColor); th->SFaceColor[3]=th->SelectedFaceTransparency;
|
|
|
+}
|
|
|
+void la_RefreshThemeColor(laTheme* th){
|
|
|
+ real hcy[3], usehcy[3], normalhcy[3];
|
|
|
+ tnsRGBtoHCY(th->Color,hcy);
|
|
|
+ la_RefreshThemeColorSelf(th);
|
|
|
+ for(laBoxedTheme* bt = th->BoxedThemes.pFirst;bt;bt=bt->Item.pNext){
|
|
|
+ la_RefreshBoxedThemeColor(bt);
|
|
|
+ (*bt->BackRef) = bt;
|
|
|
+ tnsRGBtoHCY(bt->Text, usehcy); usehcy[1]*=th->InactiveSaturation;
|
|
|
+ tnsHCYtoRGB(usehcy, bt->TextInactive); bt->TextInactive[3]=th->InactiveMix;
|
|
|
+ tnsRGBtoHCY(bt->Normal, normalhcy); normalhcy[1]*=th->InactiveSaturation;
|
|
|
+ tnsHCYtoRGB(normalhcy, bt->Inactive); bt->Inactive[3]=bt->Alpha*th->InactiveMix;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//I FUCKING HATE THIS STUPID FUNCTION
|
|
|
+int la_SetUpUiListMatrix(laUiListDraw *uild, laUiList *Target, int _L, int _R, int LimH, int PanelH, int GlobalX, int GlobalY){
|
|
|
+ laUiListDrawItem *uildi = memAcquireSimple(sizeof(laUiListDrawItem));
|
|
|
+ laUiListDrawItem *last = uild->Items.pFirst;
|
|
|
+ int LimW=_R-_L;
|
|
|
+ int SL, SR, SU, SB;
|
|
|
+ int Target__B = Target->B;
|
|
|
+ int Target__R = Target->R;
|
|
|
+
|
|
|
+ uildi->Target = Target;
|
|
|
+
|
|
|
+ //if (Target__B - Target->U > LimH) Target__B = Target->U + LimH;
|
|
|
+ if (Target__R - Target->L > LimW) Target__R = Target->L + LimW;
|
|
|
+
|
|
|
+ uildi->XP = last ? last->XP + Target->PanX : Target->PanX;
|
|
|
+ uildi->YP = last ? last->YP + Target->PanY : Target->PanY;
|
|
|
+
|
|
|
+ uildi->L = last ? Target->L - last->XP : Target->L;
|
|
|
+ uildi->R = last ? Target__R - last->XP : Target__R;
|
|
|
+ uildi->U = last ? Target->U - last->YP : Target->U;
|
|
|
+ uildi->B = last ? Target__B - last->YP : Target__B;
|
|
|
+
|
|
|
+ if (uildi->B - uildi->U > LimH) uildi->B = Target->U + LimH;
|
|
|
+
|
|
|
+ uildi->L -= GlobalX;
|
|
|
+ uildi->R -= GlobalX;
|
|
|
+ uildi->U -= GlobalY;
|
|
|
+ uildi->B -= GlobalY;
|
|
|
+
|
|
|
+ SL = last ? (uildi->L < last->L ? last->L : uildi->L) : uildi->L;
|
|
|
+ SR = last ? (uildi->R > last->R ? last->R : uildi->R) : uildi->R;
|
|
|
+ SU = last ? (uildi->U < last->U ? last->U : uildi->U) : uildi->U;
|
|
|
+ SB = last ? (uildi->B > last->B ? last->B : uildi->B) : uildi->B;
|
|
|
+
|
|
|
+ uildi->DifX = SL - uildi->L;
|
|
|
+ uildi->DifY = SU - uildi->U;
|
|
|
+
|
|
|
+ uildi->L = SL;
|
|
|
+ uildi->R = SR+uildi->DifX;
|
|
|
+ uildi->U = SU;
|
|
|
+ uildi->B = SB;//+uildi->DifY;
|
|
|
+ if(uildi->R>_R){ uildi->R=_R; }
|
|
|
+ if(uildi->B-SU>LimH){ uildi->B=SU+LimH; }
|
|
|
+
|
|
|
+ //printf("py %f %d lb %d b %d limh %d sb%d\n",Target->PanY,uildi->U,last?last->B:0,uildi->B,LimH,SB);
|
|
|
+
|
|
|
+ if(uildi->R - uildi->L<=0 || uildi->B - uildi->U<=0){
|
|
|
+ memFree(uildi);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ tnsViewportWithScissor(uildi->L, PanelH - uildi->B, uildi->R - uildi->L, uildi->B - uildi->U);
|
|
|
+ tnsOrtho(Target->L + Target->PanX + uildi->DifX,
|
|
|
+ Target->L + Target->PanX + uildi->DifX + (uildi->R - uildi->L),
|
|
|
+ Target->U + Target->PanY + uildi->DifY + (uildi->B - uildi->U),
|
|
|
+ Target->U + Target->PanY + uildi->DifY,
|
|
|
+ -100, 100);
|
|
|
+
|
|
|
+ lstPushItem(&uild->Items, uildi);
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+void la_SetUpUiListMatrixInLine(laUiListDraw *uild, int L, int R, int U, int B, int PanX, int PanY, int LimH, int PanelH){
|
|
|
+ laUiListDrawItem *uildi = memAcquireSimple(sizeof(laUiListDrawItem));
|
|
|
+ laUiListDrawItem *last = uild->Items.pFirst;
|
|
|
+ int SL, SR, SU, SB;
|
|
|
+
|
|
|
+ if (B - U > LimH) B = U + LimH;
|
|
|
+
|
|
|
+ uildi->XP = last ? last->XP + PanX : PanX;
|
|
|
+ uildi->YP = last ? last->YP + PanY : PanY;
|
|
|
+
|
|
|
+ uildi->L = last ? L - last->XP : L;
|
|
|
+ uildi->R = last ? R - last->XP : R;
|
|
|
+ uildi->U = last ? U - last->YP : U;
|
|
|
+ uildi->B = last ? B - last->YP : B;
|
|
|
+
|
|
|
+ SL = last ? (uildi->L < last->L ? last->L : uildi->L) : uildi->L;
|
|
|
+ SR = last ? (uildi->R > last->R ? last->R : uildi->R) : uildi->R;
|
|
|
+ SU = last ? (uildi->U < last->U ? last->U : uildi->U) : uildi->U;
|
|
|
+ SB = last ? (uildi->B > last->B ? last->B : uildi->B) : uildi->B;
|
|
|
+
|
|
|
+ uildi->DifX = SL - uildi->L;
|
|
|
+ uildi->DifY = SU - uildi->U;
|
|
|
+
|
|
|
+ uildi->L = SL;
|
|
|
+ uildi->R = SR;
|
|
|
+ uildi->U = SU;
|
|
|
+ uildi->B = SB;
|
|
|
+
|
|
|
+ tnsViewportWithScissor(uildi->L, PanelH - uildi->B, uildi->R - uildi->L, uildi->B - uildi->U);
|
|
|
+ tnsOrtho(L + PanX + uildi->DifX,
|
|
|
+ L + PanX + uildi->DifX + (uildi->R - uildi->L),
|
|
|
+ U + PanY + uildi->DifY + (uildi->B - uildi->U),
|
|
|
+ U + PanY + uildi->DifY,
|
|
|
+ -100, 100);
|
|
|
+
|
|
|
+ lstPushItem(&uild->Items, uildi);
|
|
|
+}
|
|
|
+
|
|
|
+void la_RebuildCurrentUiListMatrix(laUiListDraw *uild, laUiList *Target, int LimH, int PanelH){
|
|
|
+ laUiListDrawItem *uildi = uild->Items.pFirst;
|
|
|
+
|
|
|
+ tnsViewportWithScissor(uildi->L, PanelH - uildi->B, uildi->R - uildi->L, uildi->B - uildi->U);
|
|
|
+ tnsOrtho(Target->L + Target->PanX + uildi->DifX,
|
|
|
+ Target->L + Target->PanX + uildi->DifX + (uildi->R - uildi->L),
|
|
|
+ Target->U + Target->PanY + uildi->DifY + (uildi->B - uildi->U),
|
|
|
+ Target->U + Target->PanY + uildi->DifY,
|
|
|
+ -100, 100);
|
|
|
+}
|
|
|
+void la_RestoreLastUiListMatrix(laUiListDraw *uild, int PanelH){
|
|
|
+ laUiListDrawItem *uildi = lstPopItem(uild);
|
|
|
+ laUiList *Target;
|
|
|
+
|
|
|
+ memFree(uildi);
|
|
|
+ uildi = uild->Items.pFirst;
|
|
|
+
|
|
|
+ if (!uildi || !uildi->Target){
|
|
|
+ if (uild->Items.pFirst) la_RestoreLastUiListMatrix(uild, PanelH);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Target = uildi->Target;
|
|
|
+
|
|
|
+ tnsViewportWithScissor(uildi->L, PanelH - uildi->B, uildi->R - uildi->L, uildi->B - uildi->U);
|
|
|
+ tnsOrtho(Target->L + Target->PanX + uildi->DifX,
|
|
|
+ Target->L + Target->PanX + uildi->DifX + (uildi->R - uildi->L),
|
|
|
+ Target->U + Target->PanY + uildi->DifY + (uildi->B - uildi->U),
|
|
|
+ Target->U + Target->PanY + uildi->DifY,
|
|
|
+ -100, 100);
|
|
|
+}
|
|
|
+void la_SetupUiListLimitMatrix(laUiListDraw *uild, int L, int R, int U, int B, int PanelH){
|
|
|
+ laUiListDrawItem *uildi = memAcquireSimple(sizeof(laUiListDrawItem));
|
|
|
+
|
|
|
+ uildi->L = L;
|
|
|
+ uildi->R = R;
|
|
|
+ uildi->U = U;
|
|
|
+ uildi->B = B;
|
|
|
+
|
|
|
+ tnsViewportWithScissor(uildi->L, PanelH - uildi->B, uildi->R - uildi->L, uildi->B - uildi->U);
|
|
|
+ tnsOrtho(L, R, B, U, -100, 100);
|
|
|
+
|
|
|
+ lstPushItem(&uild->Items, uildi);
|
|
|
+}
|
|
|
+void la_ClearUiListMatrix(laUiListDraw *uild){
|
|
|
+ laUiListDrawItem *uildi;
|
|
|
+
|
|
|
+ while (uildi = lstPopItem(uild)){
|
|
|
+ memFree(uildi);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast, laPanel *ParentPanel);
|
|
|
+int la_DrawUiListRecursive(laUiListDraw *uild, laUiList *uil, int L, int R, int U, int B, int LimH, int ConditionStackLevel, int GlobalX, int GlobalY, int RegisterNodes);
|
|
|
+void la_DestroyUiList(laUiList *uil, int NoFree, int RemoveUsers, int OnlyRemoveUser);
|
|
|
+void la_DrawUiListScrollerV(laUiList *uil, int DisplayOffset, int TotalH, int DisplayH, int UiR);
|
|
|
+int la_TestUiListMinumWidth(laUiList *uil);
|
|
|
+
|
|
|
+void la_PanelValidateWidth(laPanel *p, laUiList *ui){
|
|
|
+ if (ui){
|
|
|
+ if (p->MaxW && p->TW > p->MaxW) p->TW = p->MaxW;
|
|
|
+ if (p->MinW && p->TW < p->MinW) p->TW = p->MinW;
|
|
|
+ la_EnsurePanelSnapping(p, MAIN.CurrentWindow->CW, MAIN.CurrentWindow->CH);
|
|
|
+ p->X = p->TX; p->Y = p->TY;
|
|
|
+ p->W = p->TW;
|
|
|
+ }
|
|
|
+}
|
|
|
+void laEnsurePanelInBound(laPanel *p, laUiList *uil){
|
|
|
+ int cw = MAIN.CurrentWindow->CW;
|
|
|
+ int ch = MAIN.CurrentWindow->CH;
|
|
|
+ int PH = p->TH;
|
|
|
+ laBoxedTheme*bt = *p->BT;
|
|
|
+
|
|
|
+ int uih=uil->B + bt->TM+bt->BM;
|
|
|
+ if (p->BoundUi && !(p->SB||p->ST)) PH = TNS_MAX2(uih, p->MinH);
|
|
|
+ if (p->MaxH && PH > p->MaxH) p->TH = p->MaxH;
|
|
|
+ else if (p->MinH && PH < p->MinH)
|
|
|
+ p->TH = p->MinH;
|
|
|
+ else
|
|
|
+ p->TH = PH;
|
|
|
+
|
|
|
+ p->H = p->TH;
|
|
|
+
|
|
|
+ if ((p->X + p->W) > cw){
|
|
|
+ p->X -= (p->X + p->W - cw);
|
|
|
+ }
|
|
|
+ if ((p->Y + p->H) > ch){
|
|
|
+ p->Y -= (p->Y + p->H - ch);
|
|
|
+ }
|
|
|
+ if (p->X < 0) p->X = 0;
|
|
|
+ if (p->Y < 0) p->Y = 0;
|
|
|
+ if ((p->X + p->W) > cw){
|
|
|
+ p->W -= (p->X + p->W - cw);
|
|
|
+ }
|
|
|
+ if ((p->Y + p->H) > ch){
|
|
|
+ p->H -= (p->Y + p->H - ch);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (p->ST) p->TY = p->ST;
|
|
|
+ if (p->SB && p->TH != ch - p->TY - p->SB) p->Refresh = LA_TAG_RECALC;
|
|
|
+ if (p->SB) p->TH = ch - p->TY - p->SB;
|
|
|
+
|
|
|
+ p->TX = p->X; p->TY = p->Y;
|
|
|
+ p->TW = p->W; p->TH = p->H;
|
|
|
+
|
|
|
+ if (p->OffScr &&
|
|
|
+ (p->W != p->OffScr->pColor[0]->Width ||
|
|
|
+ p->H != p->OffScr->pColor[0]->Height)){
|
|
|
+ tnsConfigureOffscreen(p->OffScr, p->W,p->H);
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_SetPanelMatrix(laPanel *p, laBoxedTheme *bt){
|
|
|
+ tnsDrawToOffscreen(p->OffScr, 1, 0);
|
|
|
+ tnsViewportWithScissor(0, 0, p->W, p->H);
|
|
|
+ //tnsMatrixMode(TNS_PROJECTION_MATRIX);
|
|
|
+ tnsOrtho(0, p->W, p->H, 0, -100, 100);
|
|
|
+}
|
|
|
+void la_SetPanelMatrixDrawWindow(laPanel *p, laBoxedTheme *bt){
|
|
|
+ tnsDrawToScreen();
|
|
|
+ tnsViewportWithScissor(p->X, MAIN.CurrentWindow->CH - p->H - p->Y, p->W, p->H);
|
|
|
+ tnsOrtho(0, p->W, p->H, 0, -100, 100);
|
|
|
+}
|
|
|
+void la_SetPanelMatrixLRTB(int PW, int PH, int LPadding, int RPadding, int TPadding, int BPadding, int XOffset, int YOffset){
|
|
|
+ tnsViewportWithScissor(LPadding, BPadding, PW - LPadding - RPadding, PH - TPadding - BPadding);
|
|
|
+ tnsOrtho(XOffset, XOffset + PW - LPadding - RPadding, YOffset + PH - BPadding, YOffset + TPadding, -100, 100);
|
|
|
+}
|
|
|
+void la_PanelBackgroundInit(laPanel *p, laBoxedTheme *bt){
|
|
|
+ glClearColor(LA_COLOR4(laThemeColor(bt,LA_BT_NORMAL)));
|
|
|
+ tnsClearAll();
|
|
|
+}
|
|
|
+void la_PanelDrawToWindow(laPanel *p, laWindow *w){
|
|
|
+ real Color[] = {1, 1, 1, 1};
|
|
|
+ real L, W, U, H;
|
|
|
+ switch (p->AnimationMode){
|
|
|
+ case 0:
|
|
|
+ tnsDraw2DTextureDirectly(p->OffScr->pColor[0], p->X, p->Y, p->W, p->H);
|
|
|
+ //if(p->Mode==LA_PANEL_FLOATING_TOP)
|
|
|
+ // tnsDrawStringAuto("◿",laThemeColor(*p->BT,LA_BT_BORDER),p->X+p->W-LA_RH, p->X+p->W, p->H+p->Y-LA_RH, LA_TEXT_ALIGN_CENTER);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LA_PANEL_ANIMATION_DROP_DOWN:
|
|
|
+ tnsVectorMultiSelf4d(Color, p->AnimationRatio);
|
|
|
+ tnsDraw2DTextureArg(
|
|
|
+ p->OffScr->pColor[0],
|
|
|
+ p->X, p->Y, p->W, p->H * p->AnimationRatio,
|
|
|
+ Color,
|
|
|
+ 0, 0, 1 - p->AnimationRatio, 0);
|
|
|
+ p->AnimationRatio += (1 - p->AnimationRatio) * MAIN.PanelAnimationSpeed * MAIN.LastFrameTime * 60;
|
|
|
+ if (p->AnimationRatio > 0.99) p->AnimationMode = 0;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LA_PANEL_ANIMATION_EXPAND:
|
|
|
+ L = tnsLinearItp(p->X, p->X + p->W, 0.3);
|
|
|
+ U = tnsLinearItp(p->Y, p->Y + p->H, 0.3);
|
|
|
+ W = tnsLinearItp(0, p->W, 0.4);
|
|
|
+ H = tnsLinearItp(0, p->H, 0.4);
|
|
|
+ tnsVectorMultiSelf4d(Color, p->AnimationRatio);
|
|
|
+ tnsDraw2DTextureArg(
|
|
|
+ p->OffScr->pColor[0],
|
|
|
+ tnsLinearItp(L, p->X, p->AnimationRatio), tnsLinearItp(U, p->Y, p->AnimationRatio),
|
|
|
+ tnsLinearItp(W, p->W, p->AnimationRatio), tnsLinearItp(H, p->H, p->AnimationRatio),
|
|
|
+ Color,
|
|
|
+ 0, 0, 0, 0);
|
|
|
+ p->AnimationRatio += (1 - p->AnimationRatio) * MAIN.PanelAnimationSpeed * MAIN.LastFrameTime * 60;
|
|
|
+ if (p->AnimationRatio > 0.99) p->AnimationMode = 0;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LA_PANEL_ANIMATION_DISSOVE:
|
|
|
+ L = tnsLinearItp(p->X, p->X + p->W, -0.2);
|
|
|
+ U = tnsLinearItp(p->Y, p->Y + p->H, -0.2);
|
|
|
+ W = tnsLinearItp(0, p->W, 1.4);
|
|
|
+ H = tnsLinearItp(0, p->H, 1.4);
|
|
|
+ tnsVectorMultiSelf4d(Color, (p->AnimationRatio));
|
|
|
+ if (p->OffScr) tnsDraw2DTextureArg(
|
|
|
+ p->OffScr->pColor[0],
|
|
|
+ tnsLinearItp(L, p->X, p->AnimationRatio), tnsLinearItp(U, p->Y, p->AnimationRatio),
|
|
|
+ tnsLinearItp(W, p->W, p->AnimationRatio), tnsLinearItp(H, p->H, p->AnimationRatio),
|
|
|
+ Color,
|
|
|
+ 0, 0, 0, 0);
|
|
|
+ p->AnimationRatio -= (p->AnimationRatio) * MAIN.PanelAnimationSpeed * MAIN.LastFrameTime * 60;
|
|
|
+ if (p->AnimationRatio < 0.01) p->AnimationMode = 0;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LA_PANEL_ANIMATION_COLLAPSE:
|
|
|
+ L = tnsLinearItp(p->X, p->X + p->W, 0.3);
|
|
|
+ U = tnsLinearItp(p->Y, p->Y + p->H, 0.3);
|
|
|
+ W = tnsLinearItp(0, p->W, 0.4);
|
|
|
+ H = tnsLinearItp(0, p->H, 0.4);
|
|
|
+ tnsVectorMultiSelf4d(Color, p->AnimationRatio);
|
|
|
+ if (p->OffScr) tnsDraw2DTextureArg(
|
|
|
+ p->OffScr->pColor[0],
|
|
|
+ tnsLinearItp(L, p->X, p->AnimationRatio), tnsLinearItp(U, p->Y, p->AnimationRatio),
|
|
|
+ tnsLinearItp(W, p->W, p->AnimationRatio), tnsLinearItp(H, p->H, p->AnimationRatio),
|
|
|
+ Color,
|
|
|
+ 0, 0, 0, 0);
|
|
|
+ p->AnimationRatio -= p->AnimationRatio * MAIN.PanelAnimationSpeed * MAIN.LastFrameTime * 60;
|
|
|
+ if (p->AnimationRatio < 0.01) p->AnimationMode = 0;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LA_PANEL_ANIMATION_MINIMIZE:
|
|
|
+ L = tnsLinearItp(0, p->X, 0.3);
|
|
|
+ U = tnsLinearItp(w->H, p->Y + p->H, 0.3);
|
|
|
+ W = tnsLinearItp(0, p->W, 0.4);
|
|
|
+ H = tnsLinearItp(0, p->H, 0.4);
|
|
|
+ tnsVectorMultiSelf4d(Color, p->AnimationRatio);
|
|
|
+ tnsDraw2DTextureArg(
|
|
|
+ p->OffScr->pColor[0],
|
|
|
+ tnsLinearItp(L, p->X, p->AnimationRatio), tnsLinearItp(U, p->Y, p->AnimationRatio),
|
|
|
+ tnsLinearItp(W, p->W, p->AnimationRatio), tnsLinearItp(H, p->H, p->AnimationRatio),
|
|
|
+ Color,
|
|
|
+ 0, 0, 0, 0);
|
|
|
+ p->AnimationRatio -= p->AnimationRatio * MAIN.PanelAnimationSpeed * MAIN.LastFrameTime * 60;
|
|
|
+ if (p->AnimationRatio < 0.01) p->AnimationMode = 0;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ tnsFlush();
|
|
|
+}
|
|
|
+void la_PanelDrawToOffsceen(laPanel *p, laUiList *uil){
|
|
|
+ laEnsurePanelInBound(p,p->MenuRefer?p->MenuRefer:&p->UI);
|
|
|
+ if (!p->OffScr){
|
|
|
+ p->OffScr = tnsCreate2DOffscreen(GL_RGBA8, p->W, p->H, MAIN.PanelMultisample, 0);
|
|
|
+ }
|
|
|
+ tnsDrawToOffscreen(p->OffScr, 1, 0);
|
|
|
+}
|
|
|
+void la_PanelRefreshDetachedProp(laPanel *panel){
|
|
|
+ laProp *p;
|
|
|
+ for (p = panel->PropLinkContainer->Props.pFirst; p; p = p->Item.pNext){la_StopUsingPropPack(&p->DetachedPP);
|
|
|
+ la_StepPropPack(&p->DetachedPP);
|
|
|
+ la_UsePropPack(&p->DetachedPP, 0);
|
|
|
+ //if (p->DetachedPP.LastPs && p->DetachedPP.LastPs->p->Container ? p->DetachedPP.LastPs->p->Container->Hyper : 0){
|
|
|
+ // laUseDataBlock(
|
|
|
+ // p->DetachedPP.LastPs->UseInstance,
|
|
|
+ // p->DetachedPP.LastPs->p,
|
|
|
+ // MAIN.PropMatcherContextP->FrameDistinguish,
|
|
|
+ // MAIN.PropMatcherContextP,
|
|
|
+ // la_PropPanelUserRemover, 0);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void la_PanelDrawDescendBorder(laPanel *Panel, laBoxedTheme *bt, int Width, real Alpha){
|
|
|
+ real* color=laThemeColor(bt,LA_BT_NORMAL);
|
|
|
+ tnsColor4d(LA_COLOR3(color),Alpha);
|
|
|
+ tnsVertex2d(Panel->X + Width, Panel->Y + Panel->H);
|
|
|
+ tnsVertex2d(Panel->X + Width, Panel->Y + Panel->H + Width);
|
|
|
+ tnsVertex2d(Panel->X + Panel->W, Panel->Y + Panel->H);
|
|
|
+ tnsVertex2d(Panel->X + Panel->W + Width, Panel->Y + Panel->H + Width);
|
|
|
+ tnsVertex2d(Panel->X + Panel->W, Panel->Y + Width);
|
|
|
+ tnsVertex2d(Panel->X + Panel->W + Width, Panel->Y + Width);
|
|
|
+ tnsPackAs(GL_TRIANGLE_STRIP);
|
|
|
+
|
|
|
+ tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
|
|
|
+ tnsVertex2d(Panel->X, Panel->Y);
|
|
|
+ tnsVertex2d(Panel->X, Panel->Y + Panel->H);
|
|
|
+ tnsVertex2d(Panel->X + Panel->W, Panel->Y + Panel->H);
|
|
|
+ tnsVertex2d(Panel->X + Panel->W, Panel->Y);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+}
|
|
|
+
|
|
|
+int la_AnimateUiListRecursive(laUiList *uil);
|
|
|
+
|
|
|
+void la_PanelDefDraw(laWindow *w, laPanel *p, laBoxedTheme *bt){
|
|
|
+ int DrawState_ = 0;
|
|
|
+ laUiListDraw uild = {0};
|
|
|
+
|
|
|
+ if (p->Show){
|
|
|
+ la_SetPropMathcerContext(p);
|
|
|
+ MAIN.CurrentPanel = p;
|
|
|
+
|
|
|
+ //if(p->Refresh&(LA_TAG_REDRAW|LA_TAG_RECALC)){
|
|
|
+ // printf("Draw %0xld (%s)\n", p, p->Title?p->Title->Ptr:0);
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (p->Refresh & LA_TAG_RECALC){
|
|
|
+ laRecalcPanelImmediate(p);
|
|
|
+ }
|
|
|
+ if (!p->MenuRefer){
|
|
|
+ if(!p->OffScr){la_PanelDrawToOffsceen(p,&p->UI); p->Refresh|=LA_TAG_REDRAW;}
|
|
|
+ if (p->Refresh || !p->OffScr){
|
|
|
+ la_PanelDrawToOffsceen(p, &p->UI);
|
|
|
+ la_SetupUiListLimitMatrix(&uild, 0, p->W, 0, p->H, p->H);
|
|
|
+ la_PanelBackgroundInit(p, bt);
|
|
|
+ la_DrawUiListScrollerV(&p->UI, p->UI.PanY, p->UI.B-p->UI.U-bt->TM-bt->BM, p->H-p->TitleBar.B-bt->TM-bt->BM*2, p->W);
|
|
|
+ tnsFlush();
|
|
|
+
|
|
|
+ if(((p->UI.B>p->H) && (!p->UI.ScrollerShownV))||
|
|
|
+ ((p->UI.B<=p->H) && p->UI.ScrollerShownV)){
|
|
|
+ p->UI.ScrollerShownV=!p->UI.ScrollerShownV;
|
|
|
+ DrawState_++;
|
|
|
+ }
|
|
|
+ if(p->UI.PanY && p->UI.B-p->UI.PanY<p->H-bt->BM ){
|
|
|
+ p->UI.PanY = (p->UI.B-p->H/*-bt->BM-bt->TM*/-p->TitleBar.B);
|
|
|
+ if(p->UI.PanY<0){p->UI.PanY=0;}
|
|
|
+ DrawState_++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(p->Refresh&LA_TAG_RECALC_SCROLLER) DrawState_++;
|
|
|
+
|
|
|
+ if (!la_AnimateUiListRecursive(&p->TitleBar)) p->Refresh = 0;
|
|
|
+ else p->Refresh = LA_TAG_ANIMATION;
|
|
|
+ if (!la_AnimateUiListRecursive(&p->UI)) p->Refresh = p->Refresh;
|
|
|
+ else p->Refresh = LA_TAG_ANIMATION;
|
|
|
+ DrawState_ += la_DrawUiListRecursive(&uild, &p->TitleBar, 0, p->W, 0, p->H, 10000, -1, 0, 0, 0);
|
|
|
+ if(p!=w->MaximizedUiPanel){
|
|
|
+ DrawState_ += la_DrawUiListRecursive(&uild, &p->UI, 0, p->W, 0, p->H, 10000, -1, 0, 0, 0);
|
|
|
+ }else{
|
|
|
+ tnsViewportWithScissor(0,0,p->W,p->H); tnsOrtho(0,p->W,p->H,0,-100,100);
|
|
|
+ tnsDrawStringAutoM("Canvas is maximized",0,laThemeColor(bt,LA_BT_TEXT),
|
|
|
+ bt->LM,p->W-bt->RM,(p->H - p->TitleBar.B)/2+LA_RH2,LA_TEXT_ALIGN_CENTER|LA_TEXT_LINE_WRAP);
|
|
|
+ tnsFlush();
|
|
|
+ }
|
|
|
+ if (DrawState_) p->Refresh = LA_TAG_RECALC;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (p->Refresh || !p->OffScr){
|
|
|
+ la_PanelDrawToOffsceen(p, p->MenuRefer);
|
|
|
+ la_SetupUiListLimitMatrix(&uild, 0, p->W, 0, p->H, p->H);
|
|
|
+ la_PanelBackgroundInit(p, bt);
|
|
|
+ la_DrawUiListScrollerV(p->MenuRefer, p->MenuRefer->PanY,
|
|
|
+ p->MenuRefer->B-p->MenuRefer->U-bt->TM-bt->BM, p->H-bt->TM-bt->BM*2, p->W);
|
|
|
+ tnsFlush();
|
|
|
+
|
|
|
+ if(((p->MenuRefer->TB>p->H-bt->BP) && (!p->MenuRefer->ScrollerShownV))||
|
|
|
+ ((p->MenuRefer->TB<=p->H-bt->BP) && p->MenuRefer->ScrollerShownV)){
|
|
|
+ p->MenuRefer->ScrollerShownV=!p->MenuRefer->ScrollerShownV;
|
|
|
+ DrawState_++;
|
|
|
+ }
|
|
|
+ if(p->UI.PanY && p->MenuRefer->B-p->MenuRefer->PanY<p->H-bt->BM){
|
|
|
+ p->MenuRefer->PanY = (p->MenuRefer->B-p->H-bt->BM);
|
|
|
+ if(p->MenuRefer->PanY<0){p->MenuRefer->PanY=0;}
|
|
|
+ DrawState_++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(p->Refresh&LA_TAG_RECALC_SCROLLER) DrawState_++;
|
|
|
+
|
|
|
+ if (!la_AnimateUiListRecursive(p->MenuRefer)) p->Refresh = 0;
|
|
|
+ else p->Refresh = LA_TAG_ANIMATION;
|
|
|
+ DrawState_ += la_DrawUiListRecursive(&uild, p->MenuRefer, 0, p->W, 0, p->H, 10000, -1, 0, 0, 0);
|
|
|
+ if (DrawState_) p->Refresh = LA_TAG_RECALC;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tnsDrawToScreen();
|
|
|
+ tnsViewportWithScissor(0, 0, w->CW, w->CH);
|
|
|
+ tnsOrtho(0, w->CW, w->CH, 0, -100, 100);
|
|
|
+
|
|
|
+ la_PanelDrawToWindow(p, w);
|
|
|
+
|
|
|
+ if (p->Mode && (!p->AnimationMode || (p->AnimationMode && p->AnimationRatio > 0.99))){
|
|
|
+ tnsUseNoTexture();
|
|
|
+ if (!p->IsMenuPanel){
|
|
|
+ la_PanelDrawDescendBorder(p, bt, MAIN.SolidShadowLength, MAIN.FloatingAlpha);
|
|
|
+ }
|
|
|
+ tnsFlush();
|
|
|
+ }
|
|
|
+ }elif (p->AnimationMode){
|
|
|
+ la_PanelDrawToWindow(p, w);
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_AttachedPanelDefDraw(laWindow* w, laPanel* p, laBoxedTheme* bt){
|
|
|
+ if(!p->Show && p!=w->MaximizedUiPanel) return;
|
|
|
+ if (p->SubPanels.pLast && (p->LaterDestroy ? !p->AnimationMode : 1)){
|
|
|
+ laPanel *pi, *PrevPI;
|
|
|
+ for (pi = p->SubPanels.pLast; pi; pi = PrevPI){
|
|
|
+ PrevPI = pi->Item.pPrev;
|
|
|
+ if (pi->AnimationMode && pi->LaterDestroy){
|
|
|
+ lstRemoveItem(&p->SubPanels, pi);
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->FadingPanels, pi);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ la_PanelDefDraw(w, pi, _LA_THEME_FLOATING_PANEL);
|
|
|
+ la_AttachedPanelDefDraw(w,pi,bt);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_BlockDrawDropLocations(laBlock *b, int CH, real *BorderColor4dV, real *FillColor4dv){
|
|
|
+ real PanelSquare[] = {
|
|
|
+ b->X + 2, CH - (b->Y + 2 + LA_RH),
|
|
|
+ b->X + 2, CH - (b->Y + b->H - 4),
|
|
|
+ b->X + b->W - 4, CH - (b->Y + b->H - 4),
|
|
|
+ b->X + b->W - 4, CH - (b->Y + 2 + LA_RH)};
|
|
|
+ real Center[] = {
|
|
|
+ tnsLinearItp(PanelSquare[0], PanelSquare[4], 0.5), tnsLinearItp(PanelSquare[1], PanelSquare[5], 0.5)};
|
|
|
+ real DraggingPlot[] = {
|
|
|
+ tnsLinearItp(PanelSquare[0], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[1], Center[1], 0.5),
|
|
|
+ PanelSquare[0],
|
|
|
+ PanelSquare[1],
|
|
|
+ tnsLinearItp(PanelSquare[2], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[3], Center[1], 0.5),
|
|
|
+ PanelSquare[2],
|
|
|
+ PanelSquare[3],
|
|
|
+ tnsLinearItp(PanelSquare[4], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[5], Center[1], 0.5),
|
|
|
+ PanelSquare[4],
|
|
|
+ PanelSquare[5],
|
|
|
+ tnsLinearItp(PanelSquare[6], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[7], Center[1], 0.5),
|
|
|
+ PanelSquare[6],
|
|
|
+ PanelSquare[7],
|
|
|
+ };
|
|
|
+ real Square[] = {
|
|
|
+ tnsLinearItp(PanelSquare[0], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[1], Center[1], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[2], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[3], Center[1], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[4], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[5], Center[1], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[6], Center[0], 0.5),
|
|
|
+ tnsLinearItp(PanelSquare[7], Center[1], 0.5),
|
|
|
+ };
|
|
|
+ real PlotColor[] = {LA_COLOR3(BorderColor4dV), 0.8,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0.8,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0.8,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0.8,
|
|
|
+ LA_COLOR3(BorderColor4dV), 0,
|
|
|
+ };
|
|
|
+ real FillColor[] = {LA_COLOR3(FillColor4dv), 0.8,
|
|
|
+ LA_COLOR3(FillColor4dv), 0,
|
|
|
+ LA_COLOR3(FillColor4dv), 0.8,
|
|
|
+ LA_COLOR3(FillColor4dv), 0,
|
|
|
+ LA_COLOR3(FillColor4dv), 0.8,
|
|
|
+ LA_COLOR3(FillColor4dv), 0,
|
|
|
+ LA_COLOR3(FillColor4dv), 0.8,
|
|
|
+ LA_COLOR3(FillColor4dv), 0,
|
|
|
+ };
|
|
|
+
|
|
|
+ tnsUseNoTexture();
|
|
|
+
|
|
|
+ if (MAIN.CurrentWindow->CurrentLayout->DropToBlock == b){
|
|
|
+ int Index[4];
|
|
|
+ tnsVertexArray2d(DraggingPlot, 8);
|
|
|
+ tnsColorArray4d(FillColor, 8);
|
|
|
+ switch (MAIN.CurrentWindow->CurrentLayout->DropLocation){
|
|
|
+ case 0:
|
|
|
+ Index[0] = 0; Index[1] = 2; Index[2] = 4; Index[3] = 6;
|
|
|
+ break;
|
|
|
+ case LA_BLOCK_DROP_LOCATION_L:
|
|
|
+ Index[0] = 0; Index[1] = 1; Index[2] = 3; Index[3] = 2;
|
|
|
+ break;
|
|
|
+ case LA_BLOCK_DROP_LOCATION_R:
|
|
|
+ Index[0] = 4; Index[1] = 5; Index[2] = 7; Index[3] = 6;
|
|
|
+ break;
|
|
|
+ case LA_BLOCK_DROP_LOCATION_U:
|
|
|
+ Index[0] = 0; Index[1] = 1; Index[2] = 7; Index[3] = 6;
|
|
|
+ break;
|
|
|
+ case LA_BLOCK_DROP_LOCATION_B:
|
|
|
+ Index[0] = 4; Index[1] = 5; Index[2] = 3; Index[3] = 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //glDisable(GL_CULL_FACE);
|
|
|
+ tnsIndexArray(Index, 4);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+ //tnsFlush();
|
|
|
+ }
|
|
|
+
|
|
|
+ tnsVertexArray2d(DraggingPlot, 8);
|
|
|
+ tnsColorArray4d(PlotColor, 8);
|
|
|
+ tnsPackAs(GL_LINES);
|
|
|
+
|
|
|
+ tnsVertexArray2d(Square, 4);
|
|
|
+ tnsColor4dv(BorderColor4dV);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+
|
|
|
+ glLineWidth(LA_SEAM_W);
|
|
|
+ tnsFlush();
|
|
|
+ glLineWidth(1);
|
|
|
+}
|
|
|
+void la_BlockDefDrawSelf(laBlock *b, int CH){
|
|
|
+ laBoxedTheme *bt = _LA_THEME_TAB;
|
|
|
+ laPanel *p;
|
|
|
+ real v[] = {
|
|
|
+ b->X, CH - b->Y,
|
|
|
+ b->X + LA_SEAM_W, CH - b->Y ,
|
|
|
+ b->X, CH - (b->Y + b->H),
|
|
|
+ b->X + LA_SEAM_W, CH - (b->Y + b->H - LA_SEAM_W),
|
|
|
+ b->X + b->W, CH - (b->Y + b->H),
|
|
|
+ b->X + b->W - LA_SEAM_W, CH - (b->Y + b->H - LA_SEAM_W),
|
|
|
+ b->X + b->W, CH - b->Y,
|
|
|
+ b->X + b->W - LA_SEAM_W, CH - b->Y};
|
|
|
+ real tv[8];
|
|
|
+ real ratio = 1.0001f;
|
|
|
+ int tw = 0;
|
|
|
+ int L = LA_RH+LA_SEAM_W;
|
|
|
+
|
|
|
+ for (p = b->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ tw += p->TitleWidth + LA_SEAM_W*2;
|
|
|
+ }
|
|
|
+ if (tw > b->W - LA_SEAM_W*2 - LA_RH) ratio = (real)(b->W - LA_SEAM_W*2 - LA_RH) / (real)tw;
|
|
|
+
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
|
|
|
+ tnsVertexArray2d(v, 8);
|
|
|
+ tnsPackAs(GL_TRIANGLE_STRIP);
|
|
|
+
|
|
|
+ int TitleGap=b->Folded?0:LA_RH;
|
|
|
+
|
|
|
+ tnsMakeQuad2d(tv, b->X, (CH - b->Y),
|
|
|
+ b->X + b->W, (CH - b->Y),
|
|
|
+ b->X + b->W, (CH - b->Y - TitleGap),
|
|
|
+ b->X, (CH - b->Y - TitleGap));
|
|
|
+ tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
|
|
|
+ tnsVertexArray2d(tv, 4);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+
|
|
|
+ tnsMakeQuad2d(tv,b->X + LA_SEAM_W, (CH - b->Y - TitleGap),
|
|
|
+ b->X + b->W - LA_SEAM_W, (CH - b->Y - TitleGap),
|
|
|
+ b->X + b->W - LA_SEAM_W, (CH - b->Y - TitleGap - LA_SEAM_W),
|
|
|
+ b->X + LA_SEAM_W, (CH - b->Y - TitleGap- LA_SEAM_W));
|
|
|
+ tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
|
|
|
+ tnsVertexArray2d(tv, 4);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+
|
|
|
+ if(b->Folded){
|
|
|
+ real Color[4]; tnsVectorCopy4d(laThemeColor(bt,LA_BT_BORDER), Color); Color[3]*=b->OnButton==2?1:(b->OnButton==1?0.3:0);
|
|
|
+ tnsDrawStringAuto("⯆",Color, b->X+LA_SEAM_W,b->X+LA_SEAM_W+LA_RH, CH-b->Y, LA_TEXT_REVERT_Y|LA_TEXT_ALIGN_CENTER);
|
|
|
+ tnsDrawStringAuto("⮼",Color, b->X+LA_SEAM_W+LA_RH,b->X+LA_SEAM_W+LA_2RH, CH-b->Y, LA_TEXT_REVERT_Y|LA_TEXT_ALIGN_CENTER);
|
|
|
+ tnsFlush(); return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int LT=0,RT=0;
|
|
|
+ for (p = b->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ RT = LT + p->TitleWidth + LA_SEAM_W*2;
|
|
|
+ tnsMakeQuad2d(tv,b->X + L+LT * ratio, (CH - b->Y),
|
|
|
+ b->X + L+RT * ratio, (CH - b->Y),
|
|
|
+ b->X + L+RT * ratio, (CH - b->Y - LA_RH),
|
|
|
+ b->X + L+LT * ratio, (CH - b->Y - LA_RH));
|
|
|
+
|
|
|
+ if (p == b->CurrentPanel){
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
|
|
|
+ tnsVertexArray2d(tv, 4);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+ tnsDrawStringAuto(p->Title->Ptr, laThemeColor(bt,LA_BT_TEXT_ACTIVE), b->X + L +LT* ratio + LA_SEAM_W, b->X + L +RT* ratio, CH - b->Y, LA_TEXT_REVERT_Y);
|
|
|
+ }else{
|
|
|
+ tnsDrawStringAuto(p->Title->Ptr, laThemeColor(bt,LA_BT_TEXT), b->X + L +LT* ratio + LA_SEAM_W, b->X + L +RT* ratio, CH - b->Y, LA_TEXT_REVERT_Y);
|
|
|
+ }
|
|
|
+
|
|
|
+ LT =RT;
|
|
|
+ }
|
|
|
+
|
|
|
+ tnsDrawStringAuto("🔻",laThemeColor(bt,LA_BT_BORDER), b->X+LA_SEAM_W,b->X+b->W, CH-b->Y, LA_TEXT_REVERT_Y);
|
|
|
+
|
|
|
+ tnsFlush();
|
|
|
+}
|
|
|
+void la_BlockDefDrawSelfEmpty(laBlock *b, int CH){
|
|
|
+ laBoxedTheme *bt = _LA_THEME_PANEL;
|
|
|
+ real tv[8];
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsMakeQuad2d(tv, b->X, (CH - b->Y),
|
|
|
+ b->X + b->W, (CH - b->Y),
|
|
|
+ b->X + b->W, (CH - b->Y-b->H),
|
|
|
+ b->X, (CH - b->Y-b->H));
|
|
|
+ tnsVertexArray2d(tv, 4);
|
|
|
+ tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+
|
|
|
+ tnsDrawStringAuto("Dock some panels here.", laThemeColor(bt,LA_BT_TEXT), b->X+LA_SEAM_W,b->X+b->W-LA_SEAM_W, CH-b->Y-b->H/2+LA_RH2,
|
|
|
+ LA_TEXT_ALIGN_CENTER|LA_TEXT_REVERT_Y|LA_TEXT_USE_NEWLINE|LA_TEXT_LINE_WRAP);
|
|
|
+ tnsFlush();
|
|
|
+}
|
|
|
+void la_BlockDefDrawRecursive(laWindow *w, laBoxedTheme *bt, laBlock *b){
|
|
|
+ if (b->B1){
|
|
|
+ la_BlockDefDrawRecursive(w, bt, b->B1);
|
|
|
+ la_BlockDefDrawRecursive(w, bt, b->B2);
|
|
|
+ }elif (b->CurrentPanel /*&& b->CurrentPanel->Refresh*/){
|
|
|
+ if (!b->CurrentPanel->BT) b->CurrentPanel->BT = &_LA_THEME_PANEL;
|
|
|
+ la_PanelDefDraw(w, b->CurrentPanel, *b->CurrentPanel->BT);
|
|
|
+ tnsViewportWithScissor(0, 0, w->CW, w->CH);
|
|
|
+ tnsOrtho(0, w->CW, 0, w->CH, -100, 100);
|
|
|
+ la_BlockDefDrawSelf(b, w->CH);
|
|
|
+ }else{
|
|
|
+ tnsViewportWithScissor(0, 0, w->CW, w->CH);
|
|
|
+ tnsOrtho(0, w->CW, 0, w->CH, -100, 100);
|
|
|
+ la_BlockDefDrawSelfEmpty(b, w->CH);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(b==MAIN.CurrentWindow->CurrentLayout->MovingBlock){
|
|
|
+ tnsUseNoTexture();
|
|
|
+ int at; real tv[8];
|
|
|
+ if (b->Vertical){
|
|
|
+ at = b->H * b->SplitRatio + b->Y;
|
|
|
+ tnsMakeQuad2d(tv,b->X, (w->CH - at + LA_SEAM_W),
|
|
|
+ b->X + b->W, (w->CH - at + LA_SEAM_W),
|
|
|
+ b->X + b->W, (w->CH - at - LA_SEAM_W),
|
|
|
+ b->X, (w->CH - at - LA_SEAM_W));
|
|
|
+ }else{
|
|
|
+ at = b->X + b->W * b->SplitRatio;
|
|
|
+ tnsMakeQuad2d(tv,at+ LA_SEAM_W, (w->CH - b->Y),
|
|
|
+ at- LA_SEAM_W, (w->CH - b->Y),
|
|
|
+ at- LA_SEAM_W, (w->CH - b->Y - b->H),
|
|
|
+ at+ LA_SEAM_W, (w->CH - b->Y - b->H));
|
|
|
+ }
|
|
|
+ tnsColor4dv(laThemeColor(_LA_THEME_TAB,LA_BT_BORDER));
|
|
|
+ tnsVertexArray2d(tv, 4);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+ }
|
|
|
+ //la_SetPanelMatrixDrawWindow(b->CurrentPanel, *b->CurrentPanel->BT);
|
|
|
+ tnsFlush();
|
|
|
+}
|
|
|
+void la_BlockDefDrawAttachedRecursive(laWindow *w, laBoxedTheme *bt, laBlock *b){
|
|
|
+ if (b->B1){
|
|
|
+ la_BlockDefDrawAttachedRecursive(w, bt, b->B1);
|
|
|
+ la_BlockDefDrawAttachedRecursive(w, bt, b->B2);
|
|
|
+ }elif (b->CurrentPanel /*&& b->CurrentPanel->Refresh*/){
|
|
|
+ la_AttachedPanelDefDraw(w,b->CurrentPanel,*b->CurrentPanel->BT);
|
|
|
+ }
|
|
|
+ tnsFlush();
|
|
|
+}
|
|
|
+
|
|
|
+void la_ClearBlockFramebuffersRecursive(laBlock* b, int AlsoClearCurrent){
|
|
|
+ if(b->B1)la_ClearBlockFramebuffersRecursive(b->B1,AlsoClearCurrent);
|
|
|
+ if(b->B2)la_ClearBlockFramebuffersRecursive(b->B2,AlsoClearCurrent);
|
|
|
+ for(laPanel* p=b->Panels.pFirst;p;p=p->Item.pNext){
|
|
|
+ if(!AlsoClearCurrent && p==b->CurrentPanel) continue;
|
|
|
+ if(p->OffScr){
|
|
|
+ tnsDelete2DOffscreen(p->OffScr); p->OffScr=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_ClearUnusedFramebuffers(laWindow* w){
|
|
|
+ for(laLayout* l = w->Layouts.pFirst;l;l=l->Item.pNext){
|
|
|
+ la_ClearBlockFramebuffersRecursive(l->FirstBlock, l!=w->CurrentLayout);
|
|
|
+ }
|
|
|
+ for(laPanel* p=w->Panels.pFirst;p;p=p->Item.pNext){
|
|
|
+ if(p->Show || p->AnimationMode) continue;
|
|
|
+ if(p->OffScr){
|
|
|
+ tnsDelete2DOffscreen(p->OffScr); p->OffScr=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void la_WindowDefDraw(laWindow *w, laBoxedTheme *bt){
|
|
|
+ laPanel *p, *NextP;
|
|
|
+ laLayout *l = w->CurrentLayout;
|
|
|
+
|
|
|
+ la_ClearUnusedFramebuffers(w);
|
|
|
+
|
|
|
+ tnsDrawToScreen();
|
|
|
+
|
|
|
+ tnsViewportWithScissor(0, 0, w->CW, w->CH);
|
|
|
+ glClearColor(0.2, 0.2, 0.3, 1.0);
|
|
|
+ tnsClearAll();
|
|
|
+
|
|
|
+ tnsUseNoTexture();
|
|
|
+ if (l->Draw) l->Draw(w, l);
|
|
|
+
|
|
|
+ tnsResetModelMatrix();tnsResetProjectionMatrix();tnsResetViewMatrix();
|
|
|
+ //tnsShadeMode(GL_SMOOTH);
|
|
|
+
|
|
|
+ glEnable(GL_BLEND);
|
|
|
+ //lBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
|
|
|
+
|
|
|
+ laUiItem* ui;
|
|
|
+ if((ui=w->MaximizedUi) && w->MaximizedUiPanel && ui->Type->Draw && ui->CanvasTemplate->SecondDraw){
|
|
|
+ MAIN.CurrentPanel=w->MaximizedUiPanel; laPanel* p=w->MaximizedUiPanel; int DrawState_=0;
|
|
|
+ if(p->Refresh){
|
|
|
+ if(p->Refresh&LA_TAG_RECALC){
|
|
|
+ la_SetPropMathcerContext(p);
|
|
|
+ laRecalcPanelImmediate(p);
|
|
|
+ }
|
|
|
+ ui->Type->Draw(ui, LA_RH); tnsFlush();
|
|
|
+ if (!la_AnimateUiListRecursive(&p->UI)) p->Refresh = 0;
|
|
|
+ else p->Refresh|=LA_TAG_ANIMATION;
|
|
|
+ }
|
|
|
+ tnsDrawToScreen();
|
|
|
+ tnsResetViewMatrix();
|
|
|
+ tnsViewportWithScissor(0, 0, w->CW, w->CH);
|
|
|
+ tnsOrtho(0, w->CW, w->CH, 0, -100, 100);
|
|
|
+ ui->CanvasTemplate->SecondDraw(ui, LA_RH);
|
|
|
+ tnsFlush();
|
|
|
+ if(!(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)){
|
|
|
+ laUiListDraw uild = {0}; for (laUiList* sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ tnsFlush();
|
|
|
+ DrawState_+=la_DrawUiListRecursive(&uild, sub, ui->L, ui->R, ui->U, ui->B, 10000, 0, 0, 0, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (DrawState_) p->Refresh = LA_TAG_RECALC;
|
|
|
+ }else{
|
|
|
+ laBlock* RootBlock= w->MaximizedBlock?w->MaximizedBlock:l->FirstBlock;
|
|
|
+ la_BlockDefDrawRecursive(w, bt, RootBlock);
|
|
|
+ la_BlockDefDrawAttachedRecursive(w,bt, RootBlock);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (p = w->Panels.pLast; p; p = NextP){
|
|
|
+ NextP = p->Item.pPrev;
|
|
|
+ if (!p->BT) p->BT = &_LA_THEME_FLOATING_PANEL;
|
|
|
+
|
|
|
+ if (p->AnimationMode && p->LaterDestroy){
|
|
|
+ lstRemoveItem(&w->Panels, p);
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->FadingPanels, p);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ la_PanelDefDraw(w, p, *p->BT);
|
|
|
+ }
|
|
|
+
|
|
|
+ for(laPanel* p=w->Panels.pFirst;p;p=p->Item.pNext){
|
|
|
+ la_AttachedPanelDefDraw(w,p,*p->BT);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (MAIN.CurrentWindow->CurrentLayout->DropToBlock){
|
|
|
+ laBoxedTheme* ubt=_LA_THEME_TAB;tnsUseNoTexture();
|
|
|
+ tnsViewportWithScissor(0, 0, w->CW, w->CH); tnsOrtho(0, w->CW, 0, w->CH, -100, 100);
|
|
|
+ la_BlockDrawDropLocations(MAIN.CurrentWindow->CurrentLayout->DropToBlock,
|
|
|
+ MAIN.CurrentWindow->CH, laThemeColor(ubt,LA_BT_ACTIVE), laThemeColor(ubt,LA_BT_BORDER));
|
|
|
+ tnsFlush();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (p = w->FadingPanels.pLast; p; p = NextP){
|
|
|
+ NextP = p->Item.pNext;
|
|
|
+ if (!p->AnimationMode){
|
|
|
+ lstRemoveItem(&w->FadingPanels, p);
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_DESTROY;
|
|
|
+ laDeferredDestroyPanel(p);
|
|
|
+ }else
|
|
|
+ la_PanelDrawToWindow(p, w);
|
|
|
+ }
|
|
|
+}
|
|
|
+int laStartWindow(laWindow *w){
|
|
|
+ //ShowWindow(w->win, SW_SHOWNORMAL);
|
|
|
+ glXMakeContextCurrent(MAIN.dpy, w->win,w->win, MAIN.glc);
|
|
|
+ MAIN.CurrentWindow = w;
|
|
|
+ if(!w->CurrentLayout){
|
|
|
+ if(!w->Layouts.pFirst){laDesignLayout(w, "Empty Layout");}
|
|
|
+ w->CurrentLayout=w->Layouts.pFirst;
|
|
|
+ }
|
|
|
+ laInvokeUi(0, "LA_window_operator", 0, w, 0, 0);
|
|
|
+ w->Shown = 1;
|
|
|
+}
|
|
|
+void la_AssignWindowPP(laWindow* w){
|
|
|
+ w->PP.EndInstance = w;
|
|
|
+ w->PP.LastPs = &w->FakePS;
|
|
|
+ w->PP.LastPs->p = _LA_PROP_WINDOW;
|
|
|
+ w->PP.LastPs->UseInstance = w;
|
|
|
+ w->PP.LastPs->Type = L'.';
|
|
|
+}
|
|
|
+laWindow *laDesignWindow(int X, int Y, int W, int H){
|
|
|
+ laWindow *n = memAcquireHyper(sizeof(laWindow));
|
|
|
+
|
|
|
+ strSafeSet(&n->Title, "Empty Window");
|
|
|
+ n->X = X; n->Y = Y; n->W = W; n->H = H;
|
|
|
+
|
|
|
+ la_CreateSystemWindow(n, MAIN.Windows.pFirst!=0);
|
|
|
+
|
|
|
+ lstAppendItem(&MAIN.Windows, n);
|
|
|
+ MAIN.CurrentWindow = n;
|
|
|
+
|
|
|
+ la_AssignWindowPP(n);
|
|
|
+ laui_DefaultMenuBar(n);
|
|
|
+
|
|
|
+ return n;
|
|
|
+}
|
|
|
+void laSetWindowCursor(int id){
|
|
|
+ //SetClassLongPtr(MAIN.CurrentWindow->win,
|
|
|
+ // GCLP_HCURSOR, LoadCursor(NULL, la_ConvertCursorID(id)));
|
|
|
+};
|
|
|
+void la_AssignBlockPP(laBlock* b){
|
|
|
+ b->PP.EndInstance = b;
|
|
|
+ b->PP.LastPs = &b->FakePS;
|
|
|
+ b->PP.LastPs->p = _LA_PROP_BLOCK;
|
|
|
+ b->PP.LastPs->UseInstance = b;
|
|
|
+ b->PP.LastPs->Type = L'.';
|
|
|
+}
|
|
|
+laLayout *laDesignLayout(laWindow *w, char *Title){
|
|
|
+ laLayout *l = memAcquireHyper(sizeof(laLayout));
|
|
|
+
|
|
|
+ l->FirstBlock = memAcquire(sizeof(laBlock));
|
|
|
+ la_AssignBlockPP(l->FirstBlock);
|
|
|
+
|
|
|
+ lstAppendItem(&w->Layouts, l);
|
|
|
+ strSafeSet(&l->ID, Title);
|
|
|
+
|
|
|
+ w->CurrentLayout = l;
|
|
|
+ laRenameWindow(w, Title);
|
|
|
+
|
|
|
+ return l;
|
|
|
+}
|
|
|
+void laFoldBlockTitle(laBlock* b){ if(b->B1) return; b->Folded=1; la_RecalcBlockRecursive(b,b->X,b->Y,b->W,b->H); }
|
|
|
+void laUnfoldBlockTitle(laBlock* b){ if(b->B1) return; b->Folded=0; b->OnButton=0; la_RecalcBlockRecursive(b,b->X,b->Y,b->W,b->H); }
|
|
|
+void laMaximizeBlock(laBlock* b){ if(b->B1) return; laWindow* w=MAIN.CurrentWindow;
|
|
|
+ if(w->MaximizedBlock==b){laRestoreToLayout(); return;} w->MaximizedBlock=b; la_UpdateUiPlacement(w);
|
|
|
+ laNotifyUsers("la.windows.maximized_block"); }
|
|
|
+void laRestoreToLayout(){ laWindow* w=MAIN.CurrentWindow; if(!w->MaximizedBlock) return; w->MaximizedBlock=0; la_UpdateUiPlacement(w);
|
|
|
+ laNotifyUsers("la.windows.maximized_block"); }
|
|
|
+void laMaximizeCanvasUI(laUiItem* ui, laPanel* UiParentPanel){
|
|
|
+ laRestoreCanvasUI();
|
|
|
+ if(!ui->Type||(!(ui->Type->Tag&LA_UI_TAG_IS_OFFSCREEN))||!UiParentPanel) return;
|
|
|
+ la_StopUiOperatorService(UiParentPanel); la_StopUiOperatorService(ui); laRetriggerOperators();
|
|
|
+ laWindow* w=MAIN.CurrentWindow; w->MaximizedUi=ui; w->MaximizedUiPanel=UiParentPanel; UiParentPanel->Refresh |= LA_TAG_RECALC;
|
|
|
+ UiParentPanel->Show=0;
|
|
|
+ laNotifyUsers("la.windows.maximized_ui"); laHideMenuBar();
|
|
|
+}
|
|
|
+void laRestoreCanvasUI(){
|
|
|
+ laWindow* w=MAIN.CurrentWindow; if(!w->MaximizedUi || !w->MaximizedUiPanel) return;
|
|
|
+ la_StopUiOperatorService(w->MaximizedUi); laRetriggerOperators(); w->MaximizedUiPanel->Show=1;
|
|
|
+ w->MaximizedUiPanel->Refresh |= LA_TAG_RECALC; w->MaximizedUi=0; w->MaximizedUiPanel=0; la_UpdateUiPlacement(w);
|
|
|
+ laNotifyUsers("la.windows.maximized_ui"); laShowMenuBar();
|
|
|
+}
|
|
|
+void laHideMenuBar(){ laWindow* w=MAIN.CurrentWindow; if(!w->MaximizedUi || !w->MaximizedUiPanel) return;
|
|
|
+ for(laPanel* p=MAIN.CurrentWindow->Panels.pFirst;p;p=p->Item.pNext){ if(p->IsMenuPanel){ p->Show=0; break; } }
|
|
|
+}
|
|
|
+void laShowMenuBar(){ for(laPanel* p=MAIN.CurrentWindow->Panels.pFirst;p;p=p->Item.pNext){ if(p->IsMenuPanel){ p->Show=1; break; } } }
|
|
|
+void laSplitBlockHorizon(laBlock *b, real Percentage){
|
|
|
+ laPanel *p;
|
|
|
+ b->SplitRatio = Percentage;
|
|
|
+ b->Vertical = 0;
|
|
|
+ b->B1 = memAcquire(sizeof(laBlock)); la_AssignBlockPP(b->B1); b->B1->Folded=b->Folded;
|
|
|
+ b->B2 = memAcquire(sizeof(laBlock)); la_AssignBlockPP(b->B2);
|
|
|
+ for (p = b->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ p->Block = b->B1;
|
|
|
+ }
|
|
|
+ b->B1->Panels.pFirst = b->Panels.pFirst;
|
|
|
+ b->B1->Panels.pLast = b->Panels.pLast;
|
|
|
+ b->B1->CurrentPanel = b->CurrentPanel;
|
|
|
+ b->B1->parent = b->B2->parent=b;
|
|
|
+ b->Panels.pFirst = 0;
|
|
|
+ b->Panels.pLast = 0;
|
|
|
+ b->CurrentPanel = 0;
|
|
|
+ la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
|
|
|
+}
|
|
|
+void laSplitBlockVertical(laBlock *b, real Percentage){
|
|
|
+ laPanel *p;
|
|
|
+ b->SplitRatio = Percentage;
|
|
|
+ b->Vertical = 1;
|
|
|
+ b->B1 = memAcquire(sizeof(laBlock)); la_AssignBlockPP(b->B1); b->B1->Folded=b->Folded;
|
|
|
+ b->B2 = memAcquire(sizeof(laBlock)); la_AssignBlockPP(b->B2);
|
|
|
+ for (p = b->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ p->Block = b->B1;
|
|
|
+ }
|
|
|
+ b->B1->Panels.pFirst = b->Panels.pFirst;
|
|
|
+ b->B1->Panels.pLast = b->Panels.pLast;
|
|
|
+ b->B1->CurrentPanel = b->CurrentPanel;
|
|
|
+ b->B1->parent = b->B2->parent=b;
|
|
|
+ b->Panels.pFirst = 0;
|
|
|
+ b->Panels.pLast = 0;
|
|
|
+ b->CurrentPanel = 0;
|
|
|
+ la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
|
|
|
+}
|
|
|
+void laCombineChildBlocks(laBlock *b){
|
|
|
+ laPanel *p; if(!b) return;
|
|
|
+ if (!b->B1->B1 && !b->B2->B1){
|
|
|
+ lstCombineLists(&b->Panels, &b->B1->Panels);
|
|
|
+ lstCombineLists(&b->Panels, &b->B2->Panels);
|
|
|
+ for (p = b->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ p->Block = b;
|
|
|
+ }
|
|
|
+ b->CurrentPanel = b->B1->CurrentPanel?b->B1->CurrentPanel:b->B2->CurrentPanel;
|
|
|
+ memFree(b->B1);
|
|
|
+ memFree(b->B2);
|
|
|
+ b->B1 = 0;
|
|
|
+ b->B2 = 0;
|
|
|
+ la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
|
|
|
+ }elif(!b->B1->B1){
|
|
|
+ laBlock* b1 = b->B2->B1; laBlock* b2 = b->B2->B2;
|
|
|
+ b->Vertical = b->B2->Vertical;
|
|
|
+ for (p = b->B1->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ p->Block = b1;
|
|
|
+ }
|
|
|
+ lstCombineLists(&b1->Panels, &b->B1->Panels);
|
|
|
+ memFree(b->B1); memFree(b->B2);
|
|
|
+ b->B1 = b1; b->B2 = b2;
|
|
|
+ b1->parent = b; b2->parent = b;
|
|
|
+ la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
|
|
|
+ }elif(!b->B2->B1){
|
|
|
+ laBlock* b1 = b->B1->B1;laBlock* b2 = b->B1->B2;
|
|
|
+ b->Vertical = b->B1->Vertical;
|
|
|
+ for (p = b->B2->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ p->Block = b1;
|
|
|
+ }
|
|
|
+ lstCombineLists(&b1->Panels, &b->B2->Panels);
|
|
|
+ memFree(b->B1); memFree(b->B2);
|
|
|
+ b->B1 = b1; b->B2 = b2;
|
|
|
+ b1->parent = b; b2->parent = b;
|
|
|
+ la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
|
|
|
+ }
|
|
|
+}
|
|
|
+laBlock *laBlock1(laBlock *b){
|
|
|
+ return b->B1;
|
|
|
+}
|
|
|
+laBlock *laBlock2(laBlock *b){
|
|
|
+ return b->B2;
|
|
|
+}
|
|
|
+laBlock *laSwapSubBlocks(laBlock *b){
|
|
|
+ laBlock *tB;
|
|
|
+ tB = b->B2;
|
|
|
+ b->B2 = b->B1;
|
|
|
+ b->B1 = tB;
|
|
|
+ b->SplitRatio = 1 - b->SplitRatio;
|
|
|
+ la_RecalcBlockRecursive(b, b->X, b->Y, b->W, b->H);
|
|
|
+}
|
|
|
+void laDestroyBlocksRecursive(laBlock *Root){
|
|
|
+ laPanel *p;
|
|
|
+ if (Root->B1){
|
|
|
+ laDestroyBlocksRecursive(Root->B1);
|
|
|
+ laDestroyBlocksRecursive(Root->B2);
|
|
|
+ }else{
|
|
|
+ while (p = lstPopItem(&Root->Panels)){
|
|
|
+ laDestroySinglePanel(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ memFree(Root);
|
|
|
+}
|
|
|
+laPanel* laTearOffPanel(laBlock* b, laPanel* p_if_set){
|
|
|
+ if(!b->CurrentPanel ) return 0;
|
|
|
+
|
|
|
+ laPanel* p = p_if_set?p_if_set:b->CurrentPanel;
|
|
|
+ b->CurrentPanel = p->Item.pNext?p->Item.pNext:p->Item.pPrev;
|
|
|
+ lstRemoveItem(&b->Panels, p);
|
|
|
+ if(!b->CurrentPanel && b->parent){
|
|
|
+ b=b->parent;
|
|
|
+ laCombineChildBlocks(b);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!p->TitleBar.UiItems.pFirst){
|
|
|
+ laui_DefaultPanelTitleBar(&p->TitleBar, &p->PP, &p->PropLinkPP, p->PanelTemplate->Header);
|
|
|
+ }
|
|
|
+
|
|
|
+ p->Mode = LA_PANEL_FLOATING_TOP;
|
|
|
+ p->TY-=LA_RH;
|
|
|
+ p->TH+=LA_RH;
|
|
|
+
|
|
|
+ p->Refresh=LA_TAG_RECALC;
|
|
|
+ la_RecalcBlockRecursive(b, b->X,b->Y,b->W,b->H);
|
|
|
+ p->BT = &_LA_THEME_FLOATING_PANEL;
|
|
|
+ p->Block = 0;
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+
|
|
|
+ laNotifyUsers("la.windows.panels");
|
|
|
+
|
|
|
+ return b->CurrentPanel;
|
|
|
+}
|
|
|
+void laDockPanel(laWindow* from, laBlock* b, laPanel* p){
|
|
|
+ if(!b||!p||p->Mode!=LA_PANEL_FLOATING_TOP||b->B1||b->B2) return;
|
|
|
+
|
|
|
+ lstRemoveItem(&from->Panels, p);
|
|
|
+
|
|
|
+ la_DestroyUiList(&p->TitleBar, 1, 1, 0);
|
|
|
+
|
|
|
+ p->Mode = LA_PANEL_NORMAL;
|
|
|
+ p->Block=b;
|
|
|
+ b->CurrentPanel = p;
|
|
|
+ lstPushItem(&b->Panels, p);
|
|
|
+ p->Refresh=LA_TAG_RECALC;
|
|
|
+ p->BT = &_LA_THEME_PANEL;
|
|
|
+ la_RecalcBlockRecursive(b, b->X,b->Y,b->W,b->H);
|
|
|
+ tnsFlush();
|
|
|
+
|
|
|
+ laNotifyUsers("la.windows.panels");
|
|
|
+}
|
|
|
+
|
|
|
+void laPopPanel(laPanel *p){
|
|
|
+ if (p->Mode == LA_PANEL_FLOATING_PASSIVE){
|
|
|
+ lstRemoveItem(&p->Parent->SubPanels, p);
|
|
|
+ lstPushItem(&p->Parent->SubPanels, p);
|
|
|
+ }else if (p->Mode == LA_PANEL_FLOATING_TOP){
|
|
|
+ lstRemoveItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ laNotifyUsers("la.windows.panels");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void la_EnsurePanelExtras(laPanel *p){
|
|
|
+ laUiTemplate* uit=p->PanelTemplate;
|
|
|
+
|
|
|
+ p->PropLinkContainer = memAcquire(sizeof(laPropContainer));
|
|
|
+ p->PropLinkFakeProp = memAcquire(sizeof(laSubProp));
|
|
|
+ p->PropLinkFakeProp->Base.Identifier = "LA_UI_FAKE_PROP_PLACEHOLDER";
|
|
|
+ p->PropLinkFakeProp->Base.PropertyType = LA_PROP_SUB;
|
|
|
+ p->PropLinkFakeProp->Base.SubProp = p->PropLinkContainer;
|
|
|
+ p->PropLinkFakeProp->Base.Offset = 0;
|
|
|
+ p->PropLinkFakeProp->Base.OffsetIsPointer = 1;
|
|
|
+
|
|
|
+ p->PropLinkPP.EndInstance = p;
|
|
|
+ p->PropLinkPP.LastPs = &p->PropLinkFakePS;
|
|
|
+ p->PropLinkPP.LastPs->Type = L'.';
|
|
|
+ p->PropLinkFakePS.p = p->PropLinkFakeProp;
|
|
|
+}
|
|
|
+laPanel *la_NewPanel(laUiTemplate* uit, int X, int Y, int W, int H, int MaxW, int MaxH, int MinW, int MinH, int SnapL, int SnapR, int SnapT, int SnapB){
|
|
|
+ laPanel *p = memAcquireHyper(sizeof(laPanel));
|
|
|
+ int CW = MAIN.CurrentWindow->CW;
|
|
|
+ int CH = MAIN.CurrentWindow->CH;
|
|
|
+ p->PanelTemplate = uit;
|
|
|
+
|
|
|
+ if (!MaxW) MaxW = 10000;
|
|
|
+ if (!MaxH) MaxH = 10000;
|
|
|
+
|
|
|
+ if (W > MaxW) W = MaxW;
|
|
|
+ if (H > MaxH) H = MaxH;
|
|
|
+
|
|
|
+ if (W < MinW) W = MinW;
|
|
|
+ if (H < MinH) H = MinH;
|
|
|
+
|
|
|
+ if(uit) { strSafeSet(&p->Title, uit->Title->Ptr); }
|
|
|
+ p->X = p->TX = (X < 0 ? 0 : X);
|
|
|
+ p->Y = p->TY = (Y < 0 ? 0 : Y);
|
|
|
+ p->W = p->TW = (W < 0 ? CW + W - p->X : W);
|
|
|
+ p->H = p->TH = (H < 0 ? CH + H - p->Y : H);
|
|
|
+
|
|
|
+ p->MaxW = MaxW;
|
|
|
+ p->MaxH = MaxH;
|
|
|
+ p->MinW = MinW;
|
|
|
+ p->MinH = MinH;
|
|
|
+
|
|
|
+ p->SL = SnapL;
|
|
|
+ p->ST = SnapT;
|
|
|
+ p->SR = SnapR;
|
|
|
+ p->SB = SnapB;
|
|
|
+
|
|
|
+ if (p->SR) p->X = CW - p->W - p->SR;
|
|
|
+ if (p->SB) p->Y = CH - p->H - p->SB;
|
|
|
+
|
|
|
+ la_EnsurePanelSnapping(p, CW, CH);
|
|
|
+
|
|
|
+ p->Show = 1;
|
|
|
+ p->PP.EndInstance = p;
|
|
|
+ p->PP.LastPs = &p->FakePS;
|
|
|
+ p->PP.LastPs->p = _LA_PROP_PANEL;
|
|
|
+ p->PP.LastPs->UseInstance = p;
|
|
|
+ p->PP.LastPs->Type = L'.';
|
|
|
+
|
|
|
+ la_EnsurePanelExtras(p);
|
|
|
+
|
|
|
+ p->Refresh = LA_TAG_RECALC;
|
|
|
+ p->FrameDistinguish = 100; //greater than 1 is ok
|
|
|
+
|
|
|
+ if(uit&&uit->PropFunc){ uit->PropFunc(p); }
|
|
|
+ if(uit){uit->Define(&p->UI, &p->PP, &p->PropLinkPP, 0, 0);}
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laCreatePanelT(laBlock *b, laUiTemplate* uit){
|
|
|
+ if(!uit) return 0;
|
|
|
+
|
|
|
+ laPanel *p = memAcquireHyper(sizeof(laPanel));
|
|
|
+
|
|
|
+ strSafeSet(&p->Title, uit->Title->Ptr);
|
|
|
+ p->PanelTemplate = uit;
|
|
|
+
|
|
|
+ p->Show = 1;
|
|
|
+ p->PP.EndInstance = p;
|
|
|
+ p->PP.LastPs = &p->FakePS;
|
|
|
+ p->PP.LastPs->p = _LA_PROP_PANEL;
|
|
|
+ p->PP.LastPs->UseInstance = p;
|
|
|
+ p->PP.LastPs->Type = L'.';
|
|
|
+
|
|
|
+ la_EnsurePanelExtras(p);
|
|
|
+
|
|
|
+ p->Refresh = LA_TAG_RECALC;
|
|
|
+ p->FrameDistinguish = 100; //greater than 1 is ok
|
|
|
+
|
|
|
+ p->TitleWidth = tnsStringGetWidth(p->Title->Ptr, 0, 0);
|
|
|
+
|
|
|
+ while (b->B1){
|
|
|
+ b = b->B1;
|
|
|
+ }
|
|
|
+ lstPushItem(&b->Panels, p);
|
|
|
+ p->Block = b;
|
|
|
+ b->CurrentPanel = p;
|
|
|
+
|
|
|
+ if(uit->PropFunc){ uit->PropFunc(p); }
|
|
|
+ uit->Define(&p->UI, &p->PP, &p->PropLinkPP, 0, 0);
|
|
|
+
|
|
|
+ laNotifyUsers("la.windows.panels");
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laCreatePanel(laBlock *b, char *template_id){
|
|
|
+ laUiTemplate* uit=laFindUiTemplate(template_id);
|
|
|
+ return laCreatePanelT(b, uit);
|
|
|
+}
|
|
|
+laPanel *laCreateTopPanel(laWindow *w, char *template_id, int X, int Y, int W, int H, int MaxW, int MaxH, int MinW, int MinH, int SnapL, int SnapR, int SnapT, int SnapB){
|
|
|
+ laUiTemplate* uit=0;
|
|
|
+ if(template_id) uit=laFindUiTemplate(template_id);
|
|
|
+ laPanel *p = la_NewPanel(uit, X, Y, W, H, MaxW, MaxH, MinW, MinH, SnapL, SnapR, SnapT, SnapB);
|
|
|
+ p->Mode = LA_PANEL_FLOATING_TOP;
|
|
|
+
|
|
|
+ if(uit){
|
|
|
+ laui_DefaultPanelTitleBar(&p->TitleBar, &p->PP, &p->PropLinkPP, p->PanelTemplate->Header);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (w) lstPushItem(&w->Panels, p);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+void laShowPanel(laPanel *p){
|
|
|
+ p->Show = 1;
|
|
|
+ laNotifyUsers("la.windows.panels_hidden");
|
|
|
+}
|
|
|
+void laShowPanelWithDropDownEffect(laPanel *p){
|
|
|
+ laShowPanel(p);
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_DROP_DOWN;
|
|
|
+ p->AnimationRatio = 0;
|
|
|
+}
|
|
|
+void laShowPanelWithExpandEffect(laPanel *p){
|
|
|
+ laShowPanel(p);
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_EXPAND;
|
|
|
+ p->AnimationRatio = 0;
|
|
|
+}
|
|
|
+void laHidePanel(laPanel *p){
|
|
|
+ if (!p->Mode) return;
|
|
|
+ p->Show = 0;
|
|
|
+ laNotifyUsers("la.windows.panels_hidden");
|
|
|
+}
|
|
|
+void laHidePanelWithDissoveEffect(laPanel *p){
|
|
|
+ if (!p->Mode) return;
|
|
|
+ laHidePanel(p);
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_DISSOVE;
|
|
|
+ p->AnimationRatio = 1;
|
|
|
+}
|
|
|
+void laHidePanelWithCollapseEffect(laPanel *p){
|
|
|
+ if (!p->Mode) return;
|
|
|
+ laHidePanel(p);
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_COLLAPSE;
|
|
|
+ p->AnimationRatio = 1;
|
|
|
+}
|
|
|
+void laHidePanelWithMinimizeEffect(laPanel *p){
|
|
|
+ if (!p->Mode) return;
|
|
|
+ laHidePanel(p);
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_MINIMIZE;
|
|
|
+ p->AnimationRatio = 1;
|
|
|
+}
|
|
|
+void laActivatePanel(char* TemplateID, int x, int y){
|
|
|
+ laUiTemplate* uit = laFindUiTemplate(TemplateID);
|
|
|
+ laPanel *p = la_FindFreePanelByTemplate(MAIN.CurrentWindow, uit);
|
|
|
+ if (!p){ p=laCreateTopPanel(MAIN.CurrentWindow, TemplateID, x, y, 400,400, 0, 0, 0, 0, 0, 0, 0, 0); }
|
|
|
+ laShowPanelWithExpandEffect(p); laPopPanel(p);
|
|
|
+}
|
|
|
+void laPanPanel(laPanel *p, int DeltaX, int DeltaY){
|
|
|
+ p->UI.PanX += DeltaX;
|
|
|
+ p->UI.PanY += DeltaY;
|
|
|
+}
|
|
|
+int laPanUiListFree(laUiList *uil, int X, int Y){
|
|
|
+ uil->PanX+=X; uil->PanY+=Y;
|
|
|
+}
|
|
|
+int laPanUiList(laUiList *uil, int X, int Y, int L, int R, int U, int B){
|
|
|
+ if(uil->ScrollerShownH && !uil->ScrollerShownV){
|
|
|
+ if(Y){X+=Y;Y=0;}
|
|
|
+ }
|
|
|
+ if (Y > 0){
|
|
|
+ if (uil->B - uil->PanY <= B) return 0;
|
|
|
+ else{
|
|
|
+ uil->PanY += Y;
|
|
|
+ if (uil->B - uil->PanY <= B){
|
|
|
+ uil->PanY = uil->B - B;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Y < 0){
|
|
|
+ if (uil->U - uil->PanY >= U) return 0;
|
|
|
+ else{
|
|
|
+ uil->PanY += Y;
|
|
|
+ if (uil->U - uil->PanY >= U){
|
|
|
+ uil->PanY = uil->U - U;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(uil->AllowScale){
|
|
|
+ laPanUiListFree(uil, X, 0);
|
|
|
+ }else{
|
|
|
+ if (X > 0){
|
|
|
+ if (uil->R - uil->PanX <= R) return 0;
|
|
|
+ else{
|
|
|
+ uil->PanX += X;
|
|
|
+ if (uil->R - uil->PanX <= R){
|
|
|
+ uil->PanX = uil->R - R;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (X < 0){
|
|
|
+ if (uil->L - uil->PanX >= L) return 0;
|
|
|
+ else{
|
|
|
+ uil->PanX += X;
|
|
|
+ if (uil->L - uil->PanX >= L){
|
|
|
+ uil->PanX = uil->L - L;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int laScaleUiList(laUiList *uil, real factor, int L, int R, int U, int B){
|
|
|
+ int ret=1;
|
|
|
+ if(!uil->AllowScale){ return 0; }
|
|
|
+ real NewScale=uil->Scale*factor;
|
|
|
+
|
|
|
+ if(NewScale<0.2){NewScale=0.2; ret=0;}
|
|
|
+ if(NewScale>5) {NewScale=5; ret=0;}
|
|
|
+ if(NewScale>1-1e-4 && NewScale<1+1e-4){NewScale=1;}
|
|
|
+
|
|
|
+ factor=NewScale/uil->Scale;
|
|
|
+ uil->Scale=NewScale;
|
|
|
+
|
|
|
+ real mx=(L+R)/2,my=(U+B)/2;
|
|
|
+ real dx= (mx+uil->PanX)*factor;
|
|
|
+ real dy= (my+uil->PanY)*factor;
|
|
|
+ uil->PanX=dx-mx;
|
|
|
+ uil->PanY=dy-my;
|
|
|
+
|
|
|
+ MAIN.CurrentPanel->FrameDistinguish=100;
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+int laPanUiListAuto(laUiList *uil, int X, int Y, int L, int R, int U, int B){
|
|
|
+ if(uil->AllowScale) return 0;
|
|
|
+ return laPanUiList(uil,X,Y,L,R,U,B);
|
|
|
+}
|
|
|
+
|
|
|
+laPanel *laDesignPropPanel(char *Title, int X, int Y, int W, int H,
|
|
|
+ laUiDefineFunc Define, laPropPack *This, laPropPack *OperatorProps){
|
|
|
+ laPanel *p = la_NewPanel(0, X, Y, W, H, 0, H, 0, 0, 0, 0, 0, 0);
|
|
|
+ strSafeSet(&p->Title, Title);
|
|
|
+
|
|
|
+ if (Define){
|
|
|
+ Define(laPrepareUi(p), This, OperatorProps, NULL, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ //laui_DefaultOperatorPanelTitleBar(&p->TitleBar, &p->PP, OperatorProps, 0, 0);
|
|
|
+
|
|
|
+ p->BT= &_LA_THEME_FLOATING_PANEL;
|
|
|
+ p->Mode = LA_PANEL_FLOATING_PASSIVE;
|
|
|
+ p->BoundUi = 1;
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laDesignOperatorPanel(char *Title, int X, int Y, int W, int H, int MaxW, int MaxH, int MinW, int MinH, int SnapL, int SnapR, int SnapT, int SnapB,
|
|
|
+ laUiDefineFunc Define, laPropPack *This, laPropPack *OperatorProps){
|
|
|
+ laPanel *p = la_NewPanel(0, X, Y, W, H, MaxW, MaxH, MinW, MinH, SnapL, SnapR, SnapT, SnapB);
|
|
|
+ strSafeSet(&p->Title, Title);
|
|
|
+
|
|
|
+ if (Define){
|
|
|
+ Define(laPrepareUi(p), This, OperatorProps, NULL, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ laui_DefaultOperatorPanelTitleBar(&p->TitleBar, &p->PP, OperatorProps, 0, 0);
|
|
|
+
|
|
|
+ p->BT= &_LA_THEME_FLOATING_PANEL;
|
|
|
+ p->Mode = LA_PANEL_FLOATING_TOP;
|
|
|
+ p->BoundUi = 1;
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+
|
|
|
+void laDeferredDestroyPanel(laPanel *p){
|
|
|
+ laPanel *ip;
|
|
|
+ tnsDelete2DOffscreen(p->OffScr);
|
|
|
+ p->OffScr = 0;
|
|
|
+
|
|
|
+ strSafeDestroy(&p->Title);
|
|
|
+
|
|
|
+ if (!p->AnimationMode){
|
|
|
+ if (p->Parent) lstRemoveItem(&p->Parent->SubPanels, p);
|
|
|
+ else if (p->Mode == LA_PANEL_FLOATING_TOP){
|
|
|
+ lstRemoveItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ }else if (p->Mode == LA_PANEL_NO_PARENT_MENU){
|
|
|
+ lstRemoveItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ }else if (p->Block){
|
|
|
+ lstRemoveItem(&p->Block->Panels, p);
|
|
|
+ if (p->Block->CurrentPanel == p) p->Block->CurrentPanel = p->Block->Panels.pFirst;
|
|
|
+ }
|
|
|
+ laNotifyUsers("la.windows.panels");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ip = p->SubPanels.pFirst; ip; ip = ip->Item.pNext){
|
|
|
+ //lstRemoveItem(&p->SubPanels, ip);
|
|
|
+ laDestroySinglePanel(ip);
|
|
|
+ laNotifyUsers("la.windows.panels");
|
|
|
+ }
|
|
|
+
|
|
|
+ memFree(p->PropLinkContainer); memFree(p->PropLinkFakeProp);
|
|
|
+
|
|
|
+ memFree(p);
|
|
|
+}
|
|
|
+void laDestroySinglePanel(laPanel *p){
|
|
|
+ la_SetPropMathcerContext(p);
|
|
|
+
|
|
|
+ if (p->PropLinkPP.LastPs->p->SubProp->Props.pFirst){
|
|
|
+ for(laProp* prop=p->PropLinkPP.LastPs->p->SubProp->Props.pFirst;prop;prop=prop->Item.pNext){
|
|
|
+ la_StopUsingPropPack(&prop->DetachedPP);
|
|
|
+ //laStopUsingDataBlock(prop->DetachedPP.LastPs->UseInstance, prop->DetachedPP.LastPs->p,MAIN.PropMatcherContextP);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(p==MAIN.CurrentWindow->MaximizedUiPanel){ laRestoreCanvasUI(); }
|
|
|
+
|
|
|
+ la_DestroyUiList(&p->UI, 1, 1, 0);
|
|
|
+ la_DestroyUiList(&p->TitleBar, 1, 1, 0);
|
|
|
+ la_DestroyUiList(p->MenuRefer, 0, 1, 1);
|
|
|
+
|
|
|
+ if (p->Mode){
|
|
|
+ p->AnimationMode = LA_PANEL_ANIMATION_DISSOVE;
|
|
|
+ p->AnimationRatio = p->CloseWhenMovedOut?0.0:1.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (p->ParentOperator && la_UiOperatorExists(p)) ((laOperator *)p->ParentOperator)->OperatorPanel = 0;
|
|
|
+
|
|
|
+ if (la_UiStillInService(p)){
|
|
|
+ la_StopUiOperatorService(p);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!p->AnimationMode){
|
|
|
+ laDeferredDestroyPanel(p);
|
|
|
+ }else{
|
|
|
+ p->LaterDestroy = 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int laEnclosePanelContent(laPanel *p, laUiList *uil){
|
|
|
+ laBoxedTheme *bt = _LA_THEME_FLOATING_PANEL;
|
|
|
+ int MinW,MinWt=0;
|
|
|
+ int TitleReserve=p->Mode==LA_PANEL_FLOATING_TOP?LA_RH:0;
|
|
|
+ int CW = MAIN.CurrentWindow->CW;
|
|
|
+ if(p->SL && p->SR){return 0;}
|
|
|
+ la_SetPropMathcerContext(p);
|
|
|
+
|
|
|
+ la_UpdateUiListRecursive(&p->TitleBar, bt->TM, bt->LM, p->TW - bt->LM-bt->RM, p->TH, 0, p);
|
|
|
+ la_UpdateUiListRecursive(uil, bt->TM+p->TitleBar.B, 0, 1000, 0, 0, p);
|
|
|
+ MinWt = la_TestUiListMinumWidth(&p->TitleBar);
|
|
|
+ MinW = la_TestUiListMinumWidth(uil);
|
|
|
+ if (MinW<MinWt){MinW=MinWt;}
|
|
|
+ int ScrollerW=(uil->ScrollerShownV?(LA_SCROLL_W+bt->RM):0);
|
|
|
+ if (MinW > 20){
|
|
|
+ p->TW = MinW + bt->LM + bt->RM+ScrollerW;
|
|
|
+ }
|
|
|
+ la_PanelValidateWidth(p,uil);
|
|
|
+ laEnsurePanelInBound(p,uil);
|
|
|
+ if(p->TW>CW){ p->TW=CW; }
|
|
|
+ la_UpdateUiListRecursive(&p->TitleBar, bt->TM, bt->LM, p->TW - bt->LM-bt->RM, p->TH, 0, p);
|
|
|
+ la_UpdateUiListRecursive(uil, bt->TM+p->TitleBar.B, bt->LM, p->TW - bt->RM - ScrollerW, 0, 0, p);
|
|
|
+ p->Refresh=LA_TAG_REDRAW;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+laPanel *laEnableIdlePanel(laPanel *Attachment, laOperator *a, laPropPack *OperatorProps, laUiDefineFunc ReplaceUiDefine, laPropPack *This,
|
|
|
+ int L, int R, int B, int MaxGH, int MaxW, laEvent *e){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laPanel *p;
|
|
|
+ int GX, GY, GW, t = 0;
|
|
|
+ int b;
|
|
|
+ laUiDefineFunc def = ReplaceUiDefine;
|
|
|
+ int MinW;
|
|
|
+
|
|
|
+ if (!def){ def=laui_DefaultPropDetails; }
|
|
|
+
|
|
|
+ GX = L; GY = B; GW = (R - L) > MaxW ? MaxW : (R - L);
|
|
|
+
|
|
|
+ p = laDesignPropPanel("TMP", GX, GY, GW, MaxGH, def, This, OperatorProps);
|
|
|
+ laEnclosePanelContent(p, &p->UI);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ p->CloseWhenMovedOut=1;
|
|
|
+ laInvokeUi(a, "LA_menu_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ //laShowPanelWithDropDownEffect(p);
|
|
|
+
|
|
|
+ if(!Attachment){ Attachment=MAIN.CurrentWindow->MaximizedUiPanel; }
|
|
|
+ if(Attachment){ p->Parent = Attachment; lstAppendItem(&Attachment->SubPanels, p); }
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnablePropertyPanel(laPanel *Attachment, laOperator *a, laPropPack *OperatorProps, laUiDefineFunc ReplaceUiDefine, laPropPack *This,
|
|
|
+ int L, int R, int B, int MaxGH, int MaxW, laEvent *e){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laPanel *p;
|
|
|
+ int GX, GY, GW, t = 0;
|
|
|
+ int b;
|
|
|
+ laUiDefineFunc def = ReplaceUiDefine;
|
|
|
+ int MinW;
|
|
|
+
|
|
|
+ if (!def){
|
|
|
+ if (This && This->LastPs->p->UiDefine) def = This->LastPs->p->UiDefine;
|
|
|
+ if (!def && This->LastPs->p->SubProp && This->LastPs->p->SubProp->UiDefine) def=This->LastPs->p->SubProp->UiDefine;
|
|
|
+ else def = laui_DefaultPropUiDefine;
|
|
|
+ }
|
|
|
+
|
|
|
+ //laLocalToWindow(0,Attachment, &L, &t);
|
|
|
+ //laLocalToWindow(0,Attachment, &R, &B);
|
|
|
+
|
|
|
+ GX = L;
|
|
|
+ GY = B;
|
|
|
+ GW = (R - L) > MaxW ? MaxW : (R - L);
|
|
|
+
|
|
|
+ p = laDesignPropPanel("TMP", GX, GY, GW, MaxGH, def, This, OperatorProps);
|
|
|
+ laEnclosePanelContent(p, &p->UI);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_menu_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ laShowPanelWithDropDownEffect(p);
|
|
|
+
|
|
|
+ if(!Attachment){ Attachment=MAIN.CurrentWindow->MaximizedUiPanel; }
|
|
|
+ if(Attachment){
|
|
|
+ p->Parent = Attachment;
|
|
|
+ lstAppendItem(&Attachment->SubPanels, p);
|
|
|
+ }
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnableEmptyPropertyPanel(laPanel *Attachment, laOperator *a, int L, int R, int U, int MaxGH, laEvent *e){
|
|
|
+ laPanel *p;
|
|
|
+ int t = 0;
|
|
|
+ int b;
|
|
|
+
|
|
|
+ //laLocalToWindow(0, Attachment, &L, &t);
|
|
|
+ //laLocalToWindow(0, Attachment, &R, &U);
|
|
|
+
|
|
|
+ p = laDesignPropPanel("TMP", L, U, R - L, MaxGH, 0, 0, 0);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_menu_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ laShowPanelWithDropDownEffect(p);
|
|
|
+
|
|
|
+ p->Parent = Attachment;
|
|
|
+ lstPushItem(&Attachment->SubPanels, p);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnableMenuPanel(laPanel *Attachment, laOperator *a, laUiList *MenuRefer, laPropPack *This,
|
|
|
+ int L, int R, int B, int MaxGH, int MaxW, laEvent *e){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laPanel *p;
|
|
|
+ laBoxedTheme *bt = _LA_THEME_FLOATING_PANEL;
|
|
|
+ int GX, GY, GW, t = 0;
|
|
|
+ int b;
|
|
|
+ int MinW;
|
|
|
+
|
|
|
+ //laLocalToWindow(0,Attachment, &L, &t);
|
|
|
+ //laLocalToWindow(0,Attachment, &R, &B);
|
|
|
+
|
|
|
+ GX = L;
|
|
|
+ GY = B;
|
|
|
+ GW = (R - L) > MaxW ? MaxW : (R - L);
|
|
|
+
|
|
|
+ p = laDesignPropPanel("TMP", GX, GY, GW, MaxGH, 0, 0, 0);
|
|
|
+ p->MenuRefer = MenuRefer;
|
|
|
+
|
|
|
+ laEnclosePanelContent(p, MenuRefer);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_menu_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ laShowPanelWithDropDownEffect(p);
|
|
|
+
|
|
|
+ p->Parent = Attachment;
|
|
|
+ lstPushItem(&Attachment->SubPanels, p);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laDefineAndEnableMenuPanel(laPanel *Attachment, laOperator *a, laPropPack *This,
|
|
|
+ int L, int B, int MaxGH, int MaxW, laEvent *e){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laPanel *p;
|
|
|
+ int GX, GY, GW, t = 0;
|
|
|
+ int b;
|
|
|
+
|
|
|
+ GX = L;
|
|
|
+ GY = B;
|
|
|
+ GW = MaxW;
|
|
|
+
|
|
|
+ p = laDesignPropPanel("TMP", GX, GY, GW, MaxGH, 0, 0, 0);
|
|
|
+ p->MenuRefer = &p->UI;
|
|
|
+
|
|
|
+ p->Mode = LA_PANEL_NO_PARENT_MENU;
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_menu_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ laShowPanelWithDropDownEffect(p);
|
|
|
+
|
|
|
+ if (Attachment){
|
|
|
+ p->Parent = Attachment;
|
|
|
+ lstPushItem(&Attachment->SubPanels, p);
|
|
|
+ }else{
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ }
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnableOperatorPanel(laOperator *For, laPropPack *This, int X, int Y, int W, int H, int MaxW, int MaxH, int MinW, int MinH, int SnapL, int SnapR, int SnapT, int SnapB, laEvent *e){
|
|
|
+ laOperator *ai = For;
|
|
|
+ laPanel *p;
|
|
|
+ int b;
|
|
|
+ laUiDefineFunc def = 0;
|
|
|
+
|
|
|
+ if (ai->Type->UiDefine) def = ai->Type->UiDefine;
|
|
|
+ else def = laui_DefaultPropUiDefine;
|
|
|
+
|
|
|
+ For->PP.EndInstance = For->CustomData;
|
|
|
+
|
|
|
+ p = laDesignOperatorPanel(ai->Type->Name, X, Y, W, H, MaxW, MaxH, MinW, MinH, SnapL, SnapR, SnapT, SnapB, def, This, &For->PP);
|
|
|
+ laEnclosePanelContent(p, &p->UI);
|
|
|
+ MAIN.ToPanel = p;
|
|
|
+
|
|
|
+ laShowPanelWithExpandEffect(p);
|
|
|
+
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ ai->OperatorPanel = p;
|
|
|
+ p->ParentOperator = For;
|
|
|
+
|
|
|
+ laInvokeUi(For, "LA_modal_panel_operator", 0, p, 0, 1);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnableYesNoPanel(laOperator *a, laPanel *Attachment, char *Title, char *Message, int X, int Y, int W, laEvent *e){
|
|
|
+ laPanel *p;
|
|
|
+ int b;
|
|
|
+ laUiList *uil;
|
|
|
+ laColumn *col, *cor, *corl, *corr;
|
|
|
+
|
|
|
+ p = la_NewPanel(0, X, Y, W, 0, 1000, 500, 50, 0, 0, 0, 0, 0);
|
|
|
+ strSafeSet(&p->Title, Title);
|
|
|
+ p->BoundUi = 1;
|
|
|
+ p->Mode = LA_PANEL_FLOATING_TOP;
|
|
|
+ p->BT = &_LA_THEME_FLOATING_PANEL;
|
|
|
+ MAIN.ToPanel = p;
|
|
|
+
|
|
|
+ laui_DefaultOperatorPanelTitleBar(&p->TitleBar, &p->PP, &p->PropLinkPP, 0, 0);
|
|
|
+
|
|
|
+ uil = laPrepareUi(p);
|
|
|
+ col = laFirstColumn(uil);
|
|
|
+ laSplitColumn(uil, col, 0.5);
|
|
|
+ cor = laRightColumn(col, 600);
|
|
|
+
|
|
|
+ laShowLabel(uil, col, Message, 0, 0);
|
|
|
+ laShowItem(uil, cor, 0, "LA_confirm")->Flags|=LA_UI_FLAGS_HIGHLIGHT|LA_TEXT_ALIGN_CENTER;
|
|
|
+
|
|
|
+ laEnclosePanelContent(p,uil);
|
|
|
+ laShowPanelWithExpandEffect(p);
|
|
|
+
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_modal_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnableMessagePanel(laOperator *a, laPanel *Attachment, char *Title, char *Message, int X, int Y, int W, laEvent *e){
|
|
|
+ laPanel *p;
|
|
|
+ int b;
|
|
|
+ laUiList *uil;
|
|
|
+ laColumn *col, *cor, *corl, *corr;
|
|
|
+
|
|
|
+ p = la_NewPanel(0, X, Y, W, 0, 1000, 90, 100, 0, 0, 0, 0, 0);
|
|
|
+ strSafeSet(&p->Title, Title);
|
|
|
+ p->BoundUi = 1;
|
|
|
+ p->Mode = LA_PANEL_FLOATING_TOP;
|
|
|
+ p->BT = &_LA_THEME_FLOATING_PANEL;
|
|
|
+ MAIN.ToPanel = p;
|
|
|
+
|
|
|
+ laui_DefaultOperatorPanelTitleBar(&p->TitleBar, &p->PP, &p->PropLinkPP, 0, 0);
|
|
|
+
|
|
|
+ uil = laPrepareUi(p);
|
|
|
+ col = laFirstColumn(uil);
|
|
|
+ laSplitColumn(uil, col, 0.35);
|
|
|
+ cor = laRightColumn(col, 200);
|
|
|
+
|
|
|
+ laShowLabel(uil, col, Message, 0, 0);
|
|
|
+
|
|
|
+ laShowItemFull(uil, cor, 0, "LA_confirm",0,"text=Okay;",0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT;
|
|
|
+
|
|
|
+ laEnclosePanelContent(p,uil);
|
|
|
+ laShowPanelWithExpandEffect(p);
|
|
|
+
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_modal_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+laPanel *laEnableMultiMessagePanel(laOperator *a, laPanel *Attachment, char *Title, laPanelMessageList *pml, int X, int Y, int W, laEvent *e){
|
|
|
+ laPanel *p;
|
|
|
+ int b;
|
|
|
+ laUiList *uil;
|
|
|
+ laColumn *col, *cor, *corl, *corr;
|
|
|
+ laPanelMessage *pm;
|
|
|
+
|
|
|
+ p = la_NewPanel(0, X, Y, W, 0, 1000, 1000, 100, 0, 0, 0, 0, 0);
|
|
|
+ strSafeSet(&p->Title, Title);
|
|
|
+ p->BoundUi = 1;
|
|
|
+ p->Mode = LA_PANEL_FLOATING_TOP;
|
|
|
+ p->BT = &_LA_THEME_FLOATING_PANEL;
|
|
|
+ MAIN.ToPanel = p;
|
|
|
+
|
|
|
+ laui_DefaultOperatorPanelTitleBar(&p->TitleBar, &p->PP, &p->PropLinkPP, 0, 0);
|
|
|
+
|
|
|
+ uil = laPrepareUi(p);
|
|
|
+ col = laFirstColumn(uil);
|
|
|
+ laSplitColumn(uil, col, 0.35);
|
|
|
+ cor = laRightColumn(col, 200);
|
|
|
+
|
|
|
+ while (pm = lstPopItem(pml)){
|
|
|
+ laShowLabel(uil, col, pm->Message->Ptr, 0, 0);
|
|
|
+ strSafeDestroy(&pm->Message);
|
|
|
+ FreeMem(pm);
|
|
|
+ }
|
|
|
+
|
|
|
+ laShowItemFull(uil, cor, 0, "LA_confirm",0,"text=Okay;",0,0)->Flags|=LA_UI_FLAGS_HIGHLIGHT;
|
|
|
+
|
|
|
+ laShowPanelWithExpandEffect(p);
|
|
|
+
|
|
|
+ lstPushItem(&MAIN.CurrentWindow->Panels, p);
|
|
|
+ laSetOperatorLocalizer(p);
|
|
|
+ laInvokeUi(a, "LA_modal_panel_operator", e, p, 0, 1);
|
|
|
+
|
|
|
+ return p;
|
|
|
+}
|
|
|
+
|
|
|
+void laAddPanelMessage(laPanelMessageList *pml, char *Message){
|
|
|
+ if (!Message || !Message[0]) return;
|
|
|
+ laPanelMessage *pm = CreateNew(laPanelMessage);
|
|
|
+ strSafeSet(&pm->Message, Message);
|
|
|
+ lstAppendItem(&pml->Msg, pm);
|
|
|
+}
|
|
|
+
|
|
|
+void laRedrawAllWindows(){
|
|
|
+ for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext) la_UpdateUiPlacement(w);
|
|
|
+}
|
|
|
+void laRedrawCurrentWindow(){
|
|
|
+ if (MAIN.CurrentWindow) la_UpdateUiPlacement(MAIN.CurrentWindow);
|
|
|
+}
|
|
|
+void laRedrawCurrentPanel(){
|
|
|
+ if (MAIN.CurrentPanel) MAIN.CurrentPanel->Refresh |= LA_TAG_REDRAW;
|
|
|
+ elif (MAIN.CurrentWindow->MaximizedUiPanel) MAIN.CurrentWindow->MaximizedUiPanel->Refresh |= LA_TAG_REDRAW;
|
|
|
+}
|
|
|
+void laRecalcCurrentPanel(){
|
|
|
+ if (MAIN.CurrentPanel) MAIN.CurrentPanel->Refresh |= LA_TAG_RECALC;
|
|
|
+ elif (MAIN.CurrentWindow->MaximizedUiPanel) MAIN.CurrentWindow->MaximizedUiPanel->Refresh |= LA_TAG_RECALC;
|
|
|
+}
|
|
|
+void laRecalcPanelImmediate(laPanel* p){
|
|
|
+ p->FrameDistinguish++;
|
|
|
+ laBoxedTheme* bt = (*p->BT);
|
|
|
+ int scrollw=p->UI.ScrollerShownV?bt->RM*2+LA_SCROLL_W:0;
|
|
|
+ la_PanelRefreshDetachedProp(p);
|
|
|
+ int enclosed=0;
|
|
|
+ if(p->BoundUi || p->MenuRefer){
|
|
|
+ if(p->MenuRefer) enclosed=laEnclosePanelContent(p, p->MenuRefer);
|
|
|
+ else enclosed=laEnclosePanelContent(p, &p->UI);
|
|
|
+ }
|
|
|
+ if(!enclosed){
|
|
|
+ la_PanelValidateWidth(p,&p->UI);
|
|
|
+ //laEnsurePanelInBound(p,&p->UI);
|
|
|
+ la_UpdateUiListRecursive(&p->TitleBar, bt->TM, bt->LM, p->TW-bt->RM, p->TH-bt->TM-bt->BM, 0, p);
|
|
|
+ la_UpdateUiListRecursive(&p->UI, bt->TM+p->TitleBar.TB, bt->LM, p->TW-bt->RM-scrollw, p->TH-bt->TM-bt->BM, 0, p);
|
|
|
+ }
|
|
|
+ laWindow* w=MAIN.CurrentWindow;
|
|
|
+ if(w->MaximizedUiPanel==p&&w->MaximizedUi){ int CW = w->CW; int CH = w->CH;
|
|
|
+ laUiItem* ui=w->MaximizedUi; ui->TU=ui->U=0; ui->TB=ui->B=CH; ui->TL=ui->L=0; ui->TR=ui->R=CW;
|
|
|
+ if(!ui->Page) return; laBoxedTheme* bt=(*ui->Type->Theme);
|
|
|
+ la_UpdateUiListRecursive(ui->Page, ui->TU+bt->TM, ui->TL+bt->LM, ui->TR-bt->RM, ui->TB, 0, w->MaximizedUiPanel);
|
|
|
+ }
|
|
|
+}
|
|
|
+void laRecalcCurrentPanelImmediate(){
|
|
|
+ laRecalcPanelImmediate(MAIN.CurrentPanel);
|
|
|
+}
|
|
|
+int laNonFixedPanelExists(laPanel *p){
|
|
|
+ laPanel *ip;
|
|
|
+
|
|
|
+ if (!p) return 0;
|
|
|
+
|
|
|
+ //for (ip = MAIN.CurrentWindow->CurrentLayout->Panels.pLast; ip; ip = ip->Item.pPrev) {
|
|
|
+ // if (ip == p) return 1;
|
|
|
+ //}
|
|
|
+
|
|
|
+ for (ip = MAIN.CurrentWindow->Panels.pLast; ip; ip = ip->Item.pPrev){
|
|
|
+ if (ip == p) return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int laIsInPanel(laPanel *p, int PanelX, int PanelY){
|
|
|
+ if (PanelX < 0 || PanelY < 0 || PanelY > p->H || PanelX > p->W) return 0;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int laIsCloseToPanel(laPanel *p, int PanelX, int PanelY){
|
|
|
+ int tt=MAIN.TooltipCloseDistance;
|
|
|
+ if (PanelX < -tt || PanelY < -tt || PanelY > p->H+tt || PanelX > p->W+tt) return 0;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int laPanelOverlappingEachOther(laPanel *p1, laPanel *p2){
|
|
|
+ if (p1->X > p2->X + p2->W || p1->X + p1->W < p2->X ||
|
|
|
+ p1->Y > p2->Y + p2->H || p1->Y + p1->H < p2->Y)
|
|
|
+ return 0;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+void laUnlinkSharedPanel(laPanel *p){
|
|
|
+ laWindow *w;
|
|
|
+ laPanel *ip;
|
|
|
+
|
|
|
+ for (w = MAIN.Windows.pFirst; w; w = w->Item.pNext){
|
|
|
+ for (ip = w->Panels.pFirst; ip; ip = ip->Item.pNext){
|
|
|
+ if (ip == p){
|
|
|
+ lstRemoveItem(&w->Panels, ip);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+int laIsPanelCovered(laPanel *p){
|
|
|
+ //laLayout* l = MAIN.CurrentWindow->CurrentLayout;
|
|
|
+ laPanel *ip;
|
|
|
+ laPanel *resp;
|
|
|
+ int in1 = 0, in2 = 0, in3 = 0;
|
|
|
+ laPanel *d1 = 0, *d2 = 0, *d3 = 0;
|
|
|
+
|
|
|
+ //for (ip = MAIN.CurrentWindow->CurrentLayout->Panels.pLast; ip; ip = ip->Item.pPrev) {
|
|
|
+ // if (ip == p) { in1 = 1; d1 = 0; continue; }
|
|
|
+ // if (ip->Show && laPanelOverlappingEachOther(ip, p)) d1 = ip;
|
|
|
+ //}
|
|
|
+
|
|
|
+ for (ip = MAIN.CurrentWindow->Panels.pLast; ip; ip = ip->Item.pPrev){
|
|
|
+ if (ip == p){
|
|
|
+ in3 = 1;
|
|
|
+ d3 = 0;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ip->Show && laPanelOverlappingEachOther(ip, p)) d3 = ip;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!in2 && !in3) in1 = 1;
|
|
|
+
|
|
|
+ if (in1){
|
|
|
+ if (d1 || d2 || d3) return 1;
|
|
|
+ }else{
|
|
|
+ if (in2){
|
|
|
+ if (d2 || d3) return 1;
|
|
|
+ }else if (in3)
|
|
|
+ if (d3) return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int laIsTopPanel(laPanel *p){
|
|
|
+ //if (!p->Item.pPrev) return 1;
|
|
|
+ //else {
|
|
|
+ if (!laIsPanelCovered(p)){
|
|
|
+ //laPopPanel(p);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ //}
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+void laWindowToLocal(laOperator *a, laPanel *p, int *x, int *y){
|
|
|
+ if(!p) return;
|
|
|
+ int ix = *x, iy = *y;
|
|
|
+ laListItemPointer *lip;
|
|
|
+ laOperator *ai = a;
|
|
|
+ (*x) = ix - p->X;
|
|
|
+ (*y) = iy - p->Y;
|
|
|
+ if (a){
|
|
|
+ for (lip = ai->LocalUiLists.pFirst; lip; lip = lip->pNext){
|
|
|
+ laUiList *uil = lip->p;
|
|
|
+ (*x) += uil->PanX;
|
|
|
+ (*y) += uil->PanY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void laPanelToLocal(laOperator *a, int *x, int *y){
|
|
|
+ int ix = *x, iy = *y;
|
|
|
+ laListItemPointer *lip;
|
|
|
+ if (a){
|
|
|
+ for (lip = a->LocalUiLists.pFirst; lip; lip = lip->pNext){
|
|
|
+ laUiList *uil = lip->p;
|
|
|
+ (*x) += uil->PanX;
|
|
|
+ (*y) += uil->PanY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void laLocalToWindow(laOperator *a, laPanel *p, int *x, int *y){
|
|
|
+ if(!p) return;
|
|
|
+ int ix = *x, iy = *y;
|
|
|
+ laListItemPointer *lip;
|
|
|
+ (*x) = ix + p->X;
|
|
|
+ (*y) = iy + p->Y;
|
|
|
+ if (a){
|
|
|
+ for (lip = a->LocalUiLists.pFirst; lip; lip = lip->pNext){
|
|
|
+ laUiList *uil = lip->p;
|
|
|
+ (*x) -= uil->PanX;
|
|
|
+ (*y) -= uil->PanY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void laPanelToWindow(laPanel *p, int *x, int *y){
|
|
|
+ int ix = *x, iy = *y;
|
|
|
+ laListItemPointer *lip;
|
|
|
+ (*x) = ix + p->X;
|
|
|
+ (*y) = iy + p->Y;
|
|
|
+}
|
|
|
+void laLocalToPanel(laOperator *a, int *x, int *y){
|
|
|
+ int ix = *x, iy = *y;
|
|
|
+ laListItemPointer *lip;
|
|
|
+ if (a){
|
|
|
+ for (lip = a->LocalUiLists.pFirst; lip; lip = lip->pNext){
|
|
|
+ laUiList *uil = lip->p;
|
|
|
+ (*x) -= uil->PanX;
|
|
|
+ (*y) -= uil->PanY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void laSetNextMenuPos(int X, int Y, int W, int H){
|
|
|
+ MAIN.NextX = X;
|
|
|
+ MAIN.NextY = Y;
|
|
|
+ MAIN.NextW = W;
|
|
|
+ MAIN.NextH = H;
|
|
|
+}
|
|
|
+int laIsInBlock(laBlock *b, int X, int Y){
|
|
|
+ if (X >= b->X && X <= b->X + b->W && Y >= b->Y && Y <= b->Y + b->H) return 1;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int laIsInBlockHeader(laBlock *b, int X, int Y){ if (X >= b->X && X <= b->X + b->W && Y >= b->Y && Y <= b->Y + LA_RH) return 1; return 0; }
|
|
|
+int laIsInBlockBotton1(laBlock *b, int X, int Y){ if (X >= b->X && X <= b->X + LA_RH && Y >= b->Y && Y <= b->Y + LA_RH) return 1; return 0; }
|
|
|
+int laIsInBlockBotton2(laBlock *b, int X, int Y){ if (X >= b->X+LA_RH && X <= b->X+LA_2RH && Y >= b->Y && Y <= b->Y + LA_RH) return 1; return 0; }
|
|
|
+laBlock *laDetectBlockRecursive(laBlock *b, int X, int Y){
|
|
|
+ laPanel *p;
|
|
|
+ laBlock *sb = 0;
|
|
|
+ if (!laIsInBlock(b, X, Y)) return 0;
|
|
|
+ if (!b->B1 && !b->B2) return b;
|
|
|
+ if (sb = laDetectBlockRecursive(b->B1, X, Y)) return sb;
|
|
|
+ return laDetectBlockRecursive(b->B2, X, Y);
|
|
|
+}
|
|
|
+laPanel *laDetectPanel(int X, int Y){
|
|
|
+ laPanel *p; laBlock *b;
|
|
|
+
|
|
|
+ for (p = MAIN.CurrentWindow->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ int x = X, y = Y;
|
|
|
+ laWindowToLocal(0, p, &x, &y);
|
|
|
+ if (p->Show && laIsInPanel(p, x, y)){
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(MAIN.CurrentWindow->MaximizedUiPanel){return 0;}
|
|
|
+
|
|
|
+ laBlock* RootBlock=MAIN.CurrentWindow->MaximizedBlock?MAIN.CurrentWindow->MaximizedBlock:MAIN.CurrentWindow->CurrentLayout->FirstBlock;
|
|
|
+ if (b = laDetectBlockRecursive(RootBlock, X, Y)) return b->CurrentPanel;
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+laUiList *laPrepareUi(laPanel *p){
|
|
|
+ return &p->UI;
|
|
|
+}
|
|
|
+laColumn *laFirstColumn(laUiList *uil){
|
|
|
+ if (uil->Columns.pFirst) return uil->Columns.pFirst;
|
|
|
+ else{
|
|
|
+ laColumn *c = memAcquireSimple(sizeof(laColumn));
|
|
|
+ c->SP = 1;
|
|
|
+ c->PreWidth = 1;
|
|
|
+ lstAppendItem(&uil->Columns, c);
|
|
|
+ c->Top = c;
|
|
|
+ return uil->Columns.pFirst;
|
|
|
+ }
|
|
|
+}
|
|
|
+laColumn *laSplitColumn(laUiList *uil, laColumn *c, real Percent){
|
|
|
+ laColumn *lc, *rc;
|
|
|
+
|
|
|
+ if (c->LS || c->RS) return c;
|
|
|
+
|
|
|
+ lc = memAcquireSimple(sizeof(laColumn));
|
|
|
+ rc = memAcquireSimple(sizeof(laColumn));
|
|
|
+
|
|
|
+ c->LS = lc;
|
|
|
+ c->RS = rc;
|
|
|
+
|
|
|
+ c->LS->SP = Percent;
|
|
|
+ c->RS->SP = Percent;
|
|
|
+
|
|
|
+ c->LS->Top = c->Top;
|
|
|
+ c->RS->Top = c->Top;
|
|
|
+
|
|
|
+ if (uil){
|
|
|
+ lstAppendItem(&uil->Columns, lc);
|
|
|
+ lstAppendItem(&uil->Columns, rc);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (c->LS && c->RS->MaxW == 0){
|
|
|
+ c->LS->PreWidth = c->PreWidth * c->LS->SP;
|
|
|
+ c->RS->PreWidth = c->PreWidth * (1 - c->RS->SP);
|
|
|
+ }else if (c->RS && c->LS->MaxW == 0){
|
|
|
+ c->LS->PreWidth = c->PreWidth * c->LS->SP;
|
|
|
+ c->RS->PreWidth = c->PreWidth * (1 - c->RS->SP);
|
|
|
+ }
|
|
|
+ return c;
|
|
|
+}
|
|
|
+laColumn *laLeftColumn(laColumn *c, int MaxWidth){
|
|
|
+ if (c->LS && MaxWidth) c->LS->MaxW = MaxWidth;
|
|
|
+ return c->LS;
|
|
|
+}
|
|
|
+laColumn *laRightColumn(laColumn *c, int MaxWidth){
|
|
|
+ if (c->LS && c->LS->MaxW && MaxWidth) return c->RS;
|
|
|
+ if (MaxWidth) c->RS->MaxW = MaxWidth;
|
|
|
+ return c->RS;
|
|
|
+}
|
|
|
+
|
|
|
+void la_DestroyColumnRecursive(laListHandle *List, laColumn *c){
|
|
|
+ lstRemoveItem(List, c);
|
|
|
+ if (c->LS) la_DestroyColumnRecursive(List, c->LS);
|
|
|
+ if (c->RS) la_DestroyColumnRecursive(List, c->RS);
|
|
|
+ memFree(c);
|
|
|
+}
|
|
|
+
|
|
|
+int laCheckAndMergeSubColumnsUiList(laUiList *TopUil, laColumn *c, int DoMerge){
|
|
|
+ laUiList *uil = TopUil;
|
|
|
+ laUiList *sub;
|
|
|
+ laUiItem *ui;
|
|
|
+ laColumn *cc, *NextCC = 0;
|
|
|
+ int Occupied = 0;
|
|
|
+ int Removed = 0;
|
|
|
+
|
|
|
+ if (!c->LS) return 0;
|
|
|
+ else{
|
|
|
+ laCheckAndMergeSubColumnsUiList(TopUil, c->LS, DoMerge);
|
|
|
+ laCheckAndMergeSubColumnsUiList(TopUil, c->RS, DoMerge);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ui = TopUil->UiItems.pFirst; ui; ui = ui->Item.pNext){
|
|
|
+ if (ui->C == c->LS || ui->C == c->RS){
|
|
|
+ if (DoMerge){
|
|
|
+ ui->C = c;
|
|
|
+ Occupied = 1;
|
|
|
+ }else
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (ui->Subs.pFirst){
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ laCheckAndMergeSubColumnsUiList(sub, c, DoMerge);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Removed){
|
|
|
+ for (cc = uil->Columns.pFirst; cc; cc = cc->Item.pNext){
|
|
|
+ if (cc == c){
|
|
|
+ if (c->LS) la_DestroyColumnRecursive(&uil->Columns, c->LS);
|
|
|
+ if (c->RS) la_DestroyColumnRecursive(&uil->Columns, c->RS);
|
|
|
+ c->LS = 0;
|
|
|
+ c->RS = 0;
|
|
|
+ Removed = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Occupied;
|
|
|
+}
|
|
|
+
|
|
|
+laPropContainer* laUiHasExtraProps(laUiType *ut, int size, int hyper){
|
|
|
+ ut->ExtraProps = laAddPropertyContainer(ut->Identifier, 0,0,L'◳',0,size,0,0,hyper);
|
|
|
+ ut->FakeProp = memAcquire(sizeof(laSubProp));
|
|
|
+ ut->FakeProp->Base.SubProp = ut->ExtraProps;
|
|
|
+ ut->FakeProp->Base.Identifier = ut->Identifier;
|
|
|
+ ut->FakeProp->Base.PropertyType = LA_PROP_SUB;
|
|
|
+ ut->FakeProp->Base.Offset = offsetof(laUiItem, Extra);
|
|
|
+ ut->FakeProp->Base.OffsetIsPointer = 1;
|
|
|
+ //ut->FakeProp->Base.Container = ut->ExtraProps;
|
|
|
+ return ut->ExtraProps;
|
|
|
+}
|
|
|
+laPropContainer* laCanvasHasExtraProps(laCanvasTemplate *ct, int size, int hyper){
|
|
|
+ ct->ExtraProps = laAddPropertyContainer(ct->Identifier->Ptr, 0,0,L'◳',0,size,0,0,hyper);
|
|
|
+ ct->FakeProp = memAcquire(sizeof(laSubProp));
|
|
|
+ ct->FakeProp->Base.SubProp = ct->ExtraProps;
|
|
|
+ ct->FakeProp->Base.Identifier = ct->Identifier->Ptr;
|
|
|
+ ct->FakeProp->Base.PropertyType = LA_PROP_SUB;
|
|
|
+ ct->FakeProp->Base.Offset = offsetof(laUiItem, Extra);
|
|
|
+ ct->FakeProp->Base.OffsetIsPointer = 1;
|
|
|
+ //ut->FakeProp->Base.Container = ut->ExtraProps;
|
|
|
+ return ct->ExtraProps;
|
|
|
+}
|
|
|
+void la_DestroyUiType(laUiType* uit){
|
|
|
+ laKeyMapItem* kmi; while(kmi=lstPopItem(&uit->KeyMapper.Items)){ la_FreeKeyMapItem(kmi); }
|
|
|
+ memFree(uit);
|
|
|
+}
|
|
|
+laUiType *la_RegisterUiType(const char *Identifer, int ForType, const char *UseOperator, laBoxedTheme **bt, laUiDrawFunc *Draw, laUiGetHeightFunc GetHeight, laUiInitFunc Init, laUiDestroyFunc Destroy){
|
|
|
+ laUiType *ut = memAcquire(sizeof(laUiType));
|
|
|
+
|
|
|
+ ut->Identifier = Identifer;
|
|
|
+ ut->OperatorID = UseOperator;
|
|
|
+ ut->Draw = Draw;
|
|
|
+ ut->Theme = bt;
|
|
|
+ ut->ForType = ForType;
|
|
|
+ ut->OperatorType = laGetOperatorType(UseOperator);
|
|
|
+ ut->GetHeight = GetHeight;
|
|
|
+ ut->Init = Init;
|
|
|
+ ut->Destroy = Destroy;
|
|
|
+
|
|
|
+ la_UDFAppendSharedTypePointer(Identifer, ut);
|
|
|
+
|
|
|
+ lstAppendItem(&MAIN.UiTypes, ut);
|
|
|
+
|
|
|
+ return ut;
|
|
|
+}
|
|
|
+laUiType *la_GetUiTypeFromProperty(laProp *P){
|
|
|
+ laUiType *ut = MAIN.UiTypes.pFirst;
|
|
|
+ if (!P) return 0;
|
|
|
+ if (P->DefaultUiType) return P->DefaultUiType;
|
|
|
+ if (P->SubProp == LA_PC_SOCKET_IN || P->SubProp == LA_PC_SOCKET_OUT) return _LA_UI_NODE_SOCKET;
|
|
|
+ if (P->PropertyType == LA_PROP_SUB) return _LA_UI_COLLECTION;
|
|
|
+ for (ut; ut; ut = ut->Item.pNext){
|
|
|
+ if ((ut->ForType&LA_PROP_GENERIC_BITS) == (P->PropertyType&LA_PROP_GENERIC_BITS)){
|
|
|
+ return ut;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+laUiType *la_GetUiButtonType(){
|
|
|
+ laUiType *ut = MAIN.UiTypes.pFirst;
|
|
|
+ for (ut; ut; ut = ut->Item.pNext){
|
|
|
+ if (ut->ForType == LA_PROP_OPERATOR) return ut;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+laCanvasTemplate *la_GetCanvasTemplate(char* TargetContainerID, char* TemplateID){
|
|
|
+ laCanvasTemplate *vdt;
|
|
|
+ for (vdt = MAIN.View2DTemplates.pFirst; vdt; vdt = vdt->Item.pNext){
|
|
|
+ if (strSame(TemplateID, vdt->Identifier->Ptr) || strSame(TargetContainerID, vdt->TargetContainerID)) return vdt;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void la_AssignPropExtras(laUiItem* ui){
|
|
|
+ if(!ui->Type || !ui->Type->FakeProp) return;
|
|
|
+ ui->FakePs.p = ui->Type->FakeProp;
|
|
|
+ ui->FakePs.Type = L'.';
|
|
|
+ ui->FakePs.UseInstance = ui;
|
|
|
+ ui->ExtraPP.LastPs = &ui->FakePs;
|
|
|
+}
|
|
|
+void la_AssignCanvasPropExtras(laUiItem* ui){
|
|
|
+ if(!ui->CanvasTemplate || !ui->CanvasTemplate->FakeProp) return;
|
|
|
+ laCanvasTemplate*ct=ui->CanvasTemplate;
|
|
|
+ ui->FakePs.p = ct->FakeProp;
|
|
|
+ ui->FakePs.Type = L'.';
|
|
|
+ ui->FakePs.UseInstance = ui;
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+ ui->ExtraPP.LastPs = &ui->FakePs;
|
|
|
+}
|
|
|
+laUiItem *la_UpdatePropDisplay(laUiItem *ui, laPropPack *Base, const char *Path, laUiDefineFunc Template, laWidget* Widget, char* instructions){
|
|
|
+ int result;
|
|
|
+
|
|
|
+ if (!ui) return;
|
|
|
+
|
|
|
+ laUiType* OverrideType=Widget&&Widget->Type?Widget->Type:0;
|
|
|
+
|
|
|
+ if (Path){
|
|
|
+
|
|
|
+ result = la_GetPropFromPath(&ui->PP, Base, Path, 0);
|
|
|
+
|
|
|
+ if (!result){
|
|
|
+ ui->AT = laGetOperatorType(Path);
|
|
|
+ if (!ui->AT /* && !OverrideType*/) return la_UpdatePropDisplay(ui, 0, "la.example_int", 0, 0, instructions);
|
|
|
+ ui->Type = la_GetUiButtonType();
|
|
|
+ if (OverrideType && (OverrideType->ForType == LA_PROP_OPERATOR)) ui->Type = OverrideType;
|
|
|
+ }else{
|
|
|
+ ui->Type = (OverrideType && ((OverrideType->ForType == ui->PP.LastPs->p->PropertyType) || (OverrideType->TargetSub && !strcmp(OverrideType->TargetSub, ui->PP.LastPs->p->Identifier)))) ? OverrideType : la_GetUiTypeFromProperty(ui->PP.LastPs->p);
|
|
|
+ ui->Flags|=ui->PP.LastPs->p->DefaultFlags;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Base){
|
|
|
+ ui->PP.RawThis = Base;
|
|
|
+ }
|
|
|
+ }else if (Base){
|
|
|
+ ui->PP.LastPs = Base->LastPs;
|
|
|
+ ui->Type = (OverrideType && ((OverrideType->ForType == ui->PP.LastPs->p->PropertyType) || (OverrideType->TargetSub && !strcmp(OverrideType->TargetSub, ui->PP.LastPs->p->SubProp->Identifier)))) ? OverrideType : la_GetUiTypeFromProperty(ui->PP.LastPs->p);
|
|
|
+ ui->PP.RawThis = Base; //HACK! Not Unified For Prop Access!!!<<<----------??????????
|
|
|
+ ui->Flags|=ui->PP.LastPs->p->DefaultFlags;
|
|
|
+ }
|
|
|
+
|
|
|
+ la_AssignPropExtras(ui);
|
|
|
+
|
|
|
+ if(Widget){ ui->Flags|= Widget->Flags; }
|
|
|
+ if(Template) ui->Template = Template; ui->State = LA_UI_NORMAL;
|
|
|
+ if(!ui->Type) ui->Type = Widget?Widget->Type:0;
|
|
|
+
|
|
|
+ if(instructions) strSafeSet(&ui->ExtraInstructions, instructions);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *la_UpdateLabelDisplay(laUiItem *ui, laUiDefineFunc Template, char *Content){
|
|
|
+ ui->Type = _LA_UI_LABEL;
|
|
|
+
|
|
|
+ ui->Template = Template;
|
|
|
+ ui->State = LA_UI_NORMAL;
|
|
|
+
|
|
|
+ strSafeSet(&ui->Display, Content);
|
|
|
+ la_AssignPropExtras(ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *la_CreateGroupHandle(laWidget* Widget){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->Type = (Widget&&Widget->Type)?Widget->Type : _LA_UI_FIXED_GROUP;
|
|
|
+ ui->State = LA_UI_NORMAL;
|
|
|
+ la_AssignPropExtras(ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+
|
|
|
+laUiItem *laShowLabel(laUiList *uil, laColumn *c, const char *Content, laUiDefineFunc Template, laWidget* Widget){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ transLate(Content);
|
|
|
+
|
|
|
+ la_UpdateLabelDisplay(ui, Template, Content);
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laShowLabelDynamic(laUiList *uil, laColumn *c, const char *Content, laUiDefineFunc Template, laWidget* Widget){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ la_UpdateLabelDisplay(ui, Template, Content);
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laShowIcon(laUiList *uil, laColumn *c, laPropPack *Base, const char *Path, laWidget* Widget){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ la_UpdatePropDisplay(ui, Base, Path, 0, Widget, 0);
|
|
|
+ ui->Flags |= LA_UI_FLAGS_INT_ICON;
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laShowItem(laUiList *uil, laColumn *c, laPropPack *Base, const char *Path){
|
|
|
+ return laShowItemFull(uil,c,Base,Path,0,0,0,0);
|
|
|
+}
|
|
|
+laUiItem *laShowItemFull(laUiList *uil, laColumn *c, laPropPack *Base, const char *Path, laWidget* Widget, char* instructions, laUiDefineFunc Template, int TemplateContext){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ la_UpdatePropDisplay(ui, Base, Path, Template, Widget, instructions);
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+ ui->TemplateContext = TemplateContext;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laShowNodeSocket(laUiList *uil, laColumn *c, laPropPack *Base, const char *Path, char* instructions){
|
|
|
+ return laShowItemFull(uil,c,Base,Path,LA_WIDGET_NODE_SOCKET,instructions,0,0);
|
|
|
+}
|
|
|
+laUiItem *laShowHeightAdjuster(laUiList *uil, laColumn *c, laPropPack *Base, const char *Path, char* instructions){
|
|
|
+ return laShowItemFull(uil,c,Base,Path,LA_WIDGET_HEIGHT_ADJUSTER,instructions,0,0);
|
|
|
+}
|
|
|
+laUiItem *laShowCanvas(laUiList *uil, laColumn *c, laPropPack *Base, const char *Path, const char *id2DTemplate, int Height){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->Type = _LA_UI_CANVAS;
|
|
|
+ ui->State = LA_UI_NORMAL;
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ la_GetPropFromPath(&ui->PP, Base, Path, 0);
|
|
|
+
|
|
|
+ if (id2DTemplate) ui->CanvasTemplate = la_GetCanvasTemplate(0, id2DTemplate);
|
|
|
+ else{
|
|
|
+ if(!ui->PP.LastPs || ui->PP.LastPs->p->PropertyType!=LA_PROP_SUB){ la_FreePropStepCache(ui->PP.Go); memFree(ui); return laShowItem(uil,c,Base,Path); }
|
|
|
+ laSubProp* sp=ui->PP.LastPs->p; ui->PP.LastPs->p->SubProp=la_EnsureSubTarget(sp,0);
|
|
|
+ ui->CanvasTemplate = la_GetCanvasTemplate(sp->TargetID, 0);
|
|
|
+ if(!ui->CanvasTemplate){ la_FreePropStepCache(ui->PP.Go); memFree(ui); return laShowItem(uil,c,Base,Path); }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ la_AssignCanvasPropExtras(ui);
|
|
|
+
|
|
|
+ if (Height) ui->Expand=Height; else ui->Expand=6;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laShowColumnAdjuster(laUiList *uil, laColumn *c){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+ laCanvasExtra *e;
|
|
|
+
|
|
|
+ ui->Type = _LA_UI_COLUMN_ADJUSTER;
|
|
|
+ ui->Flags |= LA_WIDGET_COLUMN_ADJUSTER->Flags;
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laShowSymbol(laUiList *uil, laColumn *c, int SymbolID, int Height){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->Type = _LA_UI_SYMBOL;
|
|
|
+
|
|
|
+ ui->SymbolID = SymbolID;
|
|
|
+ if (Height) ui->State = Height;
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+
|
|
|
+laUiItem *laBeginRow(laUiList *uil, laColumn *c, int Expand, int Even){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->Type = &_LA_UI_ROW_BEGIN;
|
|
|
+
|
|
|
+ ui->State=Expand;
|
|
|
+ ui->Flags=Even;
|
|
|
+ ui->C = c;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laEndRow(laUiList *uil, laUiItem* Begin){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->Type = &_LA_UI_ROW_END;
|
|
|
+ ui->C = Begin->C;
|
|
|
+ ui->Page = (laUiList*)Begin;
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+void la_ConditionerInit(laUiItem *ui, laUiConditionNode *Expression){
|
|
|
+ laConditionUiExtraData *e = CreateNew(laConditionUiExtraData);
|
|
|
+ e->Expression = Expression;
|
|
|
+ ui->Extra = e;
|
|
|
+ la_AssignPropExtras(ui);
|
|
|
+}
|
|
|
+
|
|
|
+laUiItem *laMakeGroup(laUiList *uil, laColumn *c, const char *Name, laWidget* Widget){
|
|
|
+ laUiItem *ui = la_CreateGroupHandle(Widget);
|
|
|
+ laUiList *nuil;
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ nuil = memAcquireSimple(sizeof(laUiList));
|
|
|
+ strSafeSet(&nuil->TabName, Name);
|
|
|
+ ui->Page = nuil;
|
|
|
+ lstAppendItem(&ui->Subs, nuil);
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laMakeFoldableGroup(laUiList *uil, laColumn *c, const char *Name, laWidget* Widget, int DefaultFolded){
|
|
|
+ laUiItem *SubUi = laMakeGroup(uil, c, Name, Widget?Widget:0);
|
|
|
+ laUiList *sub = SubUi->Page;
|
|
|
+ laColumn *s = laFirstColumn(sub);
|
|
|
+ SubUi->State = LA_UI_ACTIVE;
|
|
|
+
|
|
|
+ laUiItem *b1 = laOnConditionToggle(sub, s, 0, 0, 0, 0, 0);
|
|
|
+ strSafePrint(&b1->ExtraInstructions, "text=%s", Name);
|
|
|
+ if(!DefaultFolded) b1->State=LA_UI_ACTIVE;
|
|
|
+ b1->Flags|=LA_UI_FLAGS_NO_DECAL;
|
|
|
+ laShowSeparator(sub, s);
|
|
|
+ return SubUi;
|
|
|
+}
|
|
|
+laUiItem *laMakeEmptyGroup(laUiList *uil, laColumn *c, const char *Name, laWidget* Widget){
|
|
|
+ laUiItem *SubUi = laMakeGroup(uil, c, Name, Widget?Widget->Type:0);
|
|
|
+ laUiList *sub = SubUi->Page;
|
|
|
+ laColumn *s = laFirstColumn(sub);
|
|
|
+ SubUi->State = LA_UI_ACTIVE;
|
|
|
+ return SubUi;
|
|
|
+}
|
|
|
+void laEndFoldableGroup(laUiList *sub, laUiItem *group){
|
|
|
+ laEndCondition(sub, sub->UiItems.pFirst);
|
|
|
+}
|
|
|
+laUiItem *laMakeTab(laUiList *uil, laColumn *c, laWidget* Widget){
|
|
|
+ laUiItem *ui = la_CreateGroupHandle(Widget?Widget:LA_WIDGET_TAB);
|
|
|
+ laUiList *nuil;
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ if (ui->Type->Init) ui->Type->Init(ui);
|
|
|
+ ui->ExtraPP.EndInstance = ui->Extra;
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiList *laAddTabPage(laUiItem *ui, const char *Name){
|
|
|
+ laUiList *uil = memAcquireSimple(sizeof(laUiList));
|
|
|
+
|
|
|
+ if (!ui->Page) ui->Page = uil;
|
|
|
+ lstAppendItem(&ui->Subs, uil);
|
|
|
+ strSafeSet(&uil->TabName, Name);
|
|
|
+ laFirstColumn(uil);
|
|
|
+
|
|
|
+ //laFirstColumn(uil);
|
|
|
+
|
|
|
+ return uil;
|
|
|
+}
|
|
|
+laUiList *laAddTabPageInternal(laUiItem *ui, const char *Name){
|
|
|
+ laUiList *uil = memAcquireSimple(sizeof(laUiList));
|
|
|
+
|
|
|
+ if (!ui->Page) ui->Page = uil;
|
|
|
+ lstAppendItem(&ui->Subs, uil);
|
|
|
+ strSafeSet(&uil->TabName, Name);
|
|
|
+
|
|
|
+ //laFirstColumn(uil);
|
|
|
+
|
|
|
+ return uil;
|
|
|
+}
|
|
|
+laUiList *la_AddInstancePage(laUiItem *ui, void *Instance, laWidget* Widget){
|
|
|
+ laUiList *uil = memAcquireSimple(sizeof(laUiList));
|
|
|
+
|
|
|
+ /*if (!ui->Page) */ ui->Page = uil;
|
|
|
+ lstAppendItem(&ui->Subs, uil);
|
|
|
+ uil->Instance = Instance; ui->PP.EndInstance=Instance;
|
|
|
+
|
|
|
+ return uil;
|
|
|
+}
|
|
|
+laUiConditionNode *laTrue(){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_TRUE;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laFalse(){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_FALSE;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laPropExpression(laPropPack *Base, char *Prop){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_PROP;
|
|
|
+ la_GetPropFromPath(&ucn->PP, Base, Prop, 0);
|
|
|
+ strSafeSet(&ucn->String, Prop);
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laIntExpression(int Value){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_INT;
|
|
|
+ ucn->IntValue = Value;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laFloatExpression(real Value){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_FLOAT;
|
|
|
+ ucn->FloatValue = Value;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laStringExpression(char *Content){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_STRING;
|
|
|
+ strSafeSet(&ucn->String, Content);
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laAnd(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_AND;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laOr(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_OR;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laNot(laUiConditionNode *Expression1){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_NOT;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laEqual(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_EQ;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laGreaterThan(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_GT;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laLessThan(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_LT;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laGreaterEqual(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_GE;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+laUiConditionNode *laLessEqual(laUiConditionNode *Expression1, laUiConditionNode *Expression2){
|
|
|
+ laUiConditionNode *ucn = memAcquireSimple(sizeof(laUiConditionNode));
|
|
|
+ ucn->Type = LA_CONDITION_LE;
|
|
|
+ ucn->Expression1 = Expression1;
|
|
|
+ ucn->Expression2 = Expression2;
|
|
|
+ return ucn;
|
|
|
+}
|
|
|
+int la_GetIntConditionValue(laUiConditionNode *Expression){
|
|
|
+ if (Expression->Type != LA_CONDITION_INT) return 0;
|
|
|
+ return Expression->Expression1;
|
|
|
+}
|
|
|
+real la_GetFloatConditionValue(laUiConditionNode *Expression){
|
|
|
+ if (Expression->Type != LA_CONDITION_FLOAT) return 0;
|
|
|
+ return Expression->FloatValue;
|
|
|
+}
|
|
|
+char *la_GetStringConditionValue(laUiConditionNode *Expression){
|
|
|
+ return Expression->String->Ptr;
|
|
|
+}
|
|
|
+int la_DoCompare(int CompMode, int Mode1, int i1, real f1, char *s1, void *p1, int Mode2, int i2, real f2, char *s2, void *p2){
|
|
|
+ switch (Mode1){
|
|
|
+ case LA_PROP_ENUM:
|
|
|
+ case LA_PROP_INT:
|
|
|
+ case LA_CONDITION_INT:
|
|
|
+ switch (Mode2){
|
|
|
+ case LA_PROP_ENUM:
|
|
|
+ case LA_PROP_INT:
|
|
|
+ case LA_CONDITION_INT:
|
|
|
+ switch (CompMode){
|
|
|
+ case LA_CONDITION_GE:
|
|
|
+ return (i1 >= i2);
|
|
|
+ case LA_CONDITION_GT:
|
|
|
+ return (i1 > i2);
|
|
|
+ case LA_CONDITION_EQ:
|
|
|
+ return (i1 == i2);
|
|
|
+ case LA_CONDITION_LT:
|
|
|
+ return (i1 < i2);
|
|
|
+ case LA_CONDITION_LE:
|
|
|
+ return (i1 <= i2);
|
|
|
+ }
|
|
|
+ case LA_PROP_FLOAT:
|
|
|
+ case LA_CONDITION_FLOAT:
|
|
|
+ switch (CompMode){
|
|
|
+ case LA_CONDITION_GE:
|
|
|
+ return ((real)i1 >= f2);
|
|
|
+ case LA_CONDITION_GT:
|
|
|
+ return ((real)i1 > f2);
|
|
|
+ case LA_CONDITION_EQ:
|
|
|
+ return ((real)i1 >= f2 - 0.0001 && (real)i1 <= f2 + 0.0001);
|
|
|
+ case LA_CONDITION_LT:
|
|
|
+ return ((real)i1 < f2);
|
|
|
+ case LA_CONDITION_LE:
|
|
|
+ return ((real)i1 <= f2);
|
|
|
+ }
|
|
|
+ case LA_PROP_SUB:
|
|
|
+ if (CompMode == LA_CONDITION_EQ) return i1 == (int)p2;
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ case LA_PROP_FLOAT:
|
|
|
+ case LA_CONDITION_FLOAT:
|
|
|
+ switch (Mode2){
|
|
|
+ case LA_PROP_INT:
|
|
|
+ case LA_PROP_ENUM:
|
|
|
+ case LA_CONDITION_INT:
|
|
|
+ switch (CompMode){
|
|
|
+ case LA_CONDITION_GE:
|
|
|
+ return (f1 >= (real)i2);
|
|
|
+ case LA_CONDITION_GT:
|
|
|
+ return (f1 > (real)i2);
|
|
|
+ case LA_CONDITION_EQ:
|
|
|
+ return (f1 + 0.0001 >= (real)i2 && f1 - 0.0001 <= (real)i2);
|
|
|
+ case LA_CONDITION_LT:
|
|
|
+ return (f1 < (real)i2);
|
|
|
+ case LA_CONDITION_LE:
|
|
|
+ return (f1 <= (real)i2);
|
|
|
+ }
|
|
|
+ case LA_PROP_FLOAT:
|
|
|
+ case LA_CONDITION_FLOAT:
|
|
|
+ switch (CompMode){
|
|
|
+ case LA_CONDITION_GE:
|
|
|
+ return (f1 >= f2);
|
|
|
+ case LA_CONDITION_GT:
|
|
|
+ return (f1 > f2);
|
|
|
+ case LA_CONDITION_EQ:
|
|
|
+ return (f1 == f2);
|
|
|
+ case LA_CONDITION_LT:
|
|
|
+ return (f1 < f2);
|
|
|
+ case LA_CONDITION_LE:
|
|
|
+ return (f1 <= f2);
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ case LA_PROP_STRING:
|
|
|
+ case LA_CONDITION_STRING:
|
|
|
+ switch (Mode2){
|
|
|
+ case LA_PROP_STRING:
|
|
|
+ case LA_CONDITION_STRING:
|
|
|
+ return strSame(s1, s2);
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ case LA_PROP_SUB:
|
|
|
+ switch (Mode2){
|
|
|
+ case LA_PROP_SUB:
|
|
|
+ return p1 == p2;
|
|
|
+ case LA_CONDITION_INT:
|
|
|
+ case LA_PROP_INT:
|
|
|
+ case LA_PROP_ENUM:
|
|
|
+ return (int)p1 == i2;
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ switch (CompMode){
|
|
|
+ case LA_CONDITION_GE:
|
|
|
+ return (i1 >= i2);
|
|
|
+ case LA_CONDITION_GT:
|
|
|
+ return (i1 > i2);
|
|
|
+ case LA_CONDITION_EQ:
|
|
|
+ return (i1 == i2);
|
|
|
+ case LA_CONDITION_LT:
|
|
|
+ return (i1 < i2);
|
|
|
+ case LA_CONDITION_LE:
|
|
|
+ return (i1 <= i2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+int la_DoExpression(laUiConditionNode *Expression, int *IResult, real *FResult, char *_StrResult, void **PtrResult){
|
|
|
+ void *Instance = 0;
|
|
|
+ int IValue1 = 0, IValue2 = 0;
|
|
|
+ real FValue1 = 0, FValue2 = 0;
|
|
|
+ void *Ptr1 = 0, *Ptr2 = 0;
|
|
|
+ char Str1[128], Str2[128]={0}; char* StrResult=_StrResult;
|
|
|
+ int Result1, Result2;
|
|
|
+ laEnumItem *ei;
|
|
|
+
|
|
|
+ if (!Expression) return 0;
|
|
|
+
|
|
|
+ Str1[0] = 0;
|
|
|
+ Str2[0] = 0;
|
|
|
+
|
|
|
+ laPropIterator pi = {0};
|
|
|
+
|
|
|
+ switch (Expression->Type){
|
|
|
+ case LA_CONDITION_PROP:
|
|
|
+ if (!Expression->PP.LastPs){
|
|
|
+ (*IResult) = 0;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ switch (Expression->PP.LastPs->p->PropertyType){
|
|
|
+ case LA_PROP_INT:
|
|
|
+ *IResult = laGetInt(&Expression->PP);
|
|
|
+ if (*IResult) return LA_CONDITION_INT;
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ case LA_PROP_FLOAT:
|
|
|
+ *FResult = laGetFloat(&Expression->PP);
|
|
|
+ if (*FResult) return 1;
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ break;
|
|
|
+ case LA_PROP_STRING:
|
|
|
+ laGetString(&Expression->PP, _StrResult, &StrResult);
|
|
|
+ if (StrResult[0]) return 1;
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ break;
|
|
|
+ case LA_PROP_ENUM:
|
|
|
+ ei = laGetEnum(&Expression->PP);
|
|
|
+ if (!ei) return 0;
|
|
|
+ /*if(ei) */ *IResult = ei->Index;
|
|
|
+ if (*IResult) return LA_CONDITION_INT;
|
|
|
+ break;
|
|
|
+ case LA_PROP_SUB:
|
|
|
+ if (!Expression->PP.Go) Instance = Expression->PP.EndInstance;
|
|
|
+ else
|
|
|
+ Instance = laGetActiveInstance(Expression->PP.LastPs->p, Expression->PP.LastPs->UseInstance, &pi);
|
|
|
+ *PtrResult = Instance;
|
|
|
+ if (Instance) return 1;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ case LA_CONDITION_INT:
|
|
|
+ *IResult = Expression->IntValue;
|
|
|
+ if (*IResult) return 1;
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ case LA_CONDITION_FLOAT:
|
|
|
+ *FResult = Expression->FloatValue;
|
|
|
+ if (*FResult) return 1;
|
|
|
+ else
|
|
|
+ return 0;
|
|
|
+ case LA_CONDITION_STRING:
|
|
|
+ if (Expression->String){
|
|
|
+ strCopyFull(StrResult, Expression->String->Ptr);
|
|
|
+ return 1;
|
|
|
+ }else
|
|
|
+ return 0;
|
|
|
+ case LA_CONDITION_TRUE:
|
|
|
+ if (*IResult) *IResult = 1;
|
|
|
+ return 1;
|
|
|
+ case LA_CONDITION_FALSE:
|
|
|
+ if (*IResult) *IResult = 0;
|
|
|
+ return 0;
|
|
|
+ default:
|
|
|
+ Result1 = la_DoExpression(Expression->Expression1, &IValue1, &FValue1, &Str1, &Ptr1);
|
|
|
+ switch (Expression->Type){
|
|
|
+ case LA_CONDITION_AND:
|
|
|
+ if (Result1){
|
|
|
+ Result2 = la_DoExpression(Expression->Expression2, &IValue2, &FValue2, &Str2, &Ptr2);
|
|
|
+ if (Result2) *IResult = 1;
|
|
|
+ return (Result2);
|
|
|
+ }else
|
|
|
+ return 0;
|
|
|
+ case LA_CONDITION_OR:
|
|
|
+ if (!Result1){
|
|
|
+ Result2 = la_DoExpression(Expression->Expression2, &IValue2, &FValue2, &Str2, &Ptr2);
|
|
|
+ if (Result2) *IResult = 1;
|
|
|
+ return (Result2);
|
|
|
+ }else
|
|
|
+ return 1;
|
|
|
+ case LA_CONDITION_NOT:
|
|
|
+ return !Result1;
|
|
|
+ default:
|
|
|
+ Result2 = la_DoExpression(Expression->Expression2, &IValue2, &FValue2, &Str2, &Ptr2);
|
|
|
+ return la_DoCompare(Expression->Type,
|
|
|
+ (Expression->Expression1->Type == LA_CONDITION_PROP && Expression->Expression1->PP.LastPs) ? Expression->Expression1->PP.LastPs->p->PropertyType : Expression->Expression1->Type, IValue1, FValue1, Str1, Ptr1,
|
|
|
+ (Expression->Expression2->Type == LA_CONDITION_PROP && Expression->Expression2->PP.LastPs) ? Expression->Expression2->PP.LastPs->p->PropertyType : Expression->Expression2->Type, IValue2, FValue2, Str2, Ptr2);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int la_DoSingleExpression(laUiConditionNode *Expression){
|
|
|
+ int a;
|
|
|
+ real b;
|
|
|
+ char c[128]={0};
|
|
|
+ void *p;
|
|
|
+
|
|
|
+ if (!Expression) return 1;
|
|
|
+
|
|
|
+ c[0] = 0;
|
|
|
+
|
|
|
+ return la_DoExpression(Expression, &a, &b, c, &p);
|
|
|
+}
|
|
|
+void la_StepExpression(laUiConditionNode *e){
|
|
|
+ if (!e) return;
|
|
|
+ switch (e->Type){
|
|
|
+ case LA_CONDITION_AND:
|
|
|
+ case LA_CONDITION_OR:
|
|
|
+ case LA_CONDITION_GE:
|
|
|
+ case LA_CONDITION_GT:
|
|
|
+ case LA_CONDITION_EQ:
|
|
|
+ case LA_CONDITION_LT:
|
|
|
+ case LA_CONDITION_LE:
|
|
|
+ la_StepExpression(e->Expression1);
|
|
|
+ la_StepExpression(e->Expression2);
|
|
|
+ break;
|
|
|
+ case LA_CONDITION_NOT:
|
|
|
+ la_StepExpression(e->Expression1);
|
|
|
+ break;
|
|
|
+ case LA_CONDITION_PROP:
|
|
|
+ la_StopUsingPropPack(&e->PP);
|
|
|
+ la_StepPropPack(&e->PP);
|
|
|
+ if (e->PP.LastPs && e->PP.LastPs->p->Container && e->PP.LastPs->p->Container->Hyper){
|
|
|
+ la_UsePropPack(&e->PP, 1);
|
|
|
+ //laUseDataBlock(e->PP.Go ? e->PP.LastPs->UseInstance : e->PP.EndInstance, e->PP.LastPs->p, MAIN.PropMatcherContextP->FrameDistinguish, MAIN.PropMatcherContextP, la_PropPanelUserRemover,1);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn){
|
|
|
+ if (!ucn) return;
|
|
|
+ la_ConditionNodeFreeRecursive(ucn->Expression1);
|
|
|
+ la_ConditionNodeFreeRecursive(ucn->Expression2);
|
|
|
+ if (ucn->PP.LastPs) la_FreePropStepCache(ucn->PP.Go);
|
|
|
+ if (ucn->String) strSafeDestroy(&ucn->String);
|
|
|
+ if (ucn) memFree(ucn);
|
|
|
+}
|
|
|
+
|
|
|
+laUiItem *laOnConditionThat(laUiList *uil, laColumn *c, laUiConditionNode *Expression){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->C = c;
|
|
|
+ ui->Type = &_LA_UI_CONDITION;
|
|
|
+ la_ConditionerInit(ui, Expression);
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laElse(laUiList *uil, laUiItem *Beginner){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+ laConditionUiExtraData *cued;
|
|
|
+
|
|
|
+ ui->Type = &_LA_UI_CONDITION_ELSE;
|
|
|
+
|
|
|
+ la_ConditionerInit(ui, 0);
|
|
|
+ cued = ui->Extra;
|
|
|
+
|
|
|
+ cued->EndUi = Beginner;
|
|
|
+ ((laConditionUiExtraData *)Beginner->Extra)->ElseUi = ui;
|
|
|
+
|
|
|
+ ui->C = Beginner->C;
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laOnConditionToggle(laUiList *uil, laColumn *col, laUiDefineFunc define, int Remove, laPropPack *ExtraBase, laPropPack *ExtraThis, laWidget* Widget){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+ laConditionUiExtraData *cued;
|
|
|
+
|
|
|
+ ui->Template = define;
|
|
|
+ ui->C = col;
|
|
|
+ ui->PP.RawThis = ExtraBase;
|
|
|
+ ui->Page = ExtraThis;
|
|
|
+ ui->Type = Widget? Widget->Type : _LA_UI_CONDITION_TOGGLE;
|
|
|
+
|
|
|
+ la_ConditionerInit(ui, 0);
|
|
|
+
|
|
|
+ cued = ui->Extra;
|
|
|
+ //cued->Remove = Remove;
|
|
|
+
|
|
|
+ ui->State = LA_UI_NORMAL;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiItem *laEndCondition(laUiList *uil, laUiItem *Beginner){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+ laConditionUiExtraData *cued;
|
|
|
+
|
|
|
+ ui->Type = &_LA_UI_CONDITION_END;
|
|
|
+
|
|
|
+ la_ConditionerInit(ui, 0);
|
|
|
+ cued = ui->Extra;
|
|
|
+
|
|
|
+ cued->EndUi = Beginner;
|
|
|
+ ((laConditionUiExtraData *)Beginner->Extra)->EndUi = ui;
|
|
|
+
|
|
|
+ ui->C = Beginner->C;
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiList *laMakeMenuPage(laUiList *uil, laColumn *c, const char *Title){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+ laUiList *muil = memAcquireSimple(sizeof(laUiList));
|
|
|
+
|
|
|
+ ui->Type = _LA_UI_MENU_ROOT;
|
|
|
+ strSafeSet(&ui->Display, Title);
|
|
|
+ ui->State = LA_UI_NORMAL;
|
|
|
+ ui->C = c;
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ lstAppendItem(&ui->Subs, muil);
|
|
|
+
|
|
|
+ return muil;
|
|
|
+}
|
|
|
+laUiItem *laShowSeparator(laUiList *uil, laColumn *widest){
|
|
|
+ laUiItem *ui = memAcquireSimple(sizeof(laUiItem));
|
|
|
+
|
|
|
+ ui->Type = _LA_UI_ALIGN;
|
|
|
+ ui->C = widest;
|
|
|
+
|
|
|
+ lstAppendItem(&uil->UiItems, ui);
|
|
|
+
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+void laFixHeight(laUiList *uil, short Rows){
|
|
|
+ if (!uil) return;
|
|
|
+ uil->HeightCoeff = Rows;
|
|
|
+}
|
|
|
+
|
|
|
+int la_GetUiType(laUiItem* ui) {
|
|
|
+ if (ui->AT) return LA_UI_INTERNAL_BUTTON;
|
|
|
+
|
|
|
+ if (ui->PP.LastPs) {
|
|
|
+ if (ui->Type == _LA_UI_CANVAS) return LA_UI_INTERNAL_2D_VIEW;
|
|
|
+ return LA_UI_INTERNAL_WATCHER;
|
|
|
+ }
|
|
|
+ if (ui->Display) {
|
|
|
+ if (ui->Type == _LA_UI_MENU_ROOT) return LA_UI_INTERNAL_MENU;
|
|
|
+ return LA_UI_INTERNAL_LABEL;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Subs.pFirst) {
|
|
|
+ if (ui->Type == _LA_UI_FIXED_GROUP)return LA_UI_INTERNAL_GROUP;
|
|
|
+ if (ui->Type == _LA_UI_TAB)return LA_UI_INTERNAL_TAB;
|
|
|
+ return LA_UI_INTERNAL_GROUP;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Type == _LA_UI_BUTTON) return LA_UI_INTERNAL_BUTTON;
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION) return LA_UI_INTERNAL_BRACKET_BEGIN;
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION_ELSE) return LA_UI_INTERNAL_BRACKET_ELSE;
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION_END) return LA_UI_INTERNAL_BRACKET_END;
|
|
|
+ if (ui->Type == _LA_UI_CONDITION_TOGGLE) return LA_UI_INTERNAL_FOLDER_BEGIN;
|
|
|
+
|
|
|
+ if (ui->Type == _LA_UI_ALIGN) return LA_UI_INTERNAL_ALIGNER;
|
|
|
+ if (ui->Type == _LA_UI_COLUMN_ADJUSTER) return LA_UI_INTERNAL_ADJUSTER;
|
|
|
+ if (ui->Type == _LA_UI_SYMBOL) return LA_UI_INTERNAL_SYMBOL;
|
|
|
+
|
|
|
+ return LA_UI_INTERNAL_WATCHER;
|
|
|
+}
|
|
|
+
|
|
|
+void laMakeUiListFromTemplate(laUiList *Into, laUiDefineFunc Template,
|
|
|
+ laPropPack *PanelPP, laPropPack *PanelExtraPP, laPropPack *Base, laPropPack *Operator, laListHandle *ExtraColumns, int Context){
|
|
|
+ if (!ExtraColumns) return;
|
|
|
+ Template(Into, Base, Operator, ExtraColumns->pFirst, Context);
|
|
|
+}
|
|
|
+laUiTemplate *laFindUiTemplate(char *Identifier){
|
|
|
+ laUiTemplate *uit;
|
|
|
+ for (uit = MAIN.PanelTemplates.pFirst; uit; uit = uit->Item.pNext){
|
|
|
+ if (!strcmp(uit->Identifier->Ptr, Identifier)) return uit;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+void la_DestroyUiTemplate(laUiTemplate* uit){
|
|
|
+ strSafeDestroy(&uit->Identifier);
|
|
|
+ strSafeDestroy(&uit->Title);
|
|
|
+ laKeyMapItem* kmi; while(kmi=lstPopItem(&uit->KeyMap.Items)){ la_FreeKeyMapItem(kmi); }
|
|
|
+ memFree(uit);
|
|
|
+}
|
|
|
+void la_DestroyCanvasTemplate(laCanvasTemplate* uit){
|
|
|
+ strSafeDestroy(&uit->Identifier);
|
|
|
+ laKeyMapItem* kmi; while(kmi=lstPopItem(&uit->KeyMapper.Items)){ la_FreeKeyMapItem(kmi); }
|
|
|
+ memFree(uit);
|
|
|
+}
|
|
|
+laUiTemplate *laRegisterUiTemplate(char *Identifier, char* Title, laUiDefineFunc func,laPanelDetachedPropFunc PropFunc, laUiDefineFunc header){
|
|
|
+ laUiTemplate *uit = memAcquire(sizeof(laUiTemplate));
|
|
|
+ strSafeSet(&uit->Identifier, Identifier);
|
|
|
+ strSafeSet(&uit->Title, Title);
|
|
|
+ uit->Define = func;
|
|
|
+ uit->Header = header;
|
|
|
+ uit->PropFunc = PropFunc;
|
|
|
+ lstAppendItem(&MAIN.PanelTemplates, uit);
|
|
|
+ la_UDFAppendSharedTypePointer(Identifier, uit);
|
|
|
+ return uit;
|
|
|
+}
|
|
|
+laCanvasTemplate *laRegisterCanvasTemplate(char *Identifier, char *ForContainer, laCanvasDrawFunc Func, laUiDrawFunc SecondDraw, laUiInitFunc CustomInit, laUiDestroyFunc CustomDestroy){
|
|
|
+ laCanvasTemplate *t = memAcquire(sizeof(laCanvasTemplate));
|
|
|
+ strSafeSet(&t->Identifier, Identifier);
|
|
|
+ t->Draw = Func; t->SecondDraw = SecondDraw; t->TargetContainerID = ForContainer;
|
|
|
+ t->Init = CustomInit; t->Destroy = CustomDestroy;
|
|
|
+ lstAppendItem(&MAIN.View2DTemplates, t);
|
|
|
+ la_UDFAppendSharedTypePointer(Identifier, t);
|
|
|
+ return t;
|
|
|
+}
|
|
|
+void laFinalizeUiTemplates(){
|
|
|
+ laUiTemplate *uit;
|
|
|
+ laCanvasTemplate *u2d;
|
|
|
+ for (u2d = MAIN.View2DTemplates.pFirst; u2d; u2d = u2d->Item.pNext){
|
|
|
+ if (u2d->TargetContainerID) u2d->TargetContainer = la_ContainerLookup(u2d->TargetContainerID);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+laPanel *la_FindFreePanelByTemplate(laWindow *w, const laUiTemplate *uit){
|
|
|
+ laPanel *p;
|
|
|
+ for (p=w->Panels.pFirst; p; p = p->Item.pNext){
|
|
|
+ if (p->PanelTemplate==uit){
|
|
|
+ return p;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+void la_DestroyUiItem(laUiItem *ui, int RemoveUsers){
|
|
|
+ laUiList *uil, *NextUil;
|
|
|
+ for (uil = ui->Subs.pFirst; uil; uil = NextUil){
|
|
|
+ NextUil = uil->Item.pNext;
|
|
|
+ lstRemoveItem(&ui->Subs, uil);
|
|
|
+ la_DestroyUiList(uil, 0, RemoveUsers, 0);
|
|
|
+ }
|
|
|
+ la_StopUiOperatorService(ui);
|
|
|
+ strSafeDestroy(&ui->ExtraInstructions);
|
|
|
+ strSafeDestroy(&ui->Display);
|
|
|
+ if (RemoveUsers && ui->PP.LastPs && ui->PP.LastPs->p->Container->Hyper)
|
|
|
+ la_StopUsingPropPack(&ui->PP);
|
|
|
+ //laStopUsingDataBlock(ui->PP.LastPs->UseInstance,ui->PP.LastPs->p,MAIN.PropMatcherContextP);
|
|
|
+ la_FreePropStepCache(ui->PP.Go); //-------[Up Here], instance already been freed.XXXXXXXXXXXX!!!!!!!!!!1
|
|
|
+ if (ui->Type->Destroy) ui->Type->Destroy(ui);
|
|
|
+ memFree(ui);
|
|
|
+}
|
|
|
+void la_DestroyUiList(laUiList *uil, int NoFree, int RemoveUsers, int OnlyRemoveUser){
|
|
|
+ laUiItem *ui, *NextUi;
|
|
|
+ laColumn *col, *NextCol;
|
|
|
+ if (!uil) return;
|
|
|
+ for (ui = uil->UiItems.pFirst; ui; ui = NextUi){
|
|
|
+ NextUi = ui->Item.pNext;
|
|
|
+ if(OnlyRemoveUser && RemoveUsers){
|
|
|
+ if (ui->PP.LastPs && ui->PP.LastPs->p->Container->Hyper)
|
|
|
+ la_StopUsingPropPack(&ui->PP);
|
|
|
+ //laStopUsingDataBlock(ui->PP.LastPs->UseInstance,ui->PP.LastPs->p,MAIN.PropMatcherContextP);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ lstRemoveItem(&uil->UiItems, ui);
|
|
|
+ la_DestroyUiItem(ui, RemoveUsers);
|
|
|
+ }
|
|
|
+ if(OnlyRemoveUser){ return; }
|
|
|
+ for (col = uil->Columns.pFirst; col; col = NextCol){
|
|
|
+ NextCol = col->Item.pNext;
|
|
|
+ lstRemoveItem(&uil->Columns, col);
|
|
|
+ memFree(col);
|
|
|
+ }
|
|
|
+
|
|
|
+ strSafeDestroy(&uil->TabName);
|
|
|
+
|
|
|
+ if (!NoFree) memFree(uil);
|
|
|
+}
|
|
|
+void la_DestroyTabPage(laUiItem *ui, laUiList *Tab, int RemoveUsers){
|
|
|
+ lstRemoveItem(&ui->Subs, Tab);
|
|
|
+ la_DestroyUiList(Tab, 1, RemoveUsers, 0);
|
|
|
+}
|
|
|
+void la_CreateUiAfter(laUiList *uil, laUiItem *after, laUiDefineFunc Define, laPropPack *Base, laPropPack *This, laColumn **ExtraColums){
|
|
|
+ laUiItem *Next = after->Item.pNext;
|
|
|
+ laUiItem *Last = uil->UiItems.pLast;
|
|
|
+ after->Item.pNext = 0;
|
|
|
+ uil->UiItems.pLast = after;
|
|
|
+
|
|
|
+ Define(uil, Base, This, ExtraColums, 0);
|
|
|
+
|
|
|
+ if (Next) Next->Item.pPrev = uil->UiItems.pLast;
|
|
|
+ ((laUiItem *)uil->UiItems.pLast)->Item.pNext = Next;
|
|
|
+ if (Next != Last) uil->UiItems.pLast = Last;
|
|
|
+}
|
|
|
+//void la_RefreshExtraColumns(laUiItem* ui, int B,int FromL,int ToL,int FromR,int ToR){
|
|
|
+// int i = 0;
|
|
|
+// int FromW=FromR-FromL, ToW=ToR-ToL;
|
|
|
+// if (!ui->ExtraColums) return;
|
|
|
+// for (i; ui->ExtraColums[i]; i++) {
|
|
|
+// laColumn* c = ui->ExtraColums[i];
|
|
|
+// c->B = B;
|
|
|
+// c->IL = (c->IL - FromL) / FromW*ToW + ToL;
|
|
|
+// c->IR = (c->IR - FromL) / FromW*ToW + ToL;
|
|
|
+// }
|
|
|
+//}
|
|
|
+void la_PropPanelUserRemover(void* this_UNUSED, laItemUserLinker* iul){
|
|
|
+ laPanel* p = iul->Pointer.p; if(p->FrameDistinguish == iul->FrameDistinguish){ p->Refresh |= LA_TAG_RECALC; }
|
|
|
+}
|
|
|
+void la_CalcUiItemInfluence(laListHandle *lst, laUiItem *ui){
|
|
|
+ laColumn *c = ui->C;
|
|
|
+ laColumn *ic = lst->pFirst;
|
|
|
+
|
|
|
+ c->B = ui->TB + (*ui->Type->Theme)->BP;
|
|
|
+
|
|
|
+ for (ic; ic; ic = ic->Item.pNext){
|
|
|
+ if (((ic->IR > c->IL) && (ic->IL < c->IR)) || ((ic->IL < c->IR) && (ic->IR > c->IL))){
|
|
|
+ ic->B = ic->B < c->B ? c->B : ic->B;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ic = ui->C;
|
|
|
+ while (ic->Item.pPrev && (ic = ic->Item.pPrev))
|
|
|
+ ;
|
|
|
+ for (ic; ic; ic = ic->Item.pNext){
|
|
|
+ if (((ic->IR > c->IL) && (ic->IL < c->IR)) || ((ic->IL < c->IR) && (ic->IR > c->IL))){
|
|
|
+ ic->B = ic->B < c->B ? c->B : ic->B;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_CalcUiTopInfluence(laListHandle *lst, laUiItem *ui){
|
|
|
+ laColumn *c = ui->C;
|
|
|
+ laColumn *ic = lst->pFirst;
|
|
|
+
|
|
|
+ c->B = ui->TB + (*ui->Type->Theme)->TP;
|
|
|
+
|
|
|
+ for (ic; ic; ic = ic->Item.pNext){
|
|
|
+ if (((ic->IR > c->IL) && (ic->IL < c->IR)) || ((ic->IL < c->IR) && (ic->IR > c->IL))){
|
|
|
+ ic->B = ic->B < c->B ? c->B : ic->B;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ic = ui->C;
|
|
|
+ while (ic->Item.pPrev && (ic = ic->Item.pPrev))
|
|
|
+ ;
|
|
|
+ for (ic; ic; ic = ic->Item.pNext){
|
|
|
+ if (((ic->IR > c->IL) && (ic->IL < c->IR)) || ((ic->IL < c->IR) && (ic->IR > c->IL))){
|
|
|
+ ic->B = ic->B < c->B ? c->B : ic->B;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+int la_ResetUiColum(laColumn *c, laColumn *Top, int U, int L, int R, int LR, int repos){ //1=L,2=R
|
|
|
+ int rep;
|
|
|
+ int sp;
|
|
|
+ int rev;
|
|
|
+
|
|
|
+ if (!c) return 0;
|
|
|
+
|
|
|
+ sp = (c->SP * (R - L)) + L;
|
|
|
+ rev = sp;
|
|
|
+
|
|
|
+ /*if (U)*/ c->B = U;
|
|
|
+
|
|
|
+ if (LR == 1){
|
|
|
+ c->IL = L;
|
|
|
+ c->IR = sp;
|
|
|
+ if (repos){
|
|
|
+ c->IR = repos;
|
|
|
+ }else if (c->MaxW*LA_RH && c->IR - c->IL > c->MaxW*LA_RH){
|
|
|
+ c->IR = c->IL + c->MaxW*LA_RH;
|
|
|
+ rev = c->IR;
|
|
|
+ }
|
|
|
+ }else if (LR == 2){
|
|
|
+ c->IL = sp;
|
|
|
+ c->IR = R;
|
|
|
+ if (repos){
|
|
|
+ c->IL = repos;
|
|
|
+ }else if (c->MaxW*LA_RH && c->IR - c->IL > c->MaxW*LA_RH){
|
|
|
+ c->IL = c->IR - c->MaxW*LA_RH;
|
|
|
+ rev = c->IL;
|
|
|
+ }
|
|
|
+ }else if (LR == 0){
|
|
|
+ c->IL = L;
|
|
|
+ c->IR = R;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (c->LS && c->RS->MaxW == 0){
|
|
|
+ rep = la_ResetUiColum(c->LS, Top, U, c->IL, c->IR, 1, 0);
|
|
|
+ la_ResetUiColum(c->RS, Top, U, c->IL, c->IR, 2, rep);
|
|
|
+ c->LS->PreWidth = c->PreWidth * c->LS->SP;
|
|
|
+ c->RS->PreWidth = c->PreWidth * (1 - c->RS->SP);
|
|
|
+ }else if (c->RS && c->LS->MaxW == 0){
|
|
|
+ rep = la_ResetUiColum(c->RS, Top, U, c->IL, c->IR, 2, 0);
|
|
|
+ la_ResetUiColum(c->LS, Top, U, c->IL, c->IR, 1, rep);
|
|
|
+ c->LS->PreWidth = c->PreWidth * c->LS->SP;
|
|
|
+ c->RS->PreWidth = c->PreWidth * (1 - c->RS->SP);
|
|
|
+ }
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+
|
|
|
+STRUCTURE(laRowInfo){
|
|
|
+ int MaxW;
|
|
|
+ int MinW;
|
|
|
+ int UnitMinW;
|
|
|
+ int NonExpandW;
|
|
|
+ int TotalPadding;
|
|
|
+ int Expand, Even;
|
|
|
+ int ExpandAccum;
|
|
|
+ int CountElements;
|
|
|
+ int U,MaxB,L;
|
|
|
+ laListHandle Elements;
|
|
|
+};
|
|
|
+STRUCTURE(laRowNode){
|
|
|
+ laListItem Item;
|
|
|
+ laUiItem* ui;
|
|
|
+ int GotW, LP, RP, H;
|
|
|
+ int Expand;
|
|
|
+};
|
|
|
+int la_InitRowNode(laRowInfo* ri, laUiItem* ui, laBoxedTheme* bt){
|
|
|
+ ri->MaxW = ui->TR-ui->TL;//row node does not use margin
|
|
|
+ ri->UnitMinW=LA_RH+bt->LM+bt->RM;
|
|
|
+ ri->Expand=ui->State?1:0;
|
|
|
+ ri->Even=ui->Flags?1:0;
|
|
|
+ ri->U=ui->TU; ri->L=ui->TL;
|
|
|
+ ri->MaxB=ui->TU;
|
|
|
+}
|
|
|
+int la_AddRowNode(laRowInfo* ri, laUiItem* ui, laBoxedTheme* bt, int H){
|
|
|
+ laRowNode* rn=CreateNew(laRowNode);
|
|
|
+ rn->LP=bt->LP;rn->RP=bt->RP;
|
|
|
+ rn->GotW = (ui->Type->GetMinWidth?ui->Type->GetMinWidth(ui):(LA_RH)) +bt->LM+bt->RM;
|
|
|
+ rn->ui=ui;
|
|
|
+ rn->H=H;
|
|
|
+ rn->Expand=ui->Expand;
|
|
|
+ lstAppendItem(&ri->Elements, rn);
|
|
|
+
|
|
|
+ if(!ri->UnitMinW){ri->UnitMinW=LA_RH+bt->LM+bt->RM;}
|
|
|
+ ri->TotalPadding += bt->LP+bt->RP;
|
|
|
+ ri->MinW+=ri->UnitMinW;
|
|
|
+ ri->NonExpandW+=rn->GotW;
|
|
|
+ ri->ExpandAccum+=ui->Expand;
|
|
|
+ ri->CountElements++;
|
|
|
+ if(ui->Expand){ri->Expand=1;}
|
|
|
+ if(ri->U+H+bt->BP>ri->MaxB){ri->MaxB=ri->U+H+bt->BP;}
|
|
|
+}
|
|
|
+int la_ShrinkableRowElements(laRowInfo* ri){
|
|
|
+ int count=0;
|
|
|
+ for(laRowNode* rn=ri->Elements.pFirst;rn;rn=rn->Item.pNext){
|
|
|
+ if(rn->GotW<=ri->UnitMinW) continue;
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ return count;
|
|
|
+}
|
|
|
+int la_CalculateRowExpand(laRowInfo* ri, laUiItem* ui_end, int WaitAnimation){
|
|
|
+ int Available=ri->MaxW-ri->NonExpandW-ri->TotalPadding;
|
|
|
+ int ShareCount=0, Additional=0, AdditionalRemaining=0, Shrinkable=0; real NodeAddFraction=0;
|
|
|
+ if(Available<0){
|
|
|
+ ShareCount=1;// Shrinkable=la_ShrinkableRowElements(ri);
|
|
|
+ Additional=(ri->MaxW-ri->MinW-ri->TotalPadding)/ri->CountElements;
|
|
|
+ AdditionalRemaining = (ri->MaxW-ri->MinW-ri->TotalPadding)-Additional*ri->CountElements;
|
|
|
+ }else{
|
|
|
+ if(!ri->Expand && Available>0){Available=0;}
|
|
|
+ ShareCount=ri->ExpandAccum?ri->ExpandAccum:ri->CountElements;
|
|
|
+ }
|
|
|
+ if(!ShareCount) return;
|
|
|
+ int PerNode = Available/ShareCount;
|
|
|
+ int Remaining = Available-PerNode*ShareCount;
|
|
|
+ int L = ri->L; int i=0; laRowNode* rn;
|
|
|
+
|
|
|
+ for(rn=ri->Elements.pFirst;rn;rn=rn->Item.pNext){
|
|
|
+ laUiItem* ui=rn->ui;
|
|
|
+ int NodeAdd, Node=rn->GotW;
|
|
|
+ if(Available>=0){
|
|
|
+ NodeAdd=ri->ExpandAccum?(PerNode*rn->Expand):PerNode;
|
|
|
+ NodeAdd+=(i<Remaining?1:0);i++;
|
|
|
+ }else{
|
|
|
+ if(ri->MaxW>=ri->MinW+ri->TotalPadding) {
|
|
|
+ NodeAddFraction+=((rn->GotW>ri->UnitMinW)?(real)Available*(real)(rn->GotW-ri->UnitMinW)/(real)(ri->NonExpandW-ri->MinW):0);
|
|
|
+ NodeAdd=(int)NodeAddFraction; NodeAddFraction-=NodeAdd;
|
|
|
+ }else{ Node=ri->UnitMinW;
|
|
|
+ NodeAdd=Additional+(i<-AdditionalRemaining?-1:0);i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ui->TL = L + rn->LP;
|
|
|
+ ui->TR = ui->TL + Node+NodeAdd;
|
|
|
+ ui->TB = ui->TU + rn->H;
|
|
|
+ L=ui->TR+rn->RP;
|
|
|
+ if (!WaitAnimation){
|
|
|
+ ui->L = ui->TL; ui->R = ui->TR;
|
|
|
+ ui->U = ui->TU; ui->B = ui->TB;
|
|
|
+ }
|
|
|
+ if(ui->Type==_LA_UI_NODE_SOCKET){ la_RecordSocketRuntimePosition(ui); }
|
|
|
+ }
|
|
|
+ ui_end->TB = ri->MaxB;
|
|
|
+ while(rn=lstPopItem(&ri->Elements)){
|
|
|
+ FreeMem(rn);
|
|
|
+ }
|
|
|
+ memset(ri, 0, sizeof(laRowInfo));
|
|
|
+}
|
|
|
+void la_RecordSocketRuntimePosition(laUiItem* ui){
|
|
|
+ laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
|
|
|
+ if(pc==LA_PC_SOCKET_OUT){
|
|
|
+ laNodeOutSocket* s=ui->PP.EndInstance; s->RuntimeX=(ui->TL+ui->TR)/2; s->RuntimeY=(ui->TU+ui->TB)/2;
|
|
|
+ }else{
|
|
|
+ laNodeInSocket* s=ui->PP.EndInstance; s->RuntimeX=(ui->TL+ui->TR)/2; s->RuntimeY=(ui->TU+ui->TB)/2;
|
|
|
+ }
|
|
|
+}
|
|
|
+int la_UpdateUiListRecursive(laUiList *uil, int U, int L, int R, int B, int Fast, laPanel *ParentPanel){
|
|
|
+ laUiItem *ui;
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ int Lowest = 0;
|
|
|
+ int HyperValue = 0;
|
|
|
+ int WaitAnimation;
|
|
|
+ int RowMode=0; laRowInfo ri={0};
|
|
|
+ laBoxedTheme* pt=*(ParentPanel->BT);
|
|
|
+ int _PL=-pt->LM,_PR=-pt->RM,_PT=-pt->TM,_PB=-pt->BM;
|
|
|
+ int MaxR=0;
|
|
|
+
|
|
|
+ if(!uil->Scale){uil->Scale=1;}
|
|
|
+ uil->SaveScale=MAIN.UiScale;
|
|
|
+ MAIN.UiScale*=uil->Scale;
|
|
|
+ MAIN.ScaledUiRowHeight=MAIN.UiRowHeight*MAIN.UiScale;
|
|
|
+
|
|
|
+ uil->TU = U;uil->TL = L;uil->TR = R;uil->TB = uil->TU;
|
|
|
+ WaitAnimation = 0;
|
|
|
+
|
|
|
+ if (!uil->Columns.pFirst && !uil->UiItems.pFirst) return U;
|
|
|
+
|
|
|
+ la_ResetUiColum(uil->Columns.pFirst, uil->Columns.pFirst, U, L, R, 0, 0);
|
|
|
+
|
|
|
+ for (ui = uil->UiItems.pFirst; ui;){
|
|
|
+ int SubB = 0;
|
|
|
+ int H;
|
|
|
+ WaitAnimation = 0;
|
|
|
+ int NoGap=ui->Flags&LA_UI_FLAGS_NO_GAP;
|
|
|
+ int NoHeight=ui->Flags&LA_UI_FLAGS_UNDERNEATH;
|
|
|
+
|
|
|
+ //if (Fast && ui->C->B > B) {
|
|
|
+ // //la_CalcUiItemInfluence(&uil->Colums, ui);
|
|
|
+ // ui = ui->Item.pNext;
|
|
|
+ // continue;
|
|
|
+ //}
|
|
|
+
|
|
|
+ if (!ui->Instructions){
|
|
|
+ if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
|
|
|
+ if (ui->AT && ui->AT->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->AT->ExtraInstructions);
|
|
|
+ if (ui->PP.LastPs && ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
|
|
|
+ laOperatorProp *ap = ui->PP.LastPs->p;
|
|
|
+ if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
|
|
|
+ if (ap->OperatorType->ExtraInstructions) strMakeInstructions(&ui->Instructions, ap->OperatorType->ExtraInstructions);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (/*!ui->NoRefresh && */ ui->PP.LastPs){
|
|
|
+ la_StepPropPack(&ui->PP);
|
|
|
+ }
|
|
|
+
|
|
|
+ la_UsePropPack(&ui->PP, 0);
|
|
|
+ //if (ui->PP.LastPs && (HyperValue = ui->PP.LastPs->p->Container ? ui->PP.LastPs->p->Container->Hyper : 0)){
|
|
|
+ // laUseDataBlock(ui->PP.Go ? ui->PP.LastPs->UseInstance : ui->PP.RawThis->LastPs->UseInstance, ui->PP.LastPs->p, MAIN.PropMatcherContextP->FrameDistinguish, MAIN.PropMatcherContextP, la_PropPanelUserRemover, 0);
|
|
|
+ //}
|
|
|
+
|
|
|
+ if ((ui->AnimationDistinguish + 1) == ParentPanel->FrameDistinguish){
|
|
|
+ ParentPanel->Refresh |= LA_TAG_ANIMATION;
|
|
|
+ WaitAnimation = 1;
|
|
|
+ }
|
|
|
+ ui->AnimationDistinguish = ParentPanel->FrameDistinguish;
|
|
|
+
|
|
|
+ bt = (*ui->Type->Theme);
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ la_StepExpression(cued->Expression);
|
|
|
+ cued->IsTrue = la_DoSingleExpression(cued->Expression);
|
|
|
+ if (!cued->IsTrue){
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_END){
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_ELSE){
|
|
|
+ laConditionUiExtraData *cued = ((laConditionUiExtraData *)ui->Extra)->EndUi->Extra;
|
|
|
+ if (cued->IsTrue) ui = cued->EndUi;
|
|
|
+ else
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == _LA_UI_CONDITION_TOGGLE){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ ui->TL = ui->C->IL + bt->LP; ui->TR = ui->C->IR - bt->RP;
|
|
|
+ ui->TU = ui->C->B + bt->TP; ui->TB = ui->TU+LA_RH;
|
|
|
+ if (!WaitAnimation){
|
|
|
+ ui->L = ui->TL; ui->R = ui->TR;
|
|
|
+ ui->U = ui->TU; ui->B = ui->TB;
|
|
|
+ }
|
|
|
+ if(!RowMode){
|
|
|
+ la_CalcUiItemInfluence(&uil->Columns, ui);
|
|
|
+ }else{
|
|
|
+ H = ui->Type->GetHeight ? ui->Type->GetHeight(ui) : 1;
|
|
|
+ la_AddRowNode(&ri, ui, bt, H*LA_RH);
|
|
|
+ }
|
|
|
+ if (ui->State == LA_UI_NORMAL){
|
|
|
+ cued->IsTrue = 0;
|
|
|
+ //if(cued->Remove && (ui->Item.pNext != cued->EndUi))
|
|
|
+ // la_DestroyUiRange(uil, ui->Item.pNext, cued->ElseUi?cued->ElseUi->Item.pPrev:cued->EndUi->Item.pPrev);
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ cued->IsTrue = 1;
|
|
|
+ //if (cued->Remove && (ui->Item.pNext == cued->EndUi || ui->Item.pNext==cued->ElseUi)) {
|
|
|
+ // la_CreateUiAfter(uil, ui, ui->Template, ui->PP.RawThis, ui->Page, uil->Columns.pFirst);
|
|
|
+ //}
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Type == _LA_UI_ALIGN){
|
|
|
+ ui->TU = ui->C->B + bt->TP; ui->TB = ui->TU;
|
|
|
+ ui->TL = ui->C->IL; ui->TR = ui->C->IR;
|
|
|
+ if (ui->TB > Lowest) Lowest = ui->TB;
|
|
|
+ if (!WaitAnimation){
|
|
|
+ ui->L = ui->TL; ui->R = ui->TR;
|
|
|
+ ui->U = ui->TU; ui->B = ui->TB;
|
|
|
+ }
|
|
|
+ if(!RowMode){
|
|
|
+ la_CalcUiItemInfluence(&uil->Columns, ui);
|
|
|
+ }else{
|
|
|
+ ui->Flags|=LA_UI_FLAGS_TRANSPOSE;
|
|
|
+ H = ui->Type->GetHeight ? ui->Type->GetHeight(ui) : 1;
|
|
|
+ la_AddRowNode(&ri, ui, bt, H*LA_RH);
|
|
|
+ }
|
|
|
+ ui = ui->Item.pNext; continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_ROW_BEGIN){
|
|
|
+ ui->TU = ui->C->B; ui->TL = ui->C->IL; ui->TR = ui->C->IR;
|
|
|
+ la_InitRowNode(&ri, ui, bt);
|
|
|
+ RowMode=1; ui=ui->Item.pNext; continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_ROW_END){
|
|
|
+ la_CalculateRowExpand(&ri, ui, WaitAnimation);
|
|
|
+ la_CalcUiItemInfluence(&uil->Columns, ui);
|
|
|
+ RowMode=0; ui=ui->Item.pNext; continue;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(!RowMode){ ui->TL = ui->C->IL + (NoGap?_PL:bt->LP); ui->TR = ui->C->IR - (NoGap?_PR:bt->RP); }
|
|
|
+
|
|
|
+ int GB=0;
|
|
|
+ if (ui->Type == _LA_UI_FIXED_GROUP && ui->Page->HeightCoeff < 0 && ui->Flags&LA_UI_FLAGS_PREFER_BOTTOM){ GB=ui->Page->TB-ui->Page->PanY; }
|
|
|
+
|
|
|
+ H = ui->Type->GetHeight ? ui->Type->GetHeight(ui) : 1;
|
|
|
+ ui->TU = ui->C->B + (NoGap?_PT:bt->TP);
|
|
|
+ if (H < 0){
|
|
|
+ if(B){ H = B + (H+1) * LA_RH - ui->TU; }
|
|
|
+ else{ H=LA_RH; }
|
|
|
+ }
|
|
|
+ else H *= LA_RH;
|
|
|
+ ui->TB = ui->TU;
|
|
|
+
|
|
|
+ int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
|
|
|
+
|
|
|
+ if (ui->Type->ForType == LA_PROP_SUB && ui->PP.LastPs && ui->PP.LastPs->p && ui->PP.LastPs->p->PropertyType == LA_PROP_SUB && ui->Type != _LA_UI_CANVAS){ //DynamicCreation
|
|
|
+ laPropIterator pi = {0}; laSubProp* uisp=ui->PP.LastPs->p;
|
|
|
+ if (ui->Type == _LA_UI_COLLECTION){
|
|
|
+ //void* TInstance = ui->PP.Go?laGetInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, &pi):ui->PP.EndInstance;
|
|
|
+ void *TInstance = laGetInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, &pi);
|
|
|
+ ui->PP.EndInstance = TInstance;
|
|
|
+ laUiList *iuil = ui->Subs.pFirst;
|
|
|
+ laUiList *puil = iuil;
|
|
|
+ int Row = 0, Col = 0, RowPriority = ui->SymbolID > 0 ? 1 : 0, ElementLimit = ui->SymbolID ? abs(ui->SymbolID) : 0;
|
|
|
+ int Spread=ui->Expand>2?ui->Expand:0; if(Spread){ RowPriority=0; ElementLimit=0; }
|
|
|
+ laUiDefineFunc Template = ui->Template ? ui->Template : laGetPropertyUiDefine(&ui->PP, TInstance);
|
|
|
+
|
|
|
+ int Begin = ui->TB;
|
|
|
+ int EL = ui->TL, ER = Spread?(Spread*LA_RH+ui->TL):ui->TR;
|
|
|
+ int ElementB = ui->TU;
|
|
|
+ real ElementWidth = ElementLimit ? 1.0f / ElementLimit : 1.0;
|
|
|
+ int MaxB = ElementB;
|
|
|
+ int CanGetTheme = laCanGetTheme(ui->PP.LastPs->p);laTheme* OriginalTheme=MAIN.CurrentTheme;
|
|
|
+ int CanGetGap= laCanGetGap(ui->PP.LastPs->p);
|
|
|
+ int Gap=0;
|
|
|
+
|
|
|
+ if (!ElementLimit) RowPriority = 0;
|
|
|
+
|
|
|
+ if (!TInstance){
|
|
|
+ while (iuil){
|
|
|
+ puil = iuil->Item.pNext;ui->PP.EndInstance=iuil->Instance; la_StopUsingPropPack(&ui->PP);
|
|
|
+ la_DestroyTabPage(ui, iuil, 0);
|
|
|
+ iuil = puil;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ while (TInstance){
|
|
|
+ if(uisp->UiFilter && (!uisp->UiFilter(ui->PP.LastPs->UseInstance, TInstance))){
|
|
|
+ TInstance = laGetNextInstance(ui->PP.LastPs->p, TInstance, &pi);
|
|
|
+ Template = ui->Template?ui->Template:laGetPropertyUiDefine(&ui->PP, TInstance);
|
|
|
+ ui->PP.EndInstance = TInstance; continue;
|
|
|
+ }
|
|
|
+ if(CanGetTheme){
|
|
|
+ laTheme* t=laGetUiTheme(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, ui->PP.EndInstance);
|
|
|
+ la_SwitchThemeQuick(t, OriginalTheme);
|
|
|
+ }
|
|
|
+ if(CanGetGap){
|
|
|
+ int g=laGetUiGap(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, ui->PP.EndInstance); g=g<0?0:g;
|
|
|
+ Gap=g*LA_RH;
|
|
|
+ }else Gap=0;
|
|
|
+
|
|
|
+ if (ElementLimit){
|
|
|
+ EL = tnsInterpolate(ui->TL, ui->TR, (Col)*ElementWidth);
|
|
|
+ ER = tnsInterpolate(ui->TL, ui->TR, (Col + 1) * ElementWidth);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!iuil){
|
|
|
+ la_AddInstancePage(ui, TInstance, 0);
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ if (Template) laMakeUiListFromTemplate(ui->Page, Template, &ParentPanel->PP, &ParentPanel->PropLinkPP, &ui->PP, 0, &uil->Columns, ui->TemplateContext);
|
|
|
+ SubB = la_UpdateUiListRecursive(ui->Page, Gap+Begin+(NoDecal?0:bt->TM), EL+(NoDecal?0:bt->LM), ER-(NoDecal?0:bt->RM), B, Fast, ParentPanel) + bt->TM;
|
|
|
+ ElementB = RowPriority ? (SubB > ElementB ? SubB : ElementB) : SubB;
|
|
|
+
|
|
|
+ iuil = ui->Page->Item.pNext;
|
|
|
+ }
|
|
|
+
|
|
|
+ while (iuil && iuil->Instance != TInstance){
|
|
|
+ while (iuil && iuil->Instance != TInstance){
|
|
|
+ puil = iuil->Item.pNext;ui->PP.EndInstance=iuil->Instance; la_StopUsingPropPack(&ui->PP);
|
|
|
+ la_DestroyTabPage(ui, iuil, 0);
|
|
|
+ iuil = puil;
|
|
|
+ }
|
|
|
+ if (!iuil){
|
|
|
+ la_AddInstancePage(ui, TInstance, 0);
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ if (Template) laMakeUiListFromTemplate(ui->Page, Template, &ParentPanel->PP, &ParentPanel->PropLinkPP, &ui->PP, 0, &uil->Columns, ui->TemplateContext);
|
|
|
+ SubB = la_UpdateUiListRecursive(ui->Page, Gap+Begin+(NoDecal?0:bt->TM), EL+(NoDecal?0:bt->LM), ER-(NoDecal?0:bt->RM), B, Fast, ParentPanel) + bt->TM;
|
|
|
+ ElementB = RowPriority ? (SubB > ElementB ? SubB : ElementB) : SubB;
|
|
|
+
|
|
|
+ iuil = ui->Page->Item.pNext;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (iuil && iuil->Instance == TInstance){
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ SubB = la_UpdateUiListRecursive(iuil, Gap+Begin+(NoDecal?0:bt->TM), EL+(NoDecal?0:bt->LM), ER-(NoDecal?0:bt->RM), B, Fast, ParentPanel) + bt->TM;
|
|
|
+ ElementB = RowPriority ? (SubB > ElementB ? SubB : ElementB) : SubB;
|
|
|
+
|
|
|
+ la_CalcUiItemInfluence(&uil->Columns, ui);
|
|
|
+ iuil = iuil->Item.pNext;
|
|
|
+ //TInstance = laGetNextInstance(ui->PP.LastPs->p, TInstance, &pi);
|
|
|
+ //ui->PP.EndInstance = TInstance;
|
|
|
+ if (!TInstance){
|
|
|
+ while (iuil){
|
|
|
+ puil = iuil->Item.pNext;ui->PP.EndInstance=iuil->Instance; la_StopUsingPropPack(&ui->PP);
|
|
|
+ la_DestroyTabPage(ui, iuil, 0);
|
|
|
+ iuil = puil;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //continue;
|
|
|
+ }
|
|
|
+ TInstance = laGetNextInstance(ui->PP.LastPs->p, TInstance, &pi);
|
|
|
+ Template = ui->Template?ui->Template:laGetPropertyUiDefine(&ui->PP, TInstance);
|
|
|
+ ui->PP.EndInstance = TInstance;
|
|
|
+
|
|
|
+ if(CanGetTheme){ la_SwitchThemeQuick(0, OriginalTheme); }
|
|
|
+
|
|
|
+ if (RowPriority){
|
|
|
+ Col += 1;
|
|
|
+ if (Col >= ElementLimit){
|
|
|
+ Col = 0;
|
|
|
+ Row += 1;
|
|
|
+ Begin = ElementB + bt->TM;
|
|
|
+ }
|
|
|
+ }elif(Spread){
|
|
|
+ EL+=Spread*LA_RH;
|
|
|
+ ER+=Spread*LA_RH;
|
|
|
+ }else{
|
|
|
+ Row += 1;
|
|
|
+ Begin = ElementB + bt->TM;
|
|
|
+ if (ElementLimit && Row >= ElementLimit){
|
|
|
+ Row = 0;
|
|
|
+ Col += 1;
|
|
|
+ Begin = ui->TU + bt->TM;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ui->TB = ElementB;
|
|
|
+ MaxB = MaxB < ElementB ? ElementB : MaxB;
|
|
|
+ }
|
|
|
+ while (iuil){
|
|
|
+ puil = iuil->Item.pNext;ui->PP.EndInstance=iuil->Instance; la_StopUsingPropPack(&ui->PP);
|
|
|
+ la_DestroyTabPage(ui, iuil, 0);
|
|
|
+ iuil = puil;
|
|
|
+ }
|
|
|
+ ui->PP.EndInstance = laGetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, &pi);
|
|
|
+ ui->TB = MaxB;
|
|
|
+ if(Spread){ ui->TR=ER-Spread*LA_RH; if(ui->TR>MaxR) MaxR=ui->TR; }
|
|
|
+ if (!WaitAnimation){ ui->L = ui->TL; ui->R = ui->TR; ui->U = ui->TU; ui->B = ui->TB = MaxB; }
|
|
|
+ }else if (ui->Type == _LA_UI_COLLECTION_SELECTOR || ui->Type == _LA_UI_COLLECTION_SINGLE){
|
|
|
+ void *TInstance = laGetActiveInstanceStrict(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance);
|
|
|
+ ui->PP.EndInstance = TInstance;
|
|
|
+ laUiTemplate *Template = ui->Template ? ui->Template : laGetPropertyUiDefine(&ui->PP, TInstance);
|
|
|
+ if(!Template) Template=laui_SubPropInfoDefault;
|
|
|
+ //ui->Template = Template;
|
|
|
+ if (!ui->Subs.pFirst && TInstance){
|
|
|
+ la_AddInstancePage(ui, TInstance, 0);
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ laMakeUiListFromTemplate(ui->Page, Template, &ParentPanel->PP, &ParentPanel->PropLinkPP, &ui->PP, 0, &uil->Columns, ui->TemplateContext);
|
|
|
+ SubB = la_UpdateUiListRecursive(ui->Page, ui->TB+(NoDecal?0:bt->TM), ui->TL+(NoDecal?0:bt->LM), ui->TR-(NoDecal?0:bt->RM), B, Fast, ParentPanel);
|
|
|
+ ui->TB = SubB + bt->BM;
|
|
|
+ }else if (ui->Subs.pFirst){
|
|
|
+ if (!TInstance || TInstance != ui->Page->Instance){ui->PP.EndInstance=((laUiList*)ui->Subs.pFirst)->Instance; la_StopUsingPropPack(&ui->PP);
|
|
|
+ la_DestroyTabPage(ui, ui->Subs.pFirst, 0);
|
|
|
+ ui->Page = 0;
|
|
|
+ if (TInstance){
|
|
|
+ la_AddInstancePage(ui, TInstance, 0);
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ laMakeUiListFromTemplate(ui->Page, Template, &ParentPanel->PP, &ParentPanel->PropLinkPP, &ui->PP, 0, &uil->Columns, ui->TemplateContext);
|
|
|
+ SubB = la_UpdateUiListRecursive(ui->Page, ui->TB+(NoDecal?0:bt->TM), ui->TL+(NoDecal?0:bt->LM), ui->TR-(NoDecal?0:bt->RM), B, Fast, ParentPanel);
|
|
|
+ ui->TB = SubB + bt->BM;
|
|
|
+ }else
|
|
|
+ ui->TB = ui->TU + LA_RH + bt->BM;
|
|
|
+ }else{
|
|
|
+ SubB = la_UpdateUiListRecursive(ui->Page, ui->TB+(NoDecal?0:bt->TM), ui->TL+(NoDecal?0:bt->LM), ui->TR-(NoDecal?0:bt->RM), B, Fast, ParentPanel);
|
|
|
+ ui->TB = SubB + bt->BM;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ui->TB-ui->TU<LA_RH) ui->TB = ui->TU + LA_RH;
|
|
|
+ if (!WaitAnimation){
|
|
|
+ ui->L = ui->TL;
|
|
|
+ ui->R = ui->TR;
|
|
|
+ ui->U = ui->TU;
|
|
|
+ ui->B = ui->TB;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (ui->Type != _LA_UI_COLLECTION && (ui->Subs.pFirst || ui->Page) && ui->Type != _LA_UI_MENU_ROOT){
|
|
|
+ if (ui->Type != _LA_UI_CANVAS){
|
|
|
+ int scrollw=ui->Page->ScrollerShownV?bt->RP*2+LA_SCROLL_W:0;
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ SubB = la_UpdateUiListRecursive(ui->Page,
|
|
|
+ ui->TB + (ui->State == LA_UI_ACTIVE ? 0 : LA_RH)+(NoDecal?0:bt->TM), ui->TL+(NoDecal?0:bt->LM), ui->TR-(NoDecal?0:bt->RM)-scrollw, B, Fast, ParentPanel);
|
|
|
+ ui->TB = (ui->Page->HeightCoeff > 0 ? ui->TU + ui->Page->HeightCoeff * LA_RH :
|
|
|
+ (ui->Page->HeightCoeff < 0 ? B + (ui->Page->HeightCoeff+1) * LA_RH : SubB)) + bt->BM;
|
|
|
+ int subh = ui->TB-ui->TU-LA_RH-bt->TM-bt->BM;
|
|
|
+ if((ui->Page->TR>ui->TR-bt->RM && (!ui->Page->ScrollerShownH)) ||
|
|
|
+ (ui->Page->TR<=ui->TR-bt->RM && ui->Page->ScrollerShownH)){
|
|
|
+ ui->Page->ScrollerShownH=!ui->Page->ScrollerShownH;
|
|
|
+ }
|
|
|
+ if(ui->Page->AllowScale){ui->Page->ScrollerShownH=1;}
|
|
|
+ if(ui->Page->ScrollerShownH){subh-=LA_SCROLL_W-bt->BM;}
|
|
|
+ if(GB && ui->TB >= GB){
|
|
|
+ ui->Page->PanY=(SubB-ui->TB-bt->BM); if(ui->Page->PanY<0)ui->Page->PanY=0; }
|
|
|
+ if(ui->Page->HeightCoeff){
|
|
|
+ if((subh<ui->Page->TB-ui->Page->TU && (!ui->Page->ScrollerShownV)) ||
|
|
|
+ (subh>=ui->Page->TB-ui->Page->TU && ui->Page->ScrollerShownV)){
|
|
|
+ ui->Page->ScrollerShownV=!ui->Page->ScrollerShownV;
|
|
|
+ ParentPanel->Refresh|=LA_TAG_RECALC_SCROLLER;
|
|
|
+ }
|
|
|
+ if(SubB-ui->Page->PanY<ui->TB-bt->BM-(ui->Page->ScrollerShownH?LA_SCROLL_W+bt->BM:0)){
|
|
|
+ ui->Page->PanY = (SubB-ui->TB-bt->BM+(ui->Page->ScrollerShownH?LA_SCROLL_W+bt->BM:0));
|
|
|
+ if(ui->Page->PanY<0){ui->Page->PanY=0;}
|
|
|
+ //ParentPanel->Refresh|=LA_TAG_RECALC_SCROLLER;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(ui->Page->ScrollerShownH && !ui->Page->HeightCoeff){
|
|
|
+ ui->TB+=(bt->BP*2+LA_SCROLL_W); }
|
|
|
+ }else{
|
|
|
+ laUiList *suil;
|
|
|
+ if(!MAIN.CurrentWindow->MaximizedUi || ui!=MAIN.CurrentWindow->MaximizedUi){
|
|
|
+ la_CalcUiTopInfluence(&uil->Columns, ui);
|
|
|
+ for (suil = ui->Subs.pFirst; suil; suil = suil->Item.pNext){
|
|
|
+ SubB = la_UpdateUiListRecursive(suil, ui->TB+(NoDecal?0:bt->TM), ui->TL+(NoDecal?0:bt->LM), ui->TR-(NoDecal?0:bt->RM), ui->TU+H, Fast, ParentPanel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ui->TB = ui->TU + H;
|
|
|
+ }
|
|
|
+ }else ui->TB = ui->TU + H;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->TB > Lowest) Lowest = ui->TB + (bt ? (NoGap?_PB:bt->BP) : 0);
|
|
|
+ if(!RowMode){
|
|
|
+ if(!NoHeight) la_CalcUiItemInfluence(&uil->Columns, ui);
|
|
|
+ }else{
|
|
|
+ la_AddRowNode(&ri, ui, bt, H);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!WaitAnimation){ ui->L = ui->TL; ui->R = ui->TR; ui->U = ui->TU; ui->B = ui->TB; }
|
|
|
+
|
|
|
+ if(ui->Type==_LA_UI_NODE_SOCKET){ la_RecordSocketRuntimePosition(ui); }
|
|
|
+
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+
|
|
|
+ uil->TR=MaxR>uil->TR?MaxR:uil->TR;
|
|
|
+
|
|
|
+ if (uil->Columns.pFirst) uil->TB = ((laColumn *)uil->Columns.pFirst)->B;
|
|
|
+ else uil->TB = Lowest;
|
|
|
+
|
|
|
+ if (!WaitAnimation){
|
|
|
+ uil->L = uil->TL;
|
|
|
+ uil->R = uil->TR;
|
|
|
+ uil->U = uil->TU;
|
|
|
+ uil->B = uil->TB;
|
|
|
+ }
|
|
|
+
|
|
|
+ MAIN.UiScale=uil->SaveScale;
|
|
|
+ MAIN.ScaledUiRowHeight=MAIN.UiRowHeight*MAIN.UiScale;
|
|
|
+ return uil->TB;
|
|
|
+}
|
|
|
+int la_AnimateSingleUiSize(int To, int *Now){
|
|
|
+ int Delta;
|
|
|
+
|
|
|
+ if (To != *Now){
|
|
|
+ Delta = (To - (*Now)) * (MAIN.AnimationSpeed) * MAIN.LastFrameTime * 60;
|
|
|
+ if (!Delta) Delta = To > (*Now) ? 1 : -1;
|
|
|
+ *Now += Delta;
|
|
|
+ return 1;
|
|
|
+ }else
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int la_AnimateUiListRecursive(laUiList *uil){
|
|
|
+ laUiItem *ui;
|
|
|
+ int Again = 0;
|
|
|
+ for (ui = uil->UiItems.pFirst; ui; ui = ui->Item.pNext){
|
|
|
+ int TB = ui->B, TU = ui->U, TL = ui->L, TR = ui->R, SB, SU, SL, SR;
|
|
|
+
|
|
|
+ Again += (la_AnimateSingleUiSize(ui->TB, &ui->B) +
|
|
|
+ la_AnimateSingleUiSize(ui->TU, &ui->U) +
|
|
|
+ la_AnimateSingleUiSize(ui->TL, &ui->L) +
|
|
|
+ la_AnimateSingleUiSize(ui->TR, &ui->R));
|
|
|
+
|
|
|
+ if (ui->Type == _LA_UI_COLLECTION_SELECTOR || ui->Type == _LA_UI_COLLECTION_SINGLE ||
|
|
|
+ (ui->PP.LastPs && ui->PP.LastPs->p && ui->PP.LastPs->p->PropertyType == LA_PROP_SUB && ui->Type != _LA_UI_CANVAS)){
|
|
|
+ laUiList *suil;
|
|
|
+ for (suil = ui->Subs.pFirst; suil; suil = suil->Item.pNext){
|
|
|
+ Again += la_AnimateUiListRecursive(suil);
|
|
|
+ }
|
|
|
+ }else if (ui->Type != _LA_UI_COLLECTION && ui->Type != &_LA_UI_ROW_END &&
|
|
|
+ (ui->Subs.pFirst || ui->Page) && ui->Type != _LA_UI_MENU_ROOT){
|
|
|
+ Again += la_AnimateUiListRecursive(ui->Page);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Again += (la_AnimateSingleUiSize(uil->TB, &uil->B) +
|
|
|
+ la_AnimateSingleUiSize(uil->TU, &uil->U) +
|
|
|
+ la_AnimateSingleUiSize(uil->TL, &uil->L) +
|
|
|
+ la_AnimateSingleUiSize(uil->TR, &uil->R));
|
|
|
+
|
|
|
+ return Again;
|
|
|
+}
|
|
|
+int la_DrawUiItem(laUiItem *ui){
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsColor4d(1, 1, 1, 1);
|
|
|
+ tnsVertex2d(ui->L, ui->U);
|
|
|
+ tnsVertex2d(ui->R, ui->U);
|
|
|
+ tnsVertex2d(ui->R, ui->B);
|
|
|
+ tnsVertex2d(ui->L, ui->B);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+}
|
|
|
+int la_DrawActiveUiItemOverlay(laUiItem *ui){
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsColor4d(1, 1, 1, 1);
|
|
|
+ tnsVertex2d(ui->L - 1, ui->U - 1);
|
|
|
+ tnsVertex2d(ui->R + 1, ui->U - 1);
|
|
|
+ tnsVertex2d(ui->R + 1, ui->B + 1);
|
|
|
+ tnsVertex2d(ui->L - 1, ui->B + 1);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+}
|
|
|
+int la_UiInBound(laUiItem *ui, int L, int R, int U, int B){
|
|
|
+ if (ui->R <= L || ui->L >= R || ui->U >= B || ui->B <= U) return 0;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int la_UiInBoundEx(laUiItem *ui, laUiListDraw *uild){
|
|
|
+ laUiListDrawItem *uildi = uild->Items.pFirst;
|
|
|
+ laUiList *Target = uildi->Target;
|
|
|
+ int L, R, U, B;
|
|
|
+
|
|
|
+ if (!Target) return la_UiInBound(ui, uildi->L, uildi->R, uildi->U, uildi->B);
|
|
|
+
|
|
|
+ L = Target->L + Target->PanX + uildi->DifX;
|
|
|
+ R = Target->L + Target->PanX + uildi->DifX + (uildi->R - uildi->L);
|
|
|
+ B = Target->U + Target->PanY + uildi->DifY + (uildi->B - uildi->U);
|
|
|
+ U = Target->U + Target->PanY + uildi->DifY;
|
|
|
+
|
|
|
+ return la_UiInBound(ui, L, R, U, B);
|
|
|
+}
|
|
|
+int la_UiListInBoundEx(laUiList *uil, laUiListDraw *uild){
|
|
|
+ laUiListDrawItem *uildi = uild->Items.pFirst;
|
|
|
+ laUiList *Target = uildi->Target;
|
|
|
+ int L, R, U, B;
|
|
|
+
|
|
|
+ if (Target){
|
|
|
+ L = Target->L + Target->PanX + uildi->DifX;
|
|
|
+ R = Target->L + Target->PanX + uildi->DifX + (uildi->R - uildi->L);
|
|
|
+ B = Target->U + Target->PanY + uildi->DifY + (uildi->B - uildi->U);
|
|
|
+ U = Target->U + Target->PanY + uildi->DifY;
|
|
|
+ if (uil->R <= L || uil->L >= R || uil->U >= B || uil->B <= U) return 0;
|
|
|
+ return 1;
|
|
|
+ }else{
|
|
|
+ if (uil->R <= uildi->L || uil->L >= uildi->R || uil->U >= uildi->B || uil->B <= uildi->U) return 0;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+laUiItem *la_FindUiWithMark(laUiList *uil, char *mark){
|
|
|
+ laUiItem *ui = uil->UiItems.pFirst;
|
|
|
+ while (!strGetArgument(ui->Instructions, mark))
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ return ui;
|
|
|
+}
|
|
|
+laUiList *la_FindSubListWithInstance(laUiItem *ui, void *Instance){
|
|
|
+ laUiList *uil;
|
|
|
+ for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
|
|
|
+ if (uil->Instance == Instance) return uil;
|
|
|
+ }
|
|
|
+ return uil;
|
|
|
+}
|
|
|
+
|
|
|
+void la_DrawUiListArrows(laUiList *uil, int L, int R, int U, int B, real* color){
|
|
|
+ int mx=(L+R)/2; int my=(U+B)/2;
|
|
|
+ if(uil->R-uil->PanX>R){ tnsDrawStringAuto("▷", color, R-LA_RH, R, my-LA_RH2, LA_TEXT_ALIGN_RIGHT); }
|
|
|
+ if(uil->L-uil->PanX<L){ tnsDrawStringAuto("◁", color, L, L+LA_RH, my-LA_RH2, LA_TEXT_ALIGN_LEFT); }
|
|
|
+ if(uil->U-uil->PanY<U){ tnsDrawStringAuto("△", color, mx-LA_RH2, mx+LA_RH2, U, LA_TEXT_ALIGN_CENTER); }
|
|
|
+ if(uil->B-uil->PanY>B){ tnsDrawStringAuto("▽", color, mx-LA_RH2, mx+LA_RH2, B-LA_RH, LA_TEXT_ALIGN_CENTER); }
|
|
|
+ tnsFlush();
|
|
|
+}
|
|
|
+void la_DrawUiListScrollerV(laUiList *uil, int DisplayOffset, int TotalH, int DisplayH, int UiR){
|
|
|
+ if(!uil->ScrollerShownV) return;
|
|
|
+
|
|
|
+ int W = LA_SCROLL_W;
|
|
|
+ int Len = (int)((real)DisplayH / (real)TotalH * (real)DisplayH);
|
|
|
+ int Offset = (int)((real)DisplayOffset / (real)TotalH * (real)DisplayH);
|
|
|
+ int U = uil->U + Offset;
|
|
|
+ int B = U + Len;
|
|
|
+ int L = UiR - _LA_THEME_PANEL->RM - W;
|
|
|
+ int R = L + W;
|
|
|
+
|
|
|
+ if (B > U + DisplayH) B = U + DisplayH;
|
|
|
+ if (U < uil->U) U = uil->U;
|
|
|
+
|
|
|
+ if (B <= uil->U || U >= uil->B) return;
|
|
|
+
|
|
|
+ if (B > uil->U + DisplayH) B = uil->U + DisplayH;
|
|
|
+ if (U < uil->U) U = uil->U;
|
|
|
+
|
|
|
+ tnsUseNoTexture();
|
|
|
+
|
|
|
+ laBoxedTheme* bt=_LA_THEME_PANEL;
|
|
|
+ real* color=laThemeColor(bt, LA_BT_TEXT);
|
|
|
+ tnsColor4d(LA_COLOR3(color), 0.8);
|
|
|
+ tnsVertex2d(R, U);
|
|
|
+ tnsVertex2d(L, U);
|
|
|
+ tnsVertex2d(L, B);
|
|
|
+ tnsVertex2d(R, B);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+
|
|
|
+ tnsColor4d(LA_COLOR3(color), 0.8);
|
|
|
+ tnsVertex2d(R, uil->U);
|
|
|
+ tnsVertex2d(L, uil->U);
|
|
|
+ tnsVertex2d(L, uil->U + DisplayH);
|
|
|
+ tnsVertex2d(R, uil->U + DisplayH);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+
|
|
|
+ int HU=(U+B)/2+LA_RH2;
|
|
|
+ tnsDrawStringAuto("☰",laThemeColor(bt, LA_BT_BORDER),L-100,R+100,HU,LA_TEXT_REVERT_Y|LA_TEXT_ALIGN_CENTER);
|
|
|
+}
|
|
|
+void la_DrawUiListScrollerH(laUiList *uil, int DisplayOffset, int TotalW, int DisplayW, int UiB){
|
|
|
+ if(!uil->ScrollerShownH) return;
|
|
|
+
|
|
|
+ int W = LA_SCROLL_W;
|
|
|
+ int Len = (int)((real)DisplayW / (real)TotalW * (real)DisplayW);
|
|
|
+ int Offset = (int)((real)DisplayOffset / (real)TotalW * (real)DisplayW);
|
|
|
+ int L = uil->L + Offset;
|
|
|
+ int R = L + Len;
|
|
|
+ int U = UiB - _LA_THEME_PANEL->RM - W;
|
|
|
+ int B = U + W;
|
|
|
+
|
|
|
+ if (B > U + DisplayW) B = U + DisplayW;
|
|
|
+ if (U < uil->U) U = uil->U;
|
|
|
+
|
|
|
+ if (R <= uil->L || L >= uil->R) return;
|
|
|
+
|
|
|
+ if (R > uil->L + DisplayW) R = uil->L + DisplayW;
|
|
|
+ if (L < uil->L) L = uil->L;
|
|
|
+
|
|
|
+ tnsUseNoTexture();
|
|
|
+
|
|
|
+ laBoxedTheme* bt=_LA_THEME_PANEL;
|
|
|
+ real* color=laThemeColor(bt, LA_BT_TEXT);
|
|
|
+ tnsColor4d(LA_COLOR3(color), 0.8);
|
|
|
+ tnsVertex2d(R, U);
|
|
|
+ tnsVertex2d(L, U);
|
|
|
+ tnsVertex2d(L, B);
|
|
|
+ tnsVertex2d(R, B);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+
|
|
|
+ tnsColor4d(LA_COLOR3(color), 0.8);
|
|
|
+ tnsVertex2d(uil->L,U);
|
|
|
+ tnsVertex2d(uil->L,B);
|
|
|
+ tnsVertex2d(uil->L + DisplayW,B);
|
|
|
+ tnsVertex2d(uil->L + DisplayW,U);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+
|
|
|
+ int HU=(U+B)/2+LA_RH2;
|
|
|
+ tnsDrawStringAuto("↔",laThemeColor(bt, LA_BT_BORDER),L-100,R+100,HU,LA_TEXT_REVERT_Y|LA_TEXT_ALIGN_CENTER);
|
|
|
+}
|
|
|
+void la_DrawInstanceBkg(laUiList *uil, real* color){
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsColor4dv(color);
|
|
|
+ tnsVertex2d(uil->L, uil->U); tnsVertex2d(uil->R, uil->U);
|
|
|
+ tnsVertex2d(uil->R, uil->B); tnsVertex2d(uil->L, uil->B);
|
|
|
+ tnsPackAs(GL_TRIANGLE_FAN);
|
|
|
+}
|
|
|
+void la_InitSocketRecord(laUiListDraw* uild, laUiList* container){
|
|
|
+ laSocketRecord* sr;
|
|
|
+ while(sr=lstPopItem(&uild->SocketRecord)){ memFree(sr); }
|
|
|
+ uild->WiresContainer=container;
|
|
|
+}
|
|
|
+void la_GetUiListOffsetUntil(laUiListDraw* uild, int* X, int* Y){
|
|
|
+ *X=*Y=0; for(laUiListDrawItem* lip=uild->Items.pLast;lip&&lip->Target;lip=lip->Item.pPrev){
|
|
|
+ if(lip->Target==uild->WiresContainer) break;
|
|
|
+ laUiList* uil=lip->Target; *X+=uil->PanX; *Y+=uil->PanY;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_RecordSocket(laUiListDraw* uild, laUiList* uil, laUiItem* ui){
|
|
|
+ laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
|
|
|
+ int PanX, PanY;
|
|
|
+ if(pc==LA_PC_SOCKET_OUT){
|
|
|
+ laNodeOutSocket* s=ui->PP.EndInstance;
|
|
|
+ la_GetUiListOffsetUntil(uild, &s->RuntimePX, &s->RuntimePY);
|
|
|
+ }else{
|
|
|
+ laNodeInSocket* s=ui->PP.EndInstance; if(!s->Source) return;
|
|
|
+ laSocketRecord* sr=memAcquireSimple(sizeof(laSocketRecord));
|
|
|
+ sr->In=s; sr->Out=s->Source; lstAppendItem(&uild->SocketRecord, sr);
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_RegenerateWireColors(){
|
|
|
+ if(MAIN.WireColorCache) free(MAIN.WireColorCache);
|
|
|
+ laTheme* t=MAIN.CurrentTheme;
|
|
|
+ MAIN.WireColorCache = calloc(1, sizeof(real)*4*MAIN.WireColorSlices);
|
|
|
+ real hcy[]={0.0,0.8,0.6}; hcy[1]=t->WireSaturation; hcy[2]=t->WireBrightness;
|
|
|
+ for(int i=0;i<MAIN.WireColorSlices;i++){
|
|
|
+ hcy[0]=(real)i/(real)MAIN.WireColorSlices;
|
|
|
+ tnsHCYtoRGB(hcy, &MAIN.WireColorCache[i*4]); MAIN.WireColorCache[i*4+3]=t->WireTransparency;
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_SendWireVerts(real x1, real y1, real x2, real y2, real circle_r){
|
|
|
+ tnsVector2d v1,vi,v2,v1s,v2s; real dist=0;
|
|
|
+ v1[0]=x1; v1[1]=y1; v2[0]=x2; v2[1]=y2;
|
|
|
+ tnsInterpolate2dv(v1,v2,0.5,vi);
|
|
|
+ if(MAIN.WireSaggyness>0.01){ dist=tnsDist2dv(v1,v2); vi[1]+=log(dist+1)*MAIN.WireSaggyness; }
|
|
|
+ tnsVectorMinus2d(v1s,vi,v1); tnsNormalizeSelf2d(v1s); tnsVectorMultiSelf2d(v1s,circle_r);
|
|
|
+ tnsVectorMinus2d(v2s,vi,v2); tnsNormalizeSelf2d(v2s); tnsVectorMultiSelf2d(v2s,circle_r);
|
|
|
+ tnsVectorAccum2d(v1, v1s); tnsVectorAccum2d(v2, v2s);
|
|
|
+
|
|
|
+ if(MAIN.WireSaggyness<0.01){ tnsVertex2d(v1[0],v1[1]); tnsVertex2d(v2[0],v2[1]); return; }
|
|
|
+
|
|
|
+ int seglen=3, steps=dist/seglen+1; real step=1.0f/steps;
|
|
|
+ tnsVertex2d(v1[0],v1[1]);
|
|
|
+ for(int i=1;i<=steps;i++){
|
|
|
+ real ratio=i==steps?1.0f:step*i;
|
|
|
+ tnsInterpolateTripple2d(v1,vi,v2,ratio, v1s);
|
|
|
+ tnsVertex2d(v1s[0],v1s[1]);
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_DrawNodeWires(laUiListDraw* uild){
|
|
|
+ if(!uild->SocketRecord.pFirst && !MAIN.tNodeIn.Source){ return; }
|
|
|
+ laBoxedTheme* bt=_LA_THEME_SOCKET;
|
|
|
+
|
|
|
+ tnsUseNoTexture();
|
|
|
+#define _RSLICES 16
|
|
|
+ real v[_RSLICES*4]; int idx[_RSLICES*2+2]; real r=LA_RH2/TNS_MAX2(uild->WiresContainer->Scale,1);
|
|
|
+ for(laSocketRecord*sr=uild->SocketRecord.pFirst;sr;sr=sr->Item.pNext){
|
|
|
+ int cid=sr->In->ColorId%MAIN.WireColorSlices*4;
|
|
|
+
|
|
|
+ int inx=sr->In->RuntimeX+sr->In->RuntimePX, iny=sr->In->RuntimeY+sr->In->RuntimePY;
|
|
|
+ int outx=sr->Out->RuntimeX+sr->Out->RuntimePX, outy=sr->Out->RuntimeY+sr->Out->RuntimePY;
|
|
|
+ if(sr->Out==&MAIN.tNodeOut){ outx=inx+MAIN.tNodeOut.RuntimeX+MAIN.tNodeOut.RuntimePX; outy=iny+MAIN.tNodeOut.RuntimeY+MAIN.tNodeOut.RuntimePY; }
|
|
|
+
|
|
|
+ tnsMakeRing2d(v,idx,_RSLICES, inx, iny, r, r*0.6);
|
|
|
+ tnsVertexArray2d(v,_RSLICES*2); tnsIndexArray(idx, _RSLICES*2+2);
|
|
|
+ tnsColor4d(LA_COLOR3(&MAIN.WireColorCache[cid]),1); tnsPackAs(GL_TRIANGLE_STRIP);
|
|
|
+
|
|
|
+ tnsMakeRing2d(v,idx,_RSLICES, outx, outy, r, r*0.6);
|
|
|
+ tnsVertexArray2d(v,_RSLICES*2); tnsIndexArray(idx, _RSLICES*2+2);
|
|
|
+ tnsColor4d(LA_COLOR3(&MAIN.WireColorCache[cid]),1); tnsPackAs(GL_TRIANGLE_STRIP);
|
|
|
+ }
|
|
|
+ if(MAIN.tNodeIn.Source){
|
|
|
+ laNodeInSocket* ins=&MAIN.tNodeIn; laNodeOutSocket* outs=ins->Source;
|
|
|
+ int cid=ins->ColorId%MAIN.WireColorSlices*4;
|
|
|
+
|
|
|
+ int outx=outs->RuntimeX+outs->RuntimePX, outy=outs->RuntimeY+outs->RuntimePY;
|
|
|
+ int inx=ins->RuntimeX+ins->RuntimePX+outx, iny=ins->RuntimeY+ins->RuntimePY+outy;
|
|
|
+
|
|
|
+ tnsMakeRing2d(v,idx,_RSLICES, inx, iny, r, r*0.6);
|
|
|
+ tnsVertexArray2d(v,_RSLICES*2); tnsIndexArray(idx, _RSLICES*2+2);
|
|
|
+ tnsColor4d(LA_COLOR3(&MAIN.WireColorCache[cid]),1); tnsPackAs(GL_TRIANGLE_STRIP);
|
|
|
+
|
|
|
+ tnsMakeRing2d(v,idx,_RSLICES, outx, outy, r, r*0.6);
|
|
|
+ tnsVertexArray2d(v,_RSLICES*2); tnsIndexArray(idx, _RSLICES*2+2);
|
|
|
+ tnsColor4d(LA_COLOR3(&MAIN.WireColorCache[cid]),1); tnsPackAs(GL_TRIANGLE_STRIP);
|
|
|
+ }
|
|
|
+#undef _RSLICES
|
|
|
+ tnsFlush();
|
|
|
+
|
|
|
+ int ww=MAIN.WireThickness*TNS_MIN2(uild->WiresContainer->Scale,1);
|
|
|
+ glLineWidth(ww);
|
|
|
+ for(laSocketRecord*sr=uild->SocketRecord.pFirst;sr;sr=sr->Item.pNext){
|
|
|
+ int cid=sr->In->ColorId%MAIN.WireColorSlices*4;
|
|
|
+ int inx=sr->In->RuntimeX+sr->In->RuntimePX, iny=sr->In->RuntimeY+sr->In->RuntimePY;
|
|
|
+ int outx=sr->Out->RuntimeX+sr->Out->RuntimePX, outy=sr->Out->RuntimeY+sr->Out->RuntimePY;
|
|
|
+ if(sr->Out==&MAIN.tNodeOut){ outx=inx+MAIN.tNodeOut.RuntimeX+MAIN.tNodeOut.RuntimePX; outy=iny+MAIN.tNodeOut.RuntimeY+MAIN.tNodeOut.RuntimePY; }
|
|
|
+
|
|
|
+ la_SendWireVerts(inx, iny, outx, outy, r*0.9);
|
|
|
+ tnsColor4dv(&MAIN.WireColorCache[cid]); tnsPackAs(GL_LINE_STRIP);
|
|
|
+ }
|
|
|
+ if(MAIN.tNodeIn.Source){
|
|
|
+ laNodeInSocket* ins=&MAIN.tNodeIn; laNodeOutSocket* outs=ins->Source;
|
|
|
+ int cid=ins->ColorId%MAIN.WireColorSlices*4;
|
|
|
+
|
|
|
+ int outx=outs->RuntimeX+outs->RuntimePX, outy=outs->RuntimeY+outs->RuntimePY;
|
|
|
+ int inx=ins->RuntimeX+ins->RuntimePX+outx, iny=ins->RuntimeY+ins->RuntimePY+outy;
|
|
|
+
|
|
|
+ la_SendWireVerts(inx, iny, outx, outy, r*0.9);
|
|
|
+ tnsColor4dv(&MAIN.WireColorCache[cid]); tnsPackAs(GL_LINE_STRIP);
|
|
|
+ }
|
|
|
+ tnsFlush();
|
|
|
+ glLineWidth(1);
|
|
|
+
|
|
|
+ la_InitSocketRecord(uild,0);
|
|
|
+}
|
|
|
+void la_SwitchThemeQuick(laTheme* t, laTheme* DefaultTheme){
|
|
|
+ if(!DefaultTheme){return;} MAIN.CurrentTheme = t?t:DefaultTheme; t=MAIN.CurrentTheme;
|
|
|
+ for(laBoxedTheme* bt = t->BoxedThemes.pFirst;bt;bt=bt->Item.pNext){ (*bt->BackRef) = bt; }
|
|
|
+}
|
|
|
+int la_DrawUiListRecursive(laUiListDraw *uild, laUiList *uil, int L, int R, int U, int B, int LimH, int ConditionStackLevel, int GlobalX, int GlobalY, int RegisterNodes){
|
|
|
+ laUiItem *ui;
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ laUiList *sub;
|
|
|
+ laUiListDrawItem *uildi;
|
|
|
+ int Ret = 0;
|
|
|
+
|
|
|
+ if (!uil) return;
|
|
|
+
|
|
|
+ //printf("d %d\n",MAIN.CurrentPanel->FrameDistinguish);
|
|
|
+
|
|
|
+ ui = uil->UiItems.pFirst;
|
|
|
+ if(uil->PanY<0){uil->PanY=0;}
|
|
|
+ if (!la_SetUpUiListMatrix(uild, uil, L, R, LimH, B - U, GlobalX, GlobalY)) return 0;
|
|
|
+
|
|
|
+ uil->SaveScale=MAIN.UiScale;
|
|
|
+ MAIN.UiScale*=uil->Scale;
|
|
|
+ MAIN.ScaledUiRowHeight=MAIN.UiRowHeight*MAIN.UiScale;
|
|
|
+
|
|
|
+ for (; ui;){
|
|
|
+
|
|
|
+ bt = ui->Type->Theme ? (*ui->Type->Theme) : 0;
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ la_StepExpression(cued->Expression);
|
|
|
+ cued->IsTrue = la_DoSingleExpression(cued->Expression);
|
|
|
+ if (!cued->IsTrue){
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_END){
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_ELSE){
|
|
|
+ laConditionUiExtraData *cued = ((laConditionUiExtraData *)ui->Extra)->EndUi->Extra;
|
|
|
+ if (cued->IsTrue) ui = cued->EndUi;
|
|
|
+ else
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == _LA_UI_CONDITION_TOGGLE){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ ui->Type->Draw(ui, LA_RH);
|
|
|
+ if (ui->State == LA_UI_NORMAL){
|
|
|
+ cued->IsTrue = 0;
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ cued->IsTrue = 1;
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->AnimationDistinguish != MAIN.CurrentPanel->FrameDistinguish) Ret = 1;
|
|
|
+
|
|
|
+ int NeedDraw=0;
|
|
|
+ if (la_UiInBoundEx(ui, uild)){ NeedDraw=1; }
|
|
|
+
|
|
|
+ if(NeedDraw){
|
|
|
+ if (!ui->Type->Draw){ la_DrawUiItem(ui); tnsFlush();
|
|
|
+ }else{ ui->Type->Draw(ui, LA_RH); }
|
|
|
+
|
|
|
+ if (ui->Type->Tag & LA_UI_TAG_IS_OFFSCREEN){
|
|
|
+ tnsFlush();
|
|
|
+ tnsDrawToOffscreen(MAIN.CurrentPanel->OffScr, 1, 0);
|
|
|
+ tnsResetViewMatrix();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ui->Type->Tag & (LA_UI_TAG_NEED_REBUILD)){
|
|
|
+ la_RebuildCurrentUiListMatrix(uild, uil, LimH, B - U);
|
|
|
+ if (ui->CanvasTemplate->SecondDraw) ui->CanvasTemplate->SecondDraw(ui, LA_RH);
|
|
|
+ tnsFlush();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(NeedDraw || RegisterNodes){
|
|
|
+ if (RegisterNodes && ui->Type==_LA_UI_NODE_SOCKET){ la_RecordSocket(uild,uil,ui); }
|
|
|
+
|
|
|
+ if (ui->Type == _LA_UI_FIXED_GROUP ||
|
|
|
+ ui->Type == _LA_UI_TAB ||
|
|
|
+ ui->Type == _LA_UI_COLLECTION_SINGLE ||
|
|
|
+ ui->Type == _LA_UI_COLLECTION_SELECTOR && (ui->Subs.pFirst || ui->Page)){
|
|
|
+ if (!ui->Page){ ui = ui->Item.pNext; continue; }
|
|
|
+ tnsFlush(); int DoNodes=RegisterNodes;
|
|
|
+ if(ui->Flags&LA_UI_FLAGS_NODE_CONTAINER){ la_InitSocketRecord(uild, ui->Page); DoNodes=1; }
|
|
|
+ Ret += la_DrawUiListRecursive(uild, ui->Page, ui->L+bt->LM, ui->R-bt->RM, U, B,
|
|
|
+ (ui->Page->HeightCoeff ? ui->B - ui->Page->U : 10000), ConditionStackLevel, GlobalX, GlobalY, DoNodes);
|
|
|
+ if (ui->Page->ScrollerShownH){ la_DrawUiListScrollerH(ui->Page, ui->Page->PanX,
|
|
|
+ ui->Page->R-ui->Page->L-bt->RM-bt->LM, ui->R-ui->Page->L-bt->RM-bt->LM-(ui->Page->ScrollerShownV?LA_SCROLL_W:0),ui->B); }
|
|
|
+ if (ui->Page->HeightCoeff) la_DrawUiListScrollerV(ui->Page, ui->Page->PanY,
|
|
|
+ ui->Page->B-ui->Page->U-bt->TM-bt->BM, ui->B-ui->Page->U-bt->TM-bt->BM-(ui->Page->ScrollerShownH?LA_SCROLL_W+bt->RM:0),ui->R);
|
|
|
+ if (ui->Page->AllowScale){ la_DrawUiListArrows(ui->Page,ui->L, ui->R, ui->Page->U, ui->B-LA_SCROLL_W-bt->BM*2, laThemeColor(bt, LA_BT_BORDER)); }
|
|
|
+ }elif (ui->Type == _LA_UI_COLLECTION){
|
|
|
+ int CanGetState = laCanGetState(ui->PP.LastPs->p);
|
|
|
+ int CanGetTheme = laCanGetTheme(ui->PP.LastPs->p);laTheme* OriginalTheme=MAIN.CurrentTheme;
|
|
|
+ void *Active = laGetActiveInstanceStrict(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance);
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ int State;
|
|
|
+ ui->PP.EndInstance = sub->Instance;
|
|
|
+
|
|
|
+ if ((!la_UiListInBoundEx(sub, uild)) && (!RegisterNodes)) continue;
|
|
|
+
|
|
|
+ if(!(ui->Flags&LA_UI_COLLECTION_NO_HIGHLIGHT) && NeedDraw){
|
|
|
+ if (CanGetState){
|
|
|
+ State = laGetUiState(ui->PP.LastPs->p, sub->Instance);
|
|
|
+ la_DrawInstanceBkg(sub, laAccentColor(LA_BT_NORMAL));
|
|
|
+ }elif (sub->Instance == Active){
|
|
|
+ la_DrawInstanceBkg(sub, laAccentColor(LA_BT_NORMAL));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CanGetTheme){
|
|
|
+ laTheme* t=laGetUiTheme(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, ui->PP.EndInstance);
|
|
|
+ la_SwitchThemeQuick(t, OriginalTheme);
|
|
|
+ if(t) la_DrawInstanceBkg(sub, laThemeColor(_LA_THEME_FLOATING_PANEL ,LA_BT_NORMAL));
|
|
|
+ }
|
|
|
+
|
|
|
+ tnsFlush();
|
|
|
+ Ret += la_DrawUiListRecursive(uild, sub, L, R, U, B, 10000, ConditionStackLevel, GlobalX, GlobalY, RegisterNodes);
|
|
|
+
|
|
|
+ if(CanGetTheme){ la_SwitchThemeQuick(0, OriginalTheme); }
|
|
|
+ }
|
|
|
+ ui->PP.EndInstance = Active;
|
|
|
+ }elif (ui->Type == _LA_UI_CANVAS){
|
|
|
+ if(!(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)){
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ tnsFlush();
|
|
|
+ Ret += la_DrawUiListRecursive(uild, sub, L, R, U, B, 10000, ConditionStackLevel, GlobalX, GlobalY, RegisterNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }else{
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tnsFlush();
|
|
|
+
|
|
|
+ if(uild->WiresContainer == uil){ la_DrawNodeWires(uild); }
|
|
|
+
|
|
|
+ la_RestoreLastUiListMatrix(uild, B - U);
|
|
|
+
|
|
|
+ MAIN.UiScale=uil->SaveScale;
|
|
|
+ MAIN.ScaledUiRowHeight=MAIN.UiRowHeight*MAIN.UiScale;
|
|
|
+ return Ret;
|
|
|
+}
|
|
|
+int la_DrawPanelScrollBarV(int L, int R, int U, int B, real Total, real Range, real Offset){
|
|
|
+ int Begin = U + (int)(Offset / Total * (real)(B - U)) + 3;
|
|
|
+ int End = Begin + (int)(Range / Total * (real)(B - U)) - 3;
|
|
|
+ tnsUseNoTexture();
|
|
|
+ tnsColor4d(1, 1, 1, 1);
|
|
|
+ tnsVertex2d(L, U);
|
|
|
+ tnsVertex2d(R, U);
|
|
|
+ tnsVertex2d(R, B);
|
|
|
+ tnsVertex2d(L, B);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+ tnsVertex2d(L + 3, Begin);
|
|
|
+ tnsVertex2d(R - 3, Begin);
|
|
|
+ tnsVertex2d(R - 3, End);
|
|
|
+ tnsVertex2d(L + 3, End);
|
|
|
+ tnsPackAs(GL_LINE_LOOP);
|
|
|
+}
|
|
|
+int laIsInUiItem(laUiItem *ui, int x, int y){
|
|
|
+ if (x < ui->L || x > ui->R || y < ui->U || y > ui->B) return 0;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int laIsInBound(int x, int y, int l, int r, int u, int b){
|
|
|
+ if (x < l || x > r || y < u || y > b) return 0;
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+laColumn *la_DetectSplit(laColumn *Root, int LocalX);
|
|
|
+laUiItem *la_DetectUiItemRecursive(laUiList *uil, int x, int y, int LimB, laListHandle *LocalBuf, int Deep){
|
|
|
+ laUiItem *ui, *tui;
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ laUiList *sub;
|
|
|
+ int CPB = 0;
|
|
|
+
|
|
|
+ if (!uil || (LimB && y > LimB)) return 0;
|
|
|
+
|
|
|
+ x += uil->PanX;
|
|
|
+ y += uil->PanY;
|
|
|
+
|
|
|
+ for (ui = uil->UiItems.pFirst; ui;){
|
|
|
+
|
|
|
+ bt = ui->Type->Theme ? (*ui->Type->Theme) : 0;
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ //la_StepExpression(cued->Expression); for some reason we can't step here, only step in update :thinking:
|
|
|
+ cued->IsTrue = la_DoSingleExpression(cued->Expression);
|
|
|
+ if (!cued->IsTrue){
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_END){
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_ELSE){
|
|
|
+ laConditionUiExtraData *cued = ((laConditionUiExtraData *)ui->Extra)->EndUi->Extra;
|
|
|
+ if (cued->IsTrue) ui = cued->EndUi;
|
|
|
+ else
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == _LA_UI_CONDITION_TOGGLE){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ if (laIsInUiItem(ui, x, y)){
|
|
|
+ lstAppendPointer(LocalBuf, uil);
|
|
|
+ return ui;
|
|
|
+ }
|
|
|
+ if (ui->State == LA_UI_NORMAL){
|
|
|
+ cued->IsTrue = 0;
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ cued->IsTrue = 1;
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ //printf("%s > ",ui->Type->Identifier?ui->Type->Identifier:"-");
|
|
|
+
|
|
|
+ if (ui->Type != _LA_UI_COLLECTION && ui->Type != _LA_UI_FIXED_GROUP && ui->Type != _LA_UI_TAB && ui->Type != _LA_UI_CANVAS && laIsInUiItem(ui, x, y)){
|
|
|
+ int Add=1; if(ui->Type==_LA_UI_COLUMN_ADJUSTER){
|
|
|
+ if(!la_DetectSplit(ui->C, x)) Add=0;
|
|
|
+ }
|
|
|
+ if(Add){ lstAppendPointer(LocalBuf, uil); return ui; }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((ui->Type == _LA_UI_FIXED_GROUP || ui->Type == _LA_UI_TAB) && (ui->Subs.pFirst || ui->Page)){
|
|
|
+ if (ui->Page->HeightCoeff) CPB = ui->B;
|
|
|
+ else CPB = ui->Page->B;
|
|
|
+ if (laIsInBound(x, y, ui->Page->L, ui->Page->R, ui->Page->U, CPB)){
|
|
|
+ if (tui = la_DetectUiItemRecursive(ui->Page, x /* + ui->Page->PanX*/, y /*+ ui->Page->PanY*/, CPB, LocalBuf, Deep)){
|
|
|
+ lstAppendPointer(LocalBuf, uil);
|
|
|
+ return tui;
|
|
|
+ }
|
|
|
+ }else if (laIsInUiItem(ui, x, y)){
|
|
|
+ lstAppendPointer(LocalBuf, uil);return ui;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ui->Type == _LA_UI_COLLECTION){
|
|
|
+ if (laIsInUiItem(ui, x, y)){
|
|
|
+ lstAppendPointer(LocalBuf, uil);
|
|
|
+ if (ui->Subs.pFirst) ((laUiList *)ui->Subs.pFirst)->HeightCoeff = LimB;
|
|
|
+ if(Deep){
|
|
|
+ for(laUiList* iuil=ui->Subs.pFirst;iuil;iuil=iuil->Item.pNext){
|
|
|
+ if (laIsInBound(x, y, iuil->L, iuil->R, iuil->U, iuil->B)){
|
|
|
+ if (tui = la_DetectUiItemRecursive(iuil, x , y , iuil->B, LocalBuf, Deep)){
|
|
|
+ lstAppendPointer(LocalBuf, iuil);
|
|
|
+ return tui;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ui;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ui->Type == _LA_UI_CANVAS){
|
|
|
+ if(!(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)){
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ if (tui = la_DetectUiItemRecursive(sub, x, y, ui->B, LocalBuf, Deep)){
|
|
|
+ lstAppendPointer(LocalBuf, uil);
|
|
|
+ return tui;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (laIsInUiItem(ui, x, y)){
|
|
|
+ lstAppendPointer(LocalBuf, uil);
|
|
|
+ return ui;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+laUiItem *la_DetectSocketRecursive(laUiList* uil, int x, int y, int LimB, laPropContainer* PCInOrOut){
|
|
|
+ laListHandle Locals={0};
|
|
|
+ laUiItem* ui=la_DetectUiItemRecursive(uil, x,y,LimB,&Locals, 1);
|
|
|
+ while(lstPopPointer(&Locals));
|
|
|
+ //printf("%s\n", ui?ui->Type->Identifier:"?");
|
|
|
+ if(ui && ui->Type==_LA_UI_NODE_SOCKET){
|
|
|
+ laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
|
|
|
+ if(pc==PCInOrOut) return ui;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+laUiList *la_DetectUiListRecursive(laUiList *uil, int x, int y, int LimH,
|
|
|
+ laUiItem **ParentUi, laUiList **ScrollUil, laUiList **ContainerParent, int InToContainerUI, laUiItem *Exception){
|
|
|
+ laUiItem *ui = uil->UiItems.pFirst;
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ laUiList *tuil;
|
|
|
+ laUiList *sub;
|
|
|
+ int CPB = 0;
|
|
|
+
|
|
|
+ x += uil->PanX;
|
|
|
+ y += uil->PanY;
|
|
|
+
|
|
|
+ if (y > LimH) return uil;
|
|
|
+
|
|
|
+ if (/*uil->ScrollerShownV && */ laIsInBound(x, y, uil->R, uil->R+LA_SCROLL_W+4, uil->U, uil->B) ||
|
|
|
+ /*uil->ScrollerShownH && */ laIsInBound(x, y, uil->L, uil->R, uil->B, uil->B+LA_SCROLL_W+4)){
|
|
|
+ if (ScrollUil) *ScrollUil = uil; /* if (ParentUi)*ParentUi = uil;*/
|
|
|
+ return uil;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ui = uil->UiItems.pFirst; ui;){
|
|
|
+
|
|
|
+ bt = ui->Type->Theme ? (*ui->Type->Theme) : 0;
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ //la_StepExpression(cued->Expression);
|
|
|
+ cued->IsTrue = la_DoSingleExpression(cued->Expression);
|
|
|
+ if (!cued->IsTrue){
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION_END){
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_ELSE){
|
|
|
+ laConditionUiExtraData *cued = ((laConditionUiExtraData *)ui->Extra)->EndUi->Extra;
|
|
|
+ if (cued->IsTrue) ui = cued->EndUi;
|
|
|
+ else
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == _LA_UI_CONDITION_TOGGLE){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ if (ui->State == LA_UI_NORMAL){
|
|
|
+ cued->IsTrue = 0;
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ cued->IsTrue = 1;
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (InToContainerUI && ui != Exception){
|
|
|
+ if (ui->Type == _LA_UI_CANVAS && !(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)){
|
|
|
+ if (ContainerParent) (*ContainerParent) = uil;
|
|
|
+ if (ParentUi) *ParentUi = ui;
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ //if (y > LimH) return uil;
|
|
|
+ if (laIsInBound(x, y, sub->L, sub->R, sub->U, sub->B) && (tuil = la_DetectUiListRecursive(sub, x, y, ui->B, ParentUi, ScrollUil, ContainerParent, InToContainerUI, Exception))){
|
|
|
+ return tuil;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((ui->Type == _LA_UI_FIXED_GROUP || ui->Type == _LA_UI_TAB) && (ui->Subs.pFirst || ui->Page)){
|
|
|
+ if (ui->Page->HeightCoeff) CPB = ui->B;
|
|
|
+ else CPB = ui->Page->B;
|
|
|
+ if (ui->Page->ScrollerShownV && laIsInBound(x, y, ui->R - LA_SCROLL_W - bt->RP*2, ui->R, ui->Page->U, CPB)){
|
|
|
+ if (ScrollUil) *ScrollUil = ui->Page; if (ParentUi) *ParentUi = ui;
|
|
|
+ }elif (ui->Page->ScrollerShownH && laIsInBound(x, y, ui->Page->L, ui->Page->R, ui->B - LA_SCROLL_W - bt->BP*2, ui->B)){
|
|
|
+ if (ScrollUil) *ScrollUil = ui->Page; if (ParentUi) *ParentUi = ui;
|
|
|
+ }elif (laIsInBound(x, y, ui->Page->L, ui->Page->R, ui->Page->U, CPB)){
|
|
|
+ if (ParentUi) *ParentUi = ui;
|
|
|
+ if (tuil = la_DetectUiListRecursive(ui->Page, x, y, CPB, ParentUi, ScrollUil, ContainerParent, InToContainerUI, Exception)) return tuil;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ return uil;
|
|
|
+}
|
|
|
+laUiList *la_DetectUiListRecursiveDeep(laUiList *uil, int x, int y, int LimH, laUiItem **ParentUi, laUiList **ScrollUil,
|
|
|
+ laUiList **ContainerParent, int InToContainerUI, laUiItem *Exception, laListHandle* levels){
|
|
|
+ laUiItem *ui = uil->UiItems.pFirst;
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ laUiList *tuil;
|
|
|
+ laUiList *sub;
|
|
|
+ int CPB = 0;
|
|
|
+
|
|
|
+ laUiListRecord* uilr=lstAppendPointerSized(levels, uil, sizeof(laUiListRecord));
|
|
|
+
|
|
|
+ x += uil->PanX;
|
|
|
+ y += uil->PanY;
|
|
|
+
|
|
|
+ if (y > LimH) return uil;
|
|
|
+
|
|
|
+ if (/*uil->ScrollerShownV && */ laIsInBound(x, y, uil->R, uil->R+LA_SCROLL_W+4, uil->U, uil->B) ||
|
|
|
+ /*uil->ScrollerShownH && */ laIsInBound(x, y, uil->L, uil->R, uil->B, uil->B+LA_SCROLL_W+4)){
|
|
|
+ if (ScrollUil) *ScrollUil = uil; /* if (ParentUi)*ParentUi = uil;*/
|
|
|
+ return uil;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ui = uil->UiItems.pFirst; ui;){
|
|
|
+
|
|
|
+ bt = ui->Type->Theme ? (*ui->Type->Theme) : 0;
|
|
|
+
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ //la_StepExpression(cued->Expression);
|
|
|
+ cued->IsTrue = la_DoSingleExpression(cued->Expression);
|
|
|
+ if (!cued->IsTrue){
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (ui->Type == &_LA_UI_CONDITION_END){
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == &_LA_UI_CONDITION_ELSE){
|
|
|
+ laConditionUiExtraData *cued = ((laConditionUiExtraData *)ui->Extra)->EndUi->Extra;
|
|
|
+ if (cued->IsTrue) ui = cued->EndUi;
|
|
|
+ else
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ continue;
|
|
|
+ }else if (ui->Type == _LA_UI_CONDITION_TOGGLE){
|
|
|
+ laConditionUiExtraData *cued = ui->Extra;
|
|
|
+ if (ui->State == LA_UI_NORMAL){
|
|
|
+ cued->IsTrue = 0;
|
|
|
+ ui = cued->ElseUi ? cued->ElseUi : cued->EndUi;
|
|
|
+ }else{
|
|
|
+ cued->IsTrue = 1;
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (InToContainerUI && ui != Exception){
|
|
|
+ if (ui->Type == _LA_UI_CANVAS && !(ui->Flags&LA_UI_FLAGS_NO_OVERLAY)){
|
|
|
+ if (ContainerParent) (*ContainerParent) = uil;
|
|
|
+ if (ParentUi) *ParentUi = ui; uilr->pui=ui;
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ //if (y > LimH) return uil;
|
|
|
+ if (laIsInBound(x, y, sub->L, sub->R, sub->U, sub->B) && (tuil = la_DetectUiListRecursiveDeep(sub, x, y, ui->B, ParentUi, ScrollUil, ContainerParent, InToContainerUI, Exception, levels))){
|
|
|
+ return tuil;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((ui->Type == _LA_UI_FIXED_GROUP || ui->Type == _LA_UI_TAB) && (ui->Subs.pFirst || ui->Page)){
|
|
|
+ if (ui->Page->HeightCoeff) CPB = ui->B;
|
|
|
+ else CPB = ui->Page->B;
|
|
|
+ if (ui->Page->ScrollerShownV && laIsInBound(x, y, ui->R - LA_SCROLL_W - bt->RP*2, ui->R, ui->Page->U, CPB)){
|
|
|
+ if (ScrollUil) *ScrollUil = ui->Page; if (ParentUi) *ParentUi = ui; uilr->pui=ui;
|
|
|
+ }elif (ui->Page->ScrollerShownH && laIsInBound(x, y, ui->Page->L, ui->Page->R, ui->B - LA_SCROLL_W - bt->BP*2, ui->B)){
|
|
|
+ if (ScrollUil) *ScrollUil = ui->Page; if (ParentUi) *ParentUi = ui; uilr->pui=ui;
|
|
|
+ }elif (laIsInBound(x, y, ui->Page->L, ui->Page->R, ui->Page->U, CPB)){
|
|
|
+ if (ParentUi) *ParentUi = ui; uilr->pui=ui;
|
|
|
+ if (tuil = la_DetectUiListRecursiveDeep(ui->Page, x, y, CPB, ParentUi, ScrollUil, ContainerParent, InToContainerUI, Exception, levels)) return tuil;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((ui->PP.LastPs && ui->PP.LastPs->p->PropertyType == LA_PROP_SUB) && (ui->Subs.pFirst || ui->Page)){
|
|
|
+ if (ui->Page->HeightCoeff) CPB = ui->B;
|
|
|
+ else
|
|
|
+ CPB = ui->Page->B;
|
|
|
+ if (laIsInBound(x, y, ui->Page->R, ui->Page->R + LA_SCROLL_W + bt->RM, ui->Page->U, CPB)){
|
|
|
+ if (ScrollUil) *ScrollUil = ui->Page;
|
|
|
+ if (ParentUi) *ParentUi = ui; uilr->pui=ui;
|
|
|
+ }
|
|
|
+ if (laIsInBound(x, y, ui->Page->L, ui->Page->R, ui->Page->U, CPB)){
|
|
|
+ if (ParentUi) *ParentUi = ui; uilr->pui=ui;
|
|
|
+ if (tuil = la_DetectUiListRecursiveDeep(ui->Page, x, y, CPB, ParentUi, ScrollUil, ContainerParent, InToContainerUI, Exception, levels)) return tuil;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ return uil;
|
|
|
+}
|
|
|
+
|
|
|
+int la_TestUiListMinumWidth(laUiList *uil){
|
|
|
+ laUiItem *ui, *tui;
|
|
|
+ laBoxedTheme *bt;
|
|
|
+ laUiList *sub;
|
|
|
+ int CPB = 0;
|
|
|
+ int W = 0;
|
|
|
+ int tW, sW, RowMode=0, rW;
|
|
|
+ void *Restore;
|
|
|
+
|
|
|
+ for (ui = uil->UiItems.pFirst; ui;){
|
|
|
+ bt = ui->Type->Theme ? (*ui->Type->Theme) : 0;
|
|
|
+
|
|
|
+ if ((ui->Type == _LA_UI_FIXED_GROUP || ui->Type == _LA_UI_TAB) && (ui->Subs.pFirst || ui->Page)){
|
|
|
+ tW = la_TestUiListMinumWidth(ui->Page) + bt->LP + bt->RP;
|
|
|
+ tW = (int)((float)tW / ui->C->PreWidth + 2);
|
|
|
+ if (W < tW) W = tW;
|
|
|
+ }elif (ui->Type == _LA_UI_COLLECTION){
|
|
|
+ Restore = ui->PP.EndInstance;
|
|
|
+ tW = 0; sW = 0;
|
|
|
+ for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
|
|
|
+ ui->PP.EndInstance = sub->Instance;
|
|
|
+ sW = la_TestUiListMinumWidth(sub) + bt->LP + bt->RP;
|
|
|
+ if (sW > tW) tW = sW;
|
|
|
+ }
|
|
|
+ ui->PP.EndInstance = Restore;
|
|
|
+ tW = (int)((float)tW / ui->C->PreWidth + 2);
|
|
|
+ tW *= (ui->SymbolID > 0 ? ui->SymbolID : 1);
|
|
|
+ if (W < tW) W = tW;
|
|
|
+ }elif (ui->Type==&_LA_UI_ROW_BEGIN){
|
|
|
+ RowMode=1; rW=0;
|
|
|
+ }elif (ui->Type==&_LA_UI_ROW_END){
|
|
|
+ RowMode=0; rW=(int)((float)rW / ui->C->PreWidth + 2); if (W < rW) W = rW;
|
|
|
+ }elif (ui->Type->GetMinWidth){
|
|
|
+ tW = ui->Type->GetMinWidth(ui) + bt->LP + bt->RP;
|
|
|
+ tW = (int)((float)tW / ui->C->PreWidth + 2);
|
|
|
+ if(RowMode){ rW+=tW; }else{ if (W < tW) W = tW; }
|
|
|
+ }
|
|
|
+ ui = ui->Item.pNext;
|
|
|
+ }
|
|
|
+ return W;
|
|
|
+}
|
|
|
+
|
|
|
+void la_InitLLVM(){
|
|
|
+ //LLVMLinkInMCJIT();
|
|
|
+ //LLVMInitializeNativeTarget();
|
|
|
+ //LLVMInitializeNativeAsmPrinter();
|
|
|
+ //LLVMInitializeNativeAsmParser();
|
|
|
+
|
|
|
+ // MAIN.llvmContext = LLVMGetGlobalContext();
|
|
|
+ //MAIN.llvmModule = LLVMModuleCreateWithNameInContext(LA_NODE_MAIN_MODULE_NAME, MAIN.llvmContext);
|
|
|
+}
|
|
|
+
|
|
|
+//==================================================================================================
|
|
|
+
|
|
|
+laNodeOutSocket* laCreateOutSocket(void* NodeParentOptional, char* label, int DataType){
|
|
|
+ laNodeOutSocket* os=memAcquire(sizeof(laNodeOutSocket));
|
|
|
+ strSafeSet(&os->Label, label); os->DataType = DataType; os->Parent=NodeParentOptional;
|
|
|
+ return os;
|
|
|
+}
|
|
|
+laNodeInSocket* laCreateInSocket(char* label, int DataType){
|
|
|
+ laNodeInSocket* is=memAcquire(sizeof(laNodeInSocket));
|
|
|
+ strSafeSet(&is->Label, label); is->DataType = DataType;
|
|
|
+ return is;
|
|
|
+}
|
|
|
+
|
|
|
+//==================================================================================================
|
|
|
+
|
|
|
+void la_FreeKeyMapItem(laKeyMapItem* kmi){
|
|
|
+ if(kmi->Instructions) strSafeDestroy(&kmi->Instructions);
|
|
|
+ if(kmi->Operation) strSafeDestroy(&kmi->Operation);
|
|
|
+ if(kmi->Action.Go) la_FreePropStepCache(kmi->Action.Go);
|
|
|
+ if(kmi->Base.Go) la_FreePropStepCache(kmi->Action.Go);
|
|
|
+ memFree(kmi);
|
|
|
+}
|
|
|
+laKeyMapItem *laAssignNewKey(laKeyMapper *km, char *Path, char *Operation, char SelectBase, int SpecialKeyBits, int EventType, int Key, char *ExtraInstructions){
|
|
|
+ laKeyMapItem *kmi;
|
|
|
+
|
|
|
+ if (!km) return 0;
|
|
|
+
|
|
|
+ kmi = memAcquire(sizeof(laKeyMapItem));
|
|
|
+
|
|
|
+ if (la_GetPropFromPath(&kmi->Base, 0, Path, 0)){
|
|
|
+ la_GetPropFromPath(&kmi->Action, &kmi->Base, Operation, 0);
|
|
|
+ }else{
|
|
|
+ strSafeSet(&kmi->Operation, Operation);
|
|
|
+ }
|
|
|
+
|
|
|
+ strSafeSet(&kmi->Instructions, ExtraInstructions);
|
|
|
+
|
|
|
+ kmi->SpecialKeyBits = SpecialKeyBits;
|
|
|
+ kmi->EventType = EventType;
|
|
|
+ kmi->Key = Key;
|
|
|
+ kmi->SelectBase = SelectBase;
|
|
|
+
|
|
|
+ lstAppendItem(&km->Items, kmi);
|
|
|
+
|
|
|
+ return kmi;
|
|
|
+}
|
|
|
+int laKeyMapExecuteEvent(laOperator *from, laKeyMapper *km, laEvent *e){
|
|
|
+ laKeyMapItem *kmi; int inv=0;
|
|
|
+ char *instructions;
|
|
|
+ if(e->Type==LA_MOUSEMOVE) return 0;
|
|
|
+ for (kmi = km->Items.pFirst; kmi; kmi = kmi->Item.pNext){
|
|
|
+ if (kmi->SpecialKeyBits == e->SpecialKeyBit &&
|
|
|
+ kmi->EventType == e->Type && ((kmi->Key == e->Input) || (kmi->Key == e->key))){
|
|
|
+ instructions = kmi->Instructions ? kmi->Instructions->Ptr : 0;
|
|
|
+ if (kmi->Operation)
|
|
|
+ laInvoke(from, kmi->Operation->Ptr, e, 0, instructions, 0);
|
|
|
+ else
|
|
|
+ laInvoke(from, ((laOperatorProp *)&kmi->Action.LastPs)->OperatorID, e, &kmi->Base, instructions, 0);
|
|
|
+ inv = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return inv;
|
|
|
+}
|
|
|
+int laKeyMapExecuteEventEx(laOperator *from, laPropPack *UiExtra, laKeyMapper *km, laEvent *e){
|
|
|
+ laKeyMapItem *kmi;
|
|
|
+ char *instructions;
|
|
|
+ int inv = 0; int lx = -1, ly = -1;
|
|
|
+ if(e->Type==LA_MOUSEMOVE) return 0;
|
|
|
+ for (kmi = km->Items.pFirst; kmi; kmi = kmi->Item.pNext){
|
|
|
+ if (kmi->SpecialKeyBits == e->SpecialKeyBit &&
|
|
|
+ kmi->EventType == e->Type && ((kmi->Key == e->Input) || (kmi->Key == e->key))){
|
|
|
+ if (e->Localized){
|
|
|
+ lx = e->x;
|
|
|
+ ly = e->y;
|
|
|
+ laLocalToWindow(from, MAIN.ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ instructions = kmi->Instructions ? kmi->Instructions->Ptr : 0;
|
|
|
+ if (kmi->SelectBase == LA_KM_SEL_UI_EXTRA){
|
|
|
+ laInvoke(from, kmi->Operation->Ptr, e, UiExtra, instructions, 0);
|
|
|
+ }elif (kmi->SelectBase == LA_KM_SEL_PANEL){
|
|
|
+ laInvoke(from, kmi->Operation->Ptr, e, &((laPanel *)MAIN.ToPanel)->PP, instructions, 0);
|
|
|
+ }elif (kmi->Operation){
|
|
|
+ laInvoke(from, kmi->Operation->Ptr, e, 0, instructions, 0);
|
|
|
+ }else{
|
|
|
+ laInvoke(from, ((laOperatorProp *)&kmi->Action.LastPs)->OperatorID, e, &kmi->Base, instructions, 0);
|
|
|
+ }
|
|
|
+ inv = 1;
|
|
|
+
|
|
|
+ if (lx >= 0){
|
|
|
+ e->x = lx;
|
|
|
+ e->y = ly;
|
|
|
+ e->Localized = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return inv;
|
|
|
+}
|
|
|
+
|
|
|
+void la_DefaultOperatorParser(laStringSplitor *ss, char *IconID, char *DisplayString);
|
|
|
+
|
|
|
+void la_DestroyOperatorType(laOperatorType* at){
|
|
|
+ //if(at->PC) la_FreePropertyContainer(at->PC);
|
|
|
+ memFree(at);
|
|
|
+}
|
|
|
+laOperatorType *laCreateOperatorType(const char *ID, const char *Name, const char *Description,
|
|
|
+ laCheckFunc Check, laInitFunc Init, laExitFunc Exit, laInvokeFunc Invoke, laModalFunc Modal,
|
|
|
+ uint32_t IconID, int ExtraMark){
|
|
|
+
|
|
|
+ laOperatorType *at = memAcquire(sizeof(laOperatorType));
|
|
|
+
|
|
|
+ at->Identifier = ID;
|
|
|
+ at->Name = Name;
|
|
|
+ at->Description = Description;
|
|
|
+
|
|
|
+ at->Check = Check;
|
|
|
+ at->Invoke = Invoke;
|
|
|
+ at->Init = Init;
|
|
|
+ at->Exit = Exit;
|
|
|
+ at->Modal = Modal;
|
|
|
+ at->IconID = IconID;
|
|
|
+ at->ExtraMark = ExtraMark;
|
|
|
+
|
|
|
+ at->ParseArgs = la_DefaultOperatorParser;
|
|
|
+
|
|
|
+ hsh256InsertItemCSTR(&MAIN.OperatorTypeHash, at, at->Identifier);
|
|
|
+
|
|
|
+ return at;
|
|
|
+}
|
|
|
+
|
|
|
+laPropContainer* laDefineOperatorProps(laOperatorType* ot, int HyperLevel){
|
|
|
+ ot->PC = memAcquire(sizeof(laPropContainer));
|
|
|
+ ot->PC->Identifier = ot->Identifier;
|
|
|
+ ot->PC->Hyper = HyperLevel;
|
|
|
+ return ot->PC;
|
|
|
+}
|
|
|
+
|
|
|
+laOperator *la_CreateOperator(laOperatorType *at){
|
|
|
+ laOperator *a = CreateNew(laOperator);
|
|
|
+
|
|
|
+ a->Type = at;
|
|
|
+
|
|
|
+ if (at->PC && at->PC->Props.pFirst){
|
|
|
+ a->PP.LastPs = memAcquireSimple(sizeof(laPropStep));
|
|
|
+ a->PP.LastPs->p = memAcquire(sizeof(laProp));
|
|
|
+ a->PP.LastPs->p->SubProp = at->PC;
|
|
|
+ a->PP.LastPs->p->PropertyType = LA_PROP_SUB;
|
|
|
+ a->PP.LastPs->p->Identifier = at->PC->Identifier;
|
|
|
+ a->PP.LastPs->Type = L'.';
|
|
|
+ }
|
|
|
+
|
|
|
+ return a;
|
|
|
+}
|
|
|
+int la_OperatorTypeByID(laOperatorType *a, char *id){
|
|
|
+ return (!strcmp(a->Identifier, id));
|
|
|
+}
|
|
|
+laOperatorType *laGetOperatorType(const char *ID){
|
|
|
+ return hsh256FindItemSTR(&MAIN.OperatorTypeHash, la_OperatorTypeByID, ID);
|
|
|
+}
|
|
|
+
|
|
|
+int laOperatorExistsT(laOperatorType* at){
|
|
|
+ if (!at) return 0;
|
|
|
+ for (laOperator *a = MAIN.CurrentWindow->Operators.pFirst; a; a = a->Item.pNext){ if (at == a->Type){ return 1; } }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int laOperatorExists(const char* ID){
|
|
|
+ laOperatorType* at=laGetOperatorType(ID); if (!at) return 0;
|
|
|
+ return laOperatorExistsT(at);
|
|
|
+}
|
|
|
+int la_OperatorExists(laOperator *ac){
|
|
|
+ if (!ac) return 0;
|
|
|
+ laOperator *a;
|
|
|
+ for (a = MAIN.CurrentWindow->Operators.pFirst; a; a = a->Item.pNext){ if (ac == a){return 1;}}
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int la_UiOperatorExists(void *inst){
|
|
|
+ laOperator *a;
|
|
|
+ if (!inst) return 0;
|
|
|
+ for (a = MAIN.CurrentWindow->Operators.pFirst; a; a = a->Item.pNext){
|
|
|
+ if (((laUiItem *)a->Instance) == inst){
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (a = MAIN.CurrentWindow->PendingOperators.pFirst; a; a = a->Item.pNext){
|
|
|
+ if (a->Instance == inst){
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int la_OperatorPending(laOperator *target){
|
|
|
+ laOperator *a;
|
|
|
+ if (!target) return 0;
|
|
|
+ for (a = MAIN.CurrentWindow->PendingOperators.pFirst; a; a = a->Item.pNext){
|
|
|
+ if (a == target){
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+void laSetOperatorLocalizer(void *ToPanel){
|
|
|
+ MAIN.ToPanel = ToPanel;
|
|
|
+}
|
|
|
+
|
|
|
+void la_DestroyConfirmData(laConfirmData **cd);
|
|
|
+void *la_DestroyOperator(laOperator **a, laListHandle *Operators, int OnlyThisOne){
|
|
|
+ laOperator *ai = (*a);
|
|
|
+ laOperator *ac = ((*a)->Child);
|
|
|
+ void *Ret = 0;
|
|
|
+
|
|
|
+ if (!OnlyThisOne && ac && la_OperatorExists(ac) && !ac->Using){
|
|
|
+ la_DestroyOperator(&ac, Operators, OnlyThisOne);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((*a)->ConfirmData) la_DestroyConfirmData(&((*a)->ConfirmData));
|
|
|
+
|
|
|
+ if ((*a)->PP.LastPs){
|
|
|
+ memFree((*a)->PP.LastPs->p);
|
|
|
+ memFree((*a)->PP.LastPs);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (laNonFixedPanelExists((*a)->OperatorPanel)){
|
|
|
+ la_SetPropMathcerContext((*a)->OperatorPanel);
|
|
|
+ MAIN.CurrentPanel = (*a)->OperatorPanel;
|
|
|
+ laDestroySinglePanel((*a)->OperatorPanel);
|
|
|
+ }
|
|
|
+ if ((*a)->CreatedThis) FreeMem((*a)->CreatedThis);
|
|
|
+
|
|
|
+ if ((*a)->ExtraInstructionsP) strDestroyStringSplitor(&(*a)->ExtraInstructionsP);
|
|
|
+
|
|
|
+ lstClearPointer(&(*a)->LocalUiLists);
|
|
|
+
|
|
|
+ if (Operators){
|
|
|
+ Ret = ai->Item.pNext;
|
|
|
+ if (la_OperatorPending((*a) /*->Instance*/)) lstRemoveItem(&MAIN.CurrentWindow->PendingOperators, *a);
|
|
|
+ else
|
|
|
+ lstRemoveItem(Operators, *a);
|
|
|
+
|
|
|
+ for (ai = Operators->pFirst; ai; ai = ai->Item.pNext){
|
|
|
+ if (ai->Child == (*a)) ai->Child = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ strSafeDestroy(&(*a)->RuntimeHint);
|
|
|
+
|
|
|
+ free(*a);
|
|
|
+ return Ret;
|
|
|
+}
|
|
|
+
|
|
|
+int laOperatorAvailable(char *ID, laPropPack *This, laStringSplitor *Instructions){
|
|
|
+ laOperatorType *at = hsh256FindItemSTR(&MAIN.OperatorTypeHash, la_OperatorTypeByID, ID);
|
|
|
+ if (!at) return 0;
|
|
|
+
|
|
|
+ if (!at->Check) return 1;
|
|
|
+
|
|
|
+ return (at->Check(This, Instructions));
|
|
|
+}
|
|
|
+int laOperatorAvailableP(laOperatorType *at, laPropPack *This, laStringSplitor *Instructions){
|
|
|
+ if (!at) return 0;
|
|
|
+
|
|
|
+ if (!at->Check) return 1;
|
|
|
+
|
|
|
+ return (at->Check(This, Instructions));
|
|
|
+}
|
|
|
+int laOperatorAvailablePSafe(laOperatorType *at, laPropPack *This, void *Real_FromInstance, laStringSplitor *Instructions){
|
|
|
+ laPropPack FakePP = {0};
|
|
|
+ laPropStep FakePs = {0};
|
|
|
+ if (!at) return 0;
|
|
|
+
|
|
|
+ if (!at->Check) return 1;
|
|
|
+
|
|
|
+ FakePP.LastPs = &FakePs;
|
|
|
+ FakePP.Go = FakePP.LastPs;
|
|
|
+ FakePP.LastPs->p = This->LastPs->p;
|
|
|
+ FakePP.LastPs->UseInstance = This->EndInstance;
|
|
|
+ FakePP.EndInstance = Real_FromInstance;
|
|
|
+ FakePP.LastIndex = This->LastIndex;
|
|
|
+
|
|
|
+ return (at->Check(&FakePP, Instructions));
|
|
|
+}
|
|
|
+int laOperatorAvailableSafe(char *ID, laPropPack *This, void *Real_FromInstance, laStringSplitor *Instructions){
|
|
|
+ laOperatorType *at = hsh256FindItemSTR(&MAIN.OperatorTypeHash, la_OperatorTypeByID, ID);
|
|
|
+ return laOperatorAvailablePSafe(at, This, Real_FromInstance, Instructions);
|
|
|
+}
|
|
|
+
|
|
|
+int laInvokeUi(laOperator *From, char *ID, laEvent *e, void *inst, laListHandle *Locals, int IgnoreLocals){
|
|
|
+ laOperatorType *at;
|
|
|
+ laOperator *a, *f = From;
|
|
|
+
|
|
|
+ int rev;
|
|
|
+
|
|
|
+ if (la_UiOperatorExists(inst)) return -1;
|
|
|
+
|
|
|
+ at = hsh256FindItemSTR(&MAIN.OperatorTypeHash, la_OperatorTypeByID, ID);
|
|
|
+ if (!at) return -1;
|
|
|
+
|
|
|
+ a = la_CreateOperator(at);
|
|
|
+ a->Instance = inst;
|
|
|
+ a->ToPanel = MAIN.ToPanel;
|
|
|
+ if (!IgnoreLocals) lstGeneratePointerList(f ? &f->LocalUiLists : 0, Locals, &a->LocalUiLists);
|
|
|
+
|
|
|
+ if (From) f->Child = a;
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ if (at->Init) at->Init(a);
|
|
|
+ rev = at->Invoke(a, e);
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (rev & LA_FINISH){
|
|
|
+ a->StopNow = 1; if(From)From->Child=0;
|
|
|
+ }
|
|
|
+ if (rev & LA_BLOCK){
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->PendingOperators, a);
|
|
|
+ a->State = rev;
|
|
|
+ }else la_DestroyOperator(&a, 0, 0);
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+int laInvokeUiP(laOperator *From, laOperatorType *at, laEvent *e, void *inst, laListHandle *Locals, int IgnoreLocals){
|
|
|
+ laOperator *a, *f = From;
|
|
|
+ int rev;
|
|
|
+
|
|
|
+ if (!at || (la_UiOperatorExists(inst))){
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ a = la_CreateOperator(at);
|
|
|
+ a->Instance = inst;
|
|
|
+ a->ToPanel = MAIN.ToPanel;
|
|
|
+ if (!IgnoreLocals) lstGeneratePointerList(f ? &f->LocalUiLists : 0, Locals, &a->LocalUiLists);
|
|
|
+
|
|
|
+ if (From) f->Child = a;
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ if (at->Init) at->Init(a);
|
|
|
+ rev = at->Invoke(a, e);
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (rev & LA_FINISH){
|
|
|
+ a->StopNow = 1; if(From)From->Child=0;
|
|
|
+ }
|
|
|
+ if (rev & LA_BLOCK){
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->PendingOperators, a);
|
|
|
+ a->State = rev;
|
|
|
+ }else
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+
|
|
|
+ DEB = a;
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+
|
|
|
+int laInvoke(laOperator *From, char *ID, laEvent *e, laPropPack *This, char *args, char *args2){
|
|
|
+ laOperatorType *at;
|
|
|
+ laOperator *a, *f = From;
|
|
|
+ int rev;
|
|
|
+
|
|
|
+ at = hsh256FindItemSTR(&MAIN.OperatorTypeHash, la_OperatorTypeByID, ID);
|
|
|
+ if (!at) return -1;
|
|
|
+
|
|
|
+ if (!f && e && e->Localized) return -1;
|
|
|
+
|
|
|
+ a = la_CreateOperator(at);
|
|
|
+ a->ToPanel = MAIN.ToPanel;
|
|
|
+ a->This = This;
|
|
|
+ a->ExtraInstructions = args;
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args2);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, at->ExtraInstructions);
|
|
|
+
|
|
|
+ if (!laOperatorAvailableP(at, This, a->ExtraInstructionsP)){
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+ return LA_CANCELED;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e&&(!e->Localized) && (at->ExtraMark & LA_EXTRA_TO_PANEL)){
|
|
|
+ laWindowToLocal(0, a->ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e&&e->Localized && (!at->ExtraMark & LA_EXTRA_TO_PANEL)){
|
|
|
+ laLocalToWindow(0, a->ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (From) f->Child = a;
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ if (at->Init) at->Init(a);
|
|
|
+ rev = at->Invoke(a, e);
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (rev & LA_FINISH){
|
|
|
+ a->StopNow = 1; if(From)From->Child=0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!a->StopNow && (rev&LA_BLOCK || rev&LA_PASS_ON)){
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->PendingOperators, a);
|
|
|
+ a->State = rev;
|
|
|
+ a->PP.EndInstance = a->CustomData;
|
|
|
+ }else
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+int laInvokeCreateThis(laOperator *From, char *ID, laEvent *e, laPropPack *OrigionalThis, void *FromInstance, char *args, char *args2){
|
|
|
+ laOperatorType *at;
|
|
|
+ laOperator *a, *f = From;
|
|
|
+ int rev;
|
|
|
+ laPropPack *created;
|
|
|
+
|
|
|
+ at = hsh256FindItemSTR(&MAIN.OperatorTypeHash, la_OperatorTypeByID, ID);
|
|
|
+ if (!at) return -1;
|
|
|
+
|
|
|
+ if (!f && (e && e->Localized) || !OrigionalThis || !OrigionalThis->LastPs) return -1;
|
|
|
+
|
|
|
+ created = CreateNew(laPropPack);
|
|
|
+ created->LastPs = memAcquireSimple(sizeof(laPropStep));
|
|
|
+ created->Go = created->LastPs;
|
|
|
+ created->LastPs->p = OrigionalThis->LastPs->p;
|
|
|
+ created->LastPs->UseInstance = FromInstance;
|
|
|
+ created->EndInstance = FromInstance;
|
|
|
+ created->LastIndex = OrigionalThis->LastIndex;
|
|
|
+
|
|
|
+ a = la_CreateOperator(at);
|
|
|
+ a->ToPanel = MAIN.ToPanel;
|
|
|
+ a->This = created;
|
|
|
+ a->CreatedThis = created;
|
|
|
+ a->ExtraInstructions = args;
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args2);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, at->ExtraInstructions);
|
|
|
+
|
|
|
+ if (!laOperatorAvailableP(at, created, a->ExtraInstructionsP)){
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+ return LA_CANCELED;
|
|
|
+ }
|
|
|
+
|
|
|
+ lstGeneratePointerList(f ? &f->LocalUiLists : 0, 0, &a->LocalUiLists);
|
|
|
+
|
|
|
+ if (e&&!e->Localized && at->ExtraMark & LA_EXTRA_TO_PANEL) laWindowToLocal(0, a->ToPanel, &e->x, &e->y);
|
|
|
+
|
|
|
+ if (From) f->Child = a;
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ if (at->Init) at->Init(a);
|
|
|
+ rev = at->Invoke(a, e);
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (rev & LA_FINISH){
|
|
|
+ a->StopNow = 1; if(From)From->Child=0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!a->StopNow && (rev&LA_BLOCK || rev&LA_PASS_ON)){
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->PendingOperators, a);
|
|
|
+ a->State = rev;
|
|
|
+ a->PP.EndInstance = a->CustomData;
|
|
|
+ }else
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+int laInvokeP(laOperator *From, laOperatorType *at, laEvent *e, laPropPack *This, char *args, char *args2){
|
|
|
+ laOperator *a, *f = From;
|
|
|
+ int rev;
|
|
|
+
|
|
|
+ if (!f && e&&e->Localized) return -1;
|
|
|
+
|
|
|
+ a = la_CreateOperator(at);
|
|
|
+ a->ToPanel = MAIN.ToPanel;
|
|
|
+ a->This = This;
|
|
|
+ a->ExtraInstructions = args;
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args2);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, at->ExtraInstructions);
|
|
|
+
|
|
|
+ if (!laOperatorAvailableP(at, This, a->ExtraInstructionsP)){
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+ return LA_CANCELED;
|
|
|
+ }
|
|
|
+
|
|
|
+ lstGeneratePointerList(f ? &f->LocalUiLists : 0, 0, &a->LocalUiLists);
|
|
|
+
|
|
|
+ if (e&&!e->Localized && at->ExtraMark & LA_EXTRA_TO_PANEL){
|
|
|
+ laWindowToLocal(0, a->ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e&&e->Localized){
|
|
|
+ if (!at->ExtraMark & LA_EXTRA_TO_PANEL){
|
|
|
+ laLocalToWindow(f, f->ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 0;
|
|
|
+ }else{
|
|
|
+ laLocalToWindow(f, f->ToPanel, &e->x, &e->y);
|
|
|
+ laWindowToLocal(a, a->ToPanel, &e->x, &e->y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (From) f->Child = a;
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ if (at->Init) at->Init(a);
|
|
|
+ rev = at->Invoke(a, e);
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (rev & LA_FINISH){
|
|
|
+ a->StopNow = 1; if(From)From->Child=0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!a->StopNow && (rev&LA_BLOCK || rev&LA_PASS_ON)){
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->PendingOperators, a);
|
|
|
+ a->State = rev;
|
|
|
+ a->PP.EndInstance = a->CustomData;
|
|
|
+ if (a->PP.LastPs) a->PP.LastPs->Type = L'.';
|
|
|
+ }else
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+int laInvokePCreateThis(laOperator *From, laOperatorType *at, laEvent *e, laPropPack *OrigionalThis, void *FromInstance, char *args, char *args2){
|
|
|
+ laOperator *a, *f = From;
|
|
|
+ int rev;
|
|
|
+ laPropPack *created;
|
|
|
+
|
|
|
+ if (!f && e&&e->Localized || !OrigionalThis || !OrigionalThis->LastPs) return -1;
|
|
|
+
|
|
|
+ created = CreateNew(laPropPack);
|
|
|
+ created->LastPs = memAcquireSimple(sizeof(laPropStep));
|
|
|
+ created->Go = created->LastPs;
|
|
|
+ created->LastPs->p = OrigionalThis->LastPs->p;
|
|
|
+ created->LastPs->UseInstance = FromInstance;
|
|
|
+ created->EndInstance = FromInstance;
|
|
|
+ created->LastIndex = OrigionalThis->LastIndex;
|
|
|
+
|
|
|
+ a = la_CreateOperator(at);
|
|
|
+ a->ToPanel = MAIN.ToPanel;
|
|
|
+ a->This = created;
|
|
|
+ a->CreatedThis = created;
|
|
|
+ a->ExtraInstructions = args;
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, args2);
|
|
|
+ strMakeInstructions(&a->ExtraInstructionsP, at->ExtraInstructions);
|
|
|
+
|
|
|
+ if (!laOperatorAvailableP(at, created, a->ExtraInstructionsP)){
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+ return LA_CANCELED;
|
|
|
+ }
|
|
|
+
|
|
|
+ lstGeneratePointerList(f ? &f->LocalUiLists : 0, 0, &a->LocalUiLists);
|
|
|
+
|
|
|
+ if (e&&!e->Localized && at->ExtraMark & LA_EXTRA_TO_PANEL) laWindowToLocal(0, a->ToPanel, &e->x, &e->y);
|
|
|
+
|
|
|
+ if (From) f->Child = a;
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ if (at->Init) at->Init(a);
|
|
|
+ rev = at->Invoke(a, e);
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (rev & LA_FINISH){
|
|
|
+ a->StopNow = 1; if(From)From->Child=0;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!a->StopNow && (rev&LA_BLOCK || rev&LA_PASS_ON)){
|
|
|
+ lstAppendItem(&MAIN.CurrentWindow->PendingOperators, a);
|
|
|
+ a->State = rev;
|
|
|
+ a->PP.EndInstance = a->CustomData;
|
|
|
+ }else
|
|
|
+ la_DestroyOperator(&a, 0, 0);
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+void laRequestDelayEvent(real Seconds){
|
|
|
+ MAIN.DelayTriggered=0; MAIN.DelayStart=MAIN.TimeAccum; MAIN.DelayTime = Seconds; }
|
|
|
+
|
|
|
+int la_UiStillInService(void *UiInstance){
|
|
|
+ laOperator *ai, *dai;
|
|
|
+ for (ai = MAIN.CurrentWindow->Operators.pFirst; ai; ai = ai->Item.pNext){
|
|
|
+ if (ai->Instance == UiInstance) return 1;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+void la_StopUiOperatorService(void *UiInstance){
|
|
|
+ laOperator *ai, *dai, *NextAi;
|
|
|
+ if (!MAIN.CurrentWindow) return;
|
|
|
+ for (ai = MAIN.CurrentWindow->PendingOperators.pFirst; ai; ai = NextAi){
|
|
|
+ NextAi = ai->Item.pNext;
|
|
|
+ if (ai->Instance == UiInstance){
|
|
|
+ if (ai->Child){
|
|
|
+ la_StopUiOperatorService(ai->Child->Instance);
|
|
|
+ ai->Child = 0;
|
|
|
+ }
|
|
|
+ laOperator *dai = ai;
|
|
|
+ la_DestroyOperator(&dai, &MAIN.CurrentWindow->PendingOperators, 1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ai = MAIN.CurrentWindow->Operators.pFirst; ai; ai = NextAi){
|
|
|
+ NextAi = ai->Item.pNext;
|
|
|
+ if (ai->Instance == UiInstance){
|
|
|
+ if (ai->Instance == ai->ToPanel){
|
|
|
+ //laHidePanelWithDissoveEffect(ai->ToPanel);
|
|
|
+ //ai->ToPanel->LaterDestroy = 1;
|
|
|
+ }
|
|
|
+ if (ai->Child && la_OperatorExists(ai->Child)){
|
|
|
+ la_StopUiOperatorService(ai->Child->Instance);
|
|
|
+ //ai->Child = 0;
|
|
|
+ }
|
|
|
+ if (!ai->Using){
|
|
|
+ laOperator *dai = ai;
|
|
|
+ la_DestroyOperator(&dai, &MAIN.CurrentWindow->Operators, 1);
|
|
|
+ }else
|
|
|
+ ai->StopNow = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+void la_StopAllOperators(){
|
|
|
+ laOperator *ai, *dai, *NextAi;
|
|
|
+ if (!MAIN.CurrentWindow) return;
|
|
|
+ for (ai = MAIN.CurrentWindow->PendingOperators.pFirst; ai; ai = NextAi){
|
|
|
+ NextAi = ai->Item.pNext;
|
|
|
+ NextAi = la_DestroyOperator(&ai, &MAIN.CurrentWindow->PendingOperators, 1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for (ai = MAIN.CurrentWindow->Operators.pFirst; ai; ai = NextAi){
|
|
|
+ NextAi = ai->Item.pNext;
|
|
|
+ if (ai->Instance == ai->ToPanel && !ai->ToPanel->IsMenuPanel){
|
|
|
+ laHidePanelWithDissoveEffect(ai->ToPanel);
|
|
|
+ ai->ToPanel->LaterDestroy = 1;
|
|
|
+ }
|
|
|
+ if (!ai->Using){
|
|
|
+ laOperator *dai = ai;
|
|
|
+ la_DestroyOperator(&dai, &MAIN.CurrentWindow->Operators, 1);
|
|
|
+ }else
|
|
|
+ ai->StopNow = 1;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void la_DestroyConfirmData(laConfirmData **cd){
|
|
|
+ if ((*cd)->CustomData) (*cd)->Destroy((*cd)->CustomData);
|
|
|
+ if ((*cd)->StrData) free((*cd)->StrData);
|
|
|
+ FreeMem((*cd));
|
|
|
+ (*cd) = 0;
|
|
|
+}
|
|
|
+void laConfirmInt(laOperator *a, int Data, int mode){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laConfirmData *cd = CreateNew(laConfirmData);
|
|
|
+
|
|
|
+ cd->IData = Data;
|
|
|
+ cd->Mode = mode;
|
|
|
+
|
|
|
+ ai->NextConfirmData = cd;
|
|
|
+ laRetriggerOperators();
|
|
|
+}
|
|
|
+void laConfirmFloat(laOperator *a, real Data, int mode){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laConfirmData *cd = CreateNew(laConfirmData);
|
|
|
+
|
|
|
+ cd->FData = Data;
|
|
|
+ cd->Mode = mode;
|
|
|
+
|
|
|
+ ai->NextConfirmData = cd;
|
|
|
+ laRetriggerOperators();
|
|
|
+}
|
|
|
+void laConfirmString(laOperator *a, char *Str, int mode){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laConfirmData *cd = CreateNew(laConfirmData);
|
|
|
+ int len = strlen(Str);
|
|
|
+ char *buf = calloc(len + 1, sizeof(char));
|
|
|
+ strcpy(buf, Str);
|
|
|
+
|
|
|
+ cd->StrData = buf;
|
|
|
+ cd->Mode = mode;
|
|
|
+ cd->Destroy = free;
|
|
|
+ ai->NextConfirmData = cd;
|
|
|
+ laRetriggerOperators();
|
|
|
+}
|
|
|
+int laConfirmSameDataIfAny(laOperator *a){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laConfirmData *cd;
|
|
|
+ char *buf = 0;
|
|
|
+
|
|
|
+ if (!ai->ConfirmData || ai->NextConfirmData) return 0;
|
|
|
+
|
|
|
+ cd = CreateNew(laConfirmData);
|
|
|
+
|
|
|
+ if (ai->ConfirmData->StrData){
|
|
|
+ int len = strlen(ai->ConfirmData->StrData);
|
|
|
+ buf = calloc(len + 1, sizeof(char));
|
|
|
+ strcpy(buf, ai->ConfirmData->StrData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //cd->CustomData = cd->CustomData;
|
|
|
+ cd->IData = ai->ConfirmData->IData;
|
|
|
+ cd->FData = ai->ConfirmData->FData;
|
|
|
+ cd->StrData = buf;
|
|
|
+ cd->Mode = ai->ConfirmData->Mode;
|
|
|
+ cd->Destroy = ai->ConfirmData->Destroy;
|
|
|
+ ai->NextConfirmData = cd;
|
|
|
+ laRetriggerOperators();
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+void laConfirmUserData(laOperator *a, void *UserData, laConfirmDataDestroyFunc Destroy, int mode){
|
|
|
+ laOperator *ai = a;
|
|
|
+ laConfirmData *cd = CreateNew(laConfirmData);
|
|
|
+
|
|
|
+ cd->CustomData = UserData;
|
|
|
+ cd->Mode = mode;
|
|
|
+ cd->Destroy = Destroy;
|
|
|
+ ai->NextConfirmData = cd;
|
|
|
+ laRetriggerOperators();
|
|
|
+}
|
|
|
+
|
|
|
+int laGetConfirmMode(laOperator *a){
|
|
|
+ return ((laOperator *)a)->ConfirmData->Mode;
|
|
|
+}
|
|
|
+int laGetConfirmInt(laOperator *a){
|
|
|
+ laOperator *ai = a;
|
|
|
+ int rev = ai->ConfirmData->IData;
|
|
|
+
|
|
|
+ la_DestroyConfirmData(&ai->ConfirmData);
|
|
|
+ ai->ConfirmData = 0;
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+real laGetConfirmFloat(laOperator *a){
|
|
|
+ laOperator *ai = a;
|
|
|
+ real rev = ai->ConfirmData->FData;
|
|
|
+
|
|
|
+ la_DestroyConfirmData(&ai->ConfirmData);
|
|
|
+ ai->ConfirmData = 0;
|
|
|
+
|
|
|
+ return rev;
|
|
|
+}
|
|
|
+void laGetConfirmString(laOperator *a, char *buf){
|
|
|
+ laOperator *ai = a;
|
|
|
+
|
|
|
+ strcpy(buf, ai->ConfirmData->StrData);
|
|
|
+
|
|
|
+ la_DestroyConfirmData(&ai->ConfirmData);
|
|
|
+ ai->ConfirmData = 0;
|
|
|
+}
|
|
|
+void *laGetConfirmUserData(laOperator *a){
|
|
|
+ laOperator *ai = a;
|
|
|
+ return ai->ConfirmData->CustomData;
|
|
|
+}
|
|
|
+
|
|
|
+void laFinalizeOperators(){
|
|
|
+ laOperatorType *at;
|
|
|
+ laListHandle *lst;
|
|
|
+ int i;
|
|
|
+ for (i = 0; i < 256; i++){
|
|
|
+ lst = &MAIN.OperatorTypeHash.Entries[i];
|
|
|
+ for (at = lst->pFirst; at; at = at->Item.pNext){
|
|
|
+ if (at->PC && at->PC->Props.pFirst){
|
|
|
+ lstAppendItem(&MAIN.PropContainers, at->PC);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int la_UpdateOperatorHints(laWindow* w){
|
|
|
+ laSafeString* ss=0;
|
|
|
+ for(laOperator* o=w->Operators.pFirst;o;o=o->Item.pNext){
|
|
|
+ if(o->RuntimeHint&&o->RuntimeHint->Ptr){ strSafePrint(&ss, "%s | %s ", o->Type->Name, o->RuntimeHint->Ptr);}
|
|
|
+ }
|
|
|
+ if((w->OperatorHints&&ss&&strSame(ss->Ptr,w->OperatorHints->Ptr))||(!w->OperatorHints&&!ss)){ //pass
|
|
|
+ }else{
|
|
|
+ if(ss){ strSafeSet(&w->OperatorHints,ss->Ptr); } else { strSafeDestroy(&w->OperatorHints); }
|
|
|
+ laNotifyUsers("la.windows.operator_hints");//printf("op hint\n");
|
|
|
+ }
|
|
|
+}
|
|
|
+int la_HandleSingleEvent(laEvent *e, laListHandle *Operators){
|
|
|
+ laOperator *a, *NextA = 0;
|
|
|
+ int Result = 0;
|
|
|
+ laConfirmData *ConfirmData = 0, *NextConfirmData = 0;
|
|
|
+
|
|
|
+ a = Operators->pFirst;
|
|
|
+
|
|
|
+ while (1){
|
|
|
+ if (!a) break;
|
|
|
+
|
|
|
+ if (a->StopNow){
|
|
|
+ NextA = a->Item.pNext;
|
|
|
+ if (a->Type->Exit) a->Type->Exit(a, Result);
|
|
|
+
|
|
|
+ ConfirmData = a->NextConfirmData;
|
|
|
+ if (a->ConfirmData) la_DestroyConfirmData(&a->ConfirmData);
|
|
|
+
|
|
|
+ NextConfirmData = ConfirmData;
|
|
|
+ a->ConfirmData = 0;
|
|
|
+ a->NextConfirmData = 0;
|
|
|
+
|
|
|
+ la_DestroyOperator(&a, Operators, 0);
|
|
|
+ a = NextA;
|
|
|
+ if (a){
|
|
|
+ a->ConfirmData = NextConfirmData;
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ a->Using = 1;
|
|
|
+
|
|
|
+ la_SetPropMathcerContext(a->ToPanel);
|
|
|
+ laSetOperatorLocalizer(a->ToPanel);
|
|
|
+ MAIN.CurrentPanel = a->ToPanel;
|
|
|
+
|
|
|
+ if (a->Type->ExtraMark & LA_EXTRA_TO_PANEL){
|
|
|
+ laWindowToLocal(a, a->ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (a->State & LA_BLOCK){ Result = a->Type->Modal(a, e); }
|
|
|
+
|
|
|
+ //la_PrintOperatorStack();
|
|
|
+
|
|
|
+ if(Result == LA_OPERATOR_CALLS_SHUTOFF){ return 0; }
|
|
|
+
|
|
|
+ if (a->Type->ExtraMark & LA_EXTRA_TO_PANEL){
|
|
|
+ laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
|
|
|
+ e->Localized = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ la_SetPropMathcerContext(0);
|
|
|
+ laSetOperatorLocalizer(0);
|
|
|
+ MAIN.CurrentPanel = 0;
|
|
|
+
|
|
|
+ a->Using = 0;
|
|
|
+
|
|
|
+ if (Result & LA_PASS_ON){
|
|
|
+ laConfirmSameDataIfAny(a);
|
|
|
+ NextA = a->Item.pNext;
|
|
|
+ }else{
|
|
|
+ NextA = 0;
|
|
|
+ if (a->NextConfirmData){
|
|
|
+ la_DestroyConfirmData(&a->NextConfirmData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ConfirmData = a->NextConfirmData;
|
|
|
+ if (a->ConfirmData) la_DestroyConfirmData(&a->ConfirmData);
|
|
|
+
|
|
|
+ NextConfirmData = ConfirmData;
|
|
|
+ a->ConfirmData = 0;
|
|
|
+ a->NextConfirmData = 0;
|
|
|
+
|
|
|
+ if (Result & LA_FINISH || Result == LA_CANCEL || (a->StopNow && a->Using == 0)){
|
|
|
+ if (a->Type->Exit) a->Type->Exit(a, Result);
|
|
|
+ la_DestroyOperator(&a, Operators, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ a = NextA;
|
|
|
+
|
|
|
+ if (a){
|
|
|
+ a->ConfirmData = NextConfirmData;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int la_HandleEvents(laWindow *w){
|
|
|
+ laEvent *e, *NextE;
|
|
|
+ laOperator *a;
|
|
|
+ laThreadNotifier *tn;
|
|
|
+
|
|
|
+ MAIN.CurrentWindow=w;
|
|
|
+
|
|
|
+ //pthread_spin_lock(&MAIN.csNotifier);
|
|
|
+ while (tn = lstPopItem(&MAIN.ThreadNotifiers)){
|
|
|
+ //pthread_spin_unlock(&MAIN.csNotifier);
|
|
|
+
|
|
|
+ laNotifyUsers(tn->Path);
|
|
|
+
|
|
|
+ FreeMem(tn);
|
|
|
+
|
|
|
+ //if (MAIN.ThreadNotifiers.pFirst)
|
|
|
+ //pthread_spin_lock(&MAIN.csNotifier);
|
|
|
+ }
|
|
|
+ //pthread_spin_unlock(&MAIN.csNotifier);
|
|
|
+
|
|
|
+ while (1){
|
|
|
+ if (MAIN.ReTriggerOperators) laSendOperatorTriggerEvent();
|
|
|
+ while (w->PendingOperators.pLast){
|
|
|
+ a = w->PendingOperators.pLast;
|
|
|
+ if (a->OperatorPanel){
|
|
|
+ laSetOperatorLocalizer(a->OperatorPanel);
|
|
|
+ if (a->OperatorPanel->Mode == LA_PANEL_FLOATING_TOP)
|
|
|
+ laInvokeUi(a, "LA_modal_panel_operator", 0, a->OperatorPanel, 0, 1);
|
|
|
+ }
|
|
|
+ lstRemoveItem(&w->PendingOperators, a);
|
|
|
+ lstPushItem(&w->Operators, a);
|
|
|
+ }
|
|
|
+ while (1){
|
|
|
+ if (!w->EventList.pFirst) break;
|
|
|
+
|
|
|
+ e = lstPopItem(&w->EventList);
|
|
|
+
|
|
|
+ if (e && !w->Operators.pFirst){
|
|
|
+ laInvokeUi(0, "LA_window_operator", e, w, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (e) if(!la_HandleSingleEvent(e, &w->Operators)) return 0; //EXIT
|
|
|
+
|
|
|
+ FreeMem(e);
|
|
|
+ }
|
|
|
+ if (!MAIN.ReTriggerOperators) break;
|
|
|
+ }
|
|
|
+ la_UpdateOperatorHints(w);
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+int la_AllowInput(uint32_t ch){
|
|
|
+ if(ch>=32 || ch==L'\n' || ch==L'\t' || ch==L'\b') return 1;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+int laCopyToClipboard(unsigned char * text){
|
|
|
+ XEvent event; Window owner, window=MAIN.CurrentWindow->win;
|
|
|
+ XSetSelectionOwner(MAIN.dpy, MAIN.selection, window, 0);
|
|
|
+ if (XGetSelectionOwner (MAIN.dpy, MAIN.selection) != window) return;
|
|
|
+ strSafeSet(&MAIN.CopyPending, text);
|
|
|
+}
|
|
|
+int la_ProcessSysMessage(){
|
|
|
+ XEvent e;
|
|
|
+ int type;
|
|
|
+
|
|
|
+ int InputCount = 0, CharCount=0;
|
|
|
+ KeySym InputKeysym = 0;
|
|
|
+ Status InputStatus = 0;
|
|
|
+
|
|
|
+ int SendDelay=0,SendIdle=0;
|
|
|
+ if(!MAIN.DelayTriggered && MAIN.TimeAccum-MAIN.DelayStart>MAIN.DelayTime) SendDelay=1;
|
|
|
+ if(!MAIN.IdleTriggered && MAIN.TimeAccum-MAIN.IdleStart>MAIN.IdleTime) SendIdle=1;
|
|
|
+
|
|
|
+ while(XPending(MAIN.dpy)){
|
|
|
+ XNextEvent(MAIN.dpy, &e);
|
|
|
+ if (XFilterEvent(&e, None)) continue;
|
|
|
+ SendIdle=0; MAIN.IdleStart=MAIN.TimeAccum; MAIN.IdleTriggered=0;
|
|
|
+
|
|
|
+ switch(e.type){
|
|
|
+ case ConfigureNotify:
|
|
|
+ la_CommandResizeWindow(e.xconfigure.window, e.xconfigure.x, e.xconfigure.y, e.xconfigure.width, e.xconfigure.height);
|
|
|
+ break;
|
|
|
+ case Expose:
|
|
|
+ //glXSwapBuffers(MAIN.dpy,e.xexpose.window);
|
|
|
+ //SwapBuffers(GetDC(hwnd));
|
|
|
+ break;
|
|
|
+ case MotionNotify:
|
|
|
+ la_SendMouseEvent(e.xmotion.window, LA_MOUSEMOVE, e.xmotion.x,e.xmotion.y);
|
|
|
+ break;
|
|
|
+ case ButtonPress:
|
|
|
+ type=LA_MOUSEDOWN;
|
|
|
+ if(e.xbutton.button==1){type|=LA_KEY_MOUSE_LEFT;}
|
|
|
+ elif(e.xbutton.button==2){type|=LA_KEY_MOUSE_MIDDLE;}
|
|
|
+ elif(e.xbutton.button==3){type|=LA_KEY_MOUSE_RIGHT;}
|
|
|
+ elif(e.xbutton.button==4){type=LA_MOUSEUP|LA_KEY_MOUSE_SCROLL;}
|
|
|
+ elif(e.xbutton.button==5){type=LA_MOUSEDOWN|LA_KEY_MOUSE_SCROLL;}
|
|
|
+ la_SendMouseEvent(e.xbutton.window, type, e.xbutton.x,e.xbutton.y);
|
|
|
+ break;
|
|
|
+ case ButtonRelease:
|
|
|
+ type=LA_MOUSEUP;
|
|
|
+ if(e.xbutton.button==1){type|=LA_KEY_MOUSE_LEFT;}
|
|
|
+ elif(e.xbutton.button==2){type|=LA_KEY_MOUSE_MIDDLE;}
|
|
|
+ elif(e.xbutton.button==3){type|=LA_KEY_MOUSE_RIGHT;}
|
|
|
+ la_SendMouseEvent(e.xbutton.window, type, e.xbutton.x,e.xbutton.y);
|
|
|
+ break;
|
|
|
+ case KeyPress:
|
|
|
+ InputCount=Xutf8LookupString(MAIN.ic, (XKeyPressedEvent*)&e, MAIN.InputBuf, MAIN.InputBufMax, &InputKeysym, &InputStatus);
|
|
|
+ MAIN.InputBuf[InputCount]=0;
|
|
|
+ if (InputStatus==XBufferOverflow) printf("XInputBufferOverflow\n");
|
|
|
+ if (InputStatus == XLookupKeySym || InputStatus == XLookupBoth) { /*printf("status: %d\n", InputStatus);*/ }
|
|
|
+ /*printf("pressed KEY: %d\n", (int)InputKeysym);*/
|
|
|
+ if (InputCount){ MAIN.InputBuf[InputCount]=0; } strToUnicode(MAIN.InputBufU,MAIN.InputBuf); int UCount=strlenU(MAIN.InputBufU);
|
|
|
+ for(int i=0;i<UCount;i++){ if(la_AllowInput(MAIN.InputBufU[i])) la_SendInputEvent(e.xkey.window, MAIN.InputBufU[i]); }
|
|
|
+ if(InputKeysym=XkbKeycodeToKeysym(e.xkey.display, e.xkey.keycode, 0, 0)){
|
|
|
+ la_SendKeyboardEvent(e.xkey.window, LA_KEY_DOWN, la_TranslateSpecialKey(InputKeysym));
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case KeyRelease:
|
|
|
+ if(InputKeysym=XkbKeycodeToKeysym(e.xkey.display, e.xkey.keycode, 0, 0)){
|
|
|
+ la_SendKeyboardEvent(e.xkey.window, LA_KEY_UP, la_TranslateSpecialKey(InputKeysym));
|
|
|
+ }
|
|
|
+ case ClientMessage:
|
|
|
+ if(e.xclient.data.l[0]==MAIN.MsgDelWindow){
|
|
|
+ if(la_OnWindowDestroy(e.xclient.window)){ return 0; }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case SelectionNotify:
|
|
|
+ if(e.xselection.selection != MAIN.bufid) continue;
|
|
|
+ if (e.xselection.property){
|
|
|
+ char *result; unsigned long ressize, restail; int resbits; Atom fmtid;
|
|
|
+ XGetWindowProperty(MAIN.dpy, MAIN.CurrentWindow->win, MAIN.propid, 0, LONG_MAX/4, False, AnyPropertyType,
|
|
|
+ &fmtid, &resbits, &ressize, &restail, (unsigned char**)&result);
|
|
|
+
|
|
|
+ if (fmtid == MAIN.incrid) logPrintNew("Pasted buffer is too large and INCR reading is not implemented yet.\n");
|
|
|
+ else if(result) {
|
|
|
+ arrEnsureLength(&MAIN.InputBufU, strlen(result), &MAIN.InputBufUMax, sizeof(uint32_t));
|
|
|
+ strToUnicode(MAIN.InputBufU,result); int UCount=strlenU(MAIN.InputBufU);
|
|
|
+ for(int i=0;i<UCount;i++){ if(la_AllowInput(MAIN.InputBufU[i])) la_SendInputEvent(e.xkey.window, MAIN.InputBufU[i]); }
|
|
|
+ }
|
|
|
+
|
|
|
+ XFree(result);
|
|
|
+ return True;
|
|
|
+ }
|
|
|
+ case SelectionRequest:
|
|
|
+ if(!MAIN.CopyPending){ break; }
|
|
|
+ char* text=MAIN.CopyPending->Ptr; int size=strlen(text);
|
|
|
+ if (e.xselectionrequest.selection != MAIN.selection) break;
|
|
|
+ XSelectionRequestEvent * xsr = &e.xselectionrequest;
|
|
|
+ XSelectionEvent ev = {0};
|
|
|
+ int R = 0;
|
|
|
+ ev.type = SelectionNotify, ev.display = xsr->display, ev.requestor = xsr->requestor,
|
|
|
+ ev.selection = xsr->selection, ev.time = xsr->time, ev.target = xsr->target, ev.property = xsr->property;
|
|
|
+ if (ev.target == MAIN.targets_atom) R = XChangeProperty (ev.display, ev.requestor, ev.property, XA_ATOM, 32,
|
|
|
+ PropModeReplace, (unsigned char*)&MAIN.UTF8, 1);
|
|
|
+ else if (ev.target == XA_STRING || ev.target == MAIN.text_atom)
|
|
|
+ R = XChangeProperty(ev.display, ev.requestor, ev.property, XA_STRING, 8, PropModeReplace, text, size);
|
|
|
+ else if (ev.target == MAIN.UTF8)
|
|
|
+ R = XChangeProperty(ev.display, ev.requestor, ev.property, MAIN.UTF8, 8, PropModeReplace, text, size);
|
|
|
+ else ev.property = None;
|
|
|
+ if ((R & 2) == 0) XSendEvent (MAIN.dpy, ev.requestor, 0, 0, (XEvent *)&ev);
|
|
|
+ break;
|
|
|
+ case SelectionClear:
|
|
|
+ return;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(laWindow* w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
+ if(SendDelay) { la_SendTimerEvent(w->win, LA_TIME_DELAY); MAIN.DelayTriggered=1; }
|
|
|
+ if(SendIdle) { la_SendTimerEvent(w->win, LA_TIME_IDLE); MAIN.IdleTriggered=1; }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 1;
|
|
|
+};
|
|
|
+
|
|
|
+void la_PrintOperatorStack(){
|
|
|
+ laWindow *w = MAIN.CurrentWindow;
|
|
|
+ laOperator *a;
|
|
|
+ printf("\n");
|
|
|
+ for (a = w->Operators.pFirst; a; a = a->Item.pNext){
|
|
|
+ printf("OP [%-25s] For [0x%08x] Child[%-25s][0x%08x]\n",
|
|
|
+ a->Type->Identifier, a->Instance,
|
|
|
+ (a->Child ? a->Child->Type->Identifier : ""), a->Child);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int la_DrawWindow(laWindow *w){
|
|
|
+ MAIN.CurrentWindow = w;
|
|
|
+ la_WindowDefDraw(w, 0);
|
|
|
+}
|
|
|
+void laMainLoop(){
|
|
|
+ laWindow *w = MAIN.Windows.pFirst, *NextW;
|
|
|
+ laTimeRecorder FrameStartTime, FrameEndTime;
|
|
|
+ time_t t1, t2;
|
|
|
+ real TimeInterval, Pause, TimeAccum = 0, FrameInterval;
|
|
|
+ static int a = 0;
|
|
|
+
|
|
|
+ if(!laValidateProperties()){ laShutoff(); return; }
|
|
|
+
|
|
|
+ MAIN.DelayTriggered=1;
|
|
|
+
|
|
|
+ laCopyToClipboard("Hello clipboard!");
|
|
|
+
|
|
|
+ while (1){
|
|
|
+ laRecordTime(&FrameStartTime);
|
|
|
+
|
|
|
+ if(!la_ProcessSysMessage()){ return; }
|
|
|
+
|
|
|
+ la_UpdateControllerStatus();
|
|
|
+
|
|
|
+ for (w=MAIN.Windows.pFirst;w;w = NextW){
|
|
|
+ NextW = w->Item.pNext;
|
|
|
+ if(!la_HandleEvents(w)) return;
|
|
|
+ }
|
|
|
+ for(w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
+ tnsSwitchToCurrentWindowContext(w);
|
|
|
+ la_DrawWindow(w);
|
|
|
+ }
|
|
|
+ for(w=MAIN.Windows.pFirst;w;w=w->Item.pNext){
|
|
|
+ glXSwapBuffers(MAIN.dpy, w->win);
|
|
|
+ }
|
|
|
+ //t2 = clock();
|
|
|
+ laRecordTime(&FrameEndTime);
|
|
|
+ TimeInterval = /* (t2 - t1) / 1000.0;*/ laTimeElapsedSecondsf(&FrameEndTime, &FrameStartTime);
|
|
|
+ Pause = (1.0 / MAIN.TopFramerate - TimeInterval);
|
|
|
+
|
|
|
+ if (Pause > 0){
|
|
|
+ int ms = Pause * 1000000.0;
|
|
|
+ usleep(ms);
|
|
|
+ }
|
|
|
+
|
|
|
+ laRecordTime(&FrameEndTime);
|
|
|
+ TimeInterval = /* (t2 - t1) / 1000.0;*/ laTimeElapsedSecondsf(&FrameEndTime, &FrameStartTime);
|
|
|
+
|
|
|
+ MAIN.TimeAccum += (MAIN.LastFrameTime = (Pause + TimeInterval));
|
|
|
+ FrameInterval = 1.0 / MAIN.Animation.FrameRate;
|
|
|
+ }
|
|
|
+}
|