@@ -10,6 +10,7 @@ global.__SUIEmptyFunction = function() {}
1010// if the mouse goes > this away from the border of a button, it will be "unclicked"
1111#macro SUI_CLICK_OFFSET 96
1212
13+
1314global.sui_canvases = []
1415
1516function SUICanvas (children = []) constructor {
@@ -42,7 +43,13 @@ function SUICanvas(children = []) constructor {
4243 element.onSelect ()
4344 }
4445
46+ // /@param {String} name
47+ // /@returns {Any} value
4548 get = function (name) { return variable_struct_get (self, name) }
49+
50+ // /@param {String} name
51+ // /@param {Any} value
52+ // /@returns {Undefined}
4653 set = function (name, value) { variable_struct_set (self, name, value) }
4754
4855 forEach = function (func, arr = self.children , parent = self) {
@@ -271,8 +278,23 @@ function SUIElement(x, y, props = {}, children = []) constructor {
271278 getX = function () { return self.canvas .calculateX (self, self.parent ) }
272279 getY = function () { return self.canvas .calculateY (self, self.parent ) }
273280
281+
282+ // /@function
283+ // /@desc you should call this function at the end of your custom UI elements' constructor
284+ // /@param {Struct} props
285+ // /@self {SUIElement}
286+ function SUILoadProps (props) {
287+ SUIInherit (self, global.SUI_DEFAULT_PROPS )
288+ if (variable_struct_exists (global.SUI_DEFAULT_ELEMENT_PROPS , self.__element_type ))
289+ SUIInherit (self, global.SUI_DEFAULT_ELEMENT_PROPS [$ self.__element_type ])
290+ SUIInherit (self, props)
291+ }
292+
274293 #region get/set
275294
295+ // /@param {String} prop_name
296+ // /@param {Any} default_value
297+ // /@returns {Any} value
276298 get = function (prop_name, default_value = undefined) {
277299 var value = variable_struct_get (self, prop_name)
278300 while (is_struct (value) and instanceof (value) == " SUIBinding" ) {
@@ -284,6 +306,8 @@ function SUIElement(x, y, props = {}, children = []) constructor {
284306 else return value
285307 }
286308
309+ // /@param {String} prop_name
310+ // /@param {Any} value
287311 set = function (prop_name, value) {
288312 var old_value = variable_struct_get (self, prop_name)
289313 if (is_struct (old_value) and instanceof (old_value) == " SUIBinding" ) {
@@ -345,7 +369,13 @@ function SUIElement(x, y, props = {}, children = []) constructor {
345369 distanceToMouse = function () {
346370 var mx = SUIMouseX
347371 var my = SUIMouseY
348- return SUIDistanceToRectangle (mx, my, self.get (" left" ), self.get (" top" ), self.get (" right" ), self.get (" bottom" ))
372+
373+ var left = self.get (" left" )
374+ var top = self.get (" top" )
375+ var right = self.get (" right" )
376+ var bottom = self.get (" bottom" )
377+
378+ return SUIDistanceToRectangle (mx, my, left, top, right, bottom)
349379 }
350380
351381
0 commit comments