From 4fc3812c6369ee763cc97230d86ba1ea0c0fdb70 Mon Sep 17 00:00:00 2001 From: Bunny67 Date: Sat, 1 Jan 2022 18:17:33 +0300 Subject: [PATCH] update options --- .../OptionsFrames/ModelPicker.lua | 84 +++++++++++++++++- .../OptionsFrames/OptionsFrame.lua | 86 +++++++++++++------ 2 files changed, 144 insertions(+), 26 deletions(-) diff --git a/WeakAurasOptions/OptionsFrames/ModelPicker.lua b/WeakAurasOptions/OptionsFrames/ModelPicker.lua index 1caec21..08a037e 100644 --- a/WeakAurasOptions/OptionsFrames/ModelPicker.lua +++ b/WeakAurasOptions/OptionsFrames/ModelPicker.lua @@ -48,13 +48,95 @@ local function GetAll(baseObject, path, property, default) end local function ConstructModelPicker(frame) + local function RecurseSetFilter(tree, filter) + for k, v in ipairs(tree) do + if v.children == nil and v.text then + v.visible = not filter or filter == "" or v.text:find(filter, 1, true) ~= nil + else + RecurseSetFilter(v.children, filter) + end + end + end + local group = AceGUI:Create("InlineGroup"); group.frame:SetParent(frame); group.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -17, 87); - group.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 17, -10); + group.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 17, -15); group.frame:Hide(); group:SetLayout("flow"); + local filterInput = CreateFrame("editbox", "WeakAurasModelFilterInput", group.frame, "InputBoxTemplate") + filterInput:SetAutoFocus(false) + filterInput:SetTextInsets(16, 20, 0, 0) + + filterInput.Instructions = filterInput:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall") + filterInput.Instructions:SetText(SEARCH) + filterInput.Instructions:SetPoint("TOPLEFT", filterInput, "TOPLEFT", 16, 0) + filterInput.Instructions:SetPoint("BOTTOMRIGHT", filterInput, "BOTTOMRIGHT", -20, 0) + filterInput.Instructions:SetTextColor(0.35, 0.35, 0.35) + filterInput.Instructions:SetJustifyH("LEFT") + filterInput.Instructions:SetJustifyV("MIDDLE") + + filterInput.searchIcon = filterInput:CreateTexture(nil, "OVERLAY") + filterInput.searchIcon:SetTexture("Interface\\Common\\UI-Searchbox-Icon") + filterInput.searchIcon:SetVertexColor(0.6, 0.6, 0.6) + filterInput.searchIcon:SetSize(14, 14) + filterInput.searchIcon:SetPoint("LEFT", 0, -2) + + filterInput.clearButton = CreateFrame("Button", nil, filterInput) + filterInput.clearButton:SetSize(14, 14) + filterInput.clearButton:SetPoint("RIGHT", -3, 0) + + filterInput.clearButton.texture = filterInput.clearButton:CreateTexture() + filterInput.clearButton.texture:SetTexture("Interface\\FriendsFrame\\ClearBroadcastIcon") + filterInput.clearButton.texture:SetAlpha(0.5) + filterInput.clearButton.texture:SetSize(17, 17) + filterInput.clearButton.texture:SetPoint("CENTER", 0, 0) + + filterInput.clearButton:SetScript("OnEnter", function(self) self.texture:SetAlpha(1.0) end) + filterInput.clearButton:SetScript("OnLeave", function(self) self.texture:SetAlpha(0.5) end) + filterInput.clearButton:SetScript("OnMouseDown", function(self) if self:IsEnabled() then self.texture:SetPoint("CENTER", 1, -1) end end) + filterInput.clearButton:SetScript("OnMouseUp", function(self) self.texture:SetPoint("CENTER") end) + filterInput.clearButton:SetScript("OnClick", function(self) + local editBox = self:GetParent() + editBox:SetText("") + editBox:ClearFocus() + end) + filterInput:SetScript("OnEditFocusLost", function(self) + if self:GetText() == "" then + self.searchIcon:SetVertexColor(0.6, 0.6, 0.6) + self.clearButton:Hide() + end + end) + filterInput:SetScript("OnEditFocusGained", function(self) + self.searchIcon:SetVertexColor(1.0, 1.0, 1.0) + self.clearButton:Show() + end) + filterInput:HookScript("OnTextChanged", function(self) + if not self:HasFocus() and self:GetText() == "" then + self.searchIcon:SetVertexColor(0.6, 0.6, 0.6) + self.clearButton:Hide() + else + self.searchIcon:SetVertexColor(1.0, 1.0, 1.0) + self.clearButton:Show() + end + if self:GetText() == "" then + self.Instructions:Show() + else + self.Instructions:Hide() + end + local filterText = filterInput:GetText() + RecurseSetFilter(group.modelTree.tree, filterText) + group.modelTree.filter = filterText ~= nil and filterText ~= "" + group.modelTree:RefreshTree() + end) + filterInput:SetHeight(15) + filterInput:SetPoint("TOP", group.frame, "TOP", 0, 1) + filterInput:SetPoint("LEFT", group.frame, "LEFT", 7, 0) + filterInput:SetWidth(200) + filterInput:SetFont(STANDARD_TEXT_FONT, 10) + group.frame.filterInput = filterInput + local modelPickerZ = AceGUI:Create("Slider"); modelPickerZ:SetSliderValues(-20, 20, 0.05); modelPickerZ:SetLabel(L["Z Offset"]); diff --git a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua index 14b00a0..bae6b2a 100644 --- a/WeakAurasOptions/OptionsFrames/OptionsFrame.lua +++ b/WeakAurasOptions/OptionsFrames/OptionsFrame.lua @@ -284,7 +284,6 @@ function OptionsPrivate.CreateFrame() self.loadProgress:Hide() self.toolbarContainer.frame:Hide() self.filterInput:Hide(); - self.filterInputClear:Hide(); self.tipFrame.frame:Hide() self.bottomLeftResizer:Hide() self.bottomRightResizer:Hide() @@ -353,18 +352,16 @@ function OptionsPrivate.CreateFrame() self.loadProgress:Show() self.toolbarContainer.frame:Hide() self.filterInput:Hide(); - self.filterInputClear:Hide(); else self.loadProgress:Hide() self.toolbarContainer.frame:Show() self.filterInput:Show(); - self.filterInputClear:Show(); + --self.filterInputClear:Show(); end else self.loadProgress:Hide() self.toolbarContainer.frame:Hide() self.filterInput:Hide(); - self.filterInputClear:Hide(); end end end @@ -541,35 +538,74 @@ function OptionsPrivate.CreateFrame() -- filter line local filterInput = CreateFrame("editbox", "WeakAurasFilterInput", frame, "InputBoxTemplate") filterInput:SetAutoFocus(false) - filterInput:SetScript("OnTextChanged", function(...) WeakAuras.SortDisplayButtons(filterInput:GetText()) end) - filterInput:SetScript("OnEnterPressed", function(...) filterInput:ClearFocus() end) - filterInput:SetScript("OnEscapePressed", function(...) filterInput:SetText("") filterInput:ClearFocus() end) + filterInput:SetTextInsets(16, 20, 0, 0) + + filterInput.Instructions = filterInput:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall") + filterInput.Instructions:SetText(SEARCH) + filterInput.Instructions:SetPoint("TOPLEFT", filterInput, "TOPLEFT", 16, 0) + filterInput.Instructions:SetPoint("BOTTOMRIGHT", filterInput, "BOTTOMRIGHT", -20, 0) + filterInput.Instructions:SetTextColor(0.35, 0.35, 0.35) + filterInput.Instructions:SetJustifyH("LEFT") + filterInput.Instructions:SetJustifyV("MIDDLE") + + filterInput.searchIcon = filterInput:CreateTexture(nil, "OVERLAY") + filterInput.searchIcon:SetTexture("Interface\\Common\\UI-Searchbox-Icon") + filterInput.searchIcon:SetVertexColor(0.6, 0.6, 0.6) + filterInput.searchIcon:SetSize(14, 14) + filterInput.searchIcon:SetPoint("LEFT", 0, -2) + + filterInput.clearButton = CreateFrame("Button", nil, filterInput) + filterInput.clearButton:SetSize(14, 14) + filterInput.clearButton:SetPoint("RIGHT", -3, 0) + + filterInput.clearButton.texture = filterInput.clearButton:CreateTexture() + filterInput.clearButton.texture:SetTexture("Interface\\FriendsFrame\\ClearBroadcastIcon") + filterInput.clearButton.texture:SetAlpha(0.5) + filterInput.clearButton.texture:SetSize(17, 17) + filterInput.clearButton.texture:SetPoint("CENTER", 0, 0) + + filterInput.clearButton:SetScript("OnEnter", function(self) self.texture:SetAlpha(1.0) end) + filterInput.clearButton:SetScript("OnLeave", function(self) self.texture:SetAlpha(0.5) end) + filterInput.clearButton:SetScript("OnMouseDown", function(self) if self:IsEnabled() then self.texture:SetPoint("CENTER", 1, -1) end end) + filterInput.clearButton:SetScript("OnMouseUp", function(self) self.texture:SetPoint("CENTER") end) + filterInput.clearButton:SetScript("OnClick", function(self) + local editBox = self:GetParent() + editBox:SetText("") + editBox:ClearFocus() + end) + filterInput:SetScript("OnEditFocusLost", function(self) + if self:GetText() == "" then + self.searchIcon:SetVertexColor(0.6, 0.6, 0.6) + self.clearButton:Hide() + end + end) + filterInput:SetScript("OnEditFocusGained", function(self) + self.searchIcon:SetVertexColor(1.0, 1.0, 1.0) + self.clearButton:Show() + end) + filterInput:HookScript("OnTextChanged", function(self) + if not self:HasFocus() and self:GetText() == "" then + self.searchIcon:SetVertexColor(0.6, 0.6, 0.6) + self.clearButton:Hide() + else + self.searchIcon:SetVertexColor(1.0, 1.0, 1.0) + self.clearButton:Show() + end + if self:GetText() == "" then + self.Instructions:Show() + else + self.Instructions:Hide() + end + OptionsPrivate.SortDisplayButtons(filterInput:GetText()) + end) filterInput:SetHeight(15) filterInput:SetPoint("TOP", frame, "TOP", 0, -44) filterInput:SetPoint("LEFT", frame, "LEFT", 24, 0) filterInput:SetPoint("RIGHT", container.frame, "LEFT", -5, 0) - filterInput:SetTextInsets(16, 16, 0, 0) - - local searchIcon = filterInput:CreateTexture(nil, "overlay") - searchIcon:SetTexture("Interface\\Common\\UI-Searchbox-Icon") - searchIcon:SetVertexColor(0.6, 0.6, 0.6) - searchIcon:SetWidth(14) - searchIcon:SetHeight(14) - searchIcon:SetPoint("left", filterInput, "left", 2, -2) filterInput:SetFont(STANDARD_TEXT_FONT, 10) frame.filterInput = filterInput filterInput:Hide() - local filterInputClear = CreateFrame("BUTTON", nil, filterInput) - frame.filterInputClear = filterInputClear - filterInputClear:SetWidth(12) - filterInputClear:SetHeight(12) - filterInputClear:SetPoint("RIGHT", filterInput, "RIGHT", -4, -1) - filterInputClear:SetNormalTexture("Interface\\Common\\VoiceChat-Muted") - filterInputClear:SetHighlightTexture("Interface\\BUTTONS\\UI-Panel-MinimizeButton-Highlight.blp") - filterInputClear:SetScript("OnClick", function() filterInput:SetText("") filterInput:ClearFocus() end) - filterInputClear:Hide() - -- Left Side Container local buttonsContainer = AceGUI:Create("InlineGroup") buttonsContainer:SetWidth(170)