public
Description: WoW Addon - Crowd control assistance
Homepage: http://www.tekkub.net
Clone URL: git://github.com/tekkub/controlfreak.git
Click here to lend your support to: controlfreak and make a donation at www.pledgie.com !
Reworking DB Profile config frame
tekkub (author)
Mon Feb 18 10:27:16 -0800 2008
commit  8335514aac6167b53c963282c472a6b64f3cb618
tree    36ba977c99b535a03d09bdf3302dbdef149838e6
parent  37d3127dcbf0dfefe280c6fcc028c65ceba5b81e
...
8
9
10
11
 
12
13
14
...
27
28
29
30
31
32
33
34
35
 
 
 
 
36
37
38
39
40
41
42
 
 
 
43
44
 
45
46
47
...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70
71
72
73
74
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
77
78
 
79
80
81
 
82
83
84
 
 
85
86
87
88
 
89
90
91
92
93
94
95
 
 
 
 
96
97
98
99
100
101
102
103
104
...
110
111
112
113
 
114
115
116
117
 
118
119
120
121
122
 
123
124
125
...
8
9
10
 
11
12
13
14
...
27
28
29
 
30
 
 
 
 
31
32
33
34
35
 
 
 
 
 
36
37
38
39
40
 
41
42
43
44
...
49
50
51
 
 
 
 
52
 
 
 
 
 
 
 
 
 
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
 
 
 
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 
 
105
106
107
 
108
109
110
 
111
112
113
114
115
 
116
117
118
119
 
 
 
 
120
121
122
123
124
 
 
 
 
 
125
126
127
...
133
134
135
 
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
0
@@ -8,7 +8,7 @@ if not ControlFreak then return end
0
 ----------------------
0
 
0
 local ww = LibStub("WidgetWarlock-Alpha1")
0
-local GAP, EDGEGAP, DROPDOWNOFFSET = 8, 16, 16
0
+local GAP, EDGEGAP, DROPDOWNOFFSET, NUMROWS, ROWHEIGHT = 8, 16, 16, 13, 18
0
 
0
 
0
 ---------------------
