Mercurial > wow > hansgar_and_franzok_assist
diff Libs/DF/dropdown.lua @ 39:7944c081e5b4
- framework update.
- ToC Update.
| author | Tercio |
|---|---|
| date | Tue, 19 Jul 2016 13:23:40 -0300 |
| parents | 5da06cb420d4 |
| children | a960d5372b0c |
line wrap: on
line diff
--- a/Libs/DF/dropdown.lua Mon Jul 04 23:06:23 2016 -0300 +++ b/Libs/DF/dropdown.lua Tue Jul 19 13:23:40 2016 -0300 @@ -16,7 +16,18 @@ local cleanfunction = function() end local APIDropDownFunctions = false -local DropDownMetaFunctions = {} + +do + local metaPrototype = { + WidgetType = "dropdown", + SetHook = DF.SetHook, + RunHooksForWidget = DF.RunHooksForWidget, + } + + _G [DF.GlobalWidgetControlNames ["dropdown"]] = _G [DF.GlobalWidgetControlNames ["dropdown"]] or metaPrototype +end + +local DropDownMetaFunctions = _G [DF.GlobalWidgetControlNames ["dropdown"]] ------------------------------------------------------------------------------------------------------------ --> metatables @@ -65,21 +76,20 @@ return _rawget (self, "realsizeH") end - local get_members_function_index = { - ["value"] = gmember_value, - ["text"] = gmember_text, - ["shown"] = gmember_shown, - ["width"] = gmember_width, - ["menuwidth"] = gmember_menuwidth, - ["height"] = gmember_height, - ["menuheight"] = gmember_menuheight, - ["tooltip"] = gmember_tooltip, - ["func"] = gmember_function, - } + DropDownMetaFunctions.GetMembers = DropDownMetaFunctions.GetMembers or {} + DropDownMetaFunctions.GetMembers ["value"] = gmember_value + DropDownMetaFunctions.GetMembers ["text"] = gmember_text + DropDownMetaFunctions.GetMembers ["shown"] = gmember_shown + DropDownMetaFunctions.GetMembers ["width"] = gmember_width + DropDownMetaFunctions.GetMembers ["menuwidth"] = gmember_menuwidth + DropDownMetaFunctions.GetMembers ["height"] = gmember_height + DropDownMetaFunctions.GetMembers ["menuheight"] = gmember_menuheight + DropDownMetaFunctions.GetMembers ["tooltip"] = gmember_tooltip + DropDownMetaFunctions.GetMembers ["func"] = gmember_function DropDownMetaFunctions.__index = function (_table, _member_requested) - local func = get_members_function_index [_member_requested] + local func = DropDownMetaFunctions.GetMembers [_member_requested] if (func) then return func (_table, _member_requested) end @@ -135,19 +145,18 @@ _object:SetMenuSize (nil, _value) end - local set_members_function_index = { - ["tooltip"] = smember_tooltip, - ["show"] = smember_show, - ["hide"] = smember_hide, - ["width"] = smember_width, - ["menuwidth"] = smember_menuwidth, - ["height"] = smember_height, - ["menuheight"] = smember_menuheight, - ["func"] = smember_function, - } + DropDownMetaFunctions.SetMembers = DropDownMetaFunctions.SetMembers or {} + DropDownMetaFunctions.SetMembers ["tooltip"] = smember_tooltip + DropDownMetaFunctions.SetMembers ["show"] = smember_show + DropDownMetaFunctions.SetMembers ["hide"] = smember_hide + DropDownMetaFunctions.SetMembers ["width"] = smember_width + DropDownMetaFunctions.SetMembers ["menuwidth"] = smember_menuwidth + DropDownMetaFunctions.SetMembers ["height"] = smember_height + DropDownMetaFunctions.SetMembers ["menuheight"] = smember_menuheight + DropDownMetaFunctions.SetMembers ["func"] = smember_function DropDownMetaFunctions.__newindex = function (_table, _key, _value) - local func = set_members_function_index [_key] + local func = DropDownMetaFunctions.SetMembers [_key] if (func) then return func (_table, _value) else @@ -285,15 +294,6 @@ _rawset (self, "FixedValue", value) end ---> hooks - function DropDownMetaFunctions:SetHook (hookType, func) - if (func) then - _rawset (self, hookType.."Hook", func) - else - _rawset (self, hookType.."Hook", nil) - end - end - ------------------------------------------------------------------------------------------------------------ --> scripts @@ -752,11 +752,10 @@ function DetailsFrameworkDropDownOnEnter (self) - if (self.MyObject.OnEnterHook) then - local interrupt = self.MyObject.OnEnterHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnEnter", self, capsule) + if (kill) then + return end if (self.MyObject.onenter_backdrop) then @@ -787,11 +786,10 @@ end function DetailsFrameworkDropDownOnLeave (self) - if (self.MyObject.OnLeaveHook) then - local interrupt = self.MyObject.OnLeaveHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnLeave", self, capsule) + if (kill) then + return end if (self.MyObject.onleave_backdrop) then @@ -816,20 +814,18 @@ end function DetailsFrameworkDropDownOnShow (self) - if (self.MyObject and self.MyObject.OnShowHook) then - local interrupt = self.MyObject.OnShowHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnShow", self, capsule) + if (kill) then + return end end function DetailsFrameworkDropDownOnHide (self) - if (self.MyObject and self.MyObject.OnHideHook) then - local interrupt = self.MyObject.OnHideHook (self) - if (interrupt) then - return - end + local capsule = self.MyObject + local kill = capsule:RunHooksForWidget ("OnHide", self, capsule) + if (kill) then + return end self.MyObject:Close() @@ -934,15 +930,8 @@ end --> default members: - --> hooks - DropDownObject.OnEnterHook = nil - DropDownObject.OnLeaveHook = nil - DropDownObject.OnHideHook = nil - DropDownObject.OnShowHook = nil - DropDownObject.OnMouseDownHook = nil --> misc DropDownObject.container = container - DropDownObject.have_tooltip = nil DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate") DropDownObject.widget = DropDownObject.dropdown @@ -1002,11 +991,22 @@ DropDownObject:HideScroll() DropDownObject.label:SetSize (DropDownObject.dropdown:GetWidth()-40, 10) + DropDownObject.HookList = { + OnEnter = {}, + OnLeave = {}, + OnHide = {}, + OnShow = {}, + } + + DropDownObject.dropdown:SetScript ("OnShow", DetailsFrameworkDropDownOnShow) + DropDownObject.dropdown:SetScript ("OnHide", DetailsFrameworkDropDownOnHide) + DropDownObject.dropdown:SetScript ("OnEnter", DetailsFrameworkDropDownOnEnter) + DropDownObject.dropdown:SetScript ("OnLeave", DetailsFrameworkDropDownOnLeave) + --> setup class _setmetatable (DropDownObject, DropDownMetaFunctions) - + --> initialize first menu selected - if (type (default) == "string") then DropDownObject:Select (default) @@ -1020,6 +1020,6 @@ DropDownObject:SetTemplate (template) end - return DropDownObject + return DropDownObject end \ No newline at end of file
