comparison Libs/DF/picture.lua @ 39:7944c081e5b4

- framework update. - ToC Update.
author Tercio
date Tue, 19 Jul 2016 13:23:40 -0300
parents 5da06cb420d4
children 0682d738499b
comparison
equal deleted inserted replaced
38:219f04e5ba55 39:7944c081e5b4
13 local _math_floor = math.floor --> lua local 13 local _math_floor = math.floor --> lua local
14 local loadstring = loadstring --> lua local 14 local loadstring = loadstring --> lua local
15 15
16 local cleanfunction = function() end 16 local cleanfunction = function() end
17 local APIImageFunctions = false 17 local APIImageFunctions = false
18 local ImageMetaFunctions = {} 18
19 do
20 local metaPrototype = {
21 WidgetType = "image",
22 SetHook = DF.SetHook,
23 RunHooksForWidget = DF.RunHooksForWidget,
24 }
25
26 _G [DF.GlobalWidgetControlNames ["image"]] = _G [DF.GlobalWidgetControlNames ["image"]] or metaPrototype
27 end
28
29 local ImageMetaFunctions = _G [DF.GlobalWidgetControlNames ["image"]]
19 30
20 ------------------------------------------------------------------------------------------------------------ 31 ------------------------------------------------------------------------------------------------------------
21 --> metatables 32 --> metatables
22 33
23 ImageMetaFunctions.__call = function (_table, value) 34 ImageMetaFunctions.__call = function (_table, value)
46 --> alpha 57 --> alpha
47 local gmember_alpha = function (_object) 58 local gmember_alpha = function (_object)
48 return _object.image:GetAlpha() 59 return _object.image:GetAlpha()
49 end 60 end
50 61
51 local get_members_function_index = { 62 ImageMetaFunctions.GetMembers = ImageMetaFunctions.GetMembers or {}
52 ["shown"] = gmember_shown, 63 ImageMetaFunctions.GetMembers ["shown"] = gmember_shown
53 ["alpha"] = gmember_alpha, 64 ImageMetaFunctions.GetMembers ["alpha"] = gmember_alpha
54 ["width"] = gmember_width, 65 ImageMetaFunctions.GetMembers ["width"] = gmember_width
55 ["height"] = gmember_height, 66 ImageMetaFunctions.GetMembers ["height"] = gmember_height
56 ["texture"] = gmember_texture, 67 ImageMetaFunctions.GetMembers ["texture"] = gmember_texture
57 } 68
58
59 ImageMetaFunctions.__index = function (_table, _member_requested) 69 ImageMetaFunctions.__index = function (_table, _member_requested)
60 70
61 local func = get_members_function_index [_member_requested] 71 local func = ImageMetaFunctions.GetMembers [_member_requested]
62 if (func) then 72 if (func) then
63 return func (_table, _member_requested) 73 return func (_table, _member_requested)
64 end 74 end
65 75
66 local fromMe = _rawget (_table, _member_requested) 76 local fromMe = _rawget (_table, _member_requested)
144 else 154 else
145 _object:SetTexCoord (0, 1, 0, 1) 155 _object:SetTexCoord (0, 1, 0, 1)
146 end 156 end
147 end 157 end
148 158
149 local set_members_function_index = { 159 ImageMetaFunctions.SetMembers = ImageMetaFunctions.SetMembers or {}
150 ["show"] = smember_show, 160 ImageMetaFunctions.SetMembers ["show"] = smember_show
151 ["hide"] = smember_hide, 161 ImageMetaFunctions.SetMembers ["hide"] = smember_hide
152 ["alpha"] = smember_alpha, 162 ImageMetaFunctions.SetMembers ["alpha"] = smember_alpha
153 ["width"] = smember_width, 163 ImageMetaFunctions.SetMembers ["width"] = smember_width
154 ["height"] = smember_height, 164 ImageMetaFunctions.SetMembers ["height"] = smember_height
155 ["texture"] = smember_texture, 165 ImageMetaFunctions.SetMembers ["texture"] = smember_texture
156 ["texcoord"] = smember_texcoord, 166 ImageMetaFunctions.SetMembers ["texcoord"] = smember_texcoord
157 ["color"] = smember_color, 167 ImageMetaFunctions.SetMembers ["color"] = smember_color
158 ["blackwhite"] = smember_desaturated, 168 ImageMetaFunctions.SetMembers ["blackwhite"] = smember_desaturated
159 } 169
160
161 ImageMetaFunctions.__newindex = function (_table, _key, _value) 170 ImageMetaFunctions.__newindex = function (_table, _key, _value)
162 local func = set_members_function_index [_key] 171 local func = ImageMetaFunctions.SetMembers [_key]
163 if (func) then 172 if (func) then
164 return func (_table, _value) 173 return func (_table, _value)
165 else 174 else
166 return _rawset (_table, _key, _value) 175 return _rawset (_table, _key, _value)
167 end 176 end
278 287
279 if (coords and type (coords) == "table" and coords [4]) then 288 if (coords and type (coords) == "table" and coords [4]) then
280 ImageObject.image:SetTexCoord (unpack (coords)) 289 ImageObject.image:SetTexCoord (unpack (coords))
281 end 290 end
282 291
292 ImageObject.HookList = {
293 }
294
283 setmetatable (ImageObject, ImageMetaFunctions) 295 setmetatable (ImageObject, ImageMetaFunctions)
284 296
285 return ImageObject 297 return ImageObject
286 end 298 end