0
@@ -27,21 +27,18 @@ frame:SetScript("OnShow", function(frame)
0
   local currentlabel = ww:SummonFontString(frame, "OVERLAY", "GameFontNormal", "Current profile:", "TOPLEFT", subtitle, "BOTTOMLEFT", -2, -GAP)
0
   local current = ww:SummonFontString(frame, "OVERLAY", "GameFontHighlight", ControlFreak.db:GetCurrentProfile(), "LEFT", currentlabel, "RIGHT", 10, 0)
0
 
0
- local profiles = ControlFreak.db:GetProfiles()
0
 
0
- local selected = CreateFrame("Frame", "ControlFreakProfileMenu", frame, "UIDropDownMenuTemplate")
0
- local loadbutton = ww:SummonButton(frame, "Load", nil, nil, "TOPLEFT", selected, "BOTTOMLEFT", DROPDOWNOFFSET, -GAP/2)
0
- local copybutton = ww:SummonButton(frame, "Copy", nil, nil, "LEFT", loadbutton, "RIGHT", GAP, 0)
0
- local deletebutton = ww:SummonButton(frame, "Delete", nil, nil, "LEFT", copybutton, "RIGHT", GAP, 0)
0
+ local createname = ww:SummonEditBox(frame, 255, "TOPLEFT", currentlabel, "BOTTOMLEFT", GAP - 2, -1)
0
+ local createbutton = ww:SummonButton(frame, "Create", nil, nil, "LEFT", createname, "RIGHT", 5, 0)
0
+ createbutton:Disable()
0
+ createname:SetScript("OnTextChanged", function(frame) if frame:GetText() ~= "" then createbutton:Enable() else createbutton:Disable() end end)
0
 
0
- selected:SetPoint("TOPLEFT", currentlabel, "BOTTOMLEFT", -DROPDOWNOFFSET, -GAP)
0
- ControlFreakProfileMenuRight:ClearAllPoints()
0
- ControlFreakProfileMenuRight:SetPoint("TOP", ControlFreakProfileMenuLeft)
0
- ControlFreakProfileMenuRight:SetPoint("RIGHT", frame, -EDGEGAP + DROPDOWNOFFSET, 0)
0
- ControlFreakProfileMenuMiddle:SetPoint("RIGHT", ControlFreakProfileMenuRight, "LEFT")
0
 
0
+ local deletebutton = ww:SummonButton(frame, "Delete", nil, nil, "BOTTOMRIGHT", -EDGEGAP, EDGEGAP)
0
+ local copybutton = ww:SummonButton(frame, "Copy", nil, nil, "RIGHT", deletebutton, "LEFT", -GAP, 0)
0
+ local loadbutton = ww:SummonButton(frame, "Load", nil, nil, "RIGHT", copybutton, "LEFT", -GAP, 0)
0
   local function ToggleButtons(value)
0
- if value == ControlFreak.db:GetCurrentProfile() then
0
+ if not value or value == ControlFreak.db:GetCurrentProfile() then
0
       loadbutton:Disable()
0
       copybutton:Disable()
0
       deletebutton:Disable()
0
@@ -52,53 +49,79 @@ frame:SetScript("OnShow", function(frame)
0
     end
0
   end
0
 
0
- local function DropdownClick()
0
- UIDropDownMenu_SetSelectedValue(ControlFreakProfileMenu, this.value)
0
- ToggleButtons(this.value)
0
- end
0
 
0
- local ddt = {func = DropdownClick}
0
- local function DropdownInit()
0
- local current = ControlFreak.db:GetCurrentProfile()
0
- for i,v in ipairs(profiles) do
0
- ddt.checked = false
0
- ddt.text = v
0
- ddt.value = v
0
- ddt.disabled = v == current
0
- UIDropDownMenu_AddButton(ddt)
0
+ local rows = {}
0
+ local offset, selectedprofile, proflies = 0
0
+ local function UpdateRows()
0
+ for i,row in ipairs(rows) do
0
+ local profile = profiles[i + offset]
0
+ if profile then
0
+ row.text:SetText((profile == ControlFreak.db:GetCurrentProfile() and "|cff999999" or "")..profile)
0
+ if profile == ControlFreak.db:GetCurrentProfile() then row:Disable() else row:Enable() end
0
+ row.value = profile
0
+ row:SetChecked(selectedprofile == profile)
0
+ else
0
+ row.text:SetText()
0
+ row:Disable()
0
+ row:SetChecked(false)
0
+ end
0
     end
0
   end
0
 
0
- local function selectedOnShow(self)
0
- UIDropDownMenu_Initialize(self, DropdownInit)
0
- UIDropDownMenu_SetSelectedValue(selected, profiles[1])
0
- ToggleButtons(profiles[1])
0
+ local function rowOnClick(self)
0
+ selectedprofile = selectedprofile ~= self.value and self.value or nil
0
+ ToggleButtons(selectedprofile)
0
+ UpdateRows()
0
+ end
0
+
0
+ local function OnMouseWheel(f, val)
0
+ offset = offset - val
0
+ if (offset + NUMROWS) > #profiles then offset = #profiles - NUMROWS end
0
+ if offset < 0 then offset = 0 end
0
+ UpdateRows()
0
+ end
0
+
0
+ for i=1,NUMROWS do
0
+ local row = CreateFrame("CheckButton", nil, frame)
0
+ row:SetHeight(ROWHEIGHT)
0
+ if i == 1 then row:SetPoint("TOP", createname, "BOTTOM", 0, -2) else row:SetPoint("TOP", rows[i-1], "BOTTOM", 0, 0) end
0
+ row:SetPoint("LEFT", EDGEGAP, 0)
0
+ row:SetPoint("RIGHT", -EDGEGAP, 0)
0
+
0
+ row.text = ww:SummonFontString(row, "OVERLAY", "GameFontWhite", "SAMPLE PROFILE "..i, "LEFT", row, 10, 0)
0
+ row.text:SetPoint("RIGHT", row, -10, 0)
0
+ row.text:SetJustifyH("LEFT")
0
+
0
+ local highlight = ww:SummonTextureWithCoords(row, nil, nil, nil, "Interface\\HelpFrame\\HelpFrameButton-Highlight", 0, 1, 0, 0.578125)
0
+ highlight:SetAllPoints()
0
+ row:SetHighlightTexture(highlight)
0
+ row:SetCheckedTexture(highlight)
0
+
0
+ row:EnableMouseWheel()
0
+ row:SetScript("OnMouseWheel", OnMouseWheel)
0
+ row:SetScript("OnClick", rowOnClick)
0
+ rows[i] = row
0
   end
0
- selected:SetScript("OnShow", selectedOnShow)
0
- selectedOnShow(selected)
0
+
0
 
0
   loadbutton:SetScript("OnClick", function()
0
- local profile = UIDropDownMenu_GetSelectedValue(selected)
0
+ local profile = selectedprofile
0
     ControlFreak.db:SetProfile(profile)
0
     current:SetText(profile)
0
- ToggleButtons(profile)
0
+ ToggleButtons()
0
+ UpdateRows()
0
   end)
0
   copybutton:SetScript("OnClick", function()
0
     ControlFreak.db:ResetProfile()
0
- ControlFreak.db:CopyProfile(UIDropDownMenu_GetSelectedValue(selected))
0
+ ControlFreak.db:CopyProfile(selectedprofile)
0
     profiles = ControlFreak.db:GetProfiles()
0
   end)
0
   deletebutton:SetScript("OnClick", function()
0
- ControlFreak.db:DeleteProfile(UIDropDownMenu_GetSelectedValue(selected))
0
- profiles = ControlFreak.db:GetProfiles()
0
- UIDropDownMenu_SetSelectedValue(selected, profiles[1])
0
- ToggleButtons(profiles[1])
0
+ ControlFreak.db:DeleteProfile(selectedprofile)
0
+ profiles, selectedprofile = ControlFreak.db:GetProfiles(), nil
0
+ ToggleButtons()
0
+ UpdateRows()
0
   end)
0
-
0
- local createname = ww:SummonEditBox(frame, 187, "TOPLEFT", loadbutton, "BOTTOMLEFT", 8, 1)
0
- local createbutton = ww:SummonButton(frame, "Create", nil, nil, "LEFT", createname, "RIGHT", 5, -1)
0
- createbutton:Disable()
0
- createname:SetScript("OnTextChanged", function(frame) if frame:GetText() ~= "" then createbutton:Enable() else createbutton:Disable() end end)
0
   createbutton:SetScript("OnClick", function()
0
     local profile = createname:GetText()
0
     if profile ~= "" then
0
@@ -110,16 +133,18 @@ frame:SetScript("OnShow", function(frame)
0
       createname:SetText("")
0
       createname:ClearFocus()
0
       createbutton:Disable()
0
- ToggleButtons("")
0
+ UpdateRows()
0
     end
0
   end)
0
 
0
   ww:EnslaveTooltip(copybutton, "Copy the selected profile into your current profile.")
0
+ ww:EnslaveTooltip(deletebutton, "Delete the selected profile. Default profiles will reset to their original settings when deleted.")
0
   ww:EnslaveTooltip(createbutton, "Duplicate the current profile into a new profile.")
0
 
0
   local function OnShow(frame)
0
     ww.FadeIn(frame, 0.5)
0
     profiles = ControlFreak.db:GetProfiles()
0
+ UpdateRows()
0
   end
0
   frame:SetScript("OnShow", OnShow)
0
   OnShow(frame)

Comments

    No one has commented yet.