mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-06 21:50:00 +00:00
api: add new skin system and functions
this is a squash of several commits from `skinframes` branch. author: @xIGBClutchIx, @shagu
This commit is contained in:
+7
-176
@@ -331,7 +331,7 @@ end
|
||||
|
||||
-- [ Enable Movable ]
|
||||
-- Set all necessary functions to make a already existing frame movable.
|
||||
-- 'name' [string] Name of the Frame that should be movable
|
||||
-- 'name' [frame/string] Name of the Frame that should be movable
|
||||
-- 'addon' [string] Addon that must be loaded before being able to access the frame
|
||||
-- 'blacklist' [table] A list of frames that should be deactivated for mouse usage
|
||||
function pfUI.api.EnableMovable(name, addon, blacklist)
|
||||
@@ -367,7 +367,8 @@ function pfUI.api.EnableMovable(name, addon, blacklist)
|
||||
end
|
||||
end
|
||||
|
||||
local frame = _G[name]
|
||||
local frame = name
|
||||
if type(name) == "string" then frame = _G[name] end
|
||||
frame:SetMovable(true)
|
||||
frame:EnableMouse(true)
|
||||
frame:SetScript("OnMouseDown",function()
|
||||
@@ -529,7 +530,7 @@ end
|
||||
-- 'inset' [int] backdrop inset, defaults to border size.
|
||||
-- 'legacy' [bool] use legacy backdrop instead of creating frames.
|
||||
-- 'transp' [bool] force default transparency of 0.8.
|
||||
function pfUI.api.CreateBackdrop(f, inset, legacy, transp)
|
||||
function pfUI.api.CreateBackdrop(f, inset, legacy, transp, backdropSetting)
|
||||
-- exit if now frame was given
|
||||
if not f then return end
|
||||
|
||||
@@ -553,7 +554,9 @@ function pfUI.api.CreateBackdrop(f, inset, legacy, transp)
|
||||
|
||||
-- use legacy backdrop handling
|
||||
if legacy then
|
||||
f:SetBackdrop(pfUI.backdrop)
|
||||
local backdrop = pfUI.backdrop
|
||||
if backdropSetting then backdrop = backdropSetting end
|
||||
f:SetBackdrop(backdrop)
|
||||
f:SetBackdropColor(br, bg, bb, ba)
|
||||
f:SetBackdropBorderColor(er, eg, eb , ea)
|
||||
return
|
||||
@@ -598,178 +601,6 @@ function pfUI.api.CreateBackdrop(f, inset, legacy, transp)
|
||||
b:SetBackdropBorderColor(er, eg, eb , ea)
|
||||
end
|
||||
|
||||
-- [ Skin Button ]
|
||||
-- Applies pfUI skin to buttons:
|
||||
-- 'button' [frame/string] the button that should be skinned.
|
||||
-- 'cr' [int] mouseover color (red), defaults to classcolor.
|
||||
-- 'cg' [int] mouseover color (green), defaults to classcolor.
|
||||
-- 'cb' [int] mouseover color (blue), defaults to classcolor.
|
||||
function pfUI.api.SkinButton(button, cr, cg, cb)
|
||||
local b = getglobal(button)
|
||||
if not b then b = button end
|
||||
if not b then return end
|
||||
if not cr or not cg or not cb then
|
||||
_, class = UnitClass("player")
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
cr, cg, cb = color.r , color.g, color.b
|
||||
end
|
||||
pfUI.api.CreateBackdrop(b, nil, true)
|
||||
b:SetNormalTexture(nil)
|
||||
b:SetHighlightTexture(nil)
|
||||
b:SetPushedTexture(nil)
|
||||
b:SetDisabledTexture(nil)
|
||||
local funce = b:GetScript("OnEnter")
|
||||
local funcl = b:GetScript("OnLeave")
|
||||
b:SetScript("OnEnter", function()
|
||||
if funce then funce() end
|
||||
pfUI.api.CreateBackdrop(b, nil, true)
|
||||
b:SetBackdropBorderColor(cr,cg,cb,1)
|
||||
end)
|
||||
b:SetScript("OnLeave", function()
|
||||
if funcl then funcl() end
|
||||
pfUI.api.CreateBackdrop(b, nil, true)
|
||||
end)
|
||||
b:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE")
|
||||
end
|
||||
|
||||
-- [ Question Dialog ]
|
||||
-- Creates a pfUI user dialog popup:
|
||||
-- 'text' [string] text that will be displayed.
|
||||
-- 'yes' [function] function that is triggered on 'Okay' button.
|
||||
-- 'no' [function] function that is triggered on 'Cancel' button.
|
||||
-- 'editbox' [bool] if set, a inputfield will be shown. it can be.
|
||||
-- accessed with "GetParent().input".
|
||||
function pfUI.api.CreateQuestionDialog(text, yes, no, editbox)
|
||||
-- do not allow multiple instances of question dialogs
|
||||
if pfQuestionDialog and pfQuestionDialog:IsShown() then
|
||||
pfQuestionDialog:Hide()
|
||||
pfQuestionDialog = nil
|
||||
return
|
||||
end
|
||||
|
||||
local yes, no = yes, no
|
||||
local yescap, nocap = YES, NO
|
||||
|
||||
if yes and type(yes) == "table" then
|
||||
yescap = yes[1]
|
||||
yes = yes[2]
|
||||
end
|
||||
|
||||
if no and type(no) == "table" then
|
||||
nocap = no[1]
|
||||
no = no[2]
|
||||
end
|
||||
|
||||
if not text then text = "Are you sure?" end
|
||||
|
||||
local border = tonumber(pfUI_config.appearance.border.default)
|
||||
local padding = 15
|
||||
|
||||
-- frame
|
||||
local question = CreateFrame("Frame", "pfQuestionDialog", UIParent)
|
||||
question:ClearAllPoints()
|
||||
question:SetPoint("CENTER", 0, 0)
|
||||
question:SetFrameStrata("TOOLTIP")
|
||||
question:SetMovable(true)
|
||||
question:EnableMouse(true)
|
||||
question:SetScript("OnMouseDown",function()
|
||||
this:StartMoving()
|
||||
end)
|
||||
|
||||
question:SetScript("OnMouseUp",function()
|
||||
this:StopMovingOrSizing()
|
||||
end)
|
||||
pfUI.api.CreateBackdrop(question, nil, nil, .85)
|
||||
|
||||
-- text
|
||||
question.text = question:CreateFontString("Status", "LOW", "GameFontNormal")
|
||||
question.text:SetFontObject(GameFontWhite)
|
||||
question.text:SetPoint("TOPLEFT", question, "TOPLEFT", padding, -padding)
|
||||
question.text:SetPoint("TOPRIGHT", question, "TOPRIGHT", -padding, -padding)
|
||||
question.text:SetText(text)
|
||||
|
||||
-- editbox
|
||||
if editbox then
|
||||
question.input = CreateFrame("EditBox", "pfQuestionDialogEdit", question)
|
||||
pfUI.api.CreateBackdrop(question.input)
|
||||
question.input:SetTextColor(.2,1,.8,1)
|
||||
question.input:SetJustifyH("CENTER")
|
||||
question.input:SetAutoFocus(false)
|
||||
question.input:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", border, -padding)
|
||||
question.input:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", -border, -padding)
|
||||
question.input:SetHeight(20)
|
||||
|
||||
question.input:SetFontObject(GameFontNormal)
|
||||
question.input:SetScript("OnEscapePressed", function() this:ClearFocus() end)
|
||||
end
|
||||
|
||||
-- buttons
|
||||
question.yes = CreateFrame("Button", "pfQuestionDialogYes", question, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(question.yes)
|
||||
question.yes:SetWidth(100)
|
||||
question.yes:SetHeight(22)
|
||||
question.yes:SetText(yescap)
|
||||
question.yes:SetScript("OnClick", function()
|
||||
if yes then yes() end
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
if question.input then
|
||||
question.yes:SetPoint("TOPRIGHT", question.input, "BOTTOM", -3*border, -padding)
|
||||
else
|
||||
question.yes:SetPoint("TOPRIGHT", question.text, "BOTTOM", -3*border, -padding)
|
||||
end
|
||||
|
||||
question.no = CreateFrame("Button", "pfQuestionDialogNo", question, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(question.no)
|
||||
question.no:SetWidth(100)
|
||||
question.no:SetHeight(22)
|
||||
question.no:SetText(nocap)
|
||||
question.no:SetScript("OnClick", function()
|
||||
if no then no() end
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
if question.input then
|
||||
question.no:SetPoint("TOPLEFT", question.input, "BOTTOM", 3*border, -padding)
|
||||
else
|
||||
question.no:SetPoint("TOPLEFT", question.text, "BOTTOM", 3*border, -padding)
|
||||
end
|
||||
|
||||
question.close = CreateFrame("Button", "pfQuestionDialogClose", question)
|
||||
question.close:SetPoint("TOPRIGHT", -border, -border)
|
||||
pfUI.api.CreateBackdrop(question.close)
|
||||
question.close:SetHeight(10)
|
||||
question.close:SetWidth(10)
|
||||
question.close.texture = question.close:CreateTexture("pfQuestionDialogCloseTex")
|
||||
question.close.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\close")
|
||||
question.close.texture:ClearAllPoints()
|
||||
question.close.texture:SetAllPoints(question.close)
|
||||
question.close.texture:SetVertexColor(1,.25,.25,1)
|
||||
question.close:SetScript("OnEnter", function ()
|
||||
this.backdrop:SetBackdropBorderColor(1,.25,.25,1)
|
||||
end)
|
||||
|
||||
question.close:SetScript("OnLeave", function ()
|
||||
pfUI.api.CreateBackdrop(this)
|
||||
end)
|
||||
|
||||
question.close:SetScript("OnClick", function()
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
-- resize window
|
||||
local textspace = question.text:GetHeight() + padding
|
||||
local inputspace = 0
|
||||
if question.input then inputspace = question.input:GetHeight() + padding end
|
||||
local buttonspace = question.no:GetHeight() + padding
|
||||
question:SetHeight(textspace + inputspace + buttonspace + padding)
|
||||
|
||||
local width = 200
|
||||
if question.text:GetStringWidth() > 200 then width = question.text:GetStringWidth() end
|
||||
question:SetWidth( width + 2*padding)
|
||||
end
|
||||
|
||||
-- [ Bar Layout Options ] --
|
||||
-- 'barsize' size of bar in number of buttons
|
||||
-- returns: array of options as strings for pfUI.gui.bar
|
||||
|
||||
@@ -246,3 +246,320 @@ function pfUI.api.CreateScrollChild(name, parent)
|
||||
|
||||
return f
|
||||
end
|
||||
|
||||
-- [ Skin Button ]
|
||||
-- Applies pfUI skin to buttons:
|
||||
-- 'button' [frame/string] the button that should be skinned.
|
||||
-- 'cr' [int] mouseover color (red), defaults to classcolor.
|
||||
-- 'cg' [int] mouseover color (green), defaults to classcolor.
|
||||
-- 'cb' [int] mouseover color (blue), defaults to classcolor.
|
||||
function pfUI.api.SkinButton(button, cr, cg, cb)
|
||||
local b = getglobal(button)
|
||||
if not b then b = button end
|
||||
if not b then return end
|
||||
if not cr or not cg or not cb then
|
||||
_, class = UnitClass("player")
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
cr, cg, cb = color.r , color.g, color.b
|
||||
end
|
||||
pfUI.api.CreateBackdrop(b, nil, true)
|
||||
b:SetNormalTexture(nil)
|
||||
b:SetHighlightTexture(nil)
|
||||
b:SetPushedTexture(nil)
|
||||
b:SetDisabledTexture(nil)
|
||||
local funce = b:GetScript("OnEnter")
|
||||
local funcl = b:GetScript("OnLeave")
|
||||
b:SetScript("OnEnter", function()
|
||||
if funce then funce() end
|
||||
pfUI.api.CreateBackdrop(b, nil, true)
|
||||
b:SetBackdropBorderColor(cr,cg,cb,1)
|
||||
end)
|
||||
b:SetScript("OnLeave", function()
|
||||
if funcl then funcl() end
|
||||
pfUI.api.CreateBackdrop(b, nil, true)
|
||||
end)
|
||||
b:SetFont(pfUI.font_default, pfUI_config.global.font_size, "OUTLINE")
|
||||
end
|
||||
|
||||
-- [ Skin Rotate Button]
|
||||
-- Applies pfUI skin to rotation buttons like in character pane:
|
||||
-- 'button' [frame/string] the button that should be skinned.
|
||||
function pfUI.api.SkinRotateButton(button)
|
||||
pfUI.api.CreateBackdrop(button)
|
||||
|
||||
local _, class = UnitClass("player")
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
local cr, cg, cb = color.r , color.g, color.b
|
||||
|
||||
button:SetWidth(button:GetWidth() - 18)
|
||||
button:SetHeight(button:GetHeight() - 18)
|
||||
|
||||
button:GetNormalTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65);
|
||||
button:GetPushedTexture():SetTexCoord(0.3, 0.29, 0.3, 0.65, 0.69, 0.29, 0.69, 0.65);
|
||||
|
||||
button:GetHighlightTexture():SetTexture(cr, cg, cb, .25);
|
||||
|
||||
button:GetPushedTexture():SetAllPoints(button:GetNormalTexture());
|
||||
button:GetHighlightTexture():SetAllPoints(button:GetNormalTexture());
|
||||
end
|
||||
|
||||
-- [ Skin Close Button ]
|
||||
-- Applies pfUI close skin to buttons and can also be positioned
|
||||
-- 'button' [frame] the button that should be skinned.
|
||||
-- 'parentFrame' [frame] will anchor to the top right of the parent.
|
||||
-- 'offsetX' [integer] offsets the button horizontally
|
||||
-- 'offsetY' [integer] offsets the button vertically
|
||||
function pfUI.api.SkinCloseButton(button, parentFrame, offsetX, offsetY)
|
||||
SkinButton(button)
|
||||
|
||||
button:SetWidth(15)
|
||||
button:SetHeight(15)
|
||||
|
||||
if parentFrame then
|
||||
button:ClearAllPoints()
|
||||
button:SetPoint("TOPRIGHT", parentFrame, "TOPRIGHT", offsetX, offsetY)
|
||||
end
|
||||
|
||||
button.texture = button:CreateTexture("pfQuestionDialogCloseTex")
|
||||
button.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\close")
|
||||
button.texture:ClearAllPoints()
|
||||
button.texture:SetAllPoints(button)
|
||||
button.texture:SetVertexColor(1,.25,.25,1)
|
||||
end
|
||||
|
||||
-- [ CenterFrame ]
|
||||
-- Clears points and centers a frame
|
||||
-- 'frame' [frame] the frame that should be centered.
|
||||
-- 'relativeFrame' [frame] frame that should be used for centering if not use ui parent.
|
||||
function pfUI.api.CenterFrame(frame, relativeFrame)
|
||||
frame:ClearAllPoints()
|
||||
if relativeFrame then
|
||||
frame:SetPoint("CENTER", relativeFrame, "CENTER", 0, 0)
|
||||
else
|
||||
frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||
end
|
||||
end
|
||||
|
||||
-- [ StripTextures ]
|
||||
-- Strips all textures off a frame.
|
||||
-- 'frame' [frame] the frame that should be stripped.
|
||||
function pfUI.api.StripTextures(frame)
|
||||
for i,v in ipairs({frame:GetRegions()}) do
|
||||
if v.SetTexture then v:SetTexture("") end
|
||||
end
|
||||
end
|
||||
|
||||
function pfUI.api.SkinBackdropOffset(frame, offset)
|
||||
StripTextures(frame)
|
||||
CreateBackdrop(frame, nil, nil, .0)
|
||||
local offsetBorder = -3
|
||||
if offset then offsetBorder = offset end
|
||||
frame.backdrop:SetPoint("TOPLEFT", frame, "TOPLEFT", -offsetBorder, offsetBorder)
|
||||
frame.backdrop:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", offsetBorder, -offsetBorder)
|
||||
end
|
||||
|
||||
function pfUI.api.SkinCheckbox(frame, offset)
|
||||
frame:SetNormalTexture("")
|
||||
frame:SetPushedTexture("")
|
||||
frame:SetHighlightTexture("")
|
||||
CreateBackdrop(frame, nil, nil, .0)
|
||||
local offsetBorder = -5
|
||||
if offset then offsetBorder = offset end
|
||||
frame.backdrop:SetPoint("TOPLEFT", frame, "TOPLEFT", -offsetBorder, offsetBorder)
|
||||
frame.backdrop:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", offsetBorder, -offsetBorder)
|
||||
frame:SetHitRectInsets(-offsetBorder,-offsetBorder,-offsetBorder,-offsetBorder)
|
||||
end
|
||||
|
||||
function pfUI.api.SkinDropDown(frame, offsetX, offsetY)
|
||||
StripTextures(frame)
|
||||
CreateBackdrop(frame, nil, nil, .0)
|
||||
local offsetXBorder = -16
|
||||
if offsetX then offsetXBorder = offsetX end
|
||||
local offsetYBorder = -4
|
||||
if offsetY then offsetYBorder = offsetY end
|
||||
frame.backdrop:SetPoint("TOPLEFT", frame, "TOPLEFT", -offsetXBorder, offsetYBorder)
|
||||
frame.backdrop:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", offsetXBorder, -offsetYBorder)
|
||||
frame:SetHitRectInsets(-offsetXBorder, -offsetXBorder, -offsetYBorder, -offsetYBorder)
|
||||
local text = _G[frame:GetName().."Text"]
|
||||
text:SetPoint("TOPLEFT", frame.backdrop, "TOPLEFT")
|
||||
text:SetPoint("BOTTOMRIGHT", frame.backdrop, "BOTTOMRIGHT")
|
||||
local button = _G[frame:GetName().."Button"]
|
||||
button:ClearAllPoints()
|
||||
button:SetPoint("RIGHT", frame.backdrop, "RIGHT", -4, 0)
|
||||
button:SetHeight(16)
|
||||
button:SetWidth(16)
|
||||
local arrow = button:CreateTexture()
|
||||
arrow:SetTexture("Interface\\AddOns\\pfUI\\img\\down")
|
||||
arrow:SetAllPoints(button)
|
||||
button:SetNormalTexture(arrow)
|
||||
local arrowHighlighted = button:CreateTexture()
|
||||
arrowHighlighted:SetTexture("Interface\\AddOns\\pfUI\\img\\down")
|
||||
arrowHighlighted:SetAllPoints(button)
|
||||
button:SetHighlightTexture(arrowHighlighted)
|
||||
local arrowPushed = button:CreateTexture()
|
||||
arrowPushed:SetTexture("Interface\\AddOns\\pfUI\\img\\down")
|
||||
arrowPushed:SetAllPoints(button)
|
||||
button:SetPushedTexture(arrowPushed)
|
||||
local arrowDisabled = button:CreateTexture()
|
||||
arrowDisabled:SetTexture("Interface\\AddOns\\pfUI\\img\\down")
|
||||
arrowDisabled:SetAllPoints(button)
|
||||
arrowDisabled:SetVertexColor(0.2, 0.2, 0.2)
|
||||
button:SetDisabledTexture(arrowDisabled)
|
||||
end
|
||||
|
||||
function pfUI.api.SkinTabBottom(frame)
|
||||
StripTextures(frame)
|
||||
CreateBackdrop(frame, nil, nil, 0.8, pfUI.backdrop_no_top)
|
||||
end
|
||||
|
||||
-- [ GetCloseButton ]
|
||||
-- Get the close button from a frame.
|
||||
-- 'frame' [frame] the frame that should be searched for the button.
|
||||
function pfUI.api.GetCloseButton(frame)
|
||||
for i,v in ipairs({frame:GetChildren()}) do
|
||||
if v.GetObjectType and v:GetObjectType() == "Button" and v.GetNormalTexture and v:GetNormalTexture() then
|
||||
if v:GetNormalTexture().GetTexture and v:GetNormalTexture():GetTexture() == "Interface\\Buttons\\UI-Panel-MinimizeButton-Up" then
|
||||
return v
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- [ Question Dialog ]
|
||||
-- Creates a pfUI user dialog popup:
|
||||
-- 'text' [string] text that will be displayed.
|
||||
-- 'yes' [function] function that is triggered on 'Okay' button.
|
||||
-- 'no' [function] function that is triggered on 'Cancel' button.
|
||||
-- 'editbox' [bool] if set, a inputfield will be shown. it can be.
|
||||
-- accessed with "GetParent().input".
|
||||
function pfUI.api.CreateQuestionDialog(text, yes, no, editbox)
|
||||
-- do not allow multiple instances of question dialogs
|
||||
if pfQuestionDialog and pfQuestionDialog:IsShown() then
|
||||
pfQuestionDialog:Hide()
|
||||
pfQuestionDialog = nil
|
||||
return
|
||||
end
|
||||
|
||||
local yes, no = yes, no
|
||||
local yescap, nocap = YES, NO
|
||||
|
||||
if yes and type(yes) == "table" then
|
||||
yescap = yes[1]
|
||||
yes = yes[2]
|
||||
end
|
||||
|
||||
if no and type(no) == "table" then
|
||||
nocap = no[1]
|
||||
no = no[2]
|
||||
end
|
||||
|
||||
if not text then text = "Are you sure?" end
|
||||
|
||||
local border = tonumber(pfUI_config.appearance.border.default)
|
||||
local padding = 15
|
||||
|
||||
-- frame
|
||||
local question = CreateFrame("Frame", "pfQuestionDialog", UIParent)
|
||||
question:ClearAllPoints()
|
||||
question:SetPoint("CENTER", 0, 0)
|
||||
question:SetFrameStrata("TOOLTIP")
|
||||
question:SetMovable(true)
|
||||
question:EnableMouse(true)
|
||||
question:SetScript("OnMouseDown",function()
|
||||
this:StartMoving()
|
||||
end)
|
||||
|
||||
question:SetScript("OnMouseUp",function()
|
||||
this:StopMovingOrSizing()
|
||||
end)
|
||||
pfUI.api.CreateBackdrop(question, nil, nil, .85)
|
||||
|
||||
-- text
|
||||
question.text = question:CreateFontString("Status", "LOW", "GameFontNormal")
|
||||
question.text:SetFontObject(GameFontWhite)
|
||||
question.text:SetPoint("TOPLEFT", question, "TOPLEFT", padding, -padding)
|
||||
question.text:SetPoint("TOPRIGHT", question, "TOPRIGHT", -padding, -padding)
|
||||
question.text:SetText(text)
|
||||
|
||||
-- editbox
|
||||
if editbox then
|
||||
question.input = CreateFrame("EditBox", "pfQuestionDialogEdit", question)
|
||||
pfUI.api.CreateBackdrop(question.input)
|
||||
question.input:SetTextColor(.2,1,.8,1)
|
||||
question.input:SetJustifyH("CENTER")
|
||||
question.input:SetAutoFocus(false)
|
||||
question.input:SetPoint("TOPLEFT", question.text, "BOTTOMLEFT", border, -padding)
|
||||
question.input:SetPoint("TOPRIGHT", question.text, "BOTTOMRIGHT", -border, -padding)
|
||||
question.input:SetHeight(20)
|
||||
|
||||
question.input:SetFontObject(GameFontNormal)
|
||||
question.input:SetScript("OnEscapePressed", function() this:ClearFocus() end)
|
||||
end
|
||||
|
||||
-- buttons
|
||||
question.yes = CreateFrame("Button", "pfQuestionDialogYes", question, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(question.yes)
|
||||
question.yes:SetWidth(100)
|
||||
question.yes:SetHeight(22)
|
||||
question.yes:SetText(yescap)
|
||||
question.yes:SetScript("OnClick", function()
|
||||
if yes then yes() end
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
if question.input then
|
||||
question.yes:SetPoint("TOPRIGHT", question.input, "BOTTOM", -3*border, -padding)
|
||||
else
|
||||
question.yes:SetPoint("TOPRIGHT", question.text, "BOTTOM", -3*border, -padding)
|
||||
end
|
||||
|
||||
question.no = CreateFrame("Button", "pfQuestionDialogNo", question, "UIPanelButtonTemplate")
|
||||
pfUI.api.SkinButton(question.no)
|
||||
question.no:SetWidth(100)
|
||||
question.no:SetHeight(22)
|
||||
question.no:SetText(nocap)
|
||||
question.no:SetScript("OnClick", function()
|
||||
if no then no() end
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
if question.input then
|
||||
question.no:SetPoint("TOPLEFT", question.input, "BOTTOM", 3*border, -padding)
|
||||
else
|
||||
question.no:SetPoint("TOPLEFT", question.text, "BOTTOM", 3*border, -padding)
|
||||
end
|
||||
|
||||
question.close = CreateFrame("Button", "pfQuestionDialogClose", question)
|
||||
question.close:SetPoint("TOPRIGHT", -border, -border)
|
||||
pfUI.api.CreateBackdrop(question.close)
|
||||
question.close:SetHeight(10)
|
||||
question.close:SetWidth(10)
|
||||
question.close.texture = question.close:CreateTexture("pfQuestionDialogCloseTex")
|
||||
question.close.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\close")
|
||||
question.close.texture:ClearAllPoints()
|
||||
question.close.texture:SetAllPoints(question.close)
|
||||
question.close.texture:SetVertexColor(1,.25,.25,1)
|
||||
question.close:SetScript("OnEnter", function ()
|
||||
this.backdrop:SetBackdropBorderColor(1,.25,.25,1)
|
||||
end)
|
||||
|
||||
question.close:SetScript("OnLeave", function ()
|
||||
pfUI.api.CreateBackdrop(this)
|
||||
end)
|
||||
|
||||
question.close:SetScript("OnClick", function()
|
||||
this:GetParent():Hide()
|
||||
end)
|
||||
|
||||
-- resize window
|
||||
local textspace = question.text:GetHeight() + padding
|
||||
local inputspace = 0
|
||||
if question.input then inputspace = question.input:GetHeight() + padding end
|
||||
local buttonspace = question.no:GetHeight() + padding
|
||||
question:SetHeight(textspace + inputspace + buttonspace + padding)
|
||||
|
||||
local width = 200
|
||||
if question.text:GetStringWidth() > 200 then width = question.text:GetStringWidth() end
|
||||
question:SetWidth( width + 2*padding)
|
||||
end
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
+19
-6
@@ -1389,13 +1389,13 @@ pfUI:RegisterModule("gui", function ()
|
||||
end)
|
||||
|
||||
|
||||
-- [[ Modules ]]
|
||||
pfUI.gui.tabs.modules = pfUI.gui.tabs:CreateTabChild(T["Modules"], nil, nil, nil, true)
|
||||
pfUI.gui.tabs.modules.tabs = CreateTabFrame(pfUI.gui.tabs.modules, "TOP", true)
|
||||
-- [[ Core ]]
|
||||
pfUI.gui.tabs.components = pfUI.gui.tabs:CreateTabChild(T["Components"], nil, nil, nil, true)
|
||||
pfUI.gui.tabs.components.tabs = CreateTabFrame(pfUI.gui.tabs.components, "TOP", true)
|
||||
|
||||
-- General
|
||||
pfUI.gui.tabs.modules.tabs.general = pfUI.gui.tabs.modules.tabs:CreateTabChild(T["Modules"], 70)
|
||||
pfUI.gui.tabs.modules.tabs.general:SetScript("OnShow", function()
|
||||
-- Modules
|
||||
pfUI.gui.tabs.components.tabs.modules = pfUI.gui.tabs.components.tabs:CreateTabChild(T["Modules"], 70)
|
||||
pfUI.gui.tabs.components.tabs.modules:SetScript("OnShow", function()
|
||||
if not this.setup then
|
||||
for i,m in pairs(pfUI.modules) do
|
||||
if m ~= "gui" then
|
||||
@@ -1408,6 +1408,19 @@ pfUI:RegisterModule("gui", function ()
|
||||
end
|
||||
end)
|
||||
|
||||
-- Skins
|
||||
pfUI.gui.tabs.components.tabs.skins = pfUI.gui.tabs.components.tabs:CreateTabChild(T["Skins"], 70)
|
||||
pfUI.gui.tabs.components.tabs.skins:SetScript("OnShow", function()
|
||||
if not this.setup then
|
||||
for i,m in pairs(pfUI.skins) do
|
||||
-- create disabled entry if not existing and display
|
||||
pfUI:UpdateConfig("disabled", nil, "skin_" .. m, "0")
|
||||
CreateConfig(this, T["Disable Skin"] .. " " .. m, C.disabled, "skin_" .. m, "checkbox")
|
||||
end
|
||||
this.setup = true
|
||||
end
|
||||
end)
|
||||
|
||||
-- [[ Close ]]
|
||||
pfUI.gui.tabs.close = pfUI.gui.tabs:CreateTabChild(T["Close"], nil, nil, "BOTTOM")
|
||||
pfUI.gui.tabs.close.button:SetScript("OnClick", function()
|
||||
|
||||
@@ -37,6 +37,8 @@ pfUI_translation = {}
|
||||
pfUI.cache = {}
|
||||
pfUI.module = {}
|
||||
pfUI.modules = {}
|
||||
pfUI.skin = {}
|
||||
pfUI.skins = {}
|
||||
pfUI.environment = {}
|
||||
pfUI.movables = {}
|
||||
pfUI.version = {}
|
||||
@@ -91,6 +93,14 @@ pfUI:SetScript("OnEvent", function()
|
||||
pfUI.module[m]()
|
||||
end
|
||||
end
|
||||
|
||||
-- load skins
|
||||
for i,s in pairs(this.skins) do
|
||||
if not ( pfUI_config["disabled"] and pfUI_config["disabled"]["skin_" .. s] == "1" ) then
|
||||
setfenv(pfUI.skin[s], pfUI:GetEnvironment())
|
||||
pfUI.skin[s]()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -99,12 +109,23 @@ function pfUI:RegisterModule(n, f)
|
||||
table.insert(pfUI.modules, n)
|
||||
end
|
||||
|
||||
function pfUI:RegisterSkin(n, f)
|
||||
pfUI.skin[n] = f
|
||||
table.insert(pfUI.skins, n)
|
||||
end
|
||||
|
||||
pfUI.backdrop = {
|
||||
bgFile = "Interface\\AddOns\\pfUI\\img\\col", tile = true, tileSize = 8,
|
||||
edgeFile = "Interface\\AddOns\\pfUI\\img\\border", edgeSize = 8,
|
||||
insets = {left = -1, right = -1, top = -1, bottom = -1},
|
||||
}
|
||||
|
||||
pfUI.backdrop_no_top = {
|
||||
bgFile = "Interface\\AddOns\\pfUI\\img\\col", tile = true, tileSize = 8,
|
||||
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_no_top", edgeSize = 8,
|
||||
insets = {left = -1, right = -1, top = -1, bottom = -1},
|
||||
}
|
||||
|
||||
pfUI.backdrop_underline = {
|
||||
edgeFile = "Interface\\AddOns\\pfUI\\img\\underline", edgeSize = 8,
|
||||
insets = {left = 0, right = 0, top = 0, bottom = 0},
|
||||
|
||||
Reference in New Issue
Block a user