/*
* LaGUI: A graphical application framework.
* Copyright (C) 2022 Wu Yiming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../la_5.h"
extern LA MAIN;
extern tnsMain* T;
laWidget _LA_WIDGET_FIXED_GROUP={0};
laWidget _LA_WIDGET_TAB={0};
laWidget _LA_WIDGET_COLLECTION={0};
laWidget _LA_WIDGET_COLLECTION_ITEM={0};
laWidget _LA_WIDGET_COLLECTION_SELECTOR={0};
laWidget _LA_WIDGET_COLLECTION_SINGLE={0};
laWidget _LA_WIDGET_CONDITION_TOGGLE={0};
laWidget _LA_WIDGET_COLUMN_ADJUSTER={0,LA_UI_FLAGS_NO_HEIGHT};
laWidget _LA_WIDGET_COLUMN_VIEWER={0};
laWidget _LA_WIDGET_BUTTON={0};
laWidget _LA_WIDGET_BUTTON_NO_CONFIRM={0};
laWidget _LA_WIDGET_LABEL={0};
laWidget _LA_WIDGET_INT={0};
laWidget _LA_WIDGET_INT_PLAIN={0, LA_UI_FLAGS_PLAIN};
laWidget _LA_WIDGET_INT_PLAIN_ICON={0, LA_UI_FLAGS_INT_ICON};
laWidget _LA_WIDGET_VALUE_METER={0,LA_TEXT_ALIGN_CENTER};
laWidget _LA_WIDGET_VALUE_METER_2D={0,LA_TEXT_ALIGN_CENTER};
laWidget _LA_WIDGET_FLOAT={0};
laWidget _LA_WIDGET_FLOAT_PLAIN={0, LA_UI_FLAGS_PLAIN};
laWidget _LA_WIDGET_FLOAT_COLOR={0};
laWidget _LA_WIDGET_FLOAT_COLOR_HCY={0};
laWidget _LA_WIDGET_ENUM_SELECTOR={0};
laWidget _LA_WIDGET_ENUM_SELECTOR_ICON={0, LA_UI_FLAGS_ICON};
laWidget _LA_WIDGET_ENUM_CYCLE={0, LA_UI_FLAGS_CYCLE};
laWidget _LA_WIDGET_ENUM_CYCLE_ICON={0, LA_UI_FLAGS_CYCLE|LA_UI_FLAGS_ICON};
laWidget _LA_WIDGET_ENUM_ICON_PLAIN={0, LA_UI_FLAGS_PLAIN|LA_UI_FLAGS_ICON};
laWidget _LA_WIDGET_ENUM_HIGHLIGHT={0, LA_UI_FLAGS_HIGHLIGHT|LA_UI_FLAGS_CYCLE|LA_TEXT_ALIGN_CENTER};
laWidget _LA_WIDGET_STRING={0};
laWidget _LA_WIDGET_STRING_PLAIN={0, LA_UI_FLAGS_PLAIN};
laWidget _LA_WIDGET_STRING_MONO_PLAIN={0, LA_TEXT_MONO|LA_UI_FLAGS_PLAIN};
laWidget _LA_WIDGET_STRING_MULTI={0, LA_TEXT_MONO};
laWidget _LA_WIDGET_MENU_ROOT={0};
laWidget _LA_WIDGET_ALIGN={0};
laWidget _LA_WIDGET_3D_VIEW={0};
laWidget _LA_WIDGET_2D_VIEW={0};
laWidget _LA_WIDGET_SYMBOL={0};
laWidget _LA_WIDGET_NODE_SOCKET={0};
laWidget _LA_WIDGET_HEIGHT_ADJUSTER={0};
laWidget _LA_WIDGET_RAW={0};
laWidget _LA_WIDGET_MAPPER={0};
laWidget *LA_WIDGET_FIXED_GROUP=&_LA_WIDGET_FIXED_GROUP;
laWidget *LA_WIDGET_TAB=&_LA_WIDGET_TAB;
laWidget *LA_WIDGET_COLLECTION=&_LA_WIDGET_COLLECTION;
laWidget *LA_WIDGET_COLLECTION_ITEM=&_LA_WIDGET_COLLECTION_ITEM;
laWidget *LA_WIDGET_COLLECTION_SELECTOR=&_LA_WIDGET_COLLECTION_SELECTOR;
laWidget *LA_WIDGET_COLLECTION_SINGLE=&_LA_WIDGET_COLLECTION_SINGLE;
laWidget *LA_WIDGET_CONDITION_TOGGLE=&_LA_WIDGET_CONDITION_TOGGLE;
laWidget *LA_WIDGET_COLUMN_ADJUSTER=&_LA_WIDGET_COLUMN_ADJUSTER;
laWidget *LA_WIDGET_COLUMN_VIEWER=&_LA_WIDGET_COLUMN_VIEWER;
laWidget *LA_WIDGET_BUTTON=&_LA_WIDGET_BUTTON;
laWidget *LA_WIDGET_BUTTON_NO_CONFIRM=&_LA_WIDGET_BUTTON_NO_CONFIRM;
laWidget *LA_WIDGET_LABEL=&_LA_WIDGET_LABEL;
laWidget *LA_WIDGET_INT=&_LA_WIDGET_INT;
laWidget *LA_WIDGET_INT_PLAIN=&_LA_WIDGET_INT_PLAIN;
laWidget *LA_WIDGET_INT_PLAIN_ICON=&_LA_WIDGET_INT_PLAIN_ICON;
laWidget *LA_WIDGET_VALUE_METER=&_LA_WIDGET_VALUE_METER;
laWidget *LA_WIDGET_VALUE_METER_2D=&_LA_WIDGET_VALUE_METER_2D;
laWidget *LA_WIDGET_FLOAT=&_LA_WIDGET_FLOAT;
laWidget *LA_WIDGET_FLOAT_PLAIN=&_LA_WIDGET_FLOAT_PLAIN;
laWidget *LA_WIDGET_FLOAT_COLOR=&_LA_WIDGET_FLOAT_COLOR;
laWidget *LA_WIDGET_FLOAT_COLOR_HCY=&_LA_WIDGET_FLOAT_COLOR_HCY;
laWidget *LA_WIDGET_ENUM_SELECTOR=&_LA_WIDGET_ENUM_SELECTOR;
laWidget *LA_WIDGET_ENUM_SELECTOR_ICON=&_LA_WIDGET_ENUM_SELECTOR_ICON;
laWidget *LA_WIDGET_ENUM_CYCLE=&_LA_WIDGET_ENUM_CYCLE;
laWidget *LA_WIDGET_ENUM_CYCLE_ICON=&_LA_WIDGET_ENUM_CYCLE_ICON;
laWidget *LA_WIDGET_ENUM_ICON_PLAIN=&_LA_WIDGET_ENUM_ICON_PLAIN;
laWidget *LA_WIDGET_ENUM_HIGHLIGHT=&_LA_WIDGET_ENUM_HIGHLIGHT;
laWidget *LA_WIDGET_STRING=&_LA_WIDGET_STRING;
laWidget *LA_WIDGET_STRING_PLAIN=&_LA_WIDGET_STRING_PLAIN;
laWidget *LA_WIDGET_STRING_MULTI=&_LA_WIDGET_STRING_MULTI;
laWidget *LA_WIDGET_STRING_MONO_PLAIN=&_LA_WIDGET_STRING_MONO_PLAIN;
laWidget *LA_WIDGET_MENU_ROOT=&_LA_WIDGET_MENU_ROOT;
laWidget *LA_WIDGET_ALIGN=&_LA_WIDGET_ALIGN;
laWidget *LA_WIDGET_3D_VIEW=&_LA_WIDGET_3D_VIEW;
laWidget *LA_WIDGET_2D_VIEW=&_LA_WIDGET_2D_VIEW;
laWidget *LA_WIDGET_SYMBOL=&_LA_WIDGET_SYMBOL;
laWidget *LA_WIDGET_NODE_SOCKET=&_LA_WIDGET_NODE_SOCKET;
laWidget *LA_WIDGET_HEIGHT_ADJUSTER=&_LA_WIDGET_HEIGHT_ADJUSTER;
laWidget *LA_WIDGET_RAW=&_LA_WIDGET_RAW;
laWidget *LA_WIDGET_MAPPER=&_LA_WIDGET_MAPPER;
//============================================== [Draw]
int la_ArrayGetHeight(laUiItem *ui){
return laGetArrayLength(&ui->PP);
}
int la_ValueGetHeight(laUiItem*ui){
if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return la_ArrayGetHeight(ui); }
return 1;
}
int la_ValueMeterGetHeight(laUiItem*ui){
if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){ return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:6; }
return laGetArrayLength(&ui->PP);
}
int la_ValueMeter2DGetHeight(laUiItem*ui){
return ui->Extra->HeightCoeff?ui->Extra->HeightCoeff:(ui->Extra->HeightCoeff=(ui->TR-ui->TL)/LA_RH);
}
int la_CanvasGetHeight(laUiItem *ui){
return ui->Expand;
}
int la_EnumGetHeight(laUiItem *ui){
// norm e1
// expand e1 e2 e3
// expand vertical (vertical)
// arr expand e1 e2 e3
// e1 e2 e3
// arr exp+vert e1 e1
// e2 e2
// e3 e3
int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
int ArrLen = laGetArrayLength(&ui->PP);
if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
if(ArrLen==1){
if(IsVertical&&IsExpand) return laGetEnumEntryLen(&ui->PP);
return 1;
}else{
if(IsVertical) return EnumLen;
else return ArrLen;
}
}
int la_ColorPickerGetHeight(laUiItem *ui){
if(!ui->Extra->HeightCoeff) ui->Extra->HeightCoeff=7;
return ui->Extra->HeightCoeff;
}
int la_SymbolGetHeight(laUiItem *ui){
//if (!ui->State)
//{
// ui->State = (int)_ICON_SYMBOL_SIZE[ui->SymbolID - ICON_SYMBOL_START] * 1.4 + 1;
//}
return ui->State;
}
int la_GroupGetHeight(laUiItem *ui){
if (ui->State == LA_UI_ACTIVE) return 0;
return LA_RH;
}
int la_StringPropGetHeight(laUiItem *ui){
laBoxedTheme *bt = *ui->Type->Theme;
if(!(ui->Flags&LA_TEXT_LINE_WRAP)) return 1;
char _buf[LA_RAW_CSTR_MAX_LEN]={0}; char* buf=_buf;
laGetString(&ui->PP, _buf, &buf); int rows=0;
int strw=tnsStringGetDimension(buf, 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
return rows;
}
int la_MultiStringHeight(laUiItem *ui){
laGeneralUiExtraData *e = ui->Extra;
return e->HeightCoeff;
}
int la_LabelHeight(laUiItem *ui){
int Wrap=ui->Flags&LA_TEXT_LINE_WRAP;
if(!Wrap) return 1;
int rows;
tnsStringGetDimension(ui->Display->Ptr, 0, 0, ui->TR-ui->TL, &rows, ui->Flags&LA_TEXT_MONO);
return rows;
}
int la_SocketGetHeight(laUiItem *ui){
if(ui->Flags&(LA_UI_SOCKET_LABEL_N|LA_UI_SOCKET_LABEL_S))return 2; return 1;
}
int la_ColorSelectorGetMinWidth(laUiItem *ui){
return 5*LA_RH;
}
int la_ValueGetMinWidth(laUiItem *ui){
int ExtraW=0;
if(ui->Flags&LA_UI_FLAGS_EXPAND){ ExtraW+=tnsStringGetWidth(ui->PP.LastPs->p->Name,0,0); }
return LA_RH*4+ExtraW;
}
int la_LabelGetMinWidth(laUiItem *ui){
laBoxedTheme *bt = *ui->Type->Theme;
int strw=tnsStringGetWidth(ui->Display->Ptr, 0, ui->Flags&LA_TEXT_MONO);
if(ui->Type==_LA_UI_MENU_ROOT && strwLM + bt->RM);
}
int la_StringPropGetMinWidth(laUiItem *ui){
laBoxedTheme *bt = *ui->Type->Theme;
char _buf[LA_RAW_CSTR_MAX_LEN]={0}; int ExtraW=0; char* buf=_buf;
if(ui->Type == _LA_UI_STRING_MULTI){ExtraW=2*LA_RH+bt->LM;}
laGetString(&ui->PP, _buf, &buf); int rows=0;
int strw=tnsStringGetDimension(buf, 0, 0, 0, &rows, ui->Flags&LA_TEXT_MONO);
int Plain = ui->Flags&LA_UI_FLAGS_PLAIN;
if((!Plain)&&strwLM + bt->RM+ExtraW);
}
int la_EnumGetMinWidth(laUiItem *ui){
laBoxedTheme *bt = *ui->Type->Theme;
laEnumProp *ep = ui->PP.LastPs->p;
laEnumItem *i;
int W = 0; int tW;
int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
int IsIcon = ui->Flags&LA_UI_FLAGS_ICON;
int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
int SharedWidth;
if(!IsIcon){
SharedWidth = bt->LM + bt->RM + ((IsCycle||IsExpand)?0:LA_RH); int HasIcon=0;
if(Highlight){
if (ui->ExtraInstructions){
if (ui->Type->OperatorType->ParseArgs){
int ico; char buf[256]; buf[0]=0;
ui->Type->OperatorType->ParseArgs(ui->Instructions, &ico, buf);
tW = tnsStringGetWidth(buf, 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
}
}else{
tW = tnsStringGetWidth(ep->Base.Name, 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
}
if (tW > W) W = tW;
}else{
for (i = ep->Items.pFirst; i; i = i->Item.pNext){
tW = tnsStringGetWidth(i->Name, 0, ui->Flags&LA_TEXT_MONO) + SharedWidth;
if (i->IconID){ HasIcon=1; }
if (tW > W) W = tW;
}
if(HasIcon) W+=bt->LM+LA_RH;
}
}else{
W = LA_RH;
}
int ArrLen = laGetArrayLength(&ui->PP);
if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
if(ArrLen==1){
if(!IsVertical) return W*EnumLen;
return W;
}else{
if(IsVertical) return ArrLen*W;
return EnumLen*W;
}
return W;
}
int la_ButtonGetMinWidth(laUiItem *ui){
laBoxedTheme *bt = *ui->Type->Theme;
uint32_t IconID;
char buf[LA_RAW_CSTR_MAX_LEN]={0};
char *label;
laOperatorProp *ap;
int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
if(IconOnly) return LA_RH;
if (ui->PP.LastPs && ui->PP.LastPs->p){
ap = ui->PP.LastPs->p;
label = ap->Base.Name;
IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
}else{
label = ui->AT->Name;
IconID = ui->AT->IconID;
}
if (ui->ExtraInstructions){
if (ui->AT && ui->AT->ParseArgs){
ui->AT->ParseArgs(ui->Instructions, &IconID, buf);
if (buf[0]) label = buf;
}else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
laOperatorProp *ap = ui->PP.LastPs->p;
if (ap->OperatorType && ap->OperatorType->ParseArgs){
ap->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
if (buf[0]) label = buf;
}
}
}
int strw=tnsStringGetWidth(label, 0, ui->Flags&LA_TEXT_MONO);
if(strw){ strw+=bt->RM+bt->LM; }
return ((IconID ? (LA_RH) : 0) + strw);
}
int la_ColumnViewerGetMinWidth(laUiItem *ui){
return 350;
}
int la_ColorPickerGetMinWidth(laUiItem *ui){
return LA_RH * 9;
}
int la_SocketGetMinWidth(laUiItem *ui){
if(ui->Flags&(LA_UI_SOCKET_LABEL_W|LA_UI_SOCKET_LABEL_E))return LA_RH*3;
if(ui->Flags&(LA_UI_SOCKET_LABEL_S|LA_UI_SOCKET_LABEL_N))return LA_RH*2;
return LA_RH;
}
void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se);
void la_CollectionSelectorDraw(laUiItem *ui, int h){
char temp[128] = {0};
laBoxedTheme *bt = (*ui->Type->Theme);
real Color[16] = {0};
tnsVector4d Transp = {0};
int CrossDraw = 0;
if (!ui->State) ui->State = LA_UI_NORMAL;
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,ui->State));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
CrossDraw = laGetActiveInstanceStrict(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance) ? 1 : 0;
if (CrossDraw){
tnsVectorCopy4d(laThemeColor(bt,LA_BT_BORDER), Transp);
Transp[3] = 0;
tnsMakeLinerGradient4dv(Color, 2, Transp, laThemeColor(bt,LA_BT_BORDER));
tnsMakeLinerGradient4dv(&Color[8], 2, Transp, laThemeColor(bt,LA_BT_BORDER));
//tnsMakeLinerGradient4dv(&Color[8], 2, laThemeColor(bt, LA_BT_BORDER), Transp);
tnsVertex2d(ui->R - LA_RH, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R - LA_RH, ui->B);
tnsVertex2d(ui->R, ui->B);
tnsColorArray4d(Color, 4);
tnsPackAs(GL_TRIANGLE_STRIP);
}
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
if (CrossDraw){
tnsDrawStringAuto("๐งน", laThemeColor(bt,ui->State|LA_BT_TEXT), ui->R - LA_RH, ui->R, ui->U, 0);
}
}
void la_EmptyDraw(laUiItem *ui, int h){
char temp[128] = {0};
laBoxedTheme *bt = (*ui->Type->Theme);
if (!ui->State) ui->State = LA_UI_NORMAL;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}
}
void la_GroupDraw(laUiItem *ui, int h){
char temp[128] = {0};
laBoxedTheme *bt = (*ui->Type->Theme);
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}
if (ui->State != LA_UI_ACTIVE){
tnsDrawStringAuto(ui->Page ? transLate(ui->Page->TabName->Ptr) : transLate("No Page"),
laThemeColor(bt,ui->State|LA_BT_TEXT), ui->L+bt->LM, ui->R+bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
}
}
void la_TabDraw(laUiItem *ui, int h){
char temp[128] = {0};
laBoxedTheme *bt = (*ui->Type->Theme);
laUiList *uil;
int count = 0;
int w; // = (ui->R - ui->L) / count;
int page = 0;
int l = ui->L;
for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
count++;
}
w = (ui->R - ui->L) / (count == 0 ? 1 : count);
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U + h);
tnsVertex2d(ui->L, ui->B);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->R, ui->U + h);
tnsPackAs(GL_LINE_LOOP);
}
for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
l = page * w;
if (uil != ui->Page){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_ACTIVE));
tnsVertex2d(ui->L + l, ui->U);
tnsVertex2d(ui->L + l + w, ui->U);
tnsVertex2d(ui->L + l + w, ui->U + h);
tnsVertex2d(ui->L + l, ui->U + h);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L + l, ui->U + h);
tnsVertex2d(ui->L + l, ui->U);
tnsVertex2d(ui->L + l + w, ui->U);
tnsVertex2d(ui->L + l + w, ui->U + h);
tnsPackAs(GL_LINE_STRIP);
tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,LA_BT_TEXT), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
}else{
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L + l, ui->U);
tnsVertex2d(ui->L + l + w, ui->U);
tnsVertex2d(ui->L + l + w, ui->U + h);
tnsVertex2d(ui->L + l, ui->U + h);
tnsPackAs(GL_TRIANGLE_FAN);
tnsDrawStringAuto(transLate(uil->TabName->Ptr), laThemeColor(bt,LA_BT_TEXT_ACTIVE), ui->L+l+bt->LM, ui->L+l+w-bt->RM, ui->U, LA_TEXT_ALIGN_CENTER);
}
page++;
}
tnsFlush();
}
void la_SymbolDraw(laUiItem *ui, int h){
return;
//char temp[128] = {0};
//laBoxedTheme *bt = (*ui->Type->Theme);
//tnsFontSingleCharacter *fsc = tfntFetchVectorGraphTextureIDW(ui->SymbolID);
//int VOffset = (ui->B - ui->U - (fsc->height)) / 2;
//int HOffset = (ui->R - ui->L - (fsc->width)) / 2;
//
//if (strArgumentMatch(ui->Instructions, "mode", "invert"))
//{
// tnsUseNoTexture();
// //tnsColor4dv(laThemeColor(bt, ui->State));
// //tnsVertex2d(ui->L, ui->U);
// //tnsVertex2d(ui->R, ui->U);
// //tnsVertex2d(ui->R, ui->B);
// //tnsVertex2d(ui->L, ui->B);
// //tnsPackAs(GL_TRIANGLE_FAN);
//
// tnsUseNoTexture();
// tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
// tnsVertex2d(ui->L, ui->U);
// tnsVertex2d(ui->R, ui->U);
// tnsVertex2d(ui->R, ui->B);
// tnsVertex2d(ui->L, ui->B);
// tnsPackAs(GL_TRIANGLE_FAN);
//
// // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_THEME_INTERPOLATING), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
//}
//else
//{
// //if (!ui->State) ui->State = LA_UI_NORMAL;
//
// /*tnsUseNoTexture();
// tnsColor4dv(laThemeColor(bt, ui->State));
// tnsVertex2d(ui->L, ui->U);
// tnsVertex2d(ui->R, ui->U);
// tnsVertex2d(ui->R, ui->B);
// tnsVertex2d(ui->L, ui->B);
// tnsPackAs(GL_TRIANGLE_FAN);*/
//
// //tnsUseNoTexture();
//tnsColor4dv(LA_THEME_GET(bt, LA_UI_NORMAL)->BorderColor->RGBA);
//tnsVertex2d(ui->L, ui->U);
//tnsVertex2d(ui->R, ui->U);
//tnsVertex2d(ui->R, ui->B);
//tnsVertex2d(ui->L, ui->B);
//tnsPackAs(GL_LINE_LOOP);
//
// // tnsDrawVectorGraphPackage(ui->SymbolID, LA_THEME_GET(bt, LA_UI_NORMAL), ui->L + HOffset, ui->R, ui->U + VOffset, ui->B, 0, 0);
//}
}
void la_IntDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int Data[32];
int Len, i, Seg, W;
char buf[48] = {0};
char buf2[48] = {0};
char prefix[8][64] = {0};
int Original;
int Ranged;
int min, max;
int s, State;
int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int IsIcon=ui->Flags&LA_UI_FLAGS_ICON;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
laGetIntArray(&ui->PP, Data);
Len = laGetArrayLength(&ui->PP);
laGetPrefixP(&ui->PP, prefix);
Ranged = laGetIntRange(&ui->PP, &min, &max);
for (i = 0; i < Len; i++){
int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
if(IsVertical){
Seg = ui->R - ui->L;
_U = ui->U + i * LA_RH; _B = _U+LA_RH;
}else{
Seg = (ui->R - ui->L) / Len;
_L = ui->L + i * Seg; _R=_L+Seg;
}
if(IsIcon){
sprintf(buf, "%lc", laGetInt(&ui->PP));
}else{
buf[0] = '\0'; buf2[0] = '\0';
if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
if(i<8)strcat(Len==1?buf:buf2, &prefix[i]);
strPrintIntAfter(buf, 48, Data[i]);
strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
}
if (ui->Extra && ui->Extra->On == i + 1){
Original = ui->State;
ui->State = LA_UI_ACTIVE;
}
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,ui->State));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_TRIANGLE_FAN);
if (Ranged){
int L1 = _L;
int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
tnsColor4d(LA_COLOR3(color),0.3);
tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
tnsPackAs(GL_TRIANGLE_FAN);
}
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_LINE_LOOP);
}
if (ui->Extra->On == i + 1 && ui->Extra->Edit){
uint32_t *buf = strGetCursorLine(ui->Extra->Edit, 0)->Buf;
int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
}else{
tnsDrawStringWithPriority(buf2, buf, laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
}
if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
}
tnsFlush();
}
void la_FloatDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
real Data[32];
int Len, i, W, Seg;
char buf[48] = {0};
char buf2[48] = {0};
char prefix[8][64] = {0};
int Original;
int Ranged;
real min, max;
int s, State;
int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
int IsRad=ui->PP.LastPs->p->IsRadAngle;
if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
laGetFloatArray(&ui->PP, Data);
Len = laGetArrayLength(&ui->PP);
laGetPrefixP(&ui->PP, prefix);
Ranged = laGetFloatRange(&ui->PP, &min, &max);
for (i = 0; i < Len; i++){
int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
if(IsVertical){
Seg = ui->R - ui->L;
_U = ui->U + i * LA_RH; _B = _U+LA_RH;
}else{
Seg = (ui->R - ui->L) / Len;
_L = ui->L + i * Seg; _R=_L+Seg;
}
buf[0] = '\0'; buf2[0] = '\0';
if(Len==1){ strcat(buf2, transLate(ui->PP.LastPs->p->Name)); }
if(i<8)strcat(Len==1?buf:buf2, &prefix[i]);
strPrintFloatAfter(buf, 48, 3, IsRad?deg(Data[i]):Data[i]);
strAppend(buf, ui->PP.LastPs->p->Unit ? transLate(ui->PP.LastPs->p->Unit) : "");
if (ui->Extra && ui->Extra->On == i + 1){
Original = ui->State;
ui->State = LA_UI_ACTIVE;
}
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,ui->State));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_TRIANGLE_FAN);
if (Ranged){
int L1 = _L;
int R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(Seg) + L1;
tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
tnsColor4d(LA_COLOR3(color),0.3);
tnsVertex2d(L1, _U); tnsVertex2d(R1, _U);
tnsVertex2d(R1, _B); tnsVertex2d(L1, _B);
tnsPackAs(GL_TRIANGLE_FAN);
}
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_LINE_LOOP);
}
if (ui->Extra->On == i + 1 && ui->Extra->Edit){
uint32_t *buf = strGetCursorLine(ui->Extra->Edit,0)->Buf;
int LL = _L + (Seg - tnsStringGetWidthU(buf, 0, ui->Flags&LA_TEXT_MONO)) / 2;
tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
la_SingleLineStringDrawSelection(ui, _L, _U, bt, buf, ui->Extra->Edit);
tnsDrawStringM(0, buf, laThemeColor(bt, LA_BT_TEXT_ACTIVE), _L + bt->LM, _R - bt->RM, _U, ui->Flags);
}else{
tnsDrawStringWithPriority(buf2, buf, laThemeColor(bt, LA_BT_TEXT|ui->State), bt->TextAlign, _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
}
if (ui->Extra && ui->Extra->On == i + 1) ui->State = Original;
}
tnsFlush();
}
void la_FloatArrayColorDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
real Data[32];
int Len, i, Y = ui->U;
laGetFloatArray(&ui->PP, Data);
Len = laGetArrayLength(&ui->PP);
if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Data); }
tnsUseNoTexture();
tnsColor4d(Data[0], Data[1], Data[2], /*Len>3?Data[4]:*/ 1);
tnsVertex2d(ui->L, Y);
tnsVertex2d(ui->R, Y);
tnsVertex2d(ui->R, Y + h);
tnsVertex2d(ui->L, Y + h);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, Y);
tnsVertex2d(ui->R, Y);
tnsVertex2d(ui->R, Y + h);
tnsVertex2d(ui->L, Y + h);
tnsPackAs(GL_LINE_LOOP);
tnsFlush();
}
void la_EnumSelectorDraw(laUiItem *ui, int h){
laEnumItem *Data[32], Len;
laBoxedTheme *bt = (*ui->Type->Theme);
char buf[48] = {0};
char buf2[48] = {0};
char prefix[8][64]= {0};
laEnumProp *ep = ui->PP.LastPs->p;
int HasIcon = laEnumHasIcon(&ui->PP);
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
int NoEvent=ui->Flags&LA_UI_FLAGS_NO_EVENT;
int Highlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
// norm e1
// expand e1 e2 e3
// expand vertical (vertical)
// arr expand e1 e1 e3
// e2 e2 e3
// arr exp+vert e1 e1
// e2 e2
// e3 e3
tnsUseNoTexture();
laGetEnumArray(&ui->PP,Data);
laEnumItem* ei, *use_ei;
int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
int ArrLen = laGetArrayLength(&ui->PP);
if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
if(Highlight&&ArrLen!=1){laGetPrefixP(&ui->PP, prefix);}
if (laIsPropertyReadOnly(&ui->PP) && !NoDecal) ui->State = LA_BT_DISABLED;
int _L,_R,_U,_B, _W=ui->R - ui->L;
if(IsVertical){
if(IsExpand){ _W/=ArrLen; }
}else{
if(IsExpand){ _W/=EnumLen; }
else{ _W/=ArrLen; }
}
for(int i=0;iL; _R=ui->R; _U=ui->U; _B=ui->B; ei = ep->Items.pFirst;
for(int j=0;jU+j*LA_RH; _L=ui->L+i*_W; }
else{ _U=ui->U+i*LA_RH; _L=ui->L; }
}else{
if(IsExpand){ _U=ui->U+i*LA_RH; _L=ui->L+j*_W; }
else{ _U=ui->U; _L=ui->L+i*_W; }
}
_B=_U+LA_RH; _R=_L+_W;
int ExtraState=ui->State;
if(IsExpand&&!IsCycle){ use_ei = ei; ei=ei->Item.pNext; ExtraState=(use_ei==Data[i])?LA_BT_ACTIVE:0; }
else{ use_ei = Data[i]; if(Highlight && Data[i]->Index!=0){ ExtraState=LA_BT_ACTIVE; } }
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt, ExtraState));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_LINE_LOOP);
}
if (ui->ExtraInstructions){
if (ui->Type->OperatorType->ParseArgs){
int ico; buf[0]=0; ui->Type->OperatorType->ParseArgs(ui->Instructions, &ico, buf);
}
}
if(Highlight){ if(!buf[0] && ArrLen==1) strcpy(buf, transLate(ui->PP.LastPs->p->Name)); else{ if(i<8)strcat(buf, &prefix[i]); } }
if(!buf[0]) strcpy(buf, transLate(use_ei->Name));
int iconR; if(IconOnly)iconR=TNS_MAX2(_L+LA_RH,_R);else{ iconR=TNS_MIN2(_L+LA_RH,_R); }
if (use_ei->IconID) tnsDrawIcon(use_ei->IconID, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L,iconR, _U, LA_TEXT_ALIGN_CENTER);
if(!IconOnly){
int UseFlags=ui->Flags; if(!HasIcon && IsExpand){ if(!(UseFlags&LA_TEXT_ALIGN)); UseFlags|=LA_TEXT_ALIGN_CENTER; }
tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT|ExtraState), _L+bt->LM+(HasIcon?LA_RH:0), _R-bt->RM, _U, UseFlags);
}
if (!IsExpand && !IsVertical && !IconOnly && !IsCycle && !NoEvent){
tnsDrawIcon(L'๐ป', laThemeColor(bt, LA_BT_TEXT|ExtraState), _R-LA_RH, _R, _U, ui->Flags);
}
}
}
tnsFlush();
}
void la_ButtonDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
char buf[LA_RAW_CSTR_MAX_LEN] = {0};
char *label = 0;
uint32_t IconID=0;
int L;
char *Identifier;
laOperatorProp *ap = 0;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
int IconOnly=ui->Flags&LA_UI_FLAGS_ICON;
int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
if (ui->PP.LastPs && ui->PP.LastPs->p){
ap = ui->PP.LastPs->p;
label = transLate(ap->Base.Name);
if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
IconID = ap->Base.IconID ? ap->Base.IconID : ap->OperatorType->IconID;
}else{
label = transLate(ui->AT->Name);
IconID = ui->AT->IconID;
}
if (ui->AT && (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)))
ui->State = LA_UI_DISABLED;
elif (ap && ap->OperatorType && (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions))) ui->State = LA_UI_DISABLED;
else if (ui->State == LA_UI_DISABLED) ui->State = LA_UI_NORMAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(ui->State==LA_UI_NORMAL?(IsHighlight?laAccentColor(LA_BT_NORMAL):laThemeColor(bt, ui->State)):laThemeColor(bt, ui->State));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}
if (ui->ExtraInstructions){
uint32_t tIconID=0;
if (ui->AT && ui->AT->ParseArgs){
ui->AT->ParseArgs(ui->Instructions, &tIconID, buf);
if (buf[0]) label = buf;
if (tIconID) IconID=tIconID;
}else if (ui->PP.LastPs->p->PropertyType == LA_PROP_OPERATOR){
laOperatorProp *ap = ui->PP.LastPs->p;
if (ap->OperatorType && ap->OperatorType->ParseArgs){
ap->OperatorType->ParseArgs(ui->Instructions, &tIconID, buf);
if (buf[0]) label = buf;
if (tIconID) IconID=tIconID;
}
}
}
if (IconID) L = ui->L + bt->LM + h;
else L = ui->L + bt->LM;
if (IconID) tnsDrawIcon(IconID, laThemeColor(bt, ui->State|LA_BT_TEXT), ui->L, ui->L+LA_RH, ui->U, LA_TEXT_ALIGN_CENTER);
if (!IconOnly) tnsDrawStringAuto(label, laThemeColor(bt, ui->State|LA_BT_TEXT), L, ui->R-bt->RM, ui->U, ui->Flags);
}
void la_LabelDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
int IsHighlight=ui->Flags&LA_UI_FLAGS_HIGHLIGHT;
if (!ui->State) ui->State = LA_UI_NORMAL;
if (ui->ExtraInstructions && !ui->Instructions){
strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
}
//int State = ui->Instructions ? (strArgumentMatch(ui->Instructions, "disabled", "true") ? LA_THEME_DISABLED : LA_UI_NORMAL) : LA_UI_NORMAL;
tnsDrawStringAuto(transLate(ui->Display->Ptr),
IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):(IsHighlight?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT)),
ui->L, ui->R, ui->U, ui->Flags);
}
void la_SingleLineStringDrawSelection(laUiItem *ui, int Begin, int U, laBoxedTheme *bt, uint32_t *str, laStringEdit *se){
tnsUseNoTexture();
if (!strHasSelection(se)){
tnsColor4dv(laAccentColor(LA_BT_TEXT));
int L = (se->CursorBefore ? tnsStringGetWidthU(str, se->CursorBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
tnsVertex2d(L-1, U + LA_RH - bt->BM);
tnsVertex2d(L-1, U + bt->TM);
tnsVertex2d(L+2, U + bt->TM);
tnsVertex2d(L+2, U + LA_RH - bt->BM);
tnsPackAs(GL_TRIANGLE_FAN);
}else{
int L = (se->BeginBefore ? tnsStringGetWidthU(str, se->BeginBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
int R = (se->EndBefore ? tnsStringGetWidthU(str, se->EndBefore, ui->Flags&LA_TEXT_MONO) : 0) + Begin + bt->LM;
tnsColor4dv(laAccentColor(LA_BT_NORMAL));
tnsVertex2d(L, U + bt->TM);
tnsVertex2d(L, U + LA_RH - bt->BM);
tnsVertex2d(R, U + LA_RH - bt->TM);
tnsVertex2d(R, U + bt->BM);
tnsPackAs(GL_TRIANGLE_FAN);
}
}
void la_SingleLineStringDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
char* _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
uint32_t* line=0;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
if (!ui->State) ui->State = LA_UI_NORMAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt, ui->State));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}
if (ui->Extra && ui->Extra->Edit){
line=strGetCursorLine(ui->Extra->Edit,0)->Buf;
}else{
laGetString(&ui->PP, _temp, &temp);
}
if (line) la_SingleLineStringDrawSelection(ui, ui->L+(NoDecal?0:bt->LM), ui->U, bt, line, ui->Extra->Edit);
tnsDrawStringAutoM(line?0:temp, line, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):laThemeColor(bt,LA_BT_TEXT), ui->L+(NoDecal?0:bt->LM), ui->R-(NoDecal?0:bt->RM), ui->U, ui->Flags);
}
void la_MultiStringDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
char _temp[LA_RAW_CSTR_MAX_LEN] = {0}; char* temp=_temp;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if (!ui->State) ui->State = LA_UI_NORMAL;
int NumberWidth=bt->LM;
if(!ui->Extra->Edit){
laGetString(&ui->PP, _temp, &temp);
strBeginEdit(&ui->Extra->Edit, temp);
}
laStringEdit* se=ui->Extra->Edit;
int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
while(Count){ Count/=10; NumberWidth+=MonoWidth; }
if (ui->State!=LA_UI_ACTIVE){
strSetEditViewRange(ui->Extra->Edit,
ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
}
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt, ui->State));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
tnsColor4d(LA_COLOR3(laThemeColor(bt,LA_BT_BORDER)),0.8);
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->L+NumberWidth, ui->U);
tnsVertex2d(ui->L, ui->B); tnsVertex2d(ui->L+NumberWidth, ui->B);
tnsPackAs(GL_QUADS);
if(!(se->CursorLineViewStartLine||se->CursorLine>se->ViewStartLine+se->ViewHeight)){
int LineU=(se->CursorLine-se->ViewStartLine)*LA_RH+ui->U;
tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_NORMAL):laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->R, LineU);
tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->R, LineU+LA_RH);
tnsPackAs(GL_LINES);
tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
tnsVertex2d(ui->L, LineU); tnsVertex2d(ui->L+NumberWidth, LineU);
tnsVertex2d(ui->L, LineU+LA_RH); tnsVertex2d(ui->L+NumberWidth, LineU+LA_RH);
tnsPackAs(GL_QUADS);
}
}else{
NumberWidth=bt->LM;
}
tnsColor4dv(laThemeColor(bt, LA_BT_TEXT));
int Line=0, Skip=0, _L=ui->L+NumberWidth+bt->LM; char num[10]={0};
for(laStringLine* sl=se->Lines.pFirst;sl;sl=sl->Item.pNext){
int UseLine=Line+Skip;
if(UseLineViewStartLine){ Skip++; continue; }
if(UseLine>=se->ViewHeight+se->ViewStartLine){ break; }
int slen=strlenU(sl->Buf);
sprintf(num,"%d", UseLine+1); int LineU=ui->U+Line*LA_RH;
tnsDrawStringM(num, 0, laThemeColor(bt, ((UseLine==se->CursorLine)?LA_BT_NORMAL:LA_BT_TEXT)),
_L-bt->LM -(tnsStringGetWidth(num, 0, ui->Flags&LA_TEXT_MONO)), ui->R, LineU, ui->Flags);
if(slen>=se->ViewStartCol){
tnsDrawStringM(0, &sl->Buf[se->ViewStartCol], laThemeColor(bt, ui->State|LA_BT_TEXT), _L, ui->R, LineU, ui->Flags|LA_TEXT_OVERFLOW_ARROW);
}
if(UseLine>=se->BeginLine&&UseLine<=se->EndLine){
int BeginC=UseLine==se->BeginLine?se->BeginBefore:0; int EndC=UseLine==se->EndLine?se->EndBefore:slen;
BeginC-=se->ViewStartCol; EndC-=se->ViewStartCol; if(EndC>se->ViewWidth)EndC=se->ViewWidth;
tnsUseNoTexture();
tnsVertex2d(BeginC*MonoWidth+_L, LineU); tnsVertex2d(EndC*MonoWidth+_L, LineU);
tnsVertex2d(EndC*MonoWidth+_L, LineU+LA_RH); tnsVertex2d(BeginC*MonoWidth+_L, LineU+LA_RH);
tnsColor4dv(laAccentColor(LA_BT_NORMAL));
tnsPackAs(GL_TRIANGLE_FAN);
}
int len=strlenU(sl->Buf);
if(UseLine==se->CursorLine){
int Dist=se->CursorBefore==0?0:tnsStringGetWidthU(sl->Buf,se->CursorBefore,ui->Flags&LA_TEXT_MONO);
tnsUseNoTexture(); int d=se->ViewStartCol*MonoWidth;
tnsColor4dv(ui->State==LA_UI_ACTIVE?laAccentColor(LA_BT_TEXT):laThemeColor(bt,LA_BT_TEXT_NORMAL));
tnsVertex2d(_L+Dist-d, LineU); tnsVertex2d(_L+Dist+3-d, LineU);
tnsVertex2d(_L+Dist-d, LineU+LA_RH); tnsVertex2d(_L+Dist+3-d, LineU+LA_RH);
tnsPackAs(GL_QUADS);
}
Line++;
tnsFlush();
}
if(ui->Extra->HeightCoeff>=0)
tnsDrawStringAuto("โฟ",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
if(!NoDecal){
char buf[100]={0}; sprintf(buf, "%d,%d | %d Lines", se->CursorLine+1, se->CursorBefore+1, se->TotalLines);
tnsDrawStringAuto(buf,laThemeColor(bt,LA_BT_BORDER),ui->L, ui->R-LA_RH, ui->B-bt->BM-LA_RH, LA_TEXT_MONO|LA_TEXT_ALIGN_RIGHT);
}
//if (ui->Extra && ui->Extra->Edit) la_SingleLineStringDrawSelection(ui, ui->L, ui->U, bt, temp, ui->Extra->Edit);
tnsFlush();
}
void la_UiSeperatorDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
if (!bt) return;
if(ui->Flags&LA_UI_FLAGS_TRANSPOSE){
char str[]="๐";
int strw=tnsStringGetWidth(str,0, 0);
tnsDrawStringM(str, 0, laThemeColor(bt,LA_BT_BORDER), ui->L+(ui->R-ui->L-strw)/2, ui->R, ui->U, 0);
}else{
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsPackAs(GL_LINES);
}
}
void la_ColorCircleDrawHCY(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
real c = (real)((ui->R + ui->L) / 2) - h / 2; /*- bt->RM*/
;
real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
int i = 0;
real colors[584]={0}; //4*72*2+4*2
real verts[292]={0}; //72*2*2+2*2
real hcy[3] = {0, 1, 1};
real step = 1.0 / 72.0f;
real RealColor[4] = {0,0,0,1};
real PickerPos[2];
real pi_4;
GLuint index[26];
real v, cv, sv;
laGetFloatArray(&ui->PP, RealColor);
if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(RealColor); }
tnsRGB2HCY(RealColor, hcy);
PickerPos[0] = c + cos(hcy[0] * TNS_PI * 2) * hcy[1] * r;
PickerPos[1] = ui->U + r + sin(hcy[0] * TNS_PI * 2) * hcy[1] * r;
hcy[0] = 0;
hcy[1] = 1;
for (i; i < 72; i += 1){
int beg = i * 8;
hcy[0]+=step; tnsVectorSet3v(&colors[beg],hcy); colors[beg+3]=1;
tnsVectorSet4v(&colors[beg+4],&colors[beg]); colors[beg+5]=0;
}
tnsFlush();
int IsClay=ui->Flags&LA_UI_FLAGS_COLOR_SPACE_CLAY;
int ShowInfo=0;
if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_SRGB && (!IsClay)){
tnsUniformShowColorOverflowStripes(T->immShader,1);
}
if(IsClay){
tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_CLAY);
if(MAIN.CurrentWindow->OutputColorSpace!=TNS_COLOR_SPACE_CLAY) ShowInfo=1;
}else{
tnsUniformInputColorSpace(T->immShader,TNS_COLOR_SPACE_SRGB);
}
tnsUseNoTexture();
tnsVectorSet4(&colors[576],1,1,hcy[2],1);
tnsVectorSet4(&colors[580],1,0,hcy[2],1);
tnsColorArray4d(colors, 146);
tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 1);
for(int i=0;i<73;i++){ tnsVectorSet2(&verts[2+i*4],c,ui->U + r); }
tnsVectorSet4v(&verts[288],&verts[0]);
tnsVectorSet4v(&verts[290],&verts[2]);
tnsVertexArray2d(verts, 146);
tnsPackAs(GL_TRIANGLE_STRIP);
tnsUniformColorMode(T->immShader,1);
tnsFlush();
tnsUniformColorMode(T->immShader,0);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsMakeCircle2d(verts, 72, c, ui->U + r, r, 0);
tnsVertexArray2d(verts, 72);
tnsPackAs(GL_LINE_LOOP);
pi_4 = TNS_PI / 4;
tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, pi_4, -pi_4);
tnsMakeArc2d(verts, 12, c, ui->U + r, r + bt->LM, pi_4, -pi_4);
tnsMakeLinerGradient4d(&colors[52], 13, 0, 0, 0, 1, 1, 1, 1, 1);
tnsMakeLinerGradient4d(colors, 13, 0, 0, 0, 1, 1, 1, 1, 1);
tnsMakeBridgedIndex(index, 13, 0, 0);
tnsColorArray4d(colors, 26);
tnsVertexArray2d(verts, 26);
tnsIndexArray(index, 26);
tnsPackAs(GL_QUAD_STRIP);
tnsMakeArc2d(&verts[26], 12, c, ui->U + r, r + bt->LM + h, -pi_4, pi_4);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertexArray2d(verts, 26);
tnsPackAs(GL_LINE_LOOP);
v = -hcy[2] + 0.5;
cv = cos(v / 2 * TNS_PI);
sv = sin(v / 2 * TNS_PI);
verts[0] = cv * r + c;
verts[1] = sv * r + ui->U + r;
verts[2] = cv * (r + h) + c;
verts[3] = sv * (r + h) + ui->U + r;
tnsColor4d(1, 1, 1, 1);
tnsVertexArray2d(verts, 2);
tnsPackAs(GL_LINES);
tnsColor4dv(RealColor);
tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], 8,0);
tnsVertexArray2d(verts, 16);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4d(1, 1, 1, 1);
tnsVertexArray2d(verts, 16);
tnsPackAs(GL_LINE_LOOP);
tnsMakeCircle2d(verts, 16, PickerPos[0], PickerPos[1], 7,0);
tnsColor4d(0.1, 0.1, 0.1, 1);
tnsVertexArray2d(verts, 16);
tnsPackAs(GL_LINE_LOOP);
if(ui->Extra->HeightCoeff>=0) tnsDrawStringAuto("โฟ",laThemeColor(bt,LA_BT_BORDER),ui->R-LA_RH, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_CENTER);
if(IsClay) tnsDrawStringAuto("Clay",laThemeColor(bt,LA_BT_BORDER),ui->L, c-r+LA_RH, ui->U+bt->TM, LA_TEXT_ALIGN_RIGHT|LA_TEXT_MONO);
if(ShowInfo) tnsDrawStringAuto("๐",laThemeColor(bt,LA_BT_TEXT),c-r, ui->R, ui->B-bt->BM-LA_RH, LA_TEXT_ALIGN_LEFT);
tnsFlush();
tnsUniformShowColorOverflowStripes(T->immShader,0);
tnsUniformInputColorSpace(T->immShader,0);
}
void la_MenuItemDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt, ui->State));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}
tnsDrawStringAuto(transLate(ui->Display->Ptr), laThemeColor(bt, LA_BT_TEXT|ui->State), ui->L+bt->LM, ui->R, ui->U, ui->Flags);
}
void la_ConditionToggleDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
char temp[128] = {0};
char *buf[LA_RAW_CSTR_MAX_LEN];
uint32_t IconID;
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if (!ui->State) ui->State = LA_UI_NORMAL;
int UseState=ui->State;
if (!(ui->Flags&LA_TEXT_ALIGN)) ui->Flags|=LA_TEXT_ALIGN_CENTER;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt, ui->State));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U);
tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B);
tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}else{
UseState=LA_UI_NORMAL;
}
buf[0] = 0;
if (ui->ExtraInstructions){
if (ui->Type->OperatorType->ParseArgs){
ui->Type->OperatorType->ParseArgs(ui->Instructions, &IconID, buf);
}
}
if (buf[0]) tnsDrawStringAuto(transLate(buf), laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
else
tnsDrawStringAuto(ui->State == LA_UI_ACTIVE ? "โฏ" : "โฏ", laThemeColor(bt, LA_BT_TEXT|UseState), ui->L+bt->LM, ui->R-bt->RM, ui->U, ui->Flags);
}
void la_DrawColumnAdjusterRecursive(int U, int B, laColumn *c, int W, tnsVector3d color, int LeftMost){
if (c->LS){
la_DrawColumnAdjusterRecursive(U, B, c->LS, W, color, LeftMost);
la_DrawColumnAdjusterRecursive(U, B, c->RS, W, color, LeftMost);
}else{
if(c->IL==LeftMost) return;
tnsDrawStringAuto("โ", color, c->IL-LA_RH, c->IL+LA_RH, U, LA_TEXT_ALIGN_CENTER);
}
}
void la_ColumnAdjusterDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
la_DrawColumnAdjusterRecursive(ui->U, ui->U + LA_RH, ui->C, (bt->LM+bt->RM)/2, laThemeColor(bt, LA_BT_BORDER), ui->C->IL);
}
void la_ColumnViewerDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
laColumn *c = ui->PP.EndInstance;
int W = ui->R - ui->L - bt->LM - bt->RM;
//if (c->IR == c->IL)
// return;
int T = c->Top->IR - c->Top->IL;
int L = (int)((real)(c->IL - c->Top->IL) * W / T) + ui->L + bt->LM,
R = (int)((real)(c->IR - c->Top->IL) * W / T) + ui->L + bt->LM;
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(L, ui->U + bt->TM);
tnsVertex2d(R, ui->U + bt->TM);
tnsVertex2d(R, ui->B - bt->BM);
tnsVertex2d(L, ui->B - bt->BM);
tnsPackAs(GL_TRIANGLE_FAN);
}
void la_NodeSocketDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
char* label=0; char* icon;
laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
real* ColorBkg=0,*ColorSocket;
if(pc==LA_PC_SOCKET_IN) { laNodeInSocket*s=ui->PP.EndInstance; ColorSocket=laThemeColor(bt,LA_BT_TEXT); ColorBkg=laThemeColor(bt, LA_BT_NORMAL); label=s->Label?s->Label->Ptr:""; }
elif(pc==LA_PC_SOCKET_OUT){ laNodeOutSocket*s=ui->PP.EndInstance; ColorSocket=laThemeColor(bt,LA_BT_TEXT_ACTIVE); ColorBkg=laThemeColor(bt, LA_BT_ACTIVE); label=s->Label?s->Label->Ptr:""; }
int IsDisabled=ui->Flags&LA_UI_FLAGS_DISABLED;
tnsUseNoTexture();
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsColor4dv(ColorBkg);
tnsPackAs(GL_TRIANGLE_FAN);
int tl,tr,tu,sl,sr,su;
if(ui->Flags&LA_UI_SOCKET_LABEL_N){ tl=ui->L; tu=ui->U; tr=ui->R; sl=ui->L; sr=ui->R; su=ui->U+LA_RH; }
elif(ui->Flags&LA_UI_SOCKET_LABEL_S){ tl=ui->L; tu=ui->U+LA_RH; tr=ui->R; sl=ui->L; sr=ui->R; su=ui->U; }
elif(ui->Flags&LA_UI_SOCKET_LABEL_W){ tl=ui->L; tu=ui->U; tr=tl+LA_2RH; sl=ui->L+LA_2RH; sr=ui->R; su=ui->U; }
elif(ui->Flags&LA_UI_SOCKET_LABEL_E){ tu=ui->U; tr=ui->R; tl=tr-LA_2RH; sl=ui->L; sr=tl; su=ui->U; }
else{ sl=ui->L; su=ui->U; sr=ui->R; label=0; }
tnsDrawStringAuto("โญ", IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, sl, sr, su, LA_TEXT_ALIGN_CENTER);
if(label) tnsDrawStringAuto(label, IsDisabled?laThemeColor(bt,LA_BT_TEXT|LA_UI_DISABLED):ColorSocket, tl, tr, tu, LA_TEXT_ALIGN_CENTER|LA_TEXT_MONO);
}
void la_HeightAdjusterDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
char* str="โฐ";
if(ui->State==LA_BT_ACTIVE){ str="๐ก"; }
tnsDrawStringAuto(str, laThemeColor(bt,LA_BT_TEXT), ui->L-1000, ui->R+1000, ui->U, LA_TEXT_ALIGN_CENTER);
}
void la_RawPropDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int s=0;
//void* data=laGetRaw(&ui->PP, &s);
//char* buf[128]; sprintf(buf,"%d bytes of raw data at 0x%0x", s, data);
tnsDrawStringAuto("RAW DATA", laThemeColor(bt,LA_BT_TEXT), ui->L, ui->R, ui->U, ui->Flags|LA_TEXT_MONO);
}
void la_MapperDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int NoDecal=ui->Flags&LA_UI_FLAGS_NO_DECAL;
if(!NoDecal){
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt, LA_BT_NORMAL));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt, LA_BT_BORDER));
tnsVertex2d(ui->L, ui->U); tnsVertex2d(ui->R, ui->U);
tnsVertex2d(ui->R, ui->B); tnsVertex2d(ui->L, ui->B);
tnsPackAs(GL_LINE_LOOP);
}
laPropContainer* pc=la_EnsureSubTarget(ui->PP.LastPs->p,ui->PP.EndInstance);
if(!pc || pc!=LA_PC_MAPPER || !ui->PP.EndInstance){
tnsDrawStringAuto("Property is not a la_value_mapper.",0,ui->L+bt->LM,ui->R-bt->RM,bt->TM,LA_TEXT_LINE_WRAP); return;
}
laValueMapper* vm=ui->PP.EndInstance; int any=0;
tnsColor4dv(laAccentColor(LA_BT_TEXT));
for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y)); any++;
} tnsPackAs(GL_LINE_STRIP);
for(laValueMapperPoint* vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
tnsVertex2d(tnsInterpolate(ui->L,ui->R,vmp->x),tnsInterpolate(ui->B,ui->U,vmp->y));
} tnsPackAs(GL_POINTS);
if(any){ glLineWidth(2); glPointSize(5); tnsFlush(); glPointSize(1); glLineWidth(1); }
}
void la_ValueMeterDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int DataI[8]; real Data[8];
int Len, i, W; real Seg;
char buf[48] = {0};
char buf2[48] = {0};
char prefix[8][64] = {0};
int Original;
int Imin=-100, Imax=100;
real min=-100, max=100;
int s, State; int IsVertical=ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
Len = laGetArrayLength(&ui->PP);
laGetPrefixP(&ui->PP, prefix);
if(IsInt){
laGetIntArray(&ui->PP, DataI); for(int i=0;iPP, &Imin, &Imax); min=Imin; max=Imax;
}else{
laGetFloatArray(&ui->PP, Data);
laGetFloatRange(&ui->PP,&min,&max);
}
for (i = 0; i < Len; i++){
int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
if(IsVertical){
Seg = (real)(ui->R-ui->L)/Len;
_L = ui->L + i * Seg; _R=ui->L + (i+1) * Seg;
}else{
Seg = (real)(ui->B-ui->U)/Len;
_U = ui->U + i * Seg; _B=_U+Seg;
}
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,ui->State));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_TRIANGLE_FAN);
int R1=_R,U1=_U;
if(IsVertical){ U1 = (real)(max - Data[i]) / (real)(max - min) * (real)(_B-_U) + _U; }
else{ R1 = (real)(Data[i] - min) / (real)(max - min) * (real)(_R-_L) + _L; }
tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
tnsColor4d(LA_COLOR3(color),0.4);
tnsVertex2d(_L, U1); tnsVertex2d(R1, U1);
tnsVertex2d(R1, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_TRIANGLE_FAN);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_LINE_LOOP);
if(Len==1){ sprintf(buf,ui->PP.LastPs->p->Name); } else{ if(i<8)sprintf(buf,prefix[i]); }
tnsDrawStringAuto(buf, laThemeColor(bt, LA_BT_TEXT), _L + bt->LM, _R - bt->RM, _U, ui->Flags);//, ui->ExtraInstructions);
}
tnsFlush();
}
void la_ValueMeter2DDraw(laUiItem *ui, int h){
laBoxedTheme *bt = (*ui->Type->Theme);
int DataI[8]; real Data[8];
int Len, i, W; real Seg;
char buf[48] = {0};
char buf2[48] = {0};
char prefix[8][64] = {0};
int Original;
int Imin=-100, Imax=100;
real min=-100, max=100;
int IsInt=(ui->PP.LastPs->p->PropertyType&LA_PROP_INT)?1:0;
Len = laGetArrayLength(&ui->PP);
laGetPrefixP(&ui->PP, prefix);
if(IsInt){
laGetIntArray(&ui->PP, DataI); for(int i=0;iPP, &Imin, &Imax); min=Imin; max=Imax;
}else{
laGetFloatArray(&ui->PP, Data);
laGetFloatRange(&ui->PP,&min,&max);
}
int _L=ui->L, _R=ui->R, _U=ui->U, _B=ui->B;
tnsUseNoTexture();
tnsColor4dv(laThemeColor(bt,LA_BT_NORMAL));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_TRIANGLE_FAN);
real CL=(real)(Data[0] - min) / (real)(max - min) * (real)(_R-_L) + _L;
real CU=(real)(max - Data[1]) / (real)(max - min) * (real)(_B-_U) + _U;
real HW=((real)_R-(real)_L)/4; real HH=((real)_B-(real)_U)/4;
real ML=((real)_R+(real)_L)/2; real MU=((real)_B+(real)_U)/2;
tnsUseNoTexture(); real* color=laThemeColor(bt,LA_BT_TEXT);
tnsColor4d(LA_COLOR3(color),0.4);
tnsVertex2d(ML+HW, MU+HH); tnsVertex2d(ML-HW, MU+HH);
tnsVertex2d(ML-HW, MU-HH); tnsVertex2d(ML+HW, MU-HH);
tnsPackAs(GL_LINE_LOOP);
tnsVertex2d(_L,_U); tnsVertex2d(_R,_B);
tnsVertex2d(_R,_U); tnsVertex2d(_L,_B);
tnsVertex2d(ML,_U); tnsVertex2d(ML,_B);
tnsVertex2d(_R,MU); tnsVertex2d(_L,MU);
tnsPackAs(GL_LINES);
tnsColor4dv(laThemeColor(bt,LA_BT_BORDER));
tnsVertex2d(_L, _U); tnsVertex2d(_R, _U);
tnsVertex2d(_R, _B); tnsVertex2d(_L, _B);
tnsPackAs(GL_LINE_LOOP);
tnsFlush();
tnsColor4dv(laThemeColor(bt,LA_BT_TEXT));
tnsVertex2d(_L, CU); tnsVertex2d(_R, CU);
tnsVertex2d(CL, _U); tnsVertex2d(CL, _B);
tnsPackAs(GL_LINES);
real circle[48];
tnsMakeCircle2d(circle,24,CL,CU,LA_RH2,0);
tnsVertexArray2d(circle,24);
tnsPackAs(GL_LINE_LOOP);
glLineWidth(2);
tnsFlush();
glLineWidth(1);
}
void la_ConditionNodeFreeRecursive(laUiConditionNode *ucn);
void la_GeneralUiInit(laUiItem *ui){
ui->Extra = memAcquireSimple(sizeof(laGeneralUiExtraData));
ui->Extra->ui=ui;
}
void la_GeneralUiDestroy(laUiItem *ui){
if(ui->Extra && ui->Extra->Edit){ strEndEdit(&ui->Extra->Edit, 1); }
memFree(ui->Extra);
}
void la_ConditionUiDestroy(laUiItem *ui){
laConditionUiExtraData *cued = ui->Extra;
la_ConditionNodeFreeRecursive(cued->Expression);
FreeMem(ui->Extra);
}
void la_MultiStringInit(laUiItem *ui){
laGeneralUiExtraData *e = ui->Extra;
if (!e) e = memAcquireSimple(sizeof(laGeneralUiExtraData));
ui->Extra = e;
e->HeightCoeff = 10;
}
void la_RegisterUiTypesBasic(){
laKeyMapper* km;
laPropContainer* pc;
LA_WIDGET_INT->Type=LA_WIDGET_INT_PLAIN->Type=
_LA_UI_INT = la_RegisterUiType("LA_int_array_horizon", LA_PROP_INT | LA_PROP_ARRAY, "LA_int_array_h_operator",
&_LA_THEME_VALUATOR, la_IntDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_INT->GetMinWidth=la_ValueGetMinWidth;
LA_WIDGET_VALUE_METER->Type=
_LA_UI_VALUE_METER = la_RegisterUiType("LA_value_meter", LA_PROP_INT | LA_PROP_ARRAY, 0, &_LA_THEME_VALUATOR, la_ValueMeterDraw, la_ValueMeterGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
LA_WIDGET_VALUE_METER_2D->Type=
_LA_UI_VALUE_METER_2D = la_RegisterUiType("LA_value_meter_2d", LA_PROP_INT | LA_PROP_ARRAY, 0, &_LA_THEME_VALUATOR, la_ValueMeter2DDraw, la_ValueMeter2DGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
LA_WIDGET_FLOAT->Type=LA_WIDGET_FLOAT_PLAIN->Type=
_LA_UI_FLOAT = la_RegisterUiType("LA_real_array_horizon", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_array_h_operator",
&_LA_THEME_VALUATOR, la_FloatDraw, la_ValueGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_FLOAT->GetMinWidth=la_ValueGetMinWidth;
LA_WIDGET_FLOAT_COLOR->Type=
_LA_UI_FLOAT_COLOR = la_RegisterUiType("LA_real_color", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_color_operator",
&_LA_THEME_VALUATOR, la_FloatArrayColorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_FLOAT_COLOR->GetMinWidth=la_ColorSelectorGetMinWidth;
LA_WIDGET_FLOAT_COLOR_HCY->Type=
_LA_UI_FLOAT_COLOR_HCY = la_RegisterUiType("LA_real_hcy", LA_PROP_FLOAT | LA_PROP_ARRAY, "LA_real_hcy_operator",
&_LA_THEME_VALUATOR, la_ColorCircleDrawHCY, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_FLOAT_COLOR_HCY->GetMinWidth = la_ColorPickerGetMinWidth;
LA_WIDGET_ENUM_SELECTOR->Type=LA_WIDGET_ENUM_SELECTOR_ICON->Type=LA_WIDGET_ENUM_CYCLE->Type=LA_WIDGET_ENUM_HIGHLIGHT->Type=
_LA_UI_ENUM_SELECTOR = la_RegisterUiType("LA_enum_selector", LA_PROP_ENUM, "LA_enum_selector_operator",
&_LA_THEME_SELECTOR, la_EnumSelectorDraw, la_EnumGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_ENUM_SELECTOR->GetMinWidth = la_EnumGetMinWidth;
LA_WIDGET_FIXED_GROUP->Type=
_LA_UI_FIXED_GROUP = la_RegisterUiType("LA_group_default", 0, 0,
&_LA_THEME_COLLECTION_GROUP, la_GroupDraw, la_GroupGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_FIXED_GROUP->Tag|=LA_UI_TAG_SCISSOR;
LA_WIDGET_COLLECTION->Type=
_LA_UI_COLLECTION = la_RegisterUiType("LA_collection_default", LA_PROP_SUB, "LA_collection_operator",
&_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
LA_WIDGET_COLLECTION_SELECTOR->Type=
_LA_UI_COLLECTION_SELECTOR = la_RegisterUiType("LA_collection_selector_default", LA_PROP_SUB, "LA_collection_selector_operator",
&_LA_THEME_COLLECTION_SELECTOR, la_CollectionSelectorDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
LA_WIDGET_COLLECTION_SINGLE->Type=
_LA_UI_COLLECTION_SINGLE = la_RegisterUiType("LA_collection_single", LA_PROP_SUB, "LA_collection_operator",
&_LA_THEME_COLLECTION_GROUP, la_EmptyDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
LA_WIDGET_TAB->Type=
_LA_UI_TAB = la_RegisterUiType("LA_tab_default", 0, "LA_tab_operator",
&_LA_THEME_TAB, la_TabDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
LA_WIDGET_BUTTON->Type=LA_WIDGET_BUTTON_NO_CONFIRM->Type=
_LA_UI_BUTTON = la_RegisterUiType("LA_button_default", LA_PROP_OPERATOR, "LA_button_operator",
&_LA_THEME_BUTTON, la_ButtonDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_BUTTON->GetMinWidth = la_ButtonGetMinWidth;
LA_WIDGET_BUTTON_NO_CONFIRM->Flags|=LA_UI_FLAGS_NO_CONFIRM;
pc=laUiHasExtraProps(_LA_UI_BUTTON, sizeof(laGeneralUiExtraData),0);
LA_WIDGET_LABEL->Type=
_LA_UI_LABEL = la_RegisterUiType("LA_label_default", LA_PROP_OPERATOR, 0,
&_LA_THEME_LABEL, la_LabelDraw, la_LabelHeight, 0, 0);
_LA_UI_LABEL->GetMinWidth = la_LabelGetMinWidth;
LA_WIDGET_MENU_ROOT->Type=
_LA_UI_MENU_ROOT = la_RegisterUiType("LA_menu_default", LA_PROP_OPERATOR, "LA_menu_root_operator",
&_LA_THEME_BUTTON, la_MenuItemDraw, 0, 0, 0);
_LA_UI_MENU_ROOT->GetMinWidth=la_LabelGetMinWidth;
LA_WIDGET_CONDITION_TOGGLE->Type=
_LA_UI_CONDITION_TOGGLE = la_RegisterUiType("LA_condition_toggle_default", LA_PROP_SELF_CONDITION, "LA_condition_toggle_operator",
&_LA_THEME_BUTTON, la_ConditionToggleDraw, 0, 0, la_ConditionUiDestroy);
LA_WIDGET_STRING->Type=LA_WIDGET_STRING_PLAIN->Type=LA_WIDGET_STRING_MONO_PLAIN->Type=
_LA_UI_STRING = la_RegisterUiType("LA_string_default", LA_PROP_STRING, "LA_string_operator",
&_LA_THEME_STRING, la_SingleLineStringDraw, la_StringPropGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_STRING->GetMinWidth = la_StringPropGetMinWidth;
km=&_LA_UI_STRING->KeyMapper;
laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
pc=laUiHasExtraProps(_LA_UI_STRING, sizeof(laGeneralUiExtraData), 0);{
laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
}
LA_WIDGET_STRING_MULTI->Type=
_LA_UI_STRING_MULTI = la_RegisterUiType("LA_string_multiline", LA_PROP_STRING, "LA_string_multi",
&_LA_THEME_STRING, la_MultiStringDraw, la_MultiStringHeight, la_MultiStringInit, la_GeneralUiDestroy);
_LA_UI_STRING_MULTI->GetMinWidth = la_StringPropGetMinWidth;
km=&_LA_UI_STRING_MULTI->KeyMapper;
laAssignNewKey(km, 0, "LA_edit_string_copy", LA_KM_SEL_UI_EXTRA, LA_KEY_CTRL, LA_KEY_DOWN, 'c', 0);
laAssignNewKey(km, 0, "LA_system_paste", 0, LA_KEY_CTRL, LA_KEY_DOWN, 'v', 0);
pc=laUiHasExtraProps(_LA_UI_STRING_MULTI, sizeof(laGeneralUiExtraData), 0);{
laAddOperatorProperty(pc, "copy_selection", "Copy Selection", "Copy selected string into clipboard", "LA_edit_string_copy",0,0);
}
LA_WIDGET_ALIGN->Type=
_LA_UI_ALIGN = la_RegisterUiType("LA_colum_align_default", 0, 0,
&_LA_THEME_BUTTON, la_UiSeperatorDraw, 0, 0, 0);
LA_WIDGET_COLUMN_ADJUSTER->Type=
_LA_UI_COLUMN_ADJUSTER = la_RegisterUiType("LA_column_adjuster_default", 0, "LA_column_adjuster",
&_LA_THEME_BUTTON, la_ColumnAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_COLUMN_ADJUSTER->TargetSub = "ui_column";
LA_WIDGET_COLUMN_VIEWER->Type=
_LA_UI_COLUMN_VIEWER = la_RegisterUiType("LA_column_viewer_default", 0, 0,
&_LA_THEME_BUTTON, la_ColumnViewerDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_COLUMN_VIEWER->TargetSub = "ui_column";
_LA_UI_COLUMN_VIEWER->GetMinWidth = la_ColumnViewerGetMinWidth;
_LA_UI_CONDITION_ELSE.Theme = &_LA_THEME_BUTTON;
la_UDFAppendSharedTypePointer("LA_condition_else", &_LA_UI_CONDITION_ELSE);
_LA_UI_CONDITION.Destroy = _LA_UI_CONDITION_ELSE.Destroy = _LA_UI_CONDITION_END.Destroy =la_ConditionUiDestroy;
_LA_UI_CONDITION.Theme = &_LA_THEME_BUTTON;
la_UDFAppendSharedTypePointer("LA_condition", &_LA_UI_CONDITION);
_LA_UI_CONDITION_END.Theme = &_LA_THEME_BUTTON;
la_UDFAppendSharedTypePointer("LA_condition_end", &_LA_UI_CONDITION_END);
LA_WIDGET_SYMBOL->Type=
_LA_UI_SYMBOL = la_RegisterUiType("LA_symbol_default", 0, 0, &_LA_THEME_BUTTON, la_SymbolDraw, la_SymbolGetHeight, 0, 0);
LA_WIDGET_NODE_SOCKET->Type=
_LA_UI_NODE_SOCKET = la_RegisterUiType("LA_node_socket_default", 0, "LA_node_socket", &_LA_THEME_SOCKET, la_NodeSocketDraw, la_SocketGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_NODE_SOCKET->GetMinWidth=la_SocketGetMinWidth;
LA_WIDGET_HEIGHT_ADJUSTER->Type=
_LA_UI_HEIGHT_ADJUSTER = la_RegisterUiType("LA_height_adjuster_default", 0, "LA_height_adjuster", &_LA_THEME_COLLECTION_GROUP, la_HeightAdjusterDraw, 0, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_HEIGHT_ADJUSTER->ForType = LA_PROP_INT;
LA_WIDGET_RAW->Type=
_LA_UI_RAW = la_RegisterUiType("LA_raw_prop_default", 0, 0, &_LA_THEME_COLLECTION_GROUP, la_RawPropDraw, 0, 0, 0);
_LA_UI_RAW->ForType = LA_PROP_RAW;
LA_WIDGET_MAPPER->Type=
_LA_UI_MAPPER = la_RegisterUiType("LA_mapper_default", 0, "LA_value_mapper", &_LA_THEME_COLLECTION_GROUP, la_MapperDraw, la_ColorPickerGetHeight, la_GeneralUiInit, la_GeneralUiDestroy);
_LA_UI_ROW_BEGIN.Theme=&_LA_THEME_BUTTON;
_LA_UI_ROW_END.Theme=&_LA_THEME_BUTTON;
}
// ============================================================ [Operators]
void la_DefaultEnumPanel(laUiList *uil, laPropPack *This, laPropPack *OperatorProps, laColumn *UNUSED){
laColumn *c = laFirstColumn(uil);
laShowItem(uil, c, This, 0)->Flags=(LA_UI_FLAGS_TRANSPOSE|LA_UI_FLAGS_EXPAND);
}
int la_DetectRow(laUiItem *ui, int LocalY){
return (LocalY - ui->U) / LA_RH;
}
int la_DetectColumn(laUiItem *ui, int LocalX, int Total){
return (int)((real)(LocalX - ui->L) / (real)(ui->R - ui->L) * (real)Total);
}
laColumn *la_DetectSplit(laColumn *Root, int LocalX){
laColumn *result = 0;
if (!Root->LS) return 0;
if (LocalX - Root->LS->IR < LA_SCROLL_W && Root->LS->IR - LocalX < LA_SCROLL_W &&
!Root->LS->MaxW && !Root->RS->MaxW){
return Root;
}
result = la_DetectSplit(Root->LS, LocalX);
if (result) return result;
else
return la_DetectSplit(Root->RS, LocalX);
}
void la_AdjustColumnSplit(laColumn *c, int PxLeftPositive){
if (!c->LS || c->LS->MaxW || c->RS->MaxW) return;
if (PxLeftPositive < 0 && c->LS->IR - c->LS->IL <= LA_SCROLL_W*2) return;
if (PxLeftPositive > 0 && c->RS->IR - c->RS->IL <= LA_SCROLL_W*2) return;
c->LS->IR += PxLeftPositive;
c->RS->IL += PxLeftPositive;
c->LS->SP = (real)(c->LS->IR - c->LS->IL) / (real)(c->IR - c->IL);
c->RS->SP = c->LS->SP;
}
int OPCHK_EditStringCopySelection(laPropPack *This, laStringSplitor *Instructions){
laGeneralUiExtraData *uit = This->EndInstance; if(!uit) return 0;
if(!uit->Edit || !strHasSelection(uit->Edit)) return 0;
return 1;
}
int OPINV_EditStringCopySelection(laOperator *a, laEvent *e){
laGeneralUiExtraData *uit = a->This->EndInstance; if(!uit) return LA_FINISHED;
if(!uit->Edit || !strHasSelection(uit->Edit)) return LA_FINISHED;
char* str=strGetEditString(uit->Edit, 1);
laCopyToClipboard(str); free(str);
return LA_FINISHED;
}
int la_ProcessTextEdit(laEvent *e, laStringEdit *se, laUiItem* ui){
int Select=e->SpecialKeyBit&LA_KEY_SHIFT;
int _L, MonoWidth;
switch (e->Type){
case LA_INPUT:
switch (e->Input){
case 0x08: if(strHasSelection(se)) strClearSelection(se); else strBackspace(se); return 1;
case 0x7f: if(strHasSelection(se)) strClearSelection(se); else { strMoveCursor(se,0,0); strBackspace(se); } return 1;
case 0x09: strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' ');strInsertChar(se, ' '); return 1;
case 0x1B: case 0x0D: return 0;
default: strInsertChar(se, e->Input); return 1;
}
break;
case LA_KEY_DOWN:
switch (e->key){
case LA_KEY_ENTER: strInsertChar(se, '\n'); return 1;
case LA_KEY_ARRLEFT: strMoveCursor(se, 1, Select); return 1;
case LA_KEY_ARRRIGHT: strMoveCursor(se, 0, Select); return 1;
case LA_KEY_ARRUP: strMoveCursorLine(se, 1, Select); return 1;
case LA_KEY_ARRDOWN: strMoveCursorLine(se, 0, Select); return 1;
}
break;
case LA_L_MOUSE_DOWN:
case LA_MOUSEMOVE:
if(!ui) return 0;
MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM;
int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
if(e->Type==LA_L_MOUSE_DOWN){
strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (e->x-_L-MonoWidth/2)/MonoWidth); strCancelSelect(se); strLazySelect(se);
se->MouseSelecting=1; se->CursorPreferBefore=se->CursorBefore; return 1;
}else{
if(!se->MouseSelecting) return 0;
MonoWidth=tnsGetMonoFontAdvance(); _L=(*ui->Type->Theme)->LM;
int Count=se->TotalLines; while(Count){ Count/=10; _L+=MonoWidth; }
strSetCursor(se, (e->y-ui->U)/LA_RH+se->ViewStartLine, (e->x-_L-MonoWidth/2)/MonoWidth); strEndSelect(se);
se->CursorPreferBefore=se->CursorBefore; return 1;
}return 0;
case LA_L_MOUSE_UP:
se->MouseSelecting=0;
}
return 0;
}
int OPINV_UiItem(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
a->CustomData = ui->Extra;
return LA_RUNNING;
}
int OPINV_Tab(laOperator *a, laEvent *e){
laUiList *uil;
laUiItem *ui = a->Instance;
laGeneralUiExtraData *uit;
int count = 0;
//if (e->Type == LA_L_MOUSE_DOWN) {
//}
a->CustomData = ui->Extra;
uit = a->CustomData;
uit->TargetIndexVali = count;
return LA_RUNNING;
}
int OPEXT_UiItem(laOperator *a, int ExitCode){
laUiItem *ui = a->Instance;
return 0;
}
int OPMOD_IntArrayHorizon(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laIntProp *ip = ui->PP.LastPs->p;
int Away = 0;
int TmpArr[32];
int Len = laGetArrayLength(&ui->PP);
int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
ui->State = LA_UI_NORMAL;
if (ui->Extra) ui->Extra->On = 0;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
if (e->Type == LA_TIME_IDLE && !uit->On && !uit->Edit){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if(NoEvent){ return LA_RUNNING_PASS; }
if (e->Type == LA_L_MOUSE_DOWN){
if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
if (uit->Edit){
if (!laIsInUiItem(ui, e->x, e->y)){
strEndEdit(&uit->Edit, 1);
uit->On = 0;
laRedrawCurrentPanel();
return LA_FINISHED;
}
if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
else strSelectLineAll(uit->Edit);
return LA_RUNNING;
}
uit->LastX = e->x;
uit->LastY = e->y;
ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
if (ui->Extra->On > Len) return LA_RUNNING;
laGetIntArray(&ui->PP, &TmpArr);
uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (e->Type == LA_MOUSEMOVE && ui->Extra->On){
if(ui->Extra->Edit){ return LA_RUNNING; }
int dist=abs(e->x - uit->LastX);
if (dist > MAIN.ValuatorThreshold || uit->Dragging){
int min,max,Ranged = laGetIntRange(&ui->PP, &min, &max); real step=ip->Step; if(Ranged){ step=(real)(max-min)/(ui->R-ui->L); }
//laGetIntArray(&ui->PP, &TmpArr);
//uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
int delta=e->x-uit->LastX; if(!uit->Dragging) delta=delta>0?1:-1;
uit->TargetIndexValf += delta*step;
laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
uit->LastX = e->x;
uit->LastY = e->y;
uit->Dragging = 1;
laRedrawCurrentPanel();
}
return LA_RUNNING;
}
if (e->Type == LA_L_MOUSE_UP){
if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
if (uit->Dragging){
if (ui->Extra->On){
ui->Extra->On = 0;
laConfirmInt(a, uit->TargetIndexVali, LA_CONFIRM_DATA);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
}
}else if(ui->Extra->On){
int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
char buf[32] = {0};
uit->On=SelectOn;
laGetIntArray(&ui->PP, &TmpArr);
uit->TargetIndexVali = TmpArr[ui->Extra->On - 1];
strPrintIntAfter(buf, 32, uit->TargetIndexVali);
strBeginEdit(&uit->Edit,buf);
strSelectLineAll(uit->Edit);
}
}
uit->Dragging = 0;
laRedrawCurrentPanel();
return LA_RUNNING;
}
if(e->Type ==LA_KEY_DOWN){
if (e->key == LA_KEY_ENTER && uit->Edit){
char* buf=strEndEdit(&uit->Edit, 0);
int Result; sscanf(buf, "%d", &Result); free(buf);
laSetIntArraySingle(&ui->PP, ui->Extra->On - 1, Result);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
ui->State = LA_UI_NORMAL;
uit->Dragging = 0;
uit->On = 0;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
}
if (uit->Edit){
if (la_ProcessTextEdit(e, uit->Edit, ui)){
laRedrawCurrentPanel();
return LA_RUNNING;
}
}
if (e->Type == LA_R_MOUSE_DOWN){
int GX = e->x, GY = e->y;
ui->PP.LastIndex = la_DetectColumn(ui, e->x, Len);
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_FloatArrayHorizon(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laFloatProp *fp = ui->PP.LastPs->p;
int Away = 0;
real TmpArr[32];
int Len = laGetArrayLength(&ui->PP);
int IsVertical=(ui->Flags&LA_UI_FLAGS_TRANSPOSE)!=0;
int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
int IsRad=ui->PP.LastPs->p->IsRadAngle;
if (!laIsInUiItem(ui, e->x, e->y) && !ui->Extra->On){
ui->State = LA_UI_NORMAL;
ui->Extra->On = 0;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
if (e->Type == LA_TIME_IDLE && !uit->On && !uit->Edit){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if(NoEvent){ return LA_RUNNING_PASS; }
if (e->Type == LA_L_MOUSE_DOWN){
if (uit->Edit){
if (!laIsInUiItem(ui, e->x, e->y)){
strEndEdit(&uit->Edit, 1);
uit->On = 0;
laRedrawCurrentPanel();
return LA_FINISHED;
}
if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
else strSelectLineAll(uit->Edit);
return LA_RUNNING;
}
if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
uit->LastX = e->x;
uit->LastY = e->y;
ui->Extra->On = (IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
if (ui->Extra->On > Len) return LA_RUNNING;
laGetFloatArray(&ui->PP, &TmpArr);
uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (e->Type == LA_MOUSEMOVE && ui->Extra->On){
if(uit->Edit){ return LA_RUNNING; }
int dist=abs(e->x - uit->LastX);
if (dist > MAIN.ValuatorThreshold || uit->Dragging){
real min,max; int Ranged = laGetFloatRange(&ui->PP, &min, &max); real step=fp->Step; if(Ranged){ step=(max-min)/(ui->R-ui->L); }
laGetFloatArray(&ui->PP, &TmpArr);
uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
int delta=e->x-uit->LastX; if(!uit->Dragging) delta=delta>0?1:-1;
uit->TargetIndexValf += delta*step;
laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, uit->TargetIndexValf);
uit->LastX = e->x;
uit->LastY = e->y;
uit->Dragging = 1;
laRedrawCurrentPanel();
}
return LA_RUNNING;
}
if (e->Type == LA_L_MOUSE_UP){
if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
if (uit->Dragging){
if (ui->Extra->On){
ui->Extra->On = 0;
laConfirmFloat(a, uit->TargetIndexValf, LA_CONFIRM_DATA);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
}
}else if(ui->Extra->On){
int SelectOn=(IsVertical ? la_DetectRow(ui, e->y) : la_DetectColumn(ui, e->x, Len)) + 1;
if ((!uit->Edit) || (uit->Edit && (SelectOn != ui->Extra->On))){
char buf[32] = {0};
uit->On=SelectOn;
laGetFloatArray(&ui->PP, &TmpArr);
uit->TargetIndexValf = TmpArr[ui->Extra->On - 1];
strPrintFloatAfter(buf, 32, 5, IsRad?deg(uit->TargetIndexValf):uit->TargetIndexValf);
strBeginEdit(&uit->Edit,buf);
strSelectLineAll(uit->Edit);
}
}
uit->Dragging = 0;
laRedrawCurrentPanel();
return LA_RUNNING;
}
if(e->Type ==LA_KEY_DOWN){
if (e->key == LA_KEY_ENTER && uit->Edit){
char* buf=strEndEdit(&uit->Edit, 0);
real Result; sscanf(buf, "%lf", &Result); free(buf);
if(IsRad) Result=rad(Result);
laSetFloatArraySingle(&ui->PP, ui->Extra->On - 1, Result);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
uit->Dragging = 0;
uit->On = 0;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
}
if (uit->Edit){
if (la_ProcessTextEdit(e, uit->Edit, ui)){
laRedrawCurrentPanel();
return LA_RUNNING;
}
}
if (e->Type == LA_R_MOUSE_DOWN){
int GX = e->x, GY = e->y;
ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_FloatColor(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
int Away = 0;
int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
if (!laIsInUiItem(ui, e->x, e->y)){
return LA_FINISHED_PASS;
}
if (e->Type == LA_TIME_IDLE){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if(NoEvent){ return LA_RUNNING_PASS; }
if (e->Type == LA_L_MOUSE_DOWN){
laUiList *uil;
laColumn *col;
laPanel *p;
int GX = ui->L, GY = ui->B;
ui->State = LA_UI_ACTIVE;
laLocalToWindow(a, a->ToPanel, &GX, &GY);
p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GX + 150, GY, 500, e);{
uil = &p->UI;
col = laFirstColumn(uil);
laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT_COLOR_HCY, 0, 0, 0);
laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_FLOAT, 0, 0, 0)->Flags=LA_UI_FLAGS_TRANSPOSE;
laEnclosePanelContent(p, uil);
}
return LA_RUNNING;
}
if (e->Type == LA_R_MOUSE_DOWN){
int GX = e->x, GY = e->y;
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_ColorHCY(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *es = a->CustomData;
int Away = 0;
int i = 0;
real hcy[3] = {0};
real Color[4] = {0};
real PickerPos[2];
real abso;
if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
return LA_FINISHED_PASS;
}
if(e->Type == LA_L_MOUSE_DOWN && es->HeightCoeff>=0 && e->x>ui->R-bt->RM-LA_RH && e->y>ui->B-bt->BM-LA_RH){
es->Dragging=3; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff; return LA_RUNNING;
}
if(es->Dragging==3){
if(e->Type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel();}
elif(e->Type==LA_L_MOUSE_UP){ es->Dragging=0; }
elif(e->Type==LA_R_MOUSE_DOWN){
es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel(); }
return LA_RUNNING;
}
real c = (real)((ui->R + ui->L) / 2) - LA_RH / 2; /*- bt->RM;*/
real r = (ui->B - ui->U - bt->TP - bt->BP) / 2;
real dx = e->x - c, dy = e->y - (ui->U + r + bt->TP);
real dist = sqrt(dx * dx + dy * dy);
if (e->Type == LA_L_MOUSE_DOWN){ ui->State = LA_UI_ACTIVE; laRedrawCurrentPanel(); es->Dragging=(dist<=r)?1:2; }
if (e->Type == LA_L_MOUSE_UP){ ui->State = LA_UI_NORMAL; es->Dragging=0; laRedrawCurrentPanel(); return LA_RUNNING_PASS; }
if (e->Type & LA_MOUSE_EVENT && es->Dragging){
laGetFloatArray(&ui->PP, Color);
if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LogsRGB(Color); }
tnsRGB2HCY(Color, hcy);
if (es->Dragging==1){
abso = fabs(atan((real)dy / (real)dx));
hcy[0] = abso / TNS_PI / 2;
if (dx > 0){
if (dy < 0) hcy[0] = 1 - hcy[0];
}else{
if (dy > 0){
hcy[0] = 0.5 - hcy[0];
}else{
hcy[0] += 0.5;
}
}
hcy[1] = dist / r; TNS_CLAMP(hcy[1],0,1);
}else if (dist < r + LA_RH * 2 && dx > 0){
abso = -atan((real)dy / (real)dx) / TNS_PI * 2 + 0.5;
hcy[2] = abso; TNS_CLAMP(hcy[2],0,1);
}
tnsHCY2RGB(hcy, Color);
if(ui->PP.LastPs->p->Tag&LA_PROP_IS_LINEAR_SRGB){ tns2LinearsRGB(Color); }
laSetFloatArrayAllArray(&ui->PP, Color);
laRedrawCurrentPanel();
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_EnumSelector(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laEnumItem *ei;
laEnumProp *ep = ui->PP.LastPs->p;
int at = 0;
laEnumItem *Data[32];
int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
// norm e1
// expand e1 e2 e3
// expand vertical (vertical)
// arr expand e1 e1 e3
// e2 e2 e3
// arr exp+vert e1 e1
// e2 e2
// e3 e3
if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (!laIsInUiItem(ui, e->x, e->y)){ return LA_FINISHED_PASS; }
if (e->Type == LA_TIME_IDLE){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if(NoEvent){ return LA_RUNNING_PASS; }
if (e->Type == LA_L_MOUSE_DOWN){
if (laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING_PASS;
int IsVertical = ui->Flags&LA_UI_FLAGS_TRANSPOSE;
int IsExpand = ui->Flags&LA_UI_FLAGS_EXPAND;
int IsCycle = ui->Flags&LA_UI_FLAGS_CYCLE;
int ArrLen = laGetArrayLength(&ui->PP);
if(ArrLen==1){ if(!IsExpand) IsVertical=0; }else{ IsExpand=1; }
int EnumLen = (IsExpand&&(!IsCycle)) ? laGetEnumEntryLen(&ui->PP) : 1;
int _L,_R,_U,_B, _W=ui->R - ui->L, _Col=1;
if(IsVertical){
if(IsExpand){ _Col=ArrLen; }
}else{
if(IsExpand){ _Col=EnumLen; } else { _Col=ArrLen; }
}
int row = la_DetectRow(ui, e->y);
int col = la_DetectColumn(ui, e->x, _Col);
int ArrTarget=0, EnumTarget=0, ShowMenu=0;
if(IsVertical){
if(IsExpand){ EnumTarget=row; ArrTarget=col; } else { EnumTarget=col; }
}else{
if(IsExpand){ EnumTarget=col; ArrTarget=row; } else { if(!IsCycle) ShowMenu=1; }
}
if(ShowMenu){
int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
ui->State = LA_UI_ACTIVE;
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laLocalToWindow(a, a->ToPanel, &GR, &t);
laEnablePropertyPanel(a->ToPanel, a, 0, la_DefaultEnumPanel, 0, &ui->PP, GX, GR, GY, 200, 300, e);
laRedrawCurrentPanel();
}elif(IsCycle){
laEnumItem* ei=laGetEnumArrayIndexed(&ui->PP, ArrTarget);
ei = ei->Item.pNext?ei->Item.pNext:((laEnumProp*)ui->PP.LastPs->p)->Items.pFirst;
laSetEnumArrayIndexed(&ui->PP, ArrTarget, ei->Index);
laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED;
}else{
if(ArrTarget>=ArrLen){ArrTarget=ArrLen-1;}
if(EnumTarget>=EnumLen){EnumTarget=EnumLen-1;}
laSetEnumArrayIndexedExternal(&ui->PP, ArrTarget, EnumTarget);
laConfirmInt(a,EnumTarget,LA_CONFIRM_DATA);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
return LA_RUNNING_PASS;
}
return LA_RUNNING;
}
if(e->Type==LA_R_MOUSE_DOWN){
int GX = e->x, GY = e->y;
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnablePropertyPanel(a->ToPanel, a, 0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_Button(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
int lx, ly;
int Away = 0;
if (e->Type == LA_TIME_IDLE && !ui->State){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, &ui->ExtraPP, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if (laConfirmSameDataIfAny(a)) return LA_RUNNING_PASS;
if (e->Type == LA_ESCAPE_DOWN || e->Type == LA_INPUT) return LA_FINISHED; //debug
if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
if (e->Type == LA_L_MOUSE_DOWN){
ui->State = LA_UI_ACTIVE;
laRedrawCurrentPanel();
return LA_RUNNING;
}
char *str;
if (e->Type == LA_L_MOUSE_UP && ui->State!=LA_UI_NORMAL){
ui->State = LA_UI_NORMAL;
if (ui->AT){
if (!ui->Instructions){
if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
if (ui->AT->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->AT->ExtraInstructions);
}
if (!laOperatorAvailableP(ui->AT, 0, ui->Instructions)) return LA_RUNNING;
lx = e->x;
ly = e->y;
laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
e->Localized = 0;
laInvokeP(0, ui->AT, e, 0, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, 0);
e->x = lx;
e->y = ly;
e->Localized = 1;
}else{
laOperatorProp *ap = ui->PP.LastPs->p;
if (ap->OperatorID){
if (!ap->OperatorType) ap->OperatorType = laGetOperatorType(ap->OperatorID);
if (!ui->Instructions){
if (ui->ExtraInstructions) strMakeInstructions(&ui->Instructions, ui->ExtraInstructions->Ptr);
if (ap->OperatorType) strMakeInstructions(&ui->Instructions, ap->OperatorType->ExtraInstructions);
}
if (!laOperatorAvailablePSafe(ap->OperatorType, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->Instructions)) return LA_RUNNING;
lx = e->x;
ly = e->y;
laLocalToWindow(a, a->ToPanel, &e->x, &e->y);
e->Localized = 0;
laInvokePCreateThis(0, ap->OperatorType, e, ui->PP.RawThis, ui->PP.Go->UseInstance, ui->ExtraInstructions ? ui->ExtraInstructions->Ptr : 0, ap->Base.ExtraInstructions);
if(a->StopNow) return LA_FINISHED;
laRetriggerOperators();
e->x = lx;
e->y = ly;
e->Localized = 1;
}
}
if(MAIN.InvokeConfirmData){
a->ConfirmData=MAIN.InvokeConfirmData; laConfirmSameDataIfAny(a); a->ConfirmData=0;
}else{
if (str = strGetArgumentString(ui->Instructions, "feedback")){
if (strSame(str, "CONFIRM")) laConfirmInt(a, 0, LA_CONFIRM_OK);
elif (strSame(str, "CANCEL")) laConfirmInt(a, 0, LA_CONFIRM_CANCEL);
else { laConfirmString(a, str, LA_CONFIRM_CUSTOM_STRING); }
}elif(!(ui->Flags&LA_UI_FLAGS_NO_CONFIRM)){
laConfirmInt(a, 0, LA_CONFIRM_OK);
}
}
laRedrawCurrentPanel();
if(ui->Flags&LA_UI_FLAGS_EXIT_WHEN_TRIGGERED) return LA_FINISHED_PASS;
return LA_RUNNING_PASS;
}
return LA_RUNNING_PASS;
}
int OPMOD_MenuItem(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laPanel *p;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
int Away = 0;
if (a->ConfirmData){
ui->State = LA_UI_NORMAL;
laConfirmInt(a, a->ConfirmData->IData, a->ConfirmData->Mode);
laRedrawCurrentPanel();
return LA_RUNNING_PASS;
}
if (!laIsInUiItem(ui, e->x, e->y) && ui->State != LA_UI_ACTIVE){
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
if (e->Type == LA_L_MOUSE_DOWN){
int GX = ui->L, GY = ui->B;
laLocalToWindow(a, a->ToPanel, &GX, &GY);
ui->State = LA_UI_ACTIVE;
p = laEnableMenuPanel(a->ToPanel, a, ui->Subs.pFirst, &ui->PP, GX, GX + 300, GY, 600, 200, e);
laShowPanelWithDropDownEffect(p);
laRedrawCurrentPanel();
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_ConditionToggle(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
int Away = 0;
if (!laIsInUiItem(ui, e->x, e->y) /*&& ui->State!= LA_UI_ACTIVE*/){
return LA_FINISHED_PASS;
}
if (e->Type == LA_L_MOUSE_DOWN){
ui->State = ui->State == LA_UI_ACTIVE ? LA_UI_NORMAL : LA_UI_ACTIVE;
laRecalcCurrentPanel();
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_SingleLineString(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laStringEdit *se = uit->Edit;
int Away = 0;
char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=_buf;
int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
if (!laIsInUiItem(ui, e->x, e->y)){
if (ui->State != LA_UI_EDITING){
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}else if ((e->Type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
buf=strEndEdit(&uit->Edit, 0);
laSetString(&ui->PP, buf); free(buf);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
}
if (e->Type == LA_TIME_IDLE && !ui->State){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if(NoEvent){ return LA_RUNNING_PASS; }
if(e->Type ==LA_KEY_DOWN){
if (e->key == LA_KEY_ENTER){
buf=strEndEdit(&uit->Edit, 0);
laSetString(&ui->PP, buf); free(buf);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}else if (e->key == LA_KEY_ESCAPE && ui->State != LA_UI_NORMAL){
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED;
}
}
if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
if (ui->State == LA_UI_EDITING){
laRedrawCurrentPanel();
if (la_ProcessTextEdit(e, se, ui)) return LA_RUNNING;
}
if (e->Type == LA_L_MOUSE_DOWN){
if (ui->State == LA_UI_NORMAL){
if(laIsPropertyReadOnly(&ui->PP)) return LA_RUNNING;
ui->State = LA_UI_EDITING;
laGetString(&ui->PP, _buf, &buf);
strBeginEdit(&uit->Edit,buf);
strSelectLineAll(uit->Edit);
}elif (ui->State == LA_UI_EDITING){
if (strHasSelection(uit->Edit)) strDeselectAll(uit->Edit);
else strSelectLineAll(uit->Edit);
}
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (e->Type == LA_R_MOUSE_DOWN){
int GX = e->x, GY = e->y;
ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnablePropertyPanel(a->ToPanel, a, ui->State==LA_UI_EDITING?&ui->ExtraPP:0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if (ui->State != LA_UI_EDITING) return LA_RUNNING_PASS;
else
return LA_RUNNING;
}
void la_SetMultistringViewRange(laUiItem* ui, laStringEdit* se, laBoxedTheme* bt){
int NumberWidth=0; int MonoWidth=tnsGetMonoFontAdvance(); int Count=se->TotalLines;
while(Count){ Count/=10; NumberWidth+=MonoWidth; }
strSetEditViewRange(ui->Extra->Edit,
ui->Extra->HeightCoeff>0?ui->Extra->HeightCoeff:((ui->B-ui->U)/LA_RH),(ui->R-ui->L-NumberWidth-bt->LM*2-bt->RM)/MonoWidth);
}
int OPMOD_MultiString(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *es = a->CustomData;
laStringEdit *se = es->Edit;
int Away = 0;
char _buf[LA_RAW_CSTR_MAX_LEN] = {0}; char* buf=&_buf;
int NoEvent = ui->Flags&LA_UI_FLAGS_NO_EVENT;
if (!laIsInUiItem(ui, e->x, e->y) && !es->Dragging){
if ((e->Type & LA_MOUSEDOWN) == LA_MOUSEDOWN){
buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
ui->State = LA_UI_NORMAL;
laRedrawCurrentPanel();
return LA_FINISHED_PASS;
}
if(ui->State!=LA_UI_ACTIVE) return LA_FINISHED_PASS;
}
if (e->Type == LA_TIME_IDLE && ui->State!=LA_UI_ACTIVE){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if(NoEvent){ return LA_RUNNING_PASS; }
if(e->Type ==LA_KEY_DOWN){
if (e->key == LA_KEY_ESCAPE){
if(ui->State != LA_UI_NORMAL){
buf=strGetEditString(es->Edit, 0); laSetString(&ui->PP, buf); free(buf);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
ui->State = LA_UI_NORMAL; laRedrawCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt);
}
if(es->Dragging){ es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,es->Edit,bt); }
return LA_FINISHED;
}
}
if(laKeyMapExecuteEventEx(a, &ui->ExtraPP, &ui->Type->KeyMapper, e)) return LA_RUNNING;
if(e->Type == LA_L_MOUSE_DOWN && es->HeightCoeff>=0 && e->x>ui->R-bt->RM-LA_RH && e->y>ui->B-bt->BM-LA_RH){
es->Dragging=1; es->LastX=e->x; es->LastY=e->y; es->TargetIndexVali=es->HeightCoeff;
return LA_RUNNING;
}
if(es->Dragging){
if(e->Type==LA_MOUSEMOVE){ es->HeightCoeff=es->TargetIndexVali+((real)e->y-es->LastY+0.5)/LA_RH;
if(es->HeightCoeff<1)es->HeightCoeff=1; laRecalcCurrentPanel(); la_SetMultistringViewRange(ui,es->Edit,bt);}
elif(e->Type==LA_L_MOUSE_UP){ es->Dragging=0; }
elif(e->Type==LA_R_MOUSE_DOWN){
es->Dragging=0; es->HeightCoeff=es->TargetIndexVali; laRecalcCurrentPanel();la_SetMultistringViewRange(ui,se,bt); }
return LA_RUNNING;
}
if (ui->State == LA_UI_ACTIVE){
laRedrawCurrentPanel();
if (la_ProcessTextEdit(e, se, ui)) return LA_RUNNING;
}
int NoInactiveScroll=ui->Flags&LA_UI_FLAGS_NO_SCROLL_INACTIVE;
if((!NoInactiveScroll) || (ui->State==LA_UI_ACTIVE)){
if(e->Type==LA_MOUSE_WHEEL_DOWN){ strMoveView(se, MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
elif(e->Type==LA_MOUSE_WHEEL_UP){ strMoveView(se, -MAIN.ScrollingSpeed, 0); laRedrawCurrentPanel(); return LA_RUNNING; }
}
if (e->Type == LA_L_MOUSE_DOWN){
if (ui->State == LA_UI_NORMAL){
ui->State = LA_UI_ACTIVE;
laGetString(&ui->PP, _buf, &buf);
strBeginEdit(&es->Edit,buf);la_SetMultistringViewRange(ui,es->Edit,bt);
}
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (e->Type == LA_R_MOUSE_DOWN){
int GX = e->x, GY = e->y;
ui->PP.LastIndex = la_DetectColumn(ui, e->x, laGetArrayLength(&ui->PP));
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnablePropertyPanel(a->ToPanel, a, ui->State==LA_UI_ACTIVE?&ui->ExtraPP:0, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if (ui->State != LA_UI_ACTIVE) return LA_RUNNING_PASS;
else return LA_RUNNING;
}
int OPMOD_TabSelector(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laUiList *uil;
int Away = 0;
int count = 0;
int it = 0;
int page;
if (!laIsInUiItem(ui, e->x, e->y) || laIsInBound(e->x, e->y, ui->Page->L, ui->Page->R, ui->Page->U, ui->Page->B)){
return LA_FINISHED_PASS;
}
if (e->Type == LA_L_MOUSE_DOWN){
if (ui->Page->HeightCoeff && ui->R - e->x < LA_RH + bt->RM) return LA_RUNNING_PASS;
for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
count++;
}
page = la_DetectColumn(ui, e->x, count);
for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
if (it == page){
laRecalcCurrentPanel();
ui->Page = uil;
return LA_RUNNING;
}else
it++;
}
}
return LA_RUNNING_PASS;
}
int OPMOD_Collection(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laGeneralUiExtraData *uit = a->CustomData;
laListHandle Locals = {0};
laUiList *uil;
int lx = e->x, ly = e->y;
int at = 0;
laUiList* ToUil = a->ToPanel->MenuRefer?a->ToPanel->MenuRefer:&a->ToPanel->UI;
if (!laIsInUiItem(ui, e->x, e->y) /* || e->y>(ui->Subs.pFirst?((laUiList*)ui->Subs.pFirst)->HeightCoeff:10000)*/){
return LA_FINISHED_PASS;
}
laLocalToPanel(a, &lx, &ly); if(a->ToPanel && lyToPanel->TitleBar.B){ return LA_FINISHED_PASS; }
uil = la_DetectUiListRecursive(ToUil, lx, ly, 10000, 0, 0, 0, 0, 0);
if (uil != ((laUiListDrawItem *)a->LocalUiLists.pFirst)->Target){
//printf("EXIT\n");
return LA_FINISHED;
}
if (e->Type & LA_MOUSE_EVENT){
laUiList *sub;
laUiItem *tui;
int LimHeight = 10000;
int UIB = ui->B, UIU = ui->U;
int t = 0;
void *Active = ui->PP.EndInstance;
if (ui->Subs.pFirst) LimHeight = (int)((laUiList *)ui->Subs.pFirst)->HeightCoeff;
if (LimHeight > 0) UIB = LimHeight;
laPanelToLocal(a, &t, &UIB);
for (sub = ui->Subs.pFirst; sub; sub = sub->Item.pNext){
ui->PP.EndInstance = sub->Instance;
if ((tui = la_DetectUiItemRecursive(sub, e->x, e->y, UIB, &Locals, 0))){
if (tui && !a->Child && tui->Type->OperatorType){
//printf("invui %d\n", tui);
laSetOperatorLocalizer(a->ToPanel);
laInvokeUiP(a, tui->Type->OperatorType, e, tui, &Locals, 0);
}
}
lstClearPointer(&Locals);
}
ui->PP.EndInstance = Active;
}
if (e->Type == LA_L_MOUSE_DOWN && (!laIsPropertyReadOnly(&ui->PP))){
laUiList *uil;
for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext){
if (a->ConfirmData) return LA_RUNNING;
if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)){
laRecalcCurrentPanel();
laPropPack PP={0}; la_CopyPropPack(&ui->PP, &PP); //needed because layout can be switched after set active.
laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, uil->Instance);
laRecordAndPushProp(&PP,0); laMarkPropChanged(&PP);
char* cmd; if ((!(cmd = strGetArgumentString(ui->Instructions, "feedback")))||(!strSame(cmd,"NONE"))){
laConfirmInt(a, 0, LA_CONFIRM_DATA);
}
return LA_RUNNING_PASS;
}
}
return LA_RUNNING;
}
elif (e->Type == LA_R_MOUSE_DOWN) {
laUiList* uil;
for (uil = ui->Subs.pFirst; uil; uil = uil->Item.pNext) {
if (laIsInBound(e->x, e->y, uil->L, uil->R, uil->U, uil->B)) {
ui->PP.EndInstance=uil->Instance; lx=e->x, ly=e->y; laLocalToWindow(a,a->ToPanel,&lx,&ly);
laEnablePropertyPanel(a->ToPanel,a,0,0,laui_IdentifierOnly,&ui->PP,lx,lx,ly,0,0,e);
}
}
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_CollectionSelector(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laEnumItem *ei;
laEnumProp *ep = ui->PP.LastPs->p;
int at = 0;
if (a->ConfirmData /* && a->ConfirmData->Mode == LA_CONFIRM_DATA*/){
ui->State = LA_UI_NORMAL;
laRecalcCurrentPanel();
return LA_RUNNING;
}
if (!laIsInUiItem(ui, e->x, e->y)){
return LA_FINISHED;
}
if (e->Type == LA_TIME_IDLE && !ui->State){
int GX = e->x, GY = e->y; laLocalToWindow(a, a->ToPanel, &GX, &GY);
laPanel *p = laEnableIdlePanel(a->ToPanel, a, 0, 0, &ui->PP, GX, GX + 150, GY, 600, 200, e);
return LA_RUNNING;
}
if (e->Type == LA_L_MOUSE_DOWN){
laUiList *uil;
laColumn *col;
laPanel *p;
int GX = ui->L, GY = ui->B, GR = ui->R, t = 0;
if ((!laIsPropertyReadOnly(&ui->PP)) && e->x >= TNS_MAX2(ui->R - LA_RH,(ui->R+ui->L)/2) && e->x < ui->R){
laSetActiveInstance(ui->PP.LastPs->p, ui->PP.LastPs->UseInstance, 0);
laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
return LA_FINISHED;
}
laLocalToWindow(a, a->ToPanel, &GX, &GY);
laLocalToWindow(a, a->ToPanel, &GR, &t);
laRedrawCurrentPanel();
ui->State = LA_UI_ACTIVE;
p = laEnableEmptyPropertyPanel(a->ToPanel, a, GX, GR, GY, 500, e);{
int MinWidth;
uil = &p->UI;
col = laFirstColumn(uil);
laShowItemFull(uil, col, &ui->PP, 0, LA_WIDGET_COLLECTION, 0, ui->Template, 0)->SymbolID = ui->SymbolID;
laEnclosePanelContent(p, &p->UI);
}
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_ColumnAdjuster(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
laColumn *c = uit->Ptr1;
c = uit->Ptr1 ? uit->Ptr1 : la_DetectSplit(ui->C, e->x);
if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y)||!c)){
printf("done\n");
return LA_FINISHED_PASS;
}
if (e->Type == LA_L_MOUSE_DOWN){
uit->Ptr1 = c;
uit->LastX = e->x;
uit->Dragging=1;
return LA_RUNNING;
}
if (uit->Dragging && uit->Ptr1 && e->Type == LA_MOUSEMOVE){
la_AdjustColumnSplit(c, e->x - uit->LastX);
uit->LastX = e->x;
laRecalcCurrentPanel();
return LA_RUNNING;
}
if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
uit->Ptr1 = 0; uit->Dragging=0;
return LA_RUNNING;
}
return LA_RUNNING;
}
int OPMOD_NodeSocket(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
int lx=e->x,ly=e->y;
laProp* p=ui->PP.LastPs->p; laPropContainer* pc=la_EnsureSubTarget(p,0);
laPropContainer* PCFind;
if(pc==LA_PC_SOCKET_IN) { PCFind=LA_PC_SOCKET_OUT; }
elif(pc==LA_PC_SOCKET_OUT){ PCFind=LA_PC_SOCKET_IN; }
if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
if (e->Type == LA_L_MOUSE_DOWN){
uit->Dragging=1; MAIN.NextWireColor+=3;
if(pc==LA_PC_SOCKET_IN) {
laNodeInSocket* s=ui->PP.EndInstance;
uit->Ptr2 = s->Source;
if(!s->Source){
s->ColorId=MAIN.NextWireColor; s->Source=MAIN.tNodeOut; latouched_NodeInSocket(0,0);
MAIN.tNodeOut->RuntimeX=MAIN.tNodeOut->RuntimeY=MAIN.tNodeOut->RuntimePX=MAIN.tNodeOut->RuntimePY=0;
}else{
MAIN.tNodeIn->Source = s->Source;
MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
MAIN.tNodeIn->RuntimePX=-(s->Source->RuntimeX+s->Source->RuntimePX)+(s->RuntimeX+s->RuntimePX);
MAIN.tNodeIn->RuntimePY=-(s->Source->RuntimeY+s->Source->RuntimePY)+(s->RuntimeY+s->RuntimePY);
s->Source=0; MAIN.tNodeIn->ColorId=s->ColorId; latouched_NodeInSocket(0,0);
}
}
elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->Source=ui->PP.EndInstance; latouched_NodeInSocket(0,0);
MAIN.tNodeIn->RuntimeX=MAIN.tNodeIn->RuntimeY=MAIN.tNodeIn->RuntimePX=MAIN.tNodeIn->RuntimePY=0;
MAIN.tNodeIn->ColorId=MAIN.NextWireColor; }
uit->LastX = e->x; uit->LastY = e->y;
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (uit->Dragging && e->Type == LA_MOUSEMOVE){
laPanel* p=MAIN.CurrentPanel;
laLocalToPanel(a, &lx, &ly);
laUiItem* tui=la_DetectSocketRecursive(&p->UI,lx,ly,100000,uit->Ptr2?LA_PC_SOCKET_IN:PCFind); uit->Ptr1=tui;
if(pc==LA_PC_SOCKET_IN){
if(!uit->Ptr2){MAIN.tNodeOut->RuntimeX=e->x-uit->LastX;MAIN.tNodeOut->RuntimeY=e->y-uit->LastY;}
else { MAIN.tNodeIn->RuntimeX=e->x-uit->LastX;MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; } }
elif(pc==LA_PC_SOCKET_OUT){ MAIN.tNodeIn->RuntimeX=e->x-uit->LastX; MAIN.tNodeIn->RuntimeY=e->y-uit->LastY; }
laRedrawCurrentPanel();
return LA_RUNNING;
}
if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_DOWN || e->key == LA_KEY_ESCAPE)){
uit->Dragging=0; MAIN.tNodeIn->Source=0;
laRecalcCurrentPanel();
laUiItem* tui=uit->Ptr1; void* soc=tui?tui->PP.EndInstance:0;
if(pc == LA_PC_SOCKET_IN){
if(!uit->Ptr2){ if(!tui){ laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; return LA_RUNNING; }
laNodeInSocket* s=ui->PP.EndInstance; s->Source=0; memAssignRef(s,&s->Source,soc); latouched_NodeInSocket(0,0);
s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
}else{
if(!tui){
laNodeInSocket* s=ui->PP.EndInstance; s->Source=uit->Ptr2; memAssignRef(s,&s->Source,0); latouched_NodeInSocket(0,0);
laRecordAndPushProp(&ui->PP, 0); laMarkPropChanged(&ui->PP);
}else{
laNodeInSocket* s=soc; if(s->Source){ uit->Ptr2=0; return LA_RUNNING; } latouched_NodeInSocket(0,0);
memAssignRef(s,&s->Source,uit->Ptr2); s->ColorId=((laNodeInSocket*)ui->PP.EndInstance)->ColorId;
laRecordDifferences(&ui->PP,0); laRecordDifferences(&tui->PP,0); laPushDifferences("Socket status changed", 0);
laMarkPropChanged(&tui->PP); laMarkPropChanged(&ui->PP);
}
}
}
else{
if(!tui){ return LA_RUNNING; }
laNodeInSocket* s=soc; s->Source=0; memAssignRef(s,&s->Source,ui->PP.EndInstance); latouched_NodeInSocket(0,0);
s->ColorId=MAIN.NextWireColor; laRecordAndPushProp(&tui->PP, 0); laMarkPropChanged(&tui->PP);
}
uit->Ptr2=0;
return LA_RUNNING;
}
return LA_RUNNING_PASS;
}
int OPMOD_HeightAdjuster(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
int lx=e->x,ly=e->y;
int ClickedVal=0;
if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
if (e->Type == LA_L_MOUSE_DOWN || e->Type==LA_R_MOUSE_DOWN){
uit->Dragging=1; uit->LastY=e->y; uit->On=0; uit->TargetIndexVali=e->Type==LA_L_MOUSE_DOWN?(ui->State==LA_BT_ACTIVE?2:1):2; uit->HeightCoeff=1;
return LA_RUNNING;
}
if(e->Type==LA_L_MOUSE_UP && uit->HeightCoeff){ ui->State=(ui->State==LA_BT_ACTIVE)?LA_BT_NORMAL:LA_BT_ACTIVE; laRedrawCurrentPanel(); }
if (uit->Dragging && e->Type == LA_MOUSEMOVE){
int diff=e->y-uit->LastY; diff=((real)diff+0.5)/(ui->B-ui->U); int delta=uit->TargetIndexVali;
if(diff!=uit->On){ uit->HeightCoeff=0; int d=diff-uit->On; uit->On=diff; while(d){ laSetInt(&ui->PP, d>0?delta:-delta); d-=(d>0?1:-1); }; laRecalcCurrentPanel(); }
return LA_RUNNING;
}
if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
uit->Dragging=0; return LA_RUNNING_PASS;
}
return LA_RUNNING_PASS;
}
void la_ValueMapperSortPoint(laValueMapper* vm){
laValueMapperPoint* vmp,*ivmp; laListHandle temp={0}; int Inserted=0;
while(vmp=lstPopItem(&vm->Points)){
Inserted=0;
for(ivmp=temp.pLast;ivmp;ivmp=ivmp->Item.pPrev){
if(ivmp->xx){ lstInsertItemAfter(&temp,vmp,ivmp); Inserted=1; break; }
}
if(!Inserted){ lstPushItem(&temp,vmp); }
}
vm->Points.pFirst=temp.pFirst; vm->Points.pLast=temp.pLast;
}
laValueMapperPoint* la_ValueMapperCreatePoint(laValueMapper* vm, real x, real y){
laValueMapperPoint* vmp=memAcquire(sizeof(laValueMapperPoint));
vmp->x=x;vmp->y=y; lstAppendItem(&vm->Points,vmp);
la_ValueMapperSortPoint(vm);
return vmp;
}
laValueMapperPoint* la_ValueMapperGetPoint(laValueMapper* vm, real x, real y){
laValueMapperPoint* vmp=0,*ClosestVMP=0; real MinD=FLT_MAX;
if(x<0||x>1||y>1||y<0) return 0;
const real thres=0.1;
for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
if(vmp->x>x+thres || vmp->xy>y+thres || vmp->yx,vmp->y);
if(dPoints.pFirst){ la_ValueMapperCreatePoint(vm,0,0); }
if(vm->Points.pFirst==vm->Points.pLast){ la_ValueMapperCreatePoint(vm,1,1); }
}
laValueMapper* laValueMapperInit(){
laValueMapper* vm=memAcquire(sizeof(laValueMapper));
vm->InRange[0]=0; vm->InRange[1]=1; vm->OutRange[0]=0; vm->OutRange[1]=1;
la_ValueMapperEnsureValidPoints(vm);
return vm;
}
laValueMapper* laValueMapperDestroy(laValueMapper* vm){
laValueMapperPoint* vmp;
while(vmp=lstPopItem(&vm->Points)){ memLeave(vmp); }
memLeave(vm);
}
real laValueMapperEvaluate(laValueMapper* vm, real x, real* force_InMin, real* force_InMax, real* force_OutMin, real* force_OutMax, int ClampIn, int ClampOut){
real InMin=vm->InRange[0], InMax=vm->InRange[1], OutMin=vm->OutRange[0], OutMax=vm->OutRange[1];
if(force_InMin) InMin=*force_InMin; if(force_InMax) InMax=*force_InMax; if(force_OutMin) OutMin=*force_OutMin; if(force_OutMax) OutMax=*force_OutMax;
if(fabs(InMax-InMin)<1e-7) return 0;
x=tnsGetRatiod(InMin,InMax,x); if(ClampIn) TNS_CLAMP(x,0,1);
laValueMapperPoint* vmp,*NextVMP;
real ey=0;
for(vmp=vm->Points.pFirst;vmp;vmp=vmp->Item.pNext){
NextVMP=vmp->Item.pNext;
if(NextVMP && (!(vmp->x<=x && NextVMP->x>x))) continue;
if(!NextVMP){ NextVMP=vmp; vmp=vmp->Item.pPrev; if(!vmp) return 0; }
if(fabs(vmp->x-NextVMP->x)<1e-7){ ey=vmp->y; break; }
real ratio=tnsGetRatiod(vmp->x,NextVMP->x,x);
ey=tnsInterpolate(vmp->y,NextVMP->y,ratio); break;
}
real Out=tnsInterpolate(OutMin,OutMax,ey);
if(ClampOut) TNS_CLAMP(Out,OutMin,OutMax);
return Out;
}
int OPMOD_ValueMapper(laOperator *a, laEvent *e){
laUiItem *ui = a->Instance;
laBoxedTheme *bt = (*ui->Type->Theme);
laGeneralUiExtraData *uit = a->CustomData;
int w=ui->R-ui->L, h=ui->B-ui->U;
real x=(real)(e->x-ui->L)/w,y=(real)(ui->B-e->y)/h;
int ClickedVal=0;
if ((!uit->Dragging) && (!laIsInUiItem(ui, e->x, e->y))){ return LA_FINISHED_PASS; }
laValueMapper* vm=ui->PP.EndInstance;
if (e->Type == LA_L_MOUSE_DOWN){
uit->Dragging=1; uit->LastX=e->x; uit->LastY=e->y;
return LA_RUNNING;
}
if (uit->Dragging && e->Type == LA_MOUSEMOVE){
laValueMapperPoint* vmp=uit->Ptr1;
if(uit->Dragging==1 && tnsDistIdv2(e->x,e->y,uit->LastX,uit->LastY)>LA_RH/2){
uit->Ptr1=la_ValueMapperGetPoint(vm,x,y); if(!uit->Ptr1){ uit->Dragging=0; return LA_RUNNING; }
uit->Dragging=2;
}
elif(uit->Dragging==2){
if(x<0&&x>-0.05){ x=0; } if(x>1&&x<1.05){ x=1; } TNS_CLAMP(y,0,1);
vmp->x=x; vmp->y=y; la_ValueMapperSortPoint(vm);
laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laMarkPropChanged(&ui->PP);
}
return LA_RUNNING;
}
if (uit->Dragging && (e->Type == LA_L_MOUSE_UP || e->Type == LA_R_MOUSE_UP || e->key == LA_KEY_ESCAPE)){
uit->Dragging=0; laValueMapperPoint* vmp=uit->Ptr1;
if(vmp->x>1||vmp->x<0) {
lstRemoveItem(&vm->Points,vmp); la_ValueMapperEnsureValidPoints(vm);
laNotifyUsersPP(&ui->PP); laRedrawCurrentPanel(); laRecordAndPushProp(&ui->PP,0); laMarkPropChanged(&ui->PP);
}
return LA_RUNNING_PASS;
}
return LA_RUNNING_PASS;
}
void la_RegisterUiOperatorsBasic(){
laPropContainer *pc, *p;
laOperatorType *at;
laEnumProp *ep;
laCreateOperatorType("LA_edit_string_copy", "Copy Selection", "Copy selected string to clip board",
OPCHK_EditStringCopySelection, 0, 0, OPINV_EditStringCopySelection, 0, L'๐', LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_int_array_h_operator", "Int(Horizon) UiItem Operator", "Do Array Valuator Stuff",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_IntArrayHorizon, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_real_array_h_operator", "Float(Horizon) UiItem Operator", "Do Array Valuator Stuff",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatArrayHorizon, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_real_color_operator", "Color(Float) Display UiItem Operator", "Color Display,Click To Set Color",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_FloatColor, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_real_hcy_operator", "HCY Color Picker UiItem Operator", "HCY Color Picker,Click To Set Color",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColorHCY, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_enum_selector_operator", "Enum Selector UiItem Operator", "Do Selector Stuff",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_EnumSelector, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_button_operator", "Button UiItem Operator", "Execute an Operator",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Button, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_menu_root_operator", "Menu Root UiItem Operator", "Drop A Menu",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MenuItem, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_condition_toggle_operator", "Condition +/- Button Operator", "Do Self Condition Function",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ConditionToggle, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_string_operator", "Single Line String Operator", "Do String Modifying Function",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_SingleLineString, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_string_multi", "Multi Line String Operator", "Do String Modifying Function",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_MultiString, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_tab_operator", "Tab Switcher Operator", "Change The Page In The Tab Group",
0, 0, OPEXT_UiItem, OPINV_Tab, OPMOD_TabSelector, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_collection_operator", "Collection UiItem Operator", "Activate/Deactivate Collection Item(s)",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_Collection, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_collection_selector_operator", "Collection Dropdown Selector Operator", "Do Selector Stuff",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_CollectionSelector, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_column_adjuster", "Column Width Adjuster", "Drag To Set Width of Columns",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ColumnAdjuster, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_node_socket", "Node Socket Operator", "Drag to connect node sockets",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_NodeSocket, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_height_adjuster", "Height Adjuster Operator", "Drag to adjust heights of an instance",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_HeightAdjuster, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
laCreateOperatorType("LA_value_mapper", "Value mapper Operator", "Drag to set value mapping from input to output",
0, 0, OPEXT_UiItem, OPINV_UiItem, OPMOD_ValueMapper, L'๐ฆ', LA_EXTRA_TO_PANEL | LA_ACTUATOR_SYSTEM | LA_ACTUATOR_HIDDEN);
}