MoveIt.GUI.Modules.Reposition = {} function MoveIt.GUI.Modules.Reposition:Create(container) MoveIt.GUI.Modules:CreateEnabledCheckbox(container, "Reposition", 0.3, "Reposition") self.sliderOffsetX = AceGUI:Create("Slider") self.sliderOffsetX:SetLabel("Offset X") self.sliderOffsetX:SetSliderValues(-1000, 1000, 0.01) self.sliderOffsetX:SetRelativeWidth(0.35) self.sliderOffsetX:SetDisabled(true) self.sliderOffsetX:SetCallback("OnValueChanged", function() self:OnChangeSetting() end) container:AddChild(self.sliderOffsetX) self.sliderOffsetY = AceGUI:Create("Slider") self.sliderOffsetY:SetLabel("Offset Y") self.sliderOffsetY:SetSliderValues(-1000, 1000, 0.01) self.sliderOffsetY:SetRelativeWidth(0.35) self.sliderOffsetY:SetDisabled(true) self.sliderOffsetY:SetCallback("OnValueChanged", function() self:OnChangeSetting() end) container:AddChild(self.sliderOffsetY) self.dropdownAnchorPointFrom = AceGUI:Create("Dropdown") self.dropdownAnchorPointFrom:SetList(MoveIt.GUI.FrameSettings.anchors) self.dropdownAnchorPointFrom:SetLabel("Attach:") self.dropdownAnchorPointFrom:SetRelativeWidth(0.25) self.dropdownAnchorPointFrom:SetDisabled(true) self.dropdownAnchorPointFrom:SetCallback("OnValueChanged", function() self:OnChangeSetting() end) container:AddChild(self.dropdownAnchorPointFrom) self.dropdownAnchorPointTo = AceGUI:Create("Dropdown") self.dropdownAnchorPointTo:SetList(MoveIt.GUI.FrameSettings.anchors) self.dropdownAnchorPointTo:SetLabel("To:") self.dropdownAnchorPointTo:SetRelativeWidth(0.25) self.dropdownAnchorPointTo:SetDisabled(true) self.dropdownAnchorPointTo:SetCallback("OnValueChanged", function() self:OnChangeSetting() end) container:AddChild(self.dropdownAnchorPointTo) self.editboxAnchorTargetFrame = AceGUI:Create("EditBox") self.editboxAnchorTargetFrame:SetLabel("Of Frame:") self.editboxAnchorTargetFrame:SetRelativeWidth(0.5) self.editboxAnchorTargetFrame:SetDisabled(true) self.editboxAnchorTargetFrame:SetCallback("OnEnterPressed", function(_, _, value) self:OnAnchorTargetChanged(value) end) container:AddChild(self.editboxAnchorTargetFrame) end function MoveIt.GUI.Modules.Reposition:OnChangeSetting() local settings = MoveIt:GetFrameSettings(MoveIt.GUI.Options.selectedFrame, "Reposition") settings.OffsetX = self.sliderOffsetX:GetValue() settings.OffsetY = self.sliderOffsetY:GetValue() settings.AnchorPointFrom = self.dropdownAnchorPointFrom:GetValue() settings.AnchorPointTo = self.dropdownAnchorPointFrom:GetValue() settings.AnchorTargetFrame = self.editboxAnchorTargetFrame:GetText() MoveIt.Modules.Reposition:Apply(MoveIt.GUI.Options.selectedFrame) end function MoveIt.GUI.Modules.Reposition:Update(frameName) local modSettings = MoveIt:GetFrameSettings(frameName, "Reposition") self.checkboxEnabled:SetValue(modSettings.Enabled, false) self.sliderOffsetX:SetValue(modSettings.OffsetX, false) self.sliderOffsetY:SetValue(modSettings.OffsetY, false) self.dropdownAnchorPointFrom:SetValue(modSettings.AnchorPointFrom, false) self.dropdownAnchorPointTo:SetValue(modSettings.AnchorPointTo, false) self.editboxAnchorTargetFrame:SetText(modSettings.AnchorTargetFrame, false) local enabled = modSettings.Enabled self.checkboxEnabled:SetDisabled(false) self.sliderOffsetX:SetDisabled(not enabled) self.sliderOffsetY:SetDisabled(not enabled) self.dropdownAnchorPointFrom:SetDisabled(not enabled) self.dropdownAnchorPointTo:SetDisabled(not enabled) self.editboxAnchorTargetFrame:SetDisabled(not enabled) end function MoveIt.GUI.Modules.Reposition:Disable() self.checkboxEnabled:SetValue(false, false) self.sliderOffsetX:SetValue(0, false) self.sliderOffsetY:SetValue(0, false) self.dropdownAnchorPointFrom:SetValue("CENTER", false) self.dropdownAnchorPointTo:SetValue("CENTER", false) self.editboxAnchorTargetFrame:SetText("", false) self.checkboxEnabled:SetDisabled(true) self.sliderOffsetX:SetDisabled(true) self.sliderOffsetY:SetDisabled(true) self.dropdownAnchorPointFrom:SetDisabled(true) self.dropdownAnchorPointTo:SetDisabled(true) self.editboxAnchorTargetFrame:SetDisabled(true) end function MoveIt.GUI.Modules.Reposition:OnAnchorTargetChanged(value) local modSettings = MoveIt:GetFrameSettings(MoveIt.GUI.Options.selectedFrame, "Reposition") if MoveIt:IsValidFrame(value) or value == "UIParent" then local handle = MoveIt:GetFrameHandle(value) local frameName = MoveIt:GetFrameName(handle) modSettings.AnchorTargetFrame = frameName MoveIt.Modules.Reposition:Apply(MoveIt.GUI.Options.selectedFrame) else self.editboxAnchorTargetFrame:SetValue(modSettings.AnchorTargetFrame) end end