uicore-ts 1.0.157 → 1.0.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiledScripts/UIObject.js +1 -1
- package/compiledScripts/UIObject.js.map +2 -2
- package/compiledScripts/UIRectangle.d.ts +1 -0
- package/compiledScripts/UIRectangle.js +12 -0
- package/compiledScripts/UIRectangle.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIObject.ts +1 -1
- package/scripts/UIRectangle.ts +63 -37
|
@@ -420,7 +420,7 @@ class UIObject {
|
|
|
420
420
|
if (value instanceof UIFunctionExtender) {
|
|
421
421
|
value = value.extendedFunction(getTargetFunction());
|
|
422
422
|
}
|
|
423
|
-
UIObject.setValueForKeyPath(keyPath, UIObject.valueForKeyPath(keyPath,
|
|
423
|
+
UIObject.setValueForKeyPath(keyPath, UIObject.valueForKeyPath(keyPath, configurationTarget), result, YES);
|
|
424
424
|
UIObject.setValueForKeyPath(keyPath, value, configurationTarget, YES);
|
|
425
425
|
});
|
|
426
426
|
return result;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIObject.ts"],
|
|
4
|
-
"sourcesContent": ["import { UICoreExtensionValueObject } from \"./UICoreExtensionValueObject\"\nimport { UITimer } from \"./UITimer\"\n\n\nfunction NilFunction() {\n return nil\n}\n\n\n// The nil object avoids unnecessary crashes by allowing you to call any function or access any variable on it, returning nil\nexport var nil: any = new Proxy(Object.assign(NilFunction, { \"class\": null, \"className\": \"Nil\" }), {\n get(target, name) {\n if (name == Symbol.toPrimitive) {\n return function (hint: string) {\n if (hint == \"number\") {\n return 0\n }\n if (hint == \"string\") {\n return \"\"\n }\n return false\n }\n }\n if (name == \"toString\") {\n return function toString() {\n return \"\"\n }\n }\n return NilFunction()\n },\n set() {\n return NilFunction()\n }\n})\n\n\nexport function wrapInNil<T>(object?: T): T {\n let result = FIRST_OR_NIL(object)\n if (object instanceof Object && !(object instanceof Function)) {\n result = new Proxy(object as Object & T, {\n get(target, name) {\n if (name == \"wrapped_nil_target\") {\n return target\n }\n const value = Reflect.get(target, name)\n if (typeof value === \"object\") {\n return wrapInNil(value)\n }\n if (IS_NOT_LIKE_NULL(value)) {\n return value\n }\n return nil\n },\n set(target: Record<string, any> & T, name: string, value: any) {\n if (IS(target)) {\n // @ts-ignore\n target[name] = value\n }\n return YES\n }\n })\n }\n return result\n}\n\n\nexport const YES = true\nexport const NO = false\n\nexport function IS<T>(object: T | undefined | null | false): object is T {\n if (object && object !== nil) {\n return YES\n }\n return NO\n}\n\nexport function IS_NOT(object: any): object is undefined | null | false {\n return !IS(object)\n}\n\nexport function IS_DEFINED<T>(object: T | undefined): object is T {\n if (object != undefined) {\n return YES\n }\n return NO\n}\n\nexport function IS_UNDEFINED(object: any): object is undefined {\n return !IS_DEFINED(object)\n}\n\nexport function IS_NIL(object: any): object is typeof nil {\n if (object === nil) {\n return YES\n }\n return NO\n}\n\nexport function IS_NOT_NIL<T>(object: T | undefined | null): object is T | undefined | null {\n return !IS_NIL(object)\n}\n\n\nexport function IS_LIKE_NULL(object: any): object is undefined | null {\n return (IS_UNDEFINED(object) || IS_NIL(object) || object == null)\n}\n\nexport function IS_NOT_LIKE_NULL<T>(object: T | null | undefined): object is T {\n return !IS_LIKE_NULL(object)\n}\n\n\nexport function IS_AN_EMAIL_ADDRESS(email: string) {\n const re = /\\S+@\\S+\\.\\S+/\n return re.test(email)\n}\n\n\nexport function FIRST_OR_NIL<T>(...objects: (T | undefined | null)[]): T {\n const result = objects.find(object => IS(object))\n return result || nil\n}\n\nexport function FIRST<T>(...objects: (T | undefined | null)[]): T {\n const result = objects.find(object => IS(object))\n return result || IF(IS_DEFINED(objects.lastElement))(RETURNER(objects.lastElement))()\n}\n\n\nexport function MAKE_ID(randomPartLength = 15) {\n let result = \"\"\n const characters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"\n for (let i = 0; i < randomPartLength; i++) {\n result = result + characters.charAt(Math.floor(Math.random() * characters.length))\n }\n result = result + Date.now()\n return result\n}\n\n\nexport function RETURNER<T>(value?: T) {\n return (..._objects: any[]) => value\n}\n\n\nexport type UIIFBlockReceiver<T> = (functionToCall: () => any) => UIIFEvaluator<T>;\nexport type UIIFEvaluatorBase<T> = () => T;\n\n\nexport interface UIIFEvaluator<T> extends UIIFEvaluatorBase<T> {\n ELSE_IF: (otherValue: any) => UIIFBlockReceiver<T>;\n ELSE: (functionToCall: () => any) => T;\n}\n\n\nexport function IF<T = any>(value: any): UIIFBlockReceiver<T> {\n \n let thenFunction = nil\n let elseFunction = nil\n \n const result: any = function (functionToCall: () => T) {\n thenFunction = functionToCall\n return result.evaluateConditions\n }\n \n result.evaluateConditions = function () {\n if (IS(value)) {\n return thenFunction()\n }\n return elseFunction()\n }\n \n result.evaluateConditions.ELSE_IF = function (otherValue: any) {\n \n const functionResult = IF(otherValue) as (UIIFBlockReceiver<T> & { evaluateConditions: UIIFEvaluator<T> })\n elseFunction = functionResult.evaluateConditions\n \n const functionResultEvaluateConditionsFunction: any = function () {\n return result.evaluateConditions()\n }\n functionResultEvaluateConditionsFunction.ELSE_IF = functionResult.evaluateConditions.ELSE_IF\n functionResultEvaluateConditionsFunction.ELSE = functionResult.evaluateConditions.ELSE\n \n functionResult.evaluateConditions = functionResultEvaluateConditionsFunction\n \n return functionResult\n \n }\n \n result.evaluateConditions.ELSE = function (functionToCall: () => T) {\n elseFunction = functionToCall\n return result.evaluateConditions()\n }\n \n return result\n}\n\n\nexport class UIFunctionCall<T extends (...args: any) => any> {\n \n isAUIFunctionCallObject = YES\n parameters: Parameters<T>[]\n \n constructor(...parameters: Parameters<T>) {\n this.parameters = parameters\n }\n \n callFunction(functionToCall: T) {\n const parameters = this.parameters\n functionToCall(...parameters)\n }\n \n}\n\n\nexport function CALL<T extends (...args: any) => any>(...objects: Parameters<T>) {\n return new UIFunctionCall<T>(...objects)\n}\n\n\nexport class UIFunctionExtender<T extends (...args: any) => any> {\n \n isAUIFunctionExtenderObject = YES\n extendingFunction: T\n \n constructor(extendingFunction: T) {\n this.extendingFunction = extendingFunction\n }\n \n extendedFunction(functionToExtend: T) {\n const extendingFunction = this.extendingFunction\n \n function extendedFunction(this: any, ...objects: any[]) {\n const boundFunctionToExtend = functionToExtend.bind(this)\n boundFunctionToExtend(...objects)\n const boundExtendingFunction = extendingFunction.bind(this)\n boundExtendingFunction(...objects)\n }\n \n extendedFunction.extendedFunction = functionToExtend\n return extendedFunction\n }\n \n}\n\n\nexport function EXTEND<T extends (...args: any) => any>(extendingFunction: T) {\n return new UIFunctionExtender(extendingFunction)\n}\n\n\nexport class UILazyPropertyValue<T> {\n \n isAUILazyPropertyValueObject = YES\n initFunction: () => T\n \n constructor(initFunction: () => T) {\n this.initFunction = initFunction\n }\n \n setLazyPropertyValue(key: string, target: object) {\n \n let isValueInitialized = NO\n \n // property value\n let _value = nil\n \n const initValue = () => {\n _value = this.initFunction()\n isValueInitialized = YES\n this.initFunction = nil\n }\n \n // @ts-ignore\n if (delete target[key]) {\n \n // Create new property with getter and setter\n Object.defineProperty(target, key, {\n get: function () {\n if (IS_NOT(isValueInitialized)) {\n initValue()\n }\n return _value\n },\n set: function (newValue) {\n _value = newValue\n },\n enumerable: true,\n configurable: true\n })\n \n }\n \n }\n \n}\n\n\nexport function LAZY_VALUE<T>(initFunction: () => T) {\n return new UILazyPropertyValue(initFunction)\n}\n\n\nexport type UIInitializerObject<T> = {\n \n [P in keyof T]?:\n //T[P] extends (infer U)[] ? UIInitializerObject<U>[] :\n T[P] extends (...args: any) => any ? UIFunctionCall<T[P]> | UIFunctionExtender<T[P]> | T[P] :\n T[P] extends object ? UIInitializerObject<T[P]> | UILazyPropertyValue<T[P]> :\n T[P];\n \n}\n\n\nexport class UIObject {\n \n constructor() {\n \n // Do something here if needed\n \n }\n \n public get class(): any {\n return Object.getPrototypeOf(this).constructor\n }\n \n public get superclass(): any {\n return Object.getPrototypeOf(Object.getPrototypeOf(this)).constructor\n }\n \n isKindOfClass(classObject: any) {\n if (this.isMemberOfClass(classObject)) {\n return YES\n }\n for (let superclassObject = this.superclass; IS(superclassObject); superclassObject = superclassObject.superclass) {\n if (superclassObject == classObject) {\n return YES\n }\n }\n return NO\n }\n \n \n isMemberOfClass(classObject: any) {\n return (this.class == classObject)\n }\n \n public static wrapObject<T>(object: T): UIObject & T {\n if (IS_NOT(object)) {\n return nil\n }\n \n if ((object as any) instanceof UIObject) {\n // @ts-ignore\n return object\n }\n \n return Object.assign(new UIObject(), object)\n }\n \n \n valueForKey(key: string) {\n // @ts-ignore\n return this[key]\n }\n \n valueForKeyPath(keyPath: string): any {\n return UIObject.valueForKeyPath(keyPath, this)\n }\n \n static valueForKeyPath(keyPath: string, object: any): any {\n \n if (IS_NOT(keyPath)) {\n return object\n }\n \n const keys = keyPath.split(\".\")\n let currentObject = object\n \n for (let i = 0; i < keys.length; i++) {\n \n const key = keys[i]\n \n if (key.substring(0, 2) == \"[]\") {\n \n // This next object will be an array and the rest of the keys need to be run for each of the elements\n currentObject = currentObject[key.substring(2)]\n \n // CurrentObject is now an array\n \n const remainingKeyPath = keys.slice(i + 1).join(\".\")\n const currentArray = currentObject as unknown as any[]\n currentObject = currentArray.map(subObject => UIObject.valueForKeyPath(remainingKeyPath, subObject))\n \n break\n \n }\n \n currentObject = currentObject[key]\n if (IS_LIKE_NULL(currentObject)) {\n currentObject = nil\n }\n \n }\n \n return currentObject\n \n }\n \n setValueForKeyPath(keyPath: string, value: any, createPath = YES) {\n return UIObject.setValueForKeyPath(keyPath, value, this, createPath)\n }\n \n static setValueForKeyPath(keyPath: string, value: any, currentObject: any, createPath: boolean) {\n \n const keys = keyPath.split(\".\")\n let didSetValue = NO\n \n keys.forEach((key, index, array) => {\n if (index == array.length - 1 && IS_NOT_LIKE_NULL(currentObject)) {\n currentObject[key] = value\n didSetValue = YES\n return\n }\n else if (IS_NOT(currentObject)) {\n return\n }\n \n const currentObjectValue = currentObject[key]\n if (IS_LIKE_NULL(currentObjectValue) && createPath) {\n currentObject[key] = {}\n }\n currentObject = currentObject[key]\n })\n \n return didSetValue\n \n }\n \n \n configureWithObject(object: UIInitializerObject<this>) {\n \n return UIObject.configureWithObject(this, object)\n \n }\n \n configuredWithObject(object: UIInitializerObject<this>): this {\n \n this.configureWithObject(object)\n return this\n \n }\n \n \n static configureWithObject<TargetObjectType extends object, ConfigurationObjectType extends UIInitializerObject<TargetObjectType>>(\n configurationTarget: TargetObjectType,\n object: ConfigurationObjectType\n ): ConfigurationObjectType {\n \n const isAnObject = (item: any) => (item && typeof item === \"object\" && !Array.isArray(item) && !(item instanceof UICoreExtensionValueObject))\n const isAPureObject = (item: any) => isAnObject(item) && Object.getPrototypeOf(item) === Object.getPrototypeOf({})\n \n function isAClass(funcOrClass: object) {\n if (IS_NOT(funcOrClass)) {\n return NO\n }\n const isFunction = (functionToCheck: object) => (functionToCheck && {}.toString.call(functionToCheck) ===\n \"[object Function]\")\n const propertyNames = Object.getOwnPropertyNames(funcOrClass)\n return (isFunction(funcOrClass) && !propertyNames.includes(\"arguments\") &&\n propertyNames.includes(\"prototype\"))\n }\n \n const result = {} as ConfigurationObjectType\n \n let keyPathsAndValues: { value: any, keyPath: string }[] = []\n \n function prepareKeyPathsAndValues(target: Record<string, any>, source: object, keyPath = \"\") {\n \n if ((isAnObject(target) || isAClass(target)) && isAnObject(source)) {\n \n source.forEach((sourceValue, key) => {\n \n const valueKeyPath = keyPath + \".\" + key\n \n function addValueAndKeyPath(sourceValue: any) {\n keyPathsAndValues.push({\n value: sourceValue,\n keyPath: valueKeyPath.replace(\".\", \"\")\n })\n }\n \n \n if (isAPureObject(sourceValue) || isAClass(sourceValue)) {\n if (!(key in target) || target[key] instanceof Function) {\n addValueAndKeyPath(sourceValue)\n }\n else {\n prepareKeyPathsAndValues(target[key], sourceValue, valueKeyPath)\n }\n }\n else if (sourceValue instanceof UICoreExtensionValueObject) {\n addValueAndKeyPath(sourceValue.value)\n }\n else {\n addValueAndKeyPath(sourceValue)\n }\n \n })\n \n }\n \n }\n \n prepareKeyPathsAndValues(configurationTarget, object)\n \n // Sort based on key path lengths\n keyPathsAndValues = keyPathsAndValues.sort((a, b) => {\n \n const firstKeyPath = (a.keyPath as string).split(\".\").length\n const secondKeyPath = (b.keyPath as string).split(\".\").length\n \n if (firstKeyPath < secondKeyPath) {\n return -1\n }\n if (firstKeyPath > secondKeyPath) {\n return 1\n }\n return 0\n \n })\n \n keyPathsAndValues.forEach((valueAndKeyPath) => {\n \n const keyPath: string = valueAndKeyPath.keyPath\n let value = valueAndKeyPath.value\n \n const getTargetFunction = (bindThis = NO) => {\n let result = (UIObject.valueForKeyPath(keyPath, configurationTarget) as Function)\n if (bindThis) {\n const indexOfDot = keyPath.lastIndexOf(\".\")\n const thisObject = UIObject.valueForKeyPath(keyPath.substring(0, indexOfDot), configurationTarget)\n result = result.bind(thisObject)\n }\n return result\n }\n \n if (value instanceof UILazyPropertyValue) {\n const indexOfDot = keyPath.lastIndexOf(\".\")\n const thisObject = UIObject.valueForKeyPath(keyPath.substring(0, indexOfDot), configurationTarget)\n const key = keyPath.substring(indexOfDot + 1)\n value.setLazyPropertyValue(key, thisObject)\n return\n }\n \n if (value instanceof UIFunctionCall) {\n value.callFunction(getTargetFunction(YES))\n return\n }\n \n if (value instanceof UIFunctionExtender) {\n value = value.extendedFunction(getTargetFunction())\n }\n \n UIObject.setValueForKeyPath(keyPath, UIObject.valueForKeyPath(keyPath, value), result, YES)\n UIObject.setValueForKeyPath(keyPath, value, configurationTarget, YES)\n \n })\n \n \n return result\n \n }\n \n static configuredWithObject<T extends object>(configurationTarget: T, object: UIInitializerObject<T>) {\n this.configureWithObject(configurationTarget, object)\n return configurationTarget\n }\n \n \n performFunctionWithSelf<T>(functionToPerform: (self: this) => T): T {\n return functionToPerform(this)\n }\n \n performingFunctionWithSelf(functionToPerform: (self: this) => void): this {\n functionToPerform(this)\n return this\n }\n \n performFun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AE5B,YAAM,oBAAoB,CAAC,WAAW,OAAO;AACzC,YAAIC,UAAU,SAAS,gBAAgB,SAAS,mBAAmB;AACnE,YAAI,UAAU;AACV,gBAAM,aAAa,QAAQ,YAAY,GAAG;AAC1C,gBAAM,aAAa,SAAS,gBAAgB,QAAQ,UAAU,GAAG,UAAU,GAAG,mBAAmB;AACjG,UAAAA,UAASA,QAAO,KAAK,UAAU;AAAA,QACnC;AACA,eAAOA;AAAA,MACX;AAEA,UAAI,iBAAiB,qBAAqB;AACtC,cAAM,aAAa,QAAQ,YAAY,GAAG;AAC1C,cAAM,aAAa,SAAS,gBAAgB,QAAQ,UAAU,GAAG,UAAU,GAAG,mBAAmB;AACjG,cAAM,MAAM,QAAQ,UAAU,aAAa,CAAC;AAC5C,cAAM,qBAAqB,KAAK,UAAU;AAC1C;AAAA,MACJ;AAEA,UAAI,iBAAiB,gBAAgB;AACjC,cAAM,aAAa,kBAAkB,GAAG,CAAC;AACzC;AAAA,MACJ;AAEA,UAAI,iBAAiB,oBAAoB;AACrC,gBAAQ,MAAM,iBAAiB,kBAAkB,CAAC;AAAA,MACtD;AAEA,eAAS,mBAAmB,SAAS,SAAS,gBAAgB,SAAS,
|
|
4
|
+
"sourcesContent": ["import { UICoreExtensionValueObject } from \"./UICoreExtensionValueObject\"\nimport { UITimer } from \"./UITimer\"\n\n\nfunction NilFunction() {\n return nil\n}\n\n\n// The nil object avoids unnecessary crashes by allowing you to call any function or access any variable on it, returning nil\nexport var nil: any = new Proxy(Object.assign(NilFunction, { \"class\": null, \"className\": \"Nil\" }), {\n get(target, name) {\n if (name == Symbol.toPrimitive) {\n return function (hint: string) {\n if (hint == \"number\") {\n return 0\n }\n if (hint == \"string\") {\n return \"\"\n }\n return false\n }\n }\n if (name == \"toString\") {\n return function toString() {\n return \"\"\n }\n }\n return NilFunction()\n },\n set() {\n return NilFunction()\n }\n})\n\n\nexport function wrapInNil<T>(object?: T): T {\n let result = FIRST_OR_NIL(object)\n if (object instanceof Object && !(object instanceof Function)) {\n result = new Proxy(object as Object & T, {\n get(target, name) {\n if (name == \"wrapped_nil_target\") {\n return target\n }\n const value = Reflect.get(target, name)\n if (typeof value === \"object\") {\n return wrapInNil(value)\n }\n if (IS_NOT_LIKE_NULL(value)) {\n return value\n }\n return nil\n },\n set(target: Record<string, any> & T, name: string, value: any) {\n if (IS(target)) {\n // @ts-ignore\n target[name] = value\n }\n return YES\n }\n })\n }\n return result\n}\n\n\nexport const YES = true\nexport const NO = false\n\nexport function IS<T>(object: T | undefined | null | false): object is T {\n if (object && object !== nil) {\n return YES\n }\n return NO\n}\n\nexport function IS_NOT(object: any): object is undefined | null | false {\n return !IS(object)\n}\n\nexport function IS_DEFINED<T>(object: T | undefined): object is T {\n if (object != undefined) {\n return YES\n }\n return NO\n}\n\nexport function IS_UNDEFINED(object: any): object is undefined {\n return !IS_DEFINED(object)\n}\n\nexport function IS_NIL(object: any): object is typeof nil {\n if (object === nil) {\n return YES\n }\n return NO\n}\n\nexport function IS_NOT_NIL<T>(object: T | undefined | null): object is T | undefined | null {\n return !IS_NIL(object)\n}\n\n\nexport function IS_LIKE_NULL(object: any): object is undefined | null {\n return (IS_UNDEFINED(object) || IS_NIL(object) || object == null)\n}\n\nexport function IS_NOT_LIKE_NULL<T>(object: T | null | undefined): object is T {\n return !IS_LIKE_NULL(object)\n}\n\n\nexport function IS_AN_EMAIL_ADDRESS(email: string) {\n const re = /\\S+@\\S+\\.\\S+/\n return re.test(email)\n}\n\n\nexport function FIRST_OR_NIL<T>(...objects: (T | undefined | null)[]): T {\n const result = objects.find(object => IS(object))\n return result || nil\n}\n\nexport function FIRST<T>(...objects: (T | undefined | null)[]): T {\n const result = objects.find(object => IS(object))\n return result || IF(IS_DEFINED(objects.lastElement))(RETURNER(objects.lastElement))()\n}\n\n\nexport function MAKE_ID(randomPartLength = 15) {\n let result = \"\"\n const characters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\"\n for (let i = 0; i < randomPartLength; i++) {\n result = result + characters.charAt(Math.floor(Math.random() * characters.length))\n }\n result = result + Date.now()\n return result\n}\n\n\nexport function RETURNER<T>(value?: T) {\n return (..._objects: any[]) => value\n}\n\n\nexport type UIIFBlockReceiver<T> = (functionToCall: () => any) => UIIFEvaluator<T>;\nexport type UIIFEvaluatorBase<T> = () => T;\n\n\nexport interface UIIFEvaluator<T> extends UIIFEvaluatorBase<T> {\n ELSE_IF: (otherValue: any) => UIIFBlockReceiver<T>;\n ELSE: (functionToCall: () => any) => T;\n}\n\n\nexport function IF<T = any>(value: any): UIIFBlockReceiver<T> {\n \n let thenFunction = nil\n let elseFunction = nil\n \n const result: any = function (functionToCall: () => T) {\n thenFunction = functionToCall\n return result.evaluateConditions\n }\n \n result.evaluateConditions = function () {\n if (IS(value)) {\n return thenFunction()\n }\n return elseFunction()\n }\n \n result.evaluateConditions.ELSE_IF = function (otherValue: any) {\n \n const functionResult = IF(otherValue) as (UIIFBlockReceiver<T> & { evaluateConditions: UIIFEvaluator<T> })\n elseFunction = functionResult.evaluateConditions\n \n const functionResultEvaluateConditionsFunction: any = function () {\n return result.evaluateConditions()\n }\n functionResultEvaluateConditionsFunction.ELSE_IF = functionResult.evaluateConditions.ELSE_IF\n functionResultEvaluateConditionsFunction.ELSE = functionResult.evaluateConditions.ELSE\n \n functionResult.evaluateConditions = functionResultEvaluateConditionsFunction\n \n return functionResult\n \n }\n \n result.evaluateConditions.ELSE = function (functionToCall: () => T) {\n elseFunction = functionToCall\n return result.evaluateConditions()\n }\n \n return result\n}\n\n\nexport class UIFunctionCall<T extends (...args: any) => any> {\n \n isAUIFunctionCallObject = YES\n parameters: Parameters<T>[]\n \n constructor(...parameters: Parameters<T>) {\n this.parameters = parameters\n }\n \n callFunction(functionToCall: T) {\n const parameters = this.parameters\n functionToCall(...parameters)\n }\n \n}\n\n\nexport function CALL<T extends (...args: any) => any>(...objects: Parameters<T>) {\n return new UIFunctionCall<T>(...objects)\n}\n\n\nexport class UIFunctionExtender<T extends (...args: any) => any> {\n \n isAUIFunctionExtenderObject = YES\n extendingFunction: T\n \n constructor(extendingFunction: T) {\n this.extendingFunction = extendingFunction\n }\n \n extendedFunction(functionToExtend: T) {\n const extendingFunction = this.extendingFunction\n \n function extendedFunction(this: any, ...objects: any[]) {\n const boundFunctionToExtend = functionToExtend.bind(this)\n boundFunctionToExtend(...objects)\n const boundExtendingFunction = extendingFunction.bind(this)\n boundExtendingFunction(...objects)\n }\n \n extendedFunction.extendedFunction = functionToExtend\n return extendedFunction\n }\n \n}\n\n\nexport function EXTEND<T extends (...args: any) => any>(extendingFunction: T) {\n return new UIFunctionExtender(extendingFunction)\n}\n\n\nexport class UILazyPropertyValue<T> {\n \n isAUILazyPropertyValueObject = YES\n initFunction: () => T\n \n constructor(initFunction: () => T) {\n this.initFunction = initFunction\n }\n \n setLazyPropertyValue(key: string, target: object) {\n \n let isValueInitialized = NO\n \n // property value\n let _value = nil\n \n const initValue = () => {\n _value = this.initFunction()\n isValueInitialized = YES\n this.initFunction = nil\n }\n \n // @ts-ignore\n if (delete target[key]) {\n \n // Create new property with getter and setter\n Object.defineProperty(target, key, {\n get: function () {\n if (IS_NOT(isValueInitialized)) {\n initValue()\n }\n return _value\n },\n set: function (newValue) {\n _value = newValue\n },\n enumerable: true,\n configurable: true\n })\n \n }\n \n }\n \n}\n\n\nexport function LAZY_VALUE<T>(initFunction: () => T) {\n return new UILazyPropertyValue(initFunction)\n}\n\n\nexport type UIInitializerObject<T> = {\n \n [P in keyof T]?:\n //T[P] extends (infer U)[] ? UIInitializerObject<U>[] :\n T[P] extends (...args: any) => any ? UIFunctionCall<T[P]> | UIFunctionExtender<T[P]> | T[P] :\n T[P] extends object ? UIInitializerObject<T[P]> | UILazyPropertyValue<T[P]> :\n T[P];\n \n}\n\n\nexport class UIObject {\n \n constructor() {\n \n // Do something here if needed\n \n }\n \n public get class(): any {\n return Object.getPrototypeOf(this).constructor\n }\n \n public get superclass(): any {\n return Object.getPrototypeOf(Object.getPrototypeOf(this)).constructor\n }\n \n isKindOfClass(classObject: any) {\n if (this.isMemberOfClass(classObject)) {\n return YES\n }\n for (let superclassObject = this.superclass; IS(superclassObject); superclassObject = superclassObject.superclass) {\n if (superclassObject == classObject) {\n return YES\n }\n }\n return NO\n }\n \n \n isMemberOfClass(classObject: any) {\n return (this.class == classObject)\n }\n \n public static wrapObject<T>(object: T): UIObject & T {\n if (IS_NOT(object)) {\n return nil\n }\n \n if ((object as any) instanceof UIObject) {\n // @ts-ignore\n return object\n }\n \n return Object.assign(new UIObject(), object)\n }\n \n \n valueForKey(key: string) {\n // @ts-ignore\n return this[key]\n }\n \n valueForKeyPath(keyPath: string): any {\n return UIObject.valueForKeyPath(keyPath, this)\n }\n \n static valueForKeyPath(keyPath: string, object: any): any {\n \n if (IS_NOT(keyPath)) {\n return object\n }\n \n const keys = keyPath.split(\".\")\n let currentObject = object\n \n for (let i = 0; i < keys.length; i++) {\n \n const key = keys[i]\n \n if (key.substring(0, 2) == \"[]\") {\n \n // This next object will be an array and the rest of the keys need to be run for each of the elements\n currentObject = currentObject[key.substring(2)]\n \n // CurrentObject is now an array\n \n const remainingKeyPath = keys.slice(i + 1).join(\".\")\n const currentArray = currentObject as unknown as any[]\n currentObject = currentArray.map(subObject => UIObject.valueForKeyPath(remainingKeyPath, subObject))\n \n break\n \n }\n \n currentObject = currentObject[key]\n if (IS_LIKE_NULL(currentObject)) {\n currentObject = nil\n }\n \n }\n \n return currentObject\n \n }\n \n setValueForKeyPath(keyPath: string, value: any, createPath = YES) {\n return UIObject.setValueForKeyPath(keyPath, value, this, createPath)\n }\n \n static setValueForKeyPath(keyPath: string, value: any, currentObject: any, createPath: boolean) {\n \n const keys = keyPath.split(\".\")\n let didSetValue = NO\n \n keys.forEach((key, index, array) => {\n if (index == array.length - 1 && IS_NOT_LIKE_NULL(currentObject)) {\n currentObject[key] = value\n didSetValue = YES\n return\n }\n else if (IS_NOT(currentObject)) {\n return\n }\n \n const currentObjectValue = currentObject[key]\n if (IS_LIKE_NULL(currentObjectValue) && createPath) {\n currentObject[key] = {}\n }\n currentObject = currentObject[key]\n })\n \n return didSetValue\n \n }\n \n \n configureWithObject(object: UIInitializerObject<this>) {\n \n return UIObject.configureWithObject(this, object)\n \n }\n \n configuredWithObject(object: UIInitializerObject<this>): this {\n \n this.configureWithObject(object)\n return this\n \n }\n \n \n static configureWithObject<TargetObjectType extends object, ConfigurationObjectType extends UIInitializerObject<TargetObjectType>>(\n configurationTarget: TargetObjectType,\n object: ConfigurationObjectType\n ): ConfigurationObjectType {\n \n const isAnObject = (item: any) => (item && typeof item === \"object\" && !Array.isArray(item) && !(item instanceof UICoreExtensionValueObject))\n const isAPureObject = (item: any) => isAnObject(item) && Object.getPrototypeOf(item) === Object.getPrototypeOf({})\n \n function isAClass(funcOrClass: object) {\n if (IS_NOT(funcOrClass)) {\n return NO\n }\n const isFunction = (functionToCheck: object) => (functionToCheck && {}.toString.call(functionToCheck) ===\n \"[object Function]\")\n const propertyNames = Object.getOwnPropertyNames(funcOrClass)\n return (isFunction(funcOrClass) && !propertyNames.includes(\"arguments\") &&\n propertyNames.includes(\"prototype\"))\n }\n \n const result = {} as ConfigurationObjectType\n \n let keyPathsAndValues: { value: any, keyPath: string }[] = []\n \n function prepareKeyPathsAndValues(target: Record<string, any>, source: object, keyPath = \"\") {\n \n if ((isAnObject(target) || isAClass(target)) && isAnObject(source)) {\n \n source.forEach((sourceValue, key) => {\n \n const valueKeyPath = keyPath + \".\" + key\n \n function addValueAndKeyPath(sourceValue: any) {\n keyPathsAndValues.push({\n value: sourceValue,\n keyPath: valueKeyPath.replace(\".\", \"\")\n })\n }\n \n \n if (isAPureObject(sourceValue) || isAClass(sourceValue)) {\n if (!(key in target) || target[key] instanceof Function) {\n addValueAndKeyPath(sourceValue)\n }\n else {\n prepareKeyPathsAndValues(target[key], sourceValue, valueKeyPath)\n }\n }\n else if (sourceValue instanceof UICoreExtensionValueObject) {\n addValueAndKeyPath(sourceValue.value)\n }\n else {\n addValueAndKeyPath(sourceValue)\n }\n \n })\n \n }\n \n }\n \n prepareKeyPathsAndValues(configurationTarget, object)\n \n // Sort based on key path lengths\n keyPathsAndValues = keyPathsAndValues.sort((a, b) => {\n \n const firstKeyPath = (a.keyPath as string).split(\".\").length\n const secondKeyPath = (b.keyPath as string).split(\".\").length\n \n if (firstKeyPath < secondKeyPath) {\n return -1\n }\n if (firstKeyPath > secondKeyPath) {\n return 1\n }\n return 0\n \n })\n \n keyPathsAndValues.forEach((valueAndKeyPath) => {\n \n const keyPath: string = valueAndKeyPath.keyPath\n let value = valueAndKeyPath.value\n \n const getTargetFunction = (bindThis = NO) => {\n let result = (UIObject.valueForKeyPath(keyPath, configurationTarget) as Function)\n if (bindThis) {\n const indexOfDot = keyPath.lastIndexOf(\".\")\n const thisObject = UIObject.valueForKeyPath(keyPath.substring(0, indexOfDot), configurationTarget)\n result = result.bind(thisObject)\n }\n return result\n }\n \n if (value instanceof UILazyPropertyValue) {\n const indexOfDot = keyPath.lastIndexOf(\".\")\n const thisObject = UIObject.valueForKeyPath(keyPath.substring(0, indexOfDot), configurationTarget)\n const key = keyPath.substring(indexOfDot + 1)\n value.setLazyPropertyValue(key, thisObject)\n return\n }\n \n if (value instanceof UIFunctionCall) {\n value.callFunction(getTargetFunction(YES))\n return\n }\n \n if (value instanceof UIFunctionExtender) {\n value = value.extendedFunction(getTargetFunction())\n }\n \n UIObject.setValueForKeyPath(keyPath, UIObject.valueForKeyPath(keyPath, configurationTarget), result, YES)\n UIObject.setValueForKeyPath(keyPath, value, configurationTarget, YES)\n \n })\n \n \n return result\n \n }\n \n static configuredWithObject<T extends object>(configurationTarget: T, object: UIInitializerObject<T>) {\n this.configureWithObject(configurationTarget, object)\n return configurationTarget\n }\n \n \n performFunctionWithSelf<T>(functionToPerform: (self: this) => T): T {\n return functionToPerform(this)\n }\n \n performingFunctionWithSelf(functionToPerform: (self: this) => void): this {\n functionToPerform(this)\n return this\n }\n \n performFunctionWithDel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
|
|
@@ -42,6 +42,7 @@ export declare class UIRectangle extends UIObject {
|
|
|
42
42
|
rectangleWithY(y: number, centeredOnPosition?: number): UIRectangle;
|
|
43
43
|
rectangleByAddingX(x: number): UIRectangle;
|
|
44
44
|
rectangleByAddingY(y: number): UIRectangle;
|
|
45
|
+
rectangleRelativeToBounds(bounds: UIRectangle, relativeXPosition: number, widthMultiplier: number, relativeYPosition: number, heightMultiplier: number): UIRectangle;
|
|
45
46
|
rectanglesBySplittingWidth(weights: number[], paddings?: number | number[], absoluteWidths?: number | number[]): UIRectangle[];
|
|
46
47
|
rectanglesBySplittingHeight(weights: number[], paddings?: number | number[], absoluteHeights?: number | number[]): UIRectangle[];
|
|
47
48
|
rectanglesByEquallySplittingWidth(numberOfFrames: number, padding?: number): UIRectangle[];
|
|
@@ -260,6 +260,18 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
260
260
|
result.y = this.y + y;
|
|
261
261
|
return result;
|
|
262
262
|
}
|
|
263
|
+
rectangleRelativeToBounds(bounds, relativeXPosition, widthMultiplier, relativeYPosition, heightMultiplier) {
|
|
264
|
+
const result = this.copy();
|
|
265
|
+
const width = result.width;
|
|
266
|
+
const height = result.height;
|
|
267
|
+
result.width = widthMultiplier * width;
|
|
268
|
+
result.height = heightMultiplier * height;
|
|
269
|
+
result.center = new import_UIPoint.UIPoint(
|
|
270
|
+
relativeXPosition * width,
|
|
271
|
+
relativeYPosition * height
|
|
272
|
+
);
|
|
273
|
+
return result;
|
|
274
|
+
}
|
|
263
275
|
rectanglesBySplittingWidth(weights, paddings = 0, absoluteWidths = import_UIObject.nil) {
|
|
264
276
|
if ((0, import_UIObject.IS_NIL)(paddings)) {
|
|
265
277
|
paddings = 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIRectangle.ts"],
|
|
4
|
-
"sourcesContent": ["import { FIRST_OR_NIL, IS, IS_NIL, IS_NOT_NIL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIView } from \"./UIView\"\n\n\nexport class UIRectangle extends UIObject {\n \n _isBeingUpdated: boolean\n rectanglePointDidChange: (b: any) => void = nil\n max: UIPoint\n min: UIPoint\n \n \n constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {\n \n super()\n \n this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)\n this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)\n \n this.min.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n this.max.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n \n this._isBeingUpdated = NO\n \n this.min = new UIPoint(x, y)\n this.max = new UIPoint(x + width, y + height)\n \n if (IS_NIL(height)) {\n this.max.y = height\n }\n \n if (IS_NIL(width)) {\n this.max.x = width\n }\n \n }\n \n \n copy() {\n return new UIRectangle(this.x, this.y, this.height, this.width)\n }\n \n isEqualTo(rectangle: UIRectangle | null | undefined) {\n return (IS(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max))\n }\n \n static zero() {\n return new UIRectangle(0, 0, 0, 0)\n }\n \n containsPoint(point: UIPoint) {\n return this.min.x <= point.x && this.min.y <= point.y &&\n point.x <= this.max.x && point.y <= this.max.y\n }\n \n updateByAddingPoint(point: UIPoint) {\n \n if (!point) {\n point = new UIPoint(0, 0)\n }\n \n this.beginUpdates()\n \n const min = this.min.copy()\n if (min.x === nil) {\n min.x = this.max.x\n }\n if (min.y === nil) {\n min.y = this.max.y\n }\n \n const max = this.max.copy()\n if (max.x === nil) {\n max.x = this.min.x\n }\n if (max.y === nil) {\n max.y = this.min.y\n }\n \n this.min.x = Math.min(min.x, point.x)\n this.min.y = Math.min(min.y, point.y)\n this.max.x = Math.max(max.x, point.x)\n this.max.y = Math.max(max.y, point.y)\n \n this.finishUpdates()\n \n }\n \n scale(scale: number) {\n if (IS_NOT_NIL(this.max.y)) {\n this.height = this.height * scale\n }\n if (IS_NOT_NIL(this.max.x)) {\n this.width = this.width * scale\n }\n }\n \n get height() {\n if (this.max.y === nil) {\n return nil\n }\n return this.max.y - this.min.y\n }\n \n set height(height: number) {\n this.max.y = this.min.y + height\n }\n \n \n get width() {\n if (this.max.x === nil) {\n return nil\n }\n return this.max.x - this.min.x\n }\n \n set width(width: number) {\n this.max.x = this.min.x + width\n }\n \n \n get x() {\n return this.min.x\n }\n \n set x(x: number) {\n \n this.beginUpdates()\n \n const width = this.width\n this.min.x = x\n this.max.x = this.min.x + width\n \n this.finishUpdates()\n \n }\n \n \n get y() {\n return this.min.y\n }\n \n \n set y(y: number) {\n \n this.beginUpdates()\n \n const height = this.height\n this.min.y = y\n this.max.y = this.min.y + height\n \n this.finishUpdates()\n \n }\n \n \n get topLeft() {\n return this.min.copy()\n }\n \n get topRight() {\n return new UIPoint(this.max.x, this.y)\n }\n \n get bottomLeft() {\n return new UIPoint(this.x, this.max.y)\n }\n \n get bottomRight() {\n return this.max.copy()\n }\n \n \n get center() {\n return this.min.copy().add(this.min.to(this.max).scale(0.5))\n }\n \n set center(center: UIPoint) {\n const offset = this.center.to(center)\n this.offsetByPoint(offset)\n }\n \n offsetByPoint(offset: UIPoint) {\n this.min.add(offset)\n this.max.add(offset)\n \n return this\n }\n \n \n concatenateWithRectangle(rectangle: UIRectangle) {\n this.updateByAddingPoint(rectangle.bottomRight)\n this.updateByAddingPoint(rectangle.topLeft)\n return this\n }\n \n \n intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {\n \n const result = this.copy()\n \n result.beginUpdates()\n \n const min = result.min\n if (min.x === nil) {\n min.x = rectangle.max.x - Math.min(result.width, rectangle.width)\n }\n if (min.y === nil) {\n min.y = rectangle.max.y - Math.min(result.height, rectangle.height)\n }\n \n const max = result.max\n if (max.x === nil) {\n max.x = rectangle.min.x + Math.min(result.width, rectangle.width)\n }\n if (max.y === nil) {\n max.y = rectangle.min.y + Math.min(result.height, rectangle.height)\n }\n \n result.min.x = Math.max(result.min.x, rectangle.min.x)\n result.min.y = Math.max(result.min.y, rectangle.min.y)\n result.max.x = Math.min(result.max.x, rectangle.max.x)\n result.max.y = Math.min(result.max.y, rectangle.max.y)\n \n \n if (result.height < 0) {\n \n const averageY = (this.center.y + rectangle.center.y) * 0.5\n result.min.y = averageY\n result.max.y = averageY\n \n }\n \n if (result.width < 0) {\n \n const averageX = (this.center.x + rectangle.center.x) * 0.5\n result.min.x = averageX\n result.max.x = averageX\n \n }\n \n result.finishUpdates()\n \n return result\n \n }\n \n \n get area() {\n return this.height * this.width\n }\n \n \n intersectsWithRectangle(rectangle: UIRectangle) {\n return (this.intersectionRectangleWithRectangle(rectangle).area != 0)\n }\n \n \n // add some space around the rectangle\n rectangleWithInsets(left: number, right: number, bottom: number, top: number) {\n const result = this.copy()\n result.min.x = this.min.x + left\n result.max.x = this.max.x - right\n result.min.y = this.min.y + top\n result.max.y = this.max.y - bottom\n return result\n }\n \n rectangleWithInset(inset: number) {\n return this.rectangleWithInsets(inset, inset, inset, inset)\n }\n \n rectangleWithHeight(height: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.height = height\n \n if (centeredOnPosition != nil) {\n const change = height - this.height\n result.offsetByPoint(new UIPoint(0, change * centeredOnPosition).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithWidth(width: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.width = width\n \n if (centeredOnPosition != nil) {\n const change = width - this.width\n result.offsetByPoint(new UIPoint(change * centeredOnPosition, 0).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithHeightRelativeToWidth(heightRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithHeight(this.width * heightRatio, centeredOnPosition)\n }\n \n rectangleWithWidthRelativeToHeight(widthRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithWidth(this.height * widthRatio, centeredOnPosition)\n }\n \n rectangleWithX(x: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.x = x - result.width * centeredOnPosition\n \n return result\n \n }\n \n rectangleWithY(y: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.y = y - result.height * centeredOnPosition\n \n return result\n \n }\n \n \n rectangleByAddingX(x: number) {\n \n const result = this.copy()\n result.x = this.x + x\n \n return result\n \n }\n \n rectangleByAddingY(y: number) {\n \n const result = this.copy()\n result.y = this.y + y\n \n return result\n \n }\n \n \n rectanglesBySplittingWidth(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteWidths: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {\n absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteWidths as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue\n const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths\n let previousCellMaxX = this.x\n \n for (let i = 0; i < weights.length; i++) {\n \n let resultWidth: number\n if (IS_NOT_NIL(absoluteWidths[i])) {\n resultWidth = absoluteWidths[i] || 0\n }\n else {\n resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)\n }\n \n const rectangle = this.rectangleWithWidth(resultWidth)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.x = previousCellMaxX\n previousCellMaxX = rectangle.max.x + padding\n result.push(rectangle)\n \n }\n \n return result\n \n }\n \n rectanglesBySplittingHeight(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteHeights: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {\n absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteHeights as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue\n const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights\n var previousCellMaxY = this.y\n \n for (var i = 0; i < weights.length; i++) {\n var resultHeight: number\n if (IS_NOT_NIL(absoluteHeights[i])) {\n \n resultHeight = absoluteHeights[i] || 0\n \n }\n else {\n \n resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)\n \n }\n \n const rectangle = this.rectangleWithHeight(resultHeight)\n \n var padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.y = previousCellMaxY\n previousCellMaxY = rectangle.max.y + padding\n //rectangle = rectangle.rectangleWithInsets(0, 0, padding, 0);\n result.push(rectangle)\n }\n \n return result\n \n }\n \n \n rectanglesByEquallySplittingWidth(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultWidth = (this.width - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithWidth(resultWidth, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n rectanglesByEquallySplittingHeight(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultHeight = (this.height - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithHeight(resultHeight, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n \n distributeViewsAlongWidth(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteWidths?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n distributeViewsAlongHeight(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteHeights?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n \n distributeViewsEquallyAlongWidth(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingWidth(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n distributeViewsEquallyAlongHeight(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingHeight(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n \n rectangleForNextRow(padding: number = 0, height = this.height) {\n const result = this.rectangleWithY(this.max.y + padding)\n if (height != this.height) {\n result.height = height\n }\n return result\n }\n \n rectangleForNextColumn(padding: number = 0, width = this.width) {\n const result = this.rectangleWithX(this.max.x + padding)\n if (width != this.width) {\n result.width = width\n }\n return result\n }\n \n rectangleForPreviousRow(padding: number = 0) {\n return this.rectangleWithY(this.min.y - this.height - padding)\n }\n \n rectangleForPreviousColumn(padding: number = 0) {\n return this.rectangleWithX(this.min.x - this.width - padding)\n }\n \n \n // Bounding box\n static boundingBoxForPoints(points: string | any[]) {\n const result = new UIRectangle()\n for (let i = 0; i < points.length; i++) {\n result.updateByAddingPoint(points[i])\n }\n return result\n }\n \n \n beginUpdates() {\n this._isBeingUpdated = YES\n }\n \n finishUpdates() {\n this._isBeingUpdated = NO\n this.didChange()\n }\n \n \n didChange() {\n \n // Callback to be set by delegate\n \n }\n \n _rectanglePointDidChange() {\n if (!this._isBeingUpdated) {\n this.didChange()\n }\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6E;AAC7E,qBAAwB;AAIjB,MAAM,oBAAoB,yBAAS;AAAA,EAQtC,YAAY,IAAY,GAAG,IAAY,GAAG,SAAiB,GAAG,QAAgB,GAAG;AAE7E,UAAM;AAPV,mCAA4C;AASxC,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AACzE,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AAEzE,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAAK,wBAAwB,KAAK;AAClC,WAAK,yBAAyB;AAAA,IAClC;AACA,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAAK,wBAAwB,KAAK;AAClC,WAAK,yBAAyB;AAAA,IAClC;AAEA,SAAK,kBAAkB;AAEvB,SAAK,MAAM,IAAI,uBAAQ,GAAG,CAAC;AAC3B,SAAK,MAAM,IAAI,uBAAQ,IAAI,OAAO,IAAI,MAAM;AAE5C,YAAI,wBAAO,MAAM,GAAG;AAChB,WAAK,IAAI,IAAI;AAAA,IACjB;AAEA,YAAI,wBAAO,KAAK,GAAG;AACf,WAAK,IAAI,IAAI;AAAA,IACjB;AAAA,EAEJ;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EACJ;AAGJ;",
|
|
4
|
+
"sourcesContent": ["import { FIRST_OR_NIL, IS, IS_NIL, IS_NOT_NIL, nil, NO, UIObject, YES } from \"./UIObject\"\nimport { UIPoint } from \"./UIPoint\"\nimport { UIView } from \"./UIView\"\n\n\nexport class UIRectangle extends UIObject {\n \n _isBeingUpdated: boolean\n rectanglePointDidChange: (b: any) => void = nil\n max: UIPoint\n min: UIPoint\n \n \n constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {\n \n super()\n \n this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)\n this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)\n \n this.min.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n this.max.didChange = (point) => {\n this.rectanglePointDidChange(point)\n this._rectanglePointDidChange()\n }\n \n this._isBeingUpdated = NO\n \n this.min = new UIPoint(x, y)\n this.max = new UIPoint(x + width, y + height)\n \n if (IS_NIL(height)) {\n this.max.y = height\n }\n \n if (IS_NIL(width)) {\n this.max.x = width\n }\n \n }\n \n \n copy() {\n return new UIRectangle(this.x, this.y, this.height, this.width)\n }\n \n isEqualTo(rectangle: UIRectangle | null | undefined) {\n return (IS(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max))\n }\n \n static zero() {\n return new UIRectangle(0, 0, 0, 0)\n }\n \n containsPoint(point: UIPoint) {\n return this.min.x <= point.x && this.min.y <= point.y &&\n point.x <= this.max.x && point.y <= this.max.y\n }\n \n updateByAddingPoint(point: UIPoint) {\n \n if (!point) {\n point = new UIPoint(0, 0)\n }\n \n this.beginUpdates()\n \n const min = this.min.copy()\n if (min.x === nil) {\n min.x = this.max.x\n }\n if (min.y === nil) {\n min.y = this.max.y\n }\n \n const max = this.max.copy()\n if (max.x === nil) {\n max.x = this.min.x\n }\n if (max.y === nil) {\n max.y = this.min.y\n }\n \n this.min.x = Math.min(min.x, point.x)\n this.min.y = Math.min(min.y, point.y)\n this.max.x = Math.max(max.x, point.x)\n this.max.y = Math.max(max.y, point.y)\n \n this.finishUpdates()\n \n }\n \n scale(scale: number) {\n if (IS_NOT_NIL(this.max.y)) {\n this.height = this.height * scale\n }\n if (IS_NOT_NIL(this.max.x)) {\n this.width = this.width * scale\n }\n }\n \n get height() {\n if (this.max.y === nil) {\n return nil\n }\n return this.max.y - this.min.y\n }\n \n set height(height: number) {\n this.max.y = this.min.y + height\n }\n \n \n get width() {\n if (this.max.x === nil) {\n return nil\n }\n return this.max.x - this.min.x\n }\n \n set width(width: number) {\n this.max.x = this.min.x + width\n }\n \n \n get x() {\n return this.min.x\n }\n \n set x(x: number) {\n \n this.beginUpdates()\n \n const width = this.width\n this.min.x = x\n this.max.x = this.min.x + width\n \n this.finishUpdates()\n \n }\n \n \n get y() {\n return this.min.y\n }\n \n \n set y(y: number) {\n \n this.beginUpdates()\n \n const height = this.height\n this.min.y = y\n this.max.y = this.min.y + height\n \n this.finishUpdates()\n \n }\n \n \n get topLeft() {\n return this.min.copy()\n }\n \n get topRight() {\n return new UIPoint(this.max.x, this.y)\n }\n \n get bottomLeft() {\n return new UIPoint(this.x, this.max.y)\n }\n \n get bottomRight() {\n return this.max.copy()\n }\n \n \n get center() {\n return this.min.copy().add(this.min.to(this.max).scale(0.5))\n }\n \n set center(center: UIPoint) {\n const offset = this.center.to(center)\n this.offsetByPoint(offset)\n }\n \n offsetByPoint(offset: UIPoint) {\n this.min.add(offset)\n this.max.add(offset)\n \n return this\n }\n \n \n concatenateWithRectangle(rectangle: UIRectangle) {\n this.updateByAddingPoint(rectangle.bottomRight)\n this.updateByAddingPoint(rectangle.topLeft)\n return this\n }\n \n \n intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {\n \n const result = this.copy()\n \n result.beginUpdates()\n \n const min = result.min\n if (min.x === nil) {\n min.x = rectangle.max.x - Math.min(result.width, rectangle.width)\n }\n if (min.y === nil) {\n min.y = rectangle.max.y - Math.min(result.height, rectangle.height)\n }\n \n const max = result.max\n if (max.x === nil) {\n max.x = rectangle.min.x + Math.min(result.width, rectangle.width)\n }\n if (max.y === nil) {\n max.y = rectangle.min.y + Math.min(result.height, rectangle.height)\n }\n \n result.min.x = Math.max(result.min.x, rectangle.min.x)\n result.min.y = Math.max(result.min.y, rectangle.min.y)\n result.max.x = Math.min(result.max.x, rectangle.max.x)\n result.max.y = Math.min(result.max.y, rectangle.max.y)\n \n \n if (result.height < 0) {\n \n const averageY = (this.center.y + rectangle.center.y) * 0.5\n result.min.y = averageY\n result.max.y = averageY\n \n }\n \n if (result.width < 0) {\n \n const averageX = (this.center.x + rectangle.center.x) * 0.5\n result.min.x = averageX\n result.max.x = averageX\n \n }\n \n result.finishUpdates()\n \n return result\n \n }\n \n \n get area() {\n return this.height * this.width\n }\n \n \n intersectsWithRectangle(rectangle: UIRectangle) {\n return (this.intersectionRectangleWithRectangle(rectangle).area != 0)\n }\n \n \n // add some space around the rectangle\n rectangleWithInsets(left: number, right: number, bottom: number, top: number) {\n const result = this.copy()\n result.min.x = this.min.x + left\n result.max.x = this.max.x - right\n result.min.y = this.min.y + top\n result.max.y = this.max.y - bottom\n return result\n }\n \n rectangleWithInset(inset: number) {\n return this.rectangleWithInsets(inset, inset, inset, inset)\n }\n \n rectangleWithHeight(height: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.height = height\n \n if (centeredOnPosition != nil) {\n const change = height - this.height\n result.offsetByPoint(new UIPoint(0, change * centeredOnPosition).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithWidth(width: number, centeredOnPosition: number = nil) {\n \n if (isNaN(centeredOnPosition)) {\n centeredOnPosition = nil\n }\n \n const result = this.copy()\n result.width = width\n \n if (centeredOnPosition != nil) {\n const change = width - this.width\n result.offsetByPoint(new UIPoint(change * centeredOnPosition, 0).scale(-1))\n }\n \n return result\n \n }\n \n rectangleWithHeightRelativeToWidth(heightRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithHeight(this.width * heightRatio, centeredOnPosition)\n }\n \n rectangleWithWidthRelativeToHeight(widthRatio: number = 1, centeredOnPosition: number = nil) {\n return this.rectangleWithWidth(this.height * widthRatio, centeredOnPosition)\n }\n \n rectangleWithX(x: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.x = x - result.width * centeredOnPosition\n \n return result\n \n }\n \n rectangleWithY(y: number, centeredOnPosition: number = 0) {\n \n const result = this.copy()\n result.y = y - result.height * centeredOnPosition\n \n return result\n \n }\n \n \n rectangleByAddingX(x: number) {\n \n const result = this.copy()\n result.x = this.x + x\n \n return result\n \n }\n \n rectangleByAddingY(y: number) {\n \n const result = this.copy()\n result.y = this.y + y\n \n return result\n \n }\n \n \n rectangleRelativeToBounds(\n bounds: UIRectangle,\n relativeXPosition: number,\n widthMultiplier: number,\n relativeYPosition: number,\n heightMultiplier: number\n ) {\n \n const result = this.copy()\n \n const width = result.width\n const height = result.height\n \n result.width = widthMultiplier * width\n result.height = heightMultiplier * height\n \n result.center = new UIPoint(\n relativeXPosition * width,\n relativeYPosition * height\n )\n \n return result\n \n }\n \n \n rectanglesBySplittingWidth(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteWidths: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {\n absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteWidths as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue\n const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths\n let previousCellMaxX = this.x\n \n for (let i = 0; i < weights.length; i++) {\n \n let resultWidth: number\n if (IS_NOT_NIL(absoluteWidths[i])) {\n resultWidth = absoluteWidths[i] || 0\n }\n else {\n resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)\n }\n \n const rectangle = this.rectangleWithWidth(resultWidth)\n \n let padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.x = previousCellMaxX\n previousCellMaxX = rectangle.max.x + padding\n result.push(rectangle)\n \n }\n \n return result\n \n }\n \n rectanglesBySplittingHeight(\n weights: number[],\n paddings: number | number[] = 0,\n absoluteHeights: number | number[] = nil\n ) {\n \n if (IS_NIL(paddings)) {\n paddings = 1\n }\n if (!((paddings as any) instanceof Array)) {\n paddings = [paddings].arrayByRepeating(weights.length - 1)\n }\n paddings = (paddings as number[]).arrayByTrimmingToLengthIfLonger(weights.length - 1)\n if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {\n absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)\n }\n \n const result: UIRectangle[] = []\n const sumOfWeights = weights.reduce(\n (a, b, index) => {\n if (IS_NOT_NIL((absoluteHeights as number[])[index])) {\n b = 0\n }\n return a + b\n },\n 0\n )\n const sumOfPaddings = paddings.summedValue\n const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue\n const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights\n var previousCellMaxY = this.y\n \n for (var i = 0; i < weights.length; i++) {\n var resultHeight: number\n if (IS_NOT_NIL(absoluteHeights[i])) {\n \n resultHeight = absoluteHeights[i] || 0\n \n }\n else {\n \n resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)\n \n }\n \n const rectangle = this.rectangleWithHeight(resultHeight)\n \n var padding = 0\n if (paddings.length > i && paddings[i]) {\n padding = paddings[i]\n }\n \n rectangle.y = previousCellMaxY\n previousCellMaxY = rectangle.max.y + padding\n //rectangle = rectangle.rectangleWithInsets(0, 0, padding, 0);\n result.push(rectangle)\n }\n \n return result\n \n }\n \n \n rectanglesByEquallySplittingWidth(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultWidth = (this.width - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithWidth(resultWidth, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n rectanglesByEquallySplittingHeight(numberOfFrames: number, padding: number = 0) {\n const result: UIRectangle[] = []\n const totalPadding = padding * (numberOfFrames - 1)\n const resultHeight = (this.height - totalPadding) / numberOfFrames\n for (var i = 0; i < numberOfFrames; i++) {\n const rectangle = this.rectangleWithHeight(resultHeight, i / (numberOfFrames - 1))\n result.push(rectangle)\n }\n return result\n }\n \n \n distributeViewsAlongWidth(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteWidths?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n distributeViewsAlongHeight(\n views: UIView[],\n weights: number | number[] = 1,\n paddings?: number | number[],\n absoluteHeights?: number | number[]\n ) {\n if (!(weights instanceof Array)) {\n weights = [weights].arrayByRepeating(views.length)\n }\n const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights)\n frames.forEach((frame, index) => FIRST_OR_NIL(views[index]).frame = frame)\n return this\n }\n \n \n distributeViewsEquallyAlongWidth(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingWidth(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n distributeViewsEquallyAlongHeight(views: UIView[], padding: number) {\n const frames = this.rectanglesByEquallySplittingHeight(views.length, padding)\n frames.forEach((frame, index) => views[index].frame = frame)\n return this\n }\n \n \n rectangleForNextRow(padding: number = 0, height = this.height) {\n const result = this.rectangleWithY(this.max.y + padding)\n if (height != this.height) {\n result.height = height\n }\n return result\n }\n \n rectangleForNextColumn(padding: number = 0, width = this.width) {\n const result = this.rectangleWithX(this.max.x + padding)\n if (width != this.width) {\n result.width = width\n }\n return result\n }\n \n rectangleForPreviousRow(padding: number = 0) {\n return this.rectangleWithY(this.min.y - this.height - padding)\n }\n \n rectangleForPreviousColumn(padding: number = 0) {\n return this.rectangleWithX(this.min.x - this.width - padding)\n }\n \n \n // Bounding box\n static boundingBoxForPoints(points: string | any[]) {\n const result = new UIRectangle()\n for (let i = 0; i < points.length; i++) {\n result.updateByAddingPoint(points[i])\n }\n return result\n }\n \n \n beginUpdates() {\n this._isBeingUpdated = YES\n }\n \n finishUpdates() {\n this._isBeingUpdated = NO\n this.didChange()\n }\n \n \n didChange() {\n \n // Callback to be set by delegate\n \n }\n \n _rectanglePointDidChange() {\n if (!this._isBeingUpdated) {\n this.didChange()\n }\n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA6E;AAC7E,qBAAwB;AAIjB,MAAM,oBAAoB,yBAAS;AAAA,EAQtC,YAAY,IAAY,GAAG,IAAY,GAAG,SAAiB,GAAG,QAAgB,GAAG;AAE7E,UAAM;AAPV,mCAA4C;AASxC,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AACzE,SAAK,MAAM,IAAI,uBAAQ,OAAO,mBAAmB,OAAO,iBAAiB;AAEzE,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAAK,wBAAwB,KAAK;AAClC,WAAK,yBAAyB;AAAA,IAClC;AACA,SAAK,IAAI,YAAY,CAAC,UAAU;AAC5B,WAA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AG;AACzC,WAAO,KAAK,eAAe,KAAK,IAAI,IAAI,KAAK,SAAS,OAAO;AAAA,EACjE;AAAA,EAEA,2BAA2B,UAAkB,GAAG;AAC5C,WAAO,KAAK,eAAe,KAAK,IAAI,IAAI,KAAK,QAAQ,OAAO;AAAA,EAChE;AAAA,EAIA,OAAO,qBAAqB,QAAwB;AAChD,UAAM,SAAS,IAAI,YAAY;AAC/B,aAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACpC,aAAO,oBAAoB,OAAO,EAAE;AAAA,IACxC;AACA,WAAO;AAAA,EACX;AAAA,EAGA,eAAe;AACX,SAAK,kBAAkB;AAAA,EAC3B;AAAA,EAEA,gBAAgB;AACZ,SAAK,kBAAkB;AACvB,SAAK,UAAU;AAAA,EACnB;AAAA,EAGA,YAAY;AAAA,EAIZ;AAAA,EAEA,2BAA2B;AACvB,QAAI,CAAC,KAAK,iBAAiB;AACvB,WAAK,UAAU;AAAA,IACnB;AAAA,EACJ;AAGJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.171",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
package/scripts/UIObject.ts
CHANGED
|
@@ -562,7 +562,7 @@ export class UIObject {
|
|
|
562
562
|
value = value.extendedFunction(getTargetFunction())
|
|
563
563
|
}
|
|
564
564
|
|
|
565
|
-
UIObject.setValueForKeyPath(keyPath, UIObject.valueForKeyPath(keyPath,
|
|
565
|
+
UIObject.setValueForKeyPath(keyPath, UIObject.valueForKeyPath(keyPath, configurationTarget), result, YES)
|
|
566
566
|
UIObject.setValueForKeyPath(keyPath, value, configurationTarget, YES)
|
|
567
567
|
|
|
568
568
|
})
|
package/scripts/UIRectangle.ts
CHANGED
|
@@ -12,12 +12,12 @@ export class UIRectangle extends UIObject {
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
constructor(x: number = 0, y: number = 0, height: number = 0, width: number = 0) {
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
super()
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
this.min = new UIPoint(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)
|
|
19
19
|
this.max = new UIPoint(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY)
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
this.min.didChange = (point) => {
|
|
22
22
|
this.rectanglePointDidChange(point)
|
|
23
23
|
this._rectanglePointDidChange()
|
|
@@ -26,12 +26,12 @@ export class UIRectangle extends UIObject {
|
|
|
26
26
|
this.rectanglePointDidChange(point)
|
|
27
27
|
this._rectanglePointDidChange()
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
this._isBeingUpdated = NO
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
this.min = new UIPoint(x, y)
|
|
33
33
|
this.max = new UIPoint(x + width, y + height)
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
if (IS_NIL(height)) {
|
|
36
36
|
this.max.y = height
|
|
37
37
|
}
|
|
@@ -39,7 +39,7 @@ export class UIRectangle extends UIObject {
|
|
|
39
39
|
if (IS_NIL(width)) {
|
|
40
40
|
this.max.x = width
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
|
|
@@ -67,7 +67,7 @@ export class UIRectangle extends UIObject {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
this.beginUpdates()
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
const min = this.min.copy()
|
|
72
72
|
if (min.x === nil) {
|
|
73
73
|
min.x = this.max.x
|
|
@@ -75,7 +75,7 @@ export class UIRectangle extends UIObject {
|
|
|
75
75
|
if (min.y === nil) {
|
|
76
76
|
min.y = this.max.y
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
const max = this.max.copy()
|
|
80
80
|
if (max.x === nil) {
|
|
81
81
|
max.x = this.min.x
|
|
@@ -133,7 +133,7 @@ export class UIRectangle extends UIObject {
|
|
|
133
133
|
set x(x: number) {
|
|
134
134
|
|
|
135
135
|
this.beginUpdates()
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
const width = this.width
|
|
138
138
|
this.min.x = x
|
|
139
139
|
this.max.x = this.min.x + width
|
|
@@ -151,7 +151,7 @@ export class UIRectangle extends UIObject {
|
|
|
151
151
|
set y(y: number) {
|
|
152
152
|
|
|
153
153
|
this.beginUpdates()
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
const height = this.height
|
|
156
156
|
this.min.y = y
|
|
157
157
|
this.max.y = this.min.y + height
|
|
@@ -203,11 +203,11 @@ export class UIRectangle extends UIObject {
|
|
|
203
203
|
|
|
204
204
|
|
|
205
205
|
intersectionRectangleWithRectangle(rectangle: UIRectangle): UIRectangle {
|
|
206
|
-
|
|
206
|
+
|
|
207
207
|
const result = this.copy()
|
|
208
|
-
|
|
208
|
+
|
|
209
209
|
result.beginUpdates()
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
const min = result.min
|
|
212
212
|
if (min.x === nil) {
|
|
213
213
|
min.x = rectangle.max.x - Math.min(result.width, rectangle.width)
|
|
@@ -215,7 +215,7 @@ export class UIRectangle extends UIObject {
|
|
|
215
215
|
if (min.y === nil) {
|
|
216
216
|
min.y = rectangle.max.y - Math.min(result.height, rectangle.height)
|
|
217
217
|
}
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
const max = result.max
|
|
220
220
|
if (max.x === nil) {
|
|
221
221
|
max.x = rectangle.min.x + Math.min(result.width, rectangle.width)
|
|
@@ -231,7 +231,7 @@ export class UIRectangle extends UIObject {
|
|
|
231
231
|
|
|
232
232
|
|
|
233
233
|
if (result.height < 0) {
|
|
234
|
-
|
|
234
|
+
|
|
235
235
|
const averageY = (this.center.y + rectangle.center.y) * 0.5
|
|
236
236
|
result.min.y = averageY
|
|
237
237
|
result.max.y = averageY
|
|
@@ -239,7 +239,7 @@ export class UIRectangle extends UIObject {
|
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
if (result.width < 0) {
|
|
242
|
-
|
|
242
|
+
|
|
243
243
|
const averageX = (this.center.x + rectangle.center.x) * 0.5
|
|
244
244
|
result.min.x = averageX
|
|
245
245
|
result.max.x = averageX
|
|
@@ -282,7 +282,7 @@ export class UIRectangle extends UIObject {
|
|
|
282
282
|
if (isNaN(centeredOnPosition)) {
|
|
283
283
|
centeredOnPosition = nil
|
|
284
284
|
}
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
const result = this.copy()
|
|
287
287
|
result.height = height
|
|
288
288
|
|
|
@@ -300,7 +300,7 @@ export class UIRectangle extends UIObject {
|
|
|
300
300
|
if (isNaN(centeredOnPosition)) {
|
|
301
301
|
centeredOnPosition = nil
|
|
302
302
|
}
|
|
303
|
-
|
|
303
|
+
|
|
304
304
|
const result = this.copy()
|
|
305
305
|
result.width = width
|
|
306
306
|
|
|
@@ -322,7 +322,7 @@ export class UIRectangle extends UIObject {
|
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
rectangleWithX(x: number, centeredOnPosition: number = 0) {
|
|
325
|
-
|
|
325
|
+
|
|
326
326
|
const result = this.copy()
|
|
327
327
|
result.x = x - result.width * centeredOnPosition
|
|
328
328
|
|
|
@@ -331,7 +331,7 @@ export class UIRectangle extends UIObject {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
rectangleWithY(y: number, centeredOnPosition: number = 0) {
|
|
334
|
-
|
|
334
|
+
|
|
335
335
|
const result = this.copy()
|
|
336
336
|
result.y = y - result.height * centeredOnPosition
|
|
337
337
|
|
|
@@ -341,7 +341,7 @@ export class UIRectangle extends UIObject {
|
|
|
341
341
|
|
|
342
342
|
|
|
343
343
|
rectangleByAddingX(x: number) {
|
|
344
|
-
|
|
344
|
+
|
|
345
345
|
const result = this.copy()
|
|
346
346
|
result.x = this.x + x
|
|
347
347
|
|
|
@@ -350,7 +350,7 @@ export class UIRectangle extends UIObject {
|
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
rectangleByAddingY(y: number) {
|
|
353
|
-
|
|
353
|
+
|
|
354
354
|
const result = this.copy()
|
|
355
355
|
result.y = this.y + y
|
|
356
356
|
|
|
@@ -359,12 +359,38 @@ export class UIRectangle extends UIObject {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
|
|
362
|
+
rectangleRelativeToBounds(
|
|
363
|
+
bounds: UIRectangle,
|
|
364
|
+
relativeXPosition: number,
|
|
365
|
+
widthMultiplier: number,
|
|
366
|
+
relativeYPosition: number,
|
|
367
|
+
heightMultiplier: number
|
|
368
|
+
) {
|
|
369
|
+
|
|
370
|
+
const result = this.copy()
|
|
371
|
+
|
|
372
|
+
const width = result.width
|
|
373
|
+
const height = result.height
|
|
374
|
+
|
|
375
|
+
result.width = widthMultiplier * width
|
|
376
|
+
result.height = heightMultiplier * height
|
|
377
|
+
|
|
378
|
+
result.center = new UIPoint(
|
|
379
|
+
relativeXPosition * width,
|
|
380
|
+
relativeYPosition * height
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
return result
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
|
|
362
388
|
rectanglesBySplittingWidth(
|
|
363
389
|
weights: number[],
|
|
364
390
|
paddings: number | number[] = 0,
|
|
365
391
|
absoluteWidths: number | number[] = nil
|
|
366
392
|
) {
|
|
367
|
-
|
|
393
|
+
|
|
368
394
|
if (IS_NIL(paddings)) {
|
|
369
395
|
paddings = 1
|
|
370
396
|
}
|
|
@@ -375,7 +401,7 @@ export class UIRectangle extends UIObject {
|
|
|
375
401
|
if (!(absoluteWidths instanceof Array) && IS_NOT_NIL(absoluteWidths)) {
|
|
376
402
|
absoluteWidths = [absoluteWidths].arrayByRepeating(weights.length)
|
|
377
403
|
}
|
|
378
|
-
|
|
404
|
+
|
|
379
405
|
const result: UIRectangle[] = []
|
|
380
406
|
const sumOfWeights = weights.reduce(
|
|
381
407
|
(a, b, index) => {
|
|
@@ -390,9 +416,9 @@ export class UIRectangle extends UIObject {
|
|
|
390
416
|
const sumOfAbsoluteWidths = (absoluteWidths as number[]).summedValue
|
|
391
417
|
const totalRelativeWidth = this.width - sumOfPaddings - sumOfAbsoluteWidths
|
|
392
418
|
let previousCellMaxX = this.x
|
|
393
|
-
|
|
394
|
-
for (let i = 0; i < weights.length; i++) {
|
|
395
419
|
|
|
420
|
+
for (let i = 0; i < weights.length; i++) {
|
|
421
|
+
|
|
396
422
|
let resultWidth: number
|
|
397
423
|
if (IS_NOT_NIL(absoluteWidths[i])) {
|
|
398
424
|
resultWidth = absoluteWidths[i] || 0
|
|
@@ -400,18 +426,18 @@ export class UIRectangle extends UIObject {
|
|
|
400
426
|
else {
|
|
401
427
|
resultWidth = totalRelativeWidth * (weights[i] / sumOfWeights)
|
|
402
428
|
}
|
|
403
|
-
|
|
429
|
+
|
|
404
430
|
const rectangle = this.rectangleWithWidth(resultWidth)
|
|
405
|
-
|
|
431
|
+
|
|
406
432
|
let padding = 0
|
|
407
433
|
if (paddings.length > i && paddings[i]) {
|
|
408
434
|
padding = paddings[i]
|
|
409
435
|
}
|
|
410
|
-
|
|
436
|
+
|
|
411
437
|
rectangle.x = previousCellMaxX
|
|
412
438
|
previousCellMaxX = rectangle.max.x + padding
|
|
413
439
|
result.push(rectangle)
|
|
414
|
-
|
|
440
|
+
|
|
415
441
|
}
|
|
416
442
|
|
|
417
443
|
return result
|
|
@@ -423,7 +449,7 @@ export class UIRectangle extends UIObject {
|
|
|
423
449
|
paddings: number | number[] = 0,
|
|
424
450
|
absoluteHeights: number | number[] = nil
|
|
425
451
|
) {
|
|
426
|
-
|
|
452
|
+
|
|
427
453
|
if (IS_NIL(paddings)) {
|
|
428
454
|
paddings = 1
|
|
429
455
|
}
|
|
@@ -434,7 +460,7 @@ export class UIRectangle extends UIObject {
|
|
|
434
460
|
if (!(absoluteHeights instanceof Array) && IS_NOT_NIL(absoluteHeights)) {
|
|
435
461
|
absoluteHeights = [absoluteHeights].arrayByRepeating(weights.length)
|
|
436
462
|
}
|
|
437
|
-
|
|
463
|
+
|
|
438
464
|
const result: UIRectangle[] = []
|
|
439
465
|
const sumOfWeights = weights.reduce(
|
|
440
466
|
(a, b, index) => {
|
|
@@ -449,11 +475,11 @@ export class UIRectangle extends UIObject {
|
|
|
449
475
|
const sumOfAbsoluteHeights = (absoluteHeights as number[]).summedValue
|
|
450
476
|
const totalRelativeHeight = this.height - sumOfPaddings - sumOfAbsoluteHeights
|
|
451
477
|
var previousCellMaxY = this.y
|
|
452
|
-
|
|
478
|
+
|
|
453
479
|
for (var i = 0; i < weights.length; i++) {
|
|
454
480
|
var resultHeight: number
|
|
455
481
|
if (IS_NOT_NIL(absoluteHeights[i])) {
|
|
456
|
-
|
|
482
|
+
|
|
457
483
|
resultHeight = absoluteHeights[i] || 0
|
|
458
484
|
|
|
459
485
|
}
|
|
@@ -462,9 +488,9 @@ export class UIRectangle extends UIObject {
|
|
|
462
488
|
resultHeight = totalRelativeHeight * (weights[i] / sumOfWeights)
|
|
463
489
|
|
|
464
490
|
}
|
|
465
|
-
|
|
491
|
+
|
|
466
492
|
const rectangle = this.rectangleWithHeight(resultHeight)
|
|
467
|
-
|
|
493
|
+
|
|
468
494
|
var padding = 0
|
|
469
495
|
if (paddings.length > i && paddings[i]) {
|
|
470
496
|
padding = paddings[i]
|