comparison Libs/DF/dropdown.lua @ 40:a960d5372b0c

- framework update from v22 to v44.
author Tercio
date Wed, 31 Aug 2016 19:55:14 -0300
parents 7944c081e5b4
children 307f5af3ad02
comparison
equal deleted inserted replaced
39:7944c081e5b4 40:a960d5372b0c
590 if (not _this_row) then 590 if (not _this_row) then
591 591
592 local name = button:GetName() .. "Row" .. i 592 local name = button:GetName() .. "Row" .. i
593 local parent = scrollChild 593 local parent = scrollChild
594 594
595 _this_row = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownOptionTemplate") 595 --_this_row = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownOptionTemplate")
596 _this_row = DF:CreateDropdownButton (parent, name)
596 local anchor_i = i-1 597 local anchor_i = i-1
597 _this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5) 598 _this_row:SetPoint ("topleft", parent, "topleft", 5, (-anchor_i*20)-5)
598 _this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5) 599 _this_row:SetPoint ("topright", parent, "topright", -5, (-anchor_i*20)-5)
599 _this_row.object = object 600 _this_row.object = object
600 object.menus [i] = _this_row 601 object.menus [i] = _this_row
601 end 602 end
603
604 _this_row:SetFrameStrata (_this_row:GetParent():GetFrameStrata())
605 _this_row:SetFrameLevel (_this_row:GetParent():GetFrameLevel()+10)
602 606
603 _this_row.icon:SetTexture (_table.icon) 607 _this_row.icon:SetTexture (_table.icon)
604 if (_table.icon) then 608 if (_table.icon) then
605 609
606 _this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0) 610 _this_row.label:SetPoint ("left", _this_row.icon, "right", 5, 0)
695 --width 699 --width
696 scrollBorder:SetWidth (frame_witdh+20) 700 scrollBorder:SetWidth (frame_witdh+20)
697 scrollFrame:SetWidth (frame_witdh+20) 701 scrollFrame:SetWidth (frame_witdh+20)
698 scrollChild:SetWidth (frame_witdh+20) 702 scrollChild:SetWidth (frame_witdh+20)
699 --height 703 --height
700 scrollBorder:SetHeight (size+20) 704 scrollBorder:SetHeight (size+2)
701 scrollFrame:SetHeight (size) 705 scrollFrame:SetHeight (size+2)
702 scrollChild:SetHeight ((showing*20)+20) 706 scrollChild:SetHeight ((showing*20)+20)
703 --mouse over texture 707 --mouse over texture
704 mouseOverTexture:SetWidth (frame_witdh-7) 708 mouseOverTexture:SetWidth (frame_witdh-7)
705 --selected 709 --selected
706 selectedTexture:SetWidth (frame_witdh - 9) 710 selectedTexture:SetWidth (frame_witdh - 9)
716 --width 720 --width
717 scrollBorder:SetWidth (frame_witdh) 721 scrollBorder:SetWidth (frame_witdh)
718 scrollFrame:SetWidth (frame_witdh) 722 scrollFrame:SetWidth (frame_witdh)
719 scrollChild:SetWidth (frame_witdh) 723 scrollChild:SetWidth (frame_witdh)
720 --height 724 --height
721 scrollBorder:SetHeight ((showing*20) + 25) 725 scrollBorder:SetHeight ((showing*20) + 10)
722 scrollFrame:SetHeight ((showing*20) + 25) 726 scrollFrame:SetHeight ((showing*20) + 10)
723 --mouse over texture 727 --mouse over texture
724 mouseOverTexture:SetWidth (frame_witdh-10) 728 mouseOverTexture:SetWidth (frame_witdh-10)
725 --selected 729 --selected
726 selectedTexture:SetWidth (frame_witdh - 9) 730 selectedTexture:SetWidth (frame_witdh - 9)
727 731
931 935
932 --> default members: 936 --> default members:
933 --> misc 937 --> misc
934 DropDownObject.container = container 938 DropDownObject.container = container
935 939
936 DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate") 940 --DropDownObject.dropdown = CreateFrame ("Button", name, parent, "DetailsFrameworkDropDownTemplate")
941 DropDownObject.dropdown = DF:CreateNewDropdownFrame (parent, name)
942
937 DropDownObject.widget = DropDownObject.dropdown 943 DropDownObject.widget = DropDownObject.dropdown
938 944
939 DropDownObject.__it = {nil, nil} 945 DropDownObject.__it = {nil, nil}
940 --_G [name] = DropDownObject 946 --_G [name] = DropDownObject
941 947
1021 end 1027 end
1022 1028
1023 return DropDownObject 1029 return DropDownObject
1024 1030
1025 end 1031 end
1032
1033 local default_backdrop = {bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]], edgeFile = [[Interface\DialogFrame\UI-DialogBox-Border]],
1034 edgeSize = 1, tile = true, tileSize = 16, insets = {left = 1, right = 1, top = 0, bottom = 1}}
1035 local border_backdrop = {edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, insets = {left = 0, right = 0, top = 0, bottom = 0}}
1036 local child_backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 256, insets = {left = 0, right = 0, top = 0, bottom = 0}}
1037
1038 function DF:CreateNewDropdownFrame (parent, name)
1039 local f = CreateFrame ("button", name, parent)
1040 f:SetBackdrop (default_backdrop)
1041 f:SetSize (150, 20)
1042
1043 local statusbar = f:CreateTexture ("$parent_StatusBarTexture", "BACKGROUND")
1044 statusbar:SetPoint ("topleft", f, "topleft", 3, -3)
1045 statusbar:SetPoint ("bottomright", f, "bottomright", -3, 3)
1046 f.statusbar = statusbar
1047
1048 local icon = f:CreateTexture ("$parent_IconTexture", "ARTWORK")
1049 icon:SetPoint ("left", f, "left", 2, 0)
1050 icon:SetSize (20, 20)
1051 icon:SetTexture ([[Interface\COMMON\UI-ModelControlPanel]])
1052 icon:SetTexCoord (0.625, 0.78125, 0.328125, 0.390625)
1053 icon:SetVertexColor (1, 1, 1, 0.4)
1054 f.icon = icon
1055
1056 local text = f:CreateFontString ("$parent_Text", "ARTWORK", "GameFontHighlightSmall")
1057 text:SetPoint ("left", icon, "right", 5, 0)
1058 text:SetJustifyH ("left")
1059 text:SetText ("no option selected")
1060 text:SetTextColor (1, 1, 1, 0.4)
1061 DF:SetFontSize (text, 10)
1062 f.text = text
1063
1064 local arrow = f:CreateTexture ("$parent_ArrowTexture2", "OVERLAY")
1065 arrow:SetPoint ("right", f, "right", 5, -1)
1066 arrow:SetBlendMode ("ADD")
1067 arrow:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Highlight]])
1068 arrow:Hide()
1069 arrow:SetSize (32, 28)
1070 f.arrowTexture2 = arrow
1071
1072 local buttonTexture = f:CreateTexture ("$parent_ArrowTexture", "OVERLAY")
1073 buttonTexture:SetPoint ("right", f, "right", 5, -1)
1074 buttonTexture:SetTexture ([[Interface\Buttons\UI-ScrollBar-ScrollDownButton-Up]])
1075 buttonTexture:SetSize (32, 28)
1076 f.arrowTexture = buttonTexture
1077
1078 --scripts
1079 f:SetScript ("OnSizeChanged", DetailsFrameworkDropDownOnSizeChanged)
1080 f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOnMouseDown)
1081
1082 --on load
1083 f:SetBackdropColor (1, 1, 1, .5)
1084 f.arrowTexture:SetDrawLayer ("OVERLAY", 1)
1085 f.arrowTexture2:SetDrawLayer ("OVERLAY", 2)
1086
1087 --dropdown
1088 local border = CreateFrame ("frame", "$Parent_Border", f)
1089 border:Hide()
1090 border:SetFrameStrata ("FULLSCREEN")
1091 border:SetSize (150, 150)
1092 border:SetPoint ("topleft", f, "bottomleft")
1093 border:SetBackdrop (border_backdrop)
1094 border:SetScript ("OnHide", DetailsFrameworkDropDownOptionsFrameOnHide)
1095 border:SetBackdropColor (0, 0, 0, 0.92)
1096 border:SetBackdropBorderColor (0, 0, 0, 1)
1097 f.dropdownborder = border
1098
1099 local scroll = CreateFrame ("ScrollFrame", "$Parent_ScrollFrame", f)
1100 scroll:Hide()
1101 scroll:SetFrameStrata ("FULLSCREEN")
1102 scroll:SetSize (150, 150)
1103 scroll:SetPoint ("topleft", f, "bottomleft", 0, 0)
1104 f.dropdownframe = scroll
1105
1106 local child = CreateFrame ("frame", "$Parent_ScrollChild", scroll)
1107 child:SetSize (150, 150)
1108 child:SetPoint ("topleft", scroll, "topleft", 0, 0)
1109 child:SetBackdrop (child_backdrop)
1110 child:SetBackdropColor (0, 0, 0, 1)
1111
1112 local selected = child:CreateTexture ("$parent_SelectedTexture", "BACKGROUND")
1113 selected:SetSize (150, 16)
1114 selected:Hide()
1115 selected:SetPoint ("left", child, "left", 2, 0)
1116 selected:SetTexture ([[Interface\RAIDFRAME\Raid-Bar-Hp-Fill]])
1117 child.selected = selected
1118
1119 local mouseover = child:CreateTexture ("$parent_MouseOverTexture", "ARTWORK")
1120 mouseover:SetBlendMode ("ADD")
1121 mouseover:Hide()
1122 mouseover:SetTexture ([[Interface\Buttons\UI-Listbox-Highlight]])
1123 mouseover:SetSize (150, 15)
1124 mouseover:SetPoint ("left", child, "left", 2, 0)
1125 child.mouseover = mouseover
1126
1127 scroll:SetScrollChild (child)
1128 tinsert (UISpecialFrames, f.dropdownborder:GetName())
1129 tinsert (UISpecialFrames, f.dropdownframe:GetName())
1130
1131 return f
1132 end
1133
1134 function DF:CreateDropdownButton (parent, name)
1135
1136 local f = CreateFrame ("button", name, parent)
1137 f:SetSize (150, 20)
1138
1139 local statusbar = f:CreateTexture ("$parent_StatusBarTexture", "ARTWORK")
1140 statusbar:SetPoint ("left", f, "left", 1, 0)
1141 statusbar:SetPoint ("right", f, "right", -10, 0)
1142 statusbar:SetSize (150, 20)
1143 f.statusbar = statusbar
1144
1145 local icon = f:CreateTexture ("$parent_IconTexture", "OVERLAY")
1146 icon:SetPoint ("left", f, "left", 2, 0)
1147 icon:SetSize (20, 20)
1148 icon:SetTexture ([[Interface\ICONS\Spell_ChargePositive]])
1149 f.icon = icon
1150
1151 local text = f:CreateFontString ("$parent_Text", "OVERLAY", "GameFontHighlightSmall")
1152 text:SetPoint ("left", icon, "right", 5, 0)
1153 text:SetJustifyH ("left")
1154 DF:SetFontSize (text, 10)
1155 f.label = text
1156
1157 f:SetScript ("OnMouseDown", DetailsFrameworkDropDownOptionClick)
1158 f:SetScript ("OnEnter", DetailsFrameworkDropDownOptionOnEnter)
1159 f:SetScript ("OnLeave", DetailsFrameworkDropDownOptionOnLeave)
1160
1161 return f
1162 